Skip to content

Commit

Permalink
Better OSVersion_ValidVersion_OSX fix
Browse files Browse the repository at this point in the history
  • Loading branch information
filipnavara committed Sep 13, 2022
1 parent 203abe8 commit b563100
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,19 @@ public void OSVersion_ParseVersion(string input, int major, int minor, int build
Assert.Equal(expected, actual);
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotNativeAot))]
[Fact]
[PlatformSpecific(TestPlatforms.OSX)]
public void OSVersion_ValidVersion_OSX()
{
Version version = Environment.OSVersion.Version;

// verify that the Environment.OSVersion.Version matches the current RID
// As of 12.0, only major version numbers are included in the RID
Assert.Contains(version.ToString(1), RuntimeInformation.RuntimeIdentifier);
// NativeAOT hard-codes the runtime identifier at build time
if (!PlatformDetection.IsNativeAot)
{
// verify that the Environment.OSVersion.Version matches the current RID
// As of 12.0, only major version numbers are included in the RID
Assert.Contains(version.ToString(1), RuntimeInformation.RuntimeIdentifier);
}

Assert.True(version.Minor >= 0, "OSVersion Minor should be non-negative");
Assert.True(version.Build >= 0, "OSVersion Build should be non-negative");
Expand Down

0 comments on commit b563100

Please sign in to comment.