зеркало из https://github.com/microsoft/testfx.git
add tests
This commit is contained in:
Родитель
d1351a1ca1
Коммит
338aef8139
|
@ -0,0 +1,52 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using VerifyCS = MSTest.Analyzers.Test.CSharpCodeFixVerifier<
|
||||
MSTest.Analyzers.UseNullableForIsNullAndIsNotNullAssertionsAnalyzer,
|
||||
Microsoft.CodeAnalysis.Testing.EmptyCodeFixProvider>;
|
||||
|
||||
namespace MSTest.Analyzers.Test;
|
||||
|
||||
[TestGroup]
|
||||
public sealed class UseNullableForIsNullAndIsNotNullAssertionsAnalyzerTests(ITestExecutionContext testExecutionContext) : TestBase(testExecutionContext)
|
||||
{
|
||||
public async Task WhenIsNullAssertion_ValueParameterIsNullable_NoDiagnostic()
|
||||
{
|
||||
string code = """
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
[TestClass]
|
||||
public class MyTestClass
|
||||
{
|
||||
[TestMethod]
|
||||
public void MyTestMethod()
|
||||
{
|
||||
string? var = null;
|
||||
Assert.IsNull(var);
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
await VerifyCS.VerifyAnalyzerAsync(code);
|
||||
}
|
||||
|
||||
public async Task WhenIsNullAssertion_ValueParameterIsNotNullable_Diagnostic()
|
||||
{
|
||||
string code = """
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
[TestClass]
|
||||
public class MyTestClass
|
||||
{
|
||||
[TestMethod]
|
||||
public void MyTestMethod()
|
||||
{
|
||||
string var = "value";
|
||||
Assert.[|IsNull|](var);
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
await VerifyCS.VerifyAnalyzerAsync(code);
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче