You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[TestMethod]publicasyncTaskWhenUsingConditionalsAccess_In_Message_NoDiagnostic(){stringcode=""" #nullable enable using System.Text.RegularExpressions; using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Collections.Generic; public class A { public string? S { get; set; } public Regex? R { get; set; } } [TestClass] public class MyTestClass { [TestMethod] public void Compliant() { Assert.AreEqual(new object(), new object(), new A().S?.Length.ToString()); } } """;awaitVerifyCS.VerifyAnalyzerAsync(code);}
But it fails:
Test method MSTest.Analyzers.UnitTests.AssertionArgsShouldAvoidConditionalAccessAnalyzerTests.WhenUsingConditionalsAccess_In_Message_NoDiagnostic threw exception:
System.InvalidOperationException: Context: Diagnostics of test state
Mismatch between number of diagnostics returned, expected "0" actual "1"
Diagnostics:
// /0/Test0.cs(18,9): info MSTEST0026: Prefer adding an additional assertion that checks for null
VerifyCS.Diagnostic().WithSpan(18, 9, 18, 82),
The text was updated successfully, but these errors were encountered:
The following analyzer unit test should pass
But it fails:
The text was updated successfully, but these errors were encountered: