Skip to content

Test: Cover DateTimeConverterFactoryHelper and nullable converter WriteNullValue paths#5

Merged
ScarletKuro merged 3 commits intomasterfrom
copilot/add-tests-for-nullable-converters
Jan 15, 2026
Merged

Test: Cover DateTimeConverterFactoryHelper and nullable converter WriteNullValue paths#5
ScarletKuro merged 3 commits intomasterfrom
copilot/add-tests-for-nullable-converters

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 15, 2026

Codecov identified two uncovered code paths: the NotSupportedException in DateTimeConverterFactoryHelper.CreateConverter for unsupported types, and the writer.WriteNullValue() branch in all nullable converters.

Changes

  • Added InternalsVisibleTo attribute to main project csproj for test access to internal classes
  • Created DateTimeConverterFactoryHelperTests.cs with 11 tests covering:
    • All 8 supported type conversions (DateTime, DateTimeOffset, DateOnly, TimeOnly + nullables)
    • NotSupportedException for unsupported types (string, int)
    • ArgumentNullException for null type parameter
  • Created NullableConverterWriteTests.cs with 12 tests directly invoking converter Write methods:
    • WriteNullValue() path for all 4 nullable converters
    • Write with actual values to ensure both branches covered
    • ArgumentNullException when writer is null
  • Fixed CA1869 analyzer warning in ConverterTests.cs by using unique date format strings per test instead of reusing identical JsonSerializerOptions instances

Test Results

88 tests passing (+23 from baseline of 65)

Original prompt

Codecov shows that DateTimeConverterFactoryHelper.CreateConverter doesn't cover

throw new NotSupportedException($"{typeToConvert.FullName} is not supported by the {nameof(DateTimeConverterFactoryHelper)}.");

add:



To test it, actually test it fully and check if the correct type instance is returned

Also codecov shows that DateOnlyNullableConverter.cs, DateTimeNullableConverter.cs, DateTimeOffsetNullableConverter.cs, TimeOnlyNullableConverter.cs
doesn't fully cover the Write when it's null aka the writer.WriteNullValue(); add tests for this too


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 15, 2026 22:12
…d nullable converters

Co-authored-by: ScarletKuro <19953225+ScarletKuro@users.noreply.github.com>
Co-authored-by: ScarletKuro <19953225+ScarletKuro@users.noreply.github.com>
Copilot AI changed the title [WIP] Add tests for nullable converter coverage Add test coverage for DateTimeConverterFactoryHelper and nullable converter WriteNullValue paths Jan 15, 2026
Copilot AI requested a review from ScarletKuro January 15, 2026 22:18
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.30%. Comparing base (4ee291c) to head (0269fdb).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master       #5      +/-   ##
==========================================
+ Coverage   83.33%   92.30%   +8.97%     
==========================================
  Files          13       13              
  Lines         156      156              
  Branches       35       35              
==========================================
+ Hits          130      144      +14     
+ Misses         16        7       -9     
+ Partials       10        5       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ScarletKuro ScarletKuro marked this pull request as ready for review January 15, 2026 22:19
@ScarletKuro ScarletKuro changed the title Add test coverage for DateTimeConverterFactoryHelper and nullable converter WriteNullValue paths Test: Cover DateTimeConverterFactoryHelper and nullable converter WriteNullValue paths Jan 15, 2026
@ScarletKuro ScarletKuro merged commit a4ad7fb into master Jan 15, 2026
3 checks passed
@ScarletKuro ScarletKuro deleted the copilot/add-tests-for-nullable-converters branch January 15, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants