'Unit Tests that work in VS 2019 but fail in VS 2022
I have the following test
[TestMethod]
public void Render_WithDateTimeNow_ReturnsFormattedString()
{
var template = @"C:\temp\@(DateTime.Now.AddDays(-1).ToString(""yyyy_MM_MMMM\\dd"")).csv";
var result = new FilePathRenderer().Render(template);
result.Should().Be(@"C:\temp\" + DateTime.Now.AddDays(-1).ToString("yyyy_MM_MMMM\\dd") + ".csv");
}
The Render method looks like this:
public string Render(string filePath)
{
lock (renderLock)
{
var result = RenderAsync(filePath).GetAwaiter().GetResult();
return HttpUtility.HtmlDecode(result);
}
}
When running this test in visual studio 2019, it passes perfectly. But when opening the same solution and running the same test without modification in visual studio 2022, it fails with the following error:
FilePathRenderer_Test.Render_WithDateTimeNow_ReturnsFormattedString threw exception: Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException: Method Debug.Fail failed with 'LanguageVersion 10.0 specified in the deps file could not be parsed. ', and was translated to Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException to avoid terminating the process hosting the test.
What could be the issue here?
Thanks in advance
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
