Skip to content

Tests: Add 11 missing UnitConverters unit tests#35191

Merged
kubaflo merged 3 commits into
inflight/currentfrom
op-add-unitconverters-tests
Apr 28, 2026
Merged

Tests: Add 11 missing UnitConverters unit tests#35191
kubaflo merged 3 commits into
inflight/currentfrom
op-add-unitconverters-tests

Conversation

@PureWeen
Copy link
Copy Markdown
Member

@PureWeen PureWeen commented Apr 28, 2026

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Summary

Add unit tests for 11 UnitConverters methods that had no test coverage.

New test cases cover: FahrenheitToCelsius, CelsiusToFahrenheit, CelsiusToKelvin, KelvinToCelsius, MilesToMeters, DegreesPerSecondToHertz, RadiansPerSecondToHertz, HertzToDegreesPerSecond, HertzToRadiansPerSecond, KilopascalsToPascals, and HectopascalsToPascals.

dotnet test src/Essentials/test/UnitTests/Essentials.UnitTests.csproj --filter UnitConverters — 168 passed, 0 failed.

Add [Theory] xUnit tests for FahrenheitToCelsius, CelsiusToFahrenheit,
CelsiusToKelvin, KelvinToCelsius, MilesToMeters, DegreesPerSecondToHertz,
RadiansPerSecondToHertz, HertzToDegreesPerSecond, HertzToRadiansPerSecond,
KilopascalsToPascals, and HectopascalsToPascals. Increases test method
count from 20 to 31, covering all public methods in UnitConverters.shared.cs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 28, 2026 11:57
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 35191

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 35191"

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds missing unit test coverage for several Microsoft.Maui.Media.UnitConverters conversion methods in Essentials, improving confidence in basic numeric conversion helpers.

Changes:

  • Added theories for Fahrenheit↔Celsius and Celsius↔Kelvin conversions
  • Added theories for Miles→Meters and angular velocity ↔ frequency conversions (deg/s, rad/s, Hz)
  • Added theories for Kilopascals/Hectopascals → Pascals conversions

Comment thread src/Essentials/test/UnitTests/UnitConverters_Tests.cs
@kubaflo
Copy link
Copy Markdown
Contributor

kubaflo commented Apr 28, 2026

/review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

Expert Code Review completed successfully!

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Code Review — 3-Reviewer Adversarial Consensus

Findings

🟡 MODERATE — PR description does not match the actual changes (3/3 reviewers)

The PR description claims tests were added for: CelsiusToKelvin, KelvinToCelsius, MilesToMeters, MetersToMiles, KilometersToMiles, MilesToKilometers, DegreesToRadians, RadiansToDegrees, PoundsToKilograms, KilogramsToPounds, AtmospheresToPascals.

However, comparing against the existing file and the implementation in UnitConverters.shared.cs:

Claimed in description Actual status
MetersToMiles Method does not exist in UnitConverters.shared.cs
KilometersToMiles Already had tests
MilesToKilometers Already had tests
DegreesToRadians Already had tests
RadiansToDegrees Already had tests
PoundsToKilograms Already had tests
KilogramsToPounds Already had tests
AtmospheresToPascals Already had tests

Tests actually added (8 of which are not mentioned in the description):
FahrenheitToCelsius, CelsiusToFahrenheit, CelsiusToKelvin, KelvinToCelsius, MilesToMeters, DegreesPerSecondToHertz, RadiansPerSecondToHertz, HertzToDegreesPerSecond, HertzToRadiansPerSecond, KilopascalsToPascals, HectopascalsToPascals

Recommendation: Update the PR description to accurately list the 11 methods being tested, and remove the reference to the non-existent MetersToMiles.


🟢 MINOR — MilesToMeters missing negative input case (2/3 reviewers)

See inline comment. The existing MilesToKilometers test includes [InlineData(-1, -1.6093)]; the new MilesToMeters test only covers non-negative values. Adding a negative case would maintain consistency.


🟢 MINOR — Frequency conversion tests could use more coverage (2/3 reviewers)

See inline comment. RadiansPerSecondToHertz has only 3 test cases (vs 4–5 for other tests), and the frequency conversion tests don't include negative inputs unlike other converter tests in the file.


Discarded — CelsiusToKelvin/KelvinToCelsius body-temperature case (1/3 reviewers, follow-up disagreed)

One reviewer suggested adding body-temperature anchor cases (37°C ↔ 310.15 K). Two follow-up reviewers independently disagreed: the existing test points (absolute zero, boiling, 0 K, room temp) already validate the linear offset formula adequately, and body-temp is meaningful for the Fahrenheit fractional multiplier but redundant for Kelvin's simple + 273.15.


Test Quality & CI Assessment

  • ✅ All InlineData values verified mathematically correct against the implementation constants
  • ✅ Precision parameter (, 4) is consistent with existing tests in the file
  • ✅ Test patterns ([Theory] + [InlineData], parameter naming) follow established conventions
  • ✅ This is a test-only PR — no production code changes to validate
  • i️ PR reports 168 tests passed, 0 failed

Methodology

3 independent reviewers with adversarial consensus. Disputed findings (flagged by only 1 reviewer) were evaluated by the other 2 reviewers as follow-up. Only findings with ≥2/3 agreement are included.

Generated by Expert Code Review for issue #35191 · ● 7.9M

Comment thread src/Essentials/test/UnitTests/UnitConverters_Tests.cs
Comment thread src/Essentials/test/UnitTests/UnitConverters_Tests.cs
Copilot AI added 2 commits April 28, 2026 23:26
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kubaflo
Copy link
Copy Markdown
Contributor

kubaflo commented Apr 28, 2026

Addressed review feedback:

  • PR description: Updated to accurately list the 11 methods actually covered (Fahrenheit/Celsius, Celsius/Kelvin, MilesToMeters, frequency conversions, Kilo-/Hectopascals → Pascals).
  • MilesToMeters: Added negative case [InlineData(-1, -1609.344)] for parity with sibling tests.
  • RadiansPerSecondToHertz: Added multi-revolution case [InlineData(12.5664, 2.0000)].
  • Frequency tests (DegreesPerSecondToHertz, RadiansPerSecondToHertz, HertzToDegreesPerSecond, HertzToRadiansPerSecond): Added one negative case each for sign-handling coverage consistency.

@kubaflo kubaflo changed the base branch from main to inflight/current April 28, 2026 21:43
@kubaflo kubaflo merged commit c4f8b23 into inflight/current Apr 28, 2026
3 of 13 checks passed
@kubaflo kubaflo deleted the op-add-unitconverters-tests branch April 28, 2026 21:44
@github-actions github-actions Bot added this to the .NET 10 SR7 milestone Apr 28, 2026
PureWeen added a commit that referenced this pull request Apr 29, 2026
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

## Summary

Add unit tests for 11 `UnitConverters` methods that had no test
coverage.

New test cases cover: `FahrenheitToCelsius`, `CelsiusToFahrenheit`,
`CelsiusToKelvin`, `KelvinToCelsius`, `MilesToMeters`,
`DegreesPerSecondToHertz`, `RadiansPerSecondToHertz`,
`HertzToDegreesPerSecond`, `HertzToRadiansPerSecond`,
`KilopascalsToPascals`, and `HectopascalsToPascals`.

✅ `dotnet test src/Essentials/test/UnitTests/Essentials.UnitTests.csproj
--filter UnitConverters` — 168 passed, 0 failed.

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request May 6, 2026
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

## Summary

Add unit tests for 11 `UnitConverters` methods that had no test
coverage.

New test cases cover: `FahrenheitToCelsius`, `CelsiusToFahrenheit`,
`CelsiusToKelvin`, `KelvinToCelsius`, `MilesToMeters`,
`DegreesPerSecondToHertz`, `RadiansPerSecondToHertz`,
`HertzToDegreesPerSecond`, `HertzToRadiansPerSecond`,
`KilopascalsToPascals`, and `HectopascalsToPascals`.

✅ `dotnet test src/Essentials/test/UnitTests/Essentials.UnitTests.csproj
--filter UnitConverters` — 168 passed, 0 failed.

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request May 25, 2026
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

## Summary

Add unit tests for 11 `UnitConverters` methods that had no test
coverage.

New test cases cover: `FahrenheitToCelsius`, `CelsiusToFahrenheit`,
`CelsiusToKelvin`, `KelvinToCelsius`, `MilesToMeters`,
`DegreesPerSecondToHertz`, `RadiansPerSecondToHertz`,
`HertzToDegreesPerSecond`, `HertzToRadiansPerSecond`,
`KilopascalsToPascals`, and `HectopascalsToPascals`.

✅ `dotnet test src/Essentials/test/UnitTests/Essentials.UnitTests.csproj
--filter UnitConverters` — 168 passed, 0 failed.

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
@github-actions github-actions Bot locked and limited conversation to collaborators May 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants