Reputation: 23
I'm having a small problem with some Nunit tests I wrote for a .NET Framework application. I use Visual Studio 2019 (16.11.3) and ReSharper 2020.2
My application checks the currently used OS and does different things for different Windows versions. That's working well. But the Nunit test always fail because the Environment.OSVersion detects the wrong OS Version when I run it with the ReSharper test executor.
The following minimal test class for a .NET Framework project will fail if it's executed by the ReSharper but succeed if the Visual Studio text executor runs it on a Windows 10 OS.
[TestFixture]
public class TestClass {
[Test]
public void SomeTest()
{
TestContext.WriteLine(Environment.OSVersion);
Assert.AreEqual(10, Environment.OSVersion.Version.Major);
}
}
VS outputs Microsoft Windows NT 10.0.19042.0
ReSharper outputs Microsoft Windows NT 6.2.9200.0
Does anybody know if there is a hidden option or setting which would explain the problem?
It sounds like something related to https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/5.0/environment-osversion-returns-correct-version but my application explicitly tests for compatibilty mode and would register that as a error.
Upvotes: 0
Views: 149
Reputation: 23
A short FYI for the case that somebody has the same problem:
After contacting the ReSharper support it seems to happen because the AppManifest.xml of ReSharper's Test Runner in Version 2020.2 and the list of supported OS there.
According to the support engineer it's supposed to have been solved with version 2021.1 but I could not verify this because I haven't updated yet.
Upvotes: 1