diff --git a/src/Analyzers/MSTest.Analyzers/AnalyzerReleases.Unshipped.md b/src/Analyzers/MSTest.Analyzers/AnalyzerReleases.Unshipped.md index 042f71531d..6f9452a4df 100644 --- a/src/Analyzers/MSTest.Analyzers/AnalyzerReleases.Unshipped.md +++ b/src/Analyzers/MSTest.Analyzers/AnalyzerReleases.Unshipped.md @@ -11,3 +11,4 @@ MSTEST0021 | Design | Disabled | PreferDisposeOverTestCleanupAnalyzer, [Document MSTEST0022 | Design | Disabled | PreferTestCleanupOverDisposeAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/core/testing/mstest-analyzers/mstest0022) MSTEST0023 | Usage | Info | DoNotNegateBooleanAssertionAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/core/testing/mstest-analyzers/mstest0023) MSTEST0024 | Usage | Info | DoNotStoreStaticTestContextAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/core/testing/mstest-analyzers/mstest0024) +MSTEST0025 | Usage | Info | PreferAssertFailOverAlwaysFalseConditionsAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/core/testing/mstest-analyzers/mstest0025) diff --git a/src/Analyzers/MSTest.Analyzers/Helpers/DiagnosticIds.cs b/src/Analyzers/MSTest.Analyzers/Helpers/DiagnosticIds.cs index 1261bc79f6..48f07cfc7f 100644 --- a/src/Analyzers/MSTest.Analyzers/Helpers/DiagnosticIds.cs +++ b/src/Analyzers/MSTest.Analyzers/Helpers/DiagnosticIds.cs @@ -28,4 +28,5 @@ internal static class DiagnosticIds public const string PreferTestCleanupOverDisposeRuleId = "MSTEST0022"; public const string DoNotNegateBooleanAssertionRuleId = "MSTEST0023"; public const string DoNotStoreStaticTestContextAnalyzerRuleId = "MSTEST0024"; + public const string PreferAssertFailOverAlwaysFalseConditionsRuleId = "MSTEST0025"; } diff --git a/src/Analyzers/MSTest.Analyzers/PreferAssertFailOverAlwaysFalseConditionsAnalyzer.cs b/src/Analyzers/MSTest.Analyzers/PreferAssertFailOverAlwaysFalseConditionsAnalyzer.cs new file mode 100644 index 0000000000..1a689e87ec --- /dev/null +++ b/src/Analyzers/MSTest.Analyzers/PreferAssertFailOverAlwaysFalseConditionsAnalyzer.cs @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Collections.Immutable; + +using Analyzer.Utilities.Extensions; + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.Operations; + +using MSTest.Analyzers.Helpers; + +namespace MSTest.Analyzers; + +[DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] +public sealed class PreferAssertFailOverAlwaysFalseConditionsAnalyzer : DiagnosticAnalyzer +{ + private enum EqualityStatus + { + Unknown, + Equal, + NotEqual, + } + + private const string ExpectedParameterName = "expected"; + private const string NotExpectedParameterName = "notExpected"; + private const string ActualParameterName = "actual"; + private const string ConditionParameterName = "condition"; + private const string ValueParameterName = "value"; + + private static readonly LocalizableResourceString Title = new(nameof(Resources.PreferAssertFailOverAlwaysFalseConditionsTitle), Resources.ResourceManager, typeof(Resources)); + private static readonly LocalizableResourceString MessageFormat = new(nameof(Resources.PreferAssertFailOverAlwaysFalseConditionsMessageFormat), Resources.ResourceManager, typeof(Resources)); + + internal static readonly DiagnosticDescriptor Rule = DiagnosticDescriptorHelper.Create( + DiagnosticIds.PreferAssertFailOverAlwaysFalseConditionsRuleId, + Title, + MessageFormat, + null, + Category.Design, + DiagnosticSeverity.Info, + isEnabledByDefault: true); + + public override ImmutableArray SupportedDiagnostics { get; } + = ImmutableArray.Create(Rule); + + public override void Initialize(AnalysisContext context) + { + context.EnableConcurrentExecution(); + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics); + + context.RegisterCompilationStartAction(context => + { + Compilation compilation = context.Compilation; + INamedTypeSymbol? assertSymbol = compilation.GetOrCreateTypeByMetadataName(WellKnownTypeNames.MicrosoftVisualStudioTestToolsUnitTestingAssert); + if (assertSymbol is not null) + { + context.RegisterOperationAction(context => AnalyzeOperation(context, assertSymbol), OperationKind.Invocation); + } + }); + } + + private static void AnalyzeOperation(OperationAnalysisContext context, INamedTypeSymbol assertSymbol) + { + var operation = (IInvocationOperation)context.Operation; + if (assertSymbol.Equals(operation.TargetMethod?.ContainingType, SymbolEqualityComparer.Default) && + IsAlwaysFalse(operation)) + { + context.ReportDiagnostic(operation.CreateDiagnostic(Rule, operation.TargetMethod.Name)); + } + } + + private static bool IsAlwaysFalse(IInvocationOperation operation) + => operation.TargetMethod.Name switch + { + "IsTrue" => GetConditionArgument(operation) is { Value.ConstantValue: { HasValue: true, Value: false } }, + "IsFalse" => GetConditionArgument(operation) is { Value.ConstantValue: { HasValue: true, Value: true } }, + "AreEqual" => GetEqualityStatus(operation, ExpectedParameterName) == EqualityStatus.NotEqual, + "AreNotEqual" => GetEqualityStatus(operation, NotExpectedParameterName) == EqualityStatus.Equal, + "IsNotNull" => GetValueArgument(operation) is { Value.ConstantValue: { HasValue: true, Value: null } }, + _ => false, + }; + + private static IArgumentOperation? GetArgumentWithName(IInvocationOperation operation, string name) + => operation.Arguments.FirstOrDefault(arg => arg.Parameter?.Name == name); + + private static IArgumentOperation? GetConditionArgument(IInvocationOperation operation) + => GetArgumentWithName(operation, ConditionParameterName); + + private static IArgumentOperation? GetValueArgument(IInvocationOperation operation) + => GetArgumentWithName(operation, ValueParameterName); + + private static EqualityStatus GetEqualityStatus(IInvocationOperation operation, string expectedOrNotExpectedParameterName) + { + if (GetArgumentWithName(operation, expectedOrNotExpectedParameterName) is { } expectedOrNotExpectedArgument && + GetArgumentWithName(operation, ActualParameterName) is { } actualArgument && + expectedOrNotExpectedArgument.Value.ConstantValue.HasValue && + actualArgument.Value.ConstantValue.HasValue) + { + return Equals(expectedOrNotExpectedArgument.Value.ConstantValue.Value, actualArgument.Value.ConstantValue.Value) ? EqualityStatus.Equal : EqualityStatus.NotEqual; + } + + // We are not sure about the equality status + return EqualityStatus.Unknown; + } +} diff --git a/src/Analyzers/MSTest.Analyzers/Resources.Designer.cs b/src/Analyzers/MSTest.Analyzers/Resources.Designer.cs index 49cba6accf..c01c7554c8 100644 --- a/src/Analyzers/MSTest.Analyzers/Resources.Designer.cs +++ b/src/Analyzers/MSTest.Analyzers/Resources.Designer.cs @@ -587,6 +587,24 @@ internal static string DoNotStoreStaticTestContextAnalyzerTitle { } } + /// + /// Looks up a localized string similar to Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert. + /// + internal static string PreferAssertFailOverAlwaysFalseConditionsMessageFormat { + get { + return ResourceManager.GetString("PreferAssertFailOverAlwaysFalseConditionsMessageFormat", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Use 'Assert.Fail' instead of an always-failing assert. + /// + internal static string PreferAssertFailOverAlwaysFalseConditionsTitle { + get { + return ResourceManager.GetString("PreferAssertFailOverAlwaysFalseConditionsTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to Prefer constructors over TestInitialize methods. /// diff --git a/src/Analyzers/MSTest.Analyzers/Resources.resx b/src/Analyzers/MSTest.Analyzers/Resources.resx index 1c16915c25..17607ff84d 100644 --- a/src/Analyzers/MSTest.Analyzers/Resources.resx +++ b/src/Analyzers/MSTest.Analyzers/Resources.resx @@ -313,6 +313,12 @@ Do not store TestContext in a static member + + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + + + Use 'Assert.Fail' instead of an always-failing assert + Prefer constructors over TestInitialize methods diff --git a/src/Analyzers/MSTest.Analyzers/xlf/Resources.cs.xlf b/src/Analyzers/MSTest.Analyzers/xlf/Resources.cs.xlf index 91fe4c3d2c..2b4d7ac332 100644 --- a/src/Analyzers/MSTest.Analyzers/xlf/Resources.cs.xlf +++ b/src/Analyzers/MSTest.Analyzers/xlf/Resources.cs.xlf @@ -343,6 +343,16 @@ Neukládejte TestContext ve statickém členu + + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + + + + Use 'Assert.Fail' instead of an always-failing assert + Use 'Assert.Fail' instead of an always-failing assert + + Prefer constructors over TestInitialize methods Upřednostňovat konstruktory před metodami TestInitialize diff --git a/src/Analyzers/MSTest.Analyzers/xlf/Resources.de.xlf b/src/Analyzers/MSTest.Analyzers/xlf/Resources.de.xlf index bac1e15d95..1d2ed9a75a 100644 --- a/src/Analyzers/MSTest.Analyzers/xlf/Resources.de.xlf +++ b/src/Analyzers/MSTest.Analyzers/xlf/Resources.de.xlf @@ -339,6 +339,16 @@ TestContext nicht in einem statischen Member speichern + + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + + + + Use 'Assert.Fail' instead of an always-failing assert + Use 'Assert.Fail' instead of an always-failing assert + + Prefer constructors over TestInitialize methods Konstruktoren gegenüber TestInitialize-Methoden bevorzugen diff --git a/src/Analyzers/MSTest.Analyzers/xlf/Resources.es.xlf b/src/Analyzers/MSTest.Analyzers/xlf/Resources.es.xlf index fbb15464bc..fd4c04213a 100644 --- a/src/Analyzers/MSTest.Analyzers/xlf/Resources.es.xlf +++ b/src/Analyzers/MSTest.Analyzers/xlf/Resources.es.xlf @@ -339,6 +339,16 @@ No almacenar TestContext en un miembro estático + + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + + + + Use 'Assert.Fail' instead of an always-failing assert + Use 'Assert.Fail' instead of an always-failing assert + + Prefer constructors over TestInitialize methods Preferir constructores en lugar de métodos TestInitialize diff --git a/src/Analyzers/MSTest.Analyzers/xlf/Resources.fr.xlf b/src/Analyzers/MSTest.Analyzers/xlf/Resources.fr.xlf index 72aad390a7..3efd5dd459 100644 --- a/src/Analyzers/MSTest.Analyzers/xlf/Resources.fr.xlf +++ b/src/Analyzers/MSTest.Analyzers/xlf/Resources.fr.xlf @@ -339,6 +339,16 @@ Ne pas stocker TestContext dans un membre statique + + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + + + + Use 'Assert.Fail' instead of an always-failing assert + Use 'Assert.Fail' instead of an always-failing assert + + Prefer constructors over TestInitialize methods Préférer les constructeurs aux méthodes TestInitialize diff --git a/src/Analyzers/MSTest.Analyzers/xlf/Resources.it.xlf b/src/Analyzers/MSTest.Analyzers/xlf/Resources.it.xlf index 1ca7a5ad4f..e51366c11c 100644 --- a/src/Analyzers/MSTest.Analyzers/xlf/Resources.it.xlf +++ b/src/Analyzers/MSTest.Analyzers/xlf/Resources.it.xlf @@ -339,6 +339,16 @@ Non archiviare TestContext in un membro statico + + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + + + + Use 'Assert.Fail' instead of an always-failing assert + Use 'Assert.Fail' instead of an always-failing assert + + Prefer constructors over TestInitialize methods Preferisci costruttori rispetto ai metodi TestInitialize diff --git a/src/Analyzers/MSTest.Analyzers/xlf/Resources.ja.xlf b/src/Analyzers/MSTest.Analyzers/xlf/Resources.ja.xlf index 54aa1a1d77..b90bbd893b 100644 --- a/src/Analyzers/MSTest.Analyzers/xlf/Resources.ja.xlf +++ b/src/Analyzers/MSTest.Analyzers/xlf/Resources.ja.xlf @@ -339,6 +339,16 @@ 静的メンバーに TestContext を格納しない + + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + + + + Use 'Assert.Fail' instead of an always-failing assert + Use 'Assert.Fail' instead of an always-failing assert + + Prefer constructors over TestInitialize methods TestInitialize メソッドよりもコンストラクターを優先する diff --git a/src/Analyzers/MSTest.Analyzers/xlf/Resources.ko.xlf b/src/Analyzers/MSTest.Analyzers/xlf/Resources.ko.xlf index 63e42de430..60c9471e17 100644 --- a/src/Analyzers/MSTest.Analyzers/xlf/Resources.ko.xlf +++ b/src/Analyzers/MSTest.Analyzers/xlf/Resources.ko.xlf @@ -339,6 +339,16 @@ TestContext를 정적 멤버에 저장하지 마세요 + + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + + + + Use 'Assert.Fail' instead of an always-failing assert + Use 'Assert.Fail' instead of an always-failing assert + + Prefer constructors over TestInitialize methods TestInitialize 메서드보다 생성자 선호 diff --git a/src/Analyzers/MSTest.Analyzers/xlf/Resources.pl.xlf b/src/Analyzers/MSTest.Analyzers/xlf/Resources.pl.xlf index 0b5acaf468..5fd6b2ef66 100644 --- a/src/Analyzers/MSTest.Analyzers/xlf/Resources.pl.xlf +++ b/src/Analyzers/MSTest.Analyzers/xlf/Resources.pl.xlf @@ -339,6 +339,16 @@ Nie przechowuj elementu TestContext w statycznym elemencie członkowskim + + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + + + + Use 'Assert.Fail' instead of an always-failing assert + Use 'Assert.Fail' instead of an always-failing assert + + Prefer constructors over TestInitialize methods Preferowanie konstruktorów niż metod TestInitialize diff --git a/src/Analyzers/MSTest.Analyzers/xlf/Resources.pt-BR.xlf b/src/Analyzers/MSTest.Analyzers/xlf/Resources.pt-BR.xlf index 93086e9826..62f81188cb 100644 --- a/src/Analyzers/MSTest.Analyzers/xlf/Resources.pt-BR.xlf +++ b/src/Analyzers/MSTest.Analyzers/xlf/Resources.pt-BR.xlf @@ -339,6 +339,16 @@ Não armazene TestContext em um membro estático + + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + + + + Use 'Assert.Fail' instead of an always-failing assert + Use 'Assert.Fail' instead of an always-failing assert + + Prefer constructors over TestInitialize methods Preferir construtores em vez de métodos TestInitialize diff --git a/src/Analyzers/MSTest.Analyzers/xlf/Resources.ru.xlf b/src/Analyzers/MSTest.Analyzers/xlf/Resources.ru.xlf index f807938287..5259ba751b 100644 --- a/src/Analyzers/MSTest.Analyzers/xlf/Resources.ru.xlf +++ b/src/Analyzers/MSTest.Analyzers/xlf/Resources.ru.xlf @@ -339,6 +339,16 @@ Не хранить TestContext в статическом элементе + + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + + + + Use 'Assert.Fail' instead of an always-failing assert + Use 'Assert.Fail' instead of an always-failing assert + + Prefer constructors over TestInitialize methods Предпочитать конструкторы методам TestInitialize diff --git a/src/Analyzers/MSTest.Analyzers/xlf/Resources.tr.xlf b/src/Analyzers/MSTest.Analyzers/xlf/Resources.tr.xlf index ba3ab12d04..b9bc822c31 100644 --- a/src/Analyzers/MSTest.Analyzers/xlf/Resources.tr.xlf +++ b/src/Analyzers/MSTest.Analyzers/xlf/Resources.tr.xlf @@ -339,6 +339,16 @@ TestContext'i statik üyede depolama + + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + + + + Use 'Assert.Fail' instead of an always-failing assert + Use 'Assert.Fail' instead of an always-failing assert + + Prefer constructors over TestInitialize methods Oluşturucuları TestInitialize yöntemlerine tercih et diff --git a/src/Analyzers/MSTest.Analyzers/xlf/Resources.zh-Hans.xlf b/src/Analyzers/MSTest.Analyzers/xlf/Resources.zh-Hans.xlf index 0cac7e5596..304762a384 100644 --- a/src/Analyzers/MSTest.Analyzers/xlf/Resources.zh-Hans.xlf +++ b/src/Analyzers/MSTest.Analyzers/xlf/Resources.zh-Hans.xlf @@ -339,6 +339,16 @@ 不要将 TestContext 存储在静态成员中 + + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + + + + Use 'Assert.Fail' instead of an always-failing assert + Use 'Assert.Fail' instead of an always-failing assert + + Prefer constructors over TestInitialize methods 首选构造函数而不是 TestInitialize 方法 diff --git a/src/Analyzers/MSTest.Analyzers/xlf/Resources.zh-Hant.xlf b/src/Analyzers/MSTest.Analyzers/xlf/Resources.zh-Hant.xlf index 2e0fc4f575..cea2b5d5a9 100644 --- a/src/Analyzers/MSTest.Analyzers/xlf/Resources.zh-Hant.xlf +++ b/src/Analyzers/MSTest.Analyzers/xlf/Resources.zh-Hant.xlf @@ -339,6 +339,16 @@ 請勿將 TestContext 儲存在靜態成員中 + + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert + + + + Use 'Assert.Fail' instead of an always-failing assert + Use 'Assert.Fail' instead of an always-failing assert + + Prefer constructors over TestInitialize methods 偏好建構函式勝於 TestInitialize 方法 diff --git a/test/UnitTests/MSTest.Analyzers.UnitTests/PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.cs b/test/UnitTests/MSTest.Analyzers.UnitTests/PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.cs new file mode 100644 index 0000000000..a9b4009dda --- /dev/null +++ b/test/UnitTests/MSTest.Analyzers.UnitTests/PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.cs @@ -0,0 +1,961 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.Testing.Internal.Framework; +using Microsoft.Testing.TestInfrastructure; + +using VerifyCS = MSTest.Analyzers.Test.CSharpCodeFixVerifier< + MSTest.Analyzers.PreferAssertFailOverAlwaysFalseConditionsAnalyzer, + Microsoft.CodeAnalysis.Testing.EmptyCodeFixProvider>; + +namespace MSTest.Analyzers.Test; + +[TestGroup] +public sealed class PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests(ITestExecutionContext testExecutionContext) : TestBase(testExecutionContext) +{ + public async Task WhenAssertIsTrueIsPassedTrue_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.IsTrue(true); + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsTrueIsPassedTrue_WithMessage_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.IsTrue(true, "message"); + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsTrueIsPassedTrue_WithMessageFirst_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.IsTrue(message: "message", condition: true); + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsTrueIsPassedFalse_Diagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + [|Assert.IsTrue(false)|]; + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsTrueIsPassedFalse_WithMessage_Diagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + [|Assert.IsTrue(false, "message")|]; + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsTrueIsPassedFalse_WithMessageFirst_Diagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + [|Assert.IsTrue(message: "message", condition: false)|]; + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsTrueIsPassedUnknown_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.IsTrue(GetBoolean()); + } + + private static bool GetBoolean() => true; + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsTrueIsPassedUnknown_WithMessage_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.IsTrue(GetBoolean(), "message"); + } + + private static bool GetBoolean() => true; + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsTrueIsPassedUnknown_WithMessageFirst_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.IsTrue(message: "message", condition: GetBoolean()); + } + + private static bool GetBoolean() => true; + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsFalseIsPassedTrue_Diagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + [|Assert.IsFalse(true)|]; + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsFalseIsPassedTrue_WithMessage_Diagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + [|Assert.IsFalse(true, "message")|]; + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsFalseIsPassedTrue_WithMessageFirst_Diagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + [|Assert.IsFalse(message: "message", condition: true)|]; + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsFalseIsPassedFalse_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.IsFalse(false); + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsFalseIsPassedFalse_WithMessage_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.IsFalse(false, "message"); + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsFalseIsPassedFalse_WithMessageFirst_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.IsFalse(message: "message", condition: false); + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsFalseIsPassedUnknown_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.IsFalse(GetBoolean()); + } + + private static bool GetBoolean() => true; + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsFalseIsPassedUnknown_WithMessage_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.IsFalse(GetBoolean(), "message"); + } + + private static bool GetBoolean() => true; + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsFalseIsPassedUnknown_WithMessageFirst_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.IsFalse(message: "message", condition: GetBoolean()); + } + + private static bool GetBoolean() => true; + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsNotNullIsPassedNull_Diagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + [|Assert.IsNotNull(null)|]; + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsNotNullIsPassedNull_WithMessage_Diagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + [|Assert.IsNotNull(null, "message")|]; + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsNotNullIsPassedNull_WithMessageFirst_Diagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + [|Assert.IsNotNull(message: "message", value: null)|]; + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsNotNullIsPassedUnknown_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.IsNotNull(GetObject()); + } + + private static object GetObject() => new object(); + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsNotNullIsPassedUnknown_WithMessage_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.IsNotNull(GetObject(), "message"); + } + + private static object GetObject() => new object(); + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertIsNotNullIsPassedUnknown_WithMessageFirst_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.IsNotNull(message: "message", value: GetObject()); + } + + private static object GetObject() => new object(); + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreEqualIsPassedEqual_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.AreEqual(true, true); + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreEqualIsPassedEqual_WithMessage_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.AreEqual(true, true, "message"); + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreEqualIsPassedEqual_WithMessageFirst_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.AreEqual(message: "message", expected: true, actual: true); + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreEqualIsPassedEqual_WithMessageSecond_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.AreEqual(expected: true, message: "message", actual: true); + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreEqualIsPassedNonEqual_Diagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + [|Assert.AreEqual(true, false)|]; + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreEqualIsPassedNonEqual_WithMessage_Diagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + [|Assert.AreEqual(true, false, "message")|]; + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreEqualIsPassedNonEqual_WithMessageFirst_Diagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + [|Assert.AreEqual(message: "message", expected: true, actual: false)|]; + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreEqualIsPassedNonEqual_WithMessageSecond_Diagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + [|Assert.AreEqual(expected: true, message: "message", actual: false)|]; + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreEqualIsPassedUnknown_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.AreEqual(GetBoolean(), GetBoolean()); + } + + private static bool GetBoolean() => true; + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreEqualIsPassedUnknown_WithMessage_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.AreEqual(GetBoolean(), GetBoolean(), "message"); + } + + private static bool GetBoolean() => true; + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreEqualIsPassedUnknown_WithMessageFirst_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.AreEqual(message: "message", expected: GetBoolean(), actual: GetBoolean()); + } + + private static bool GetBoolean() => true; + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreEqualIsPassedUnknown_WithMessageSecond_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.AreEqual(expected: GetBoolean(), message: "message", actual: GetBoolean()); + } + + private static bool GetBoolean() => true; + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreNotEqualIsPassedEqual_Diagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + [|Assert.AreNotEqual(true, true)|]; + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreNotEqualIsPassedEqual_WithMessage_Diagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + [|Assert.AreNotEqual(true, true, "message")|]; + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreNotEqualIsPassedEqual_WithMessageFirst_Diagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + [|Assert.AreNotEqual(message: "message", notExpected: true, actual: true)|]; + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreNotEqualIsPassedEqual_WithMessageSecond_Diagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + [|Assert.AreNotEqual(notExpected: true, message: "message", actual: true)|]; + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreNotEqualIsPassedNonEqual_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.AreNotEqual(true, false); + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreNotEqualIsPassedNonEqual_WithMessage_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.AreNotEqual(true, false, "message"); + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreNotEqualIsPassedNonEqual_WithMessageFirst_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.AreNotEqual(message: "message", notExpected: true, actual: false); + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreNotEqualIsPassedNonEqual_WithMessageSecond_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.AreNotEqual(notExpected: true, message: "message", actual: false); + } + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreNotEqualIsPassedUnknown_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.AreNotEqual(GetBoolean(), GetBoolean()); + } + + private static bool GetBoolean() => true; + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreNotEqualIsPassedUnknown_WithMessage_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.AreNotEqual(GetBoolean(), GetBoolean(), "message"); + } + + private static bool GetBoolean() => true; + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreNotEqualIsPassedUnknown_WithMessageFirst_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.AreNotEqual(message: "message", notExpected: GetBoolean(), actual: GetBoolean()); + } + + private static bool GetBoolean() => true; + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } + + public async Task WhenAssertAreNotEqualIsPassedUnknown_WithMessageSecond_NoDiagnostic() + { + string code = """ + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public class MyTestClass + { + [TestMethod] + public void TestMethod() + { + Assert.AreNotEqual(message: "message", notExpected: GetBoolean(), actual: GetBoolean()); + } + + private static bool GetBoolean() => true; + } + """; + + await VerifyCS.VerifyCodeFixAsync(code, code); + } +} diff --git a/test/UnitTests/MSTest.Analyzers.UnitTests/testsbaseline.txt b/test/UnitTests/MSTest.Analyzers.UnitTests/testsbaseline.txt index b57bfae1d0..61b3dc8d4e 100644 --- a/test/UnitTests/MSTest.Analyzers.UnitTests/testsbaseline.txt +++ b/test/UnitTests/MSTest.Analyzers.UnitTests/testsbaseline.txt @@ -91,6 +91,54 @@ MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.DoNotNegateBooleanAssertionAnal MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.DoNotNegateBooleanAssertionAnalyzerTests.WhenAssertionIsNotNegated_NoDiagnostic() MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.DoNotStoreStaticTestContextAnalyzerTests.WhenAssemblyInitializeOrClassInitialize_Diagnostic() MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.DoNotStoreStaticTestContextAnalyzerTests.WhenOtherTestContext_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreEqualIsPassedEqual_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreEqualIsPassedEqual_WithMessage_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreEqualIsPassedEqual_WithMessageFirst_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreEqualIsPassedEqual_WithMessageSecond_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreEqualIsPassedNonEqual_Diagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreEqualIsPassedNonEqual_WithMessage_Diagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreEqualIsPassedNonEqual_WithMessageFirst_Diagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreEqualIsPassedNonEqual_WithMessageSecond_Diagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreEqualIsPassedUnknown_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreEqualIsPassedUnknown_WithMessage_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreEqualIsPassedUnknown_WithMessageFirst_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreEqualIsPassedUnknown_WithMessageSecond_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreNotEqualIsPassedEqual_Diagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreNotEqualIsPassedEqual_WithMessage_Diagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreNotEqualIsPassedEqual_WithMessageFirst_Diagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreNotEqualIsPassedEqual_WithMessageSecond_Diagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreNotEqualIsPassedNonEqual_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreNotEqualIsPassedNonEqual_WithMessage_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreNotEqualIsPassedNonEqual_WithMessageFirst_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreNotEqualIsPassedNonEqual_WithMessageSecond_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreNotEqualIsPassedUnknown_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreNotEqualIsPassedUnknown_WithMessage_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreNotEqualIsPassedUnknown_WithMessageFirst_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertAreNotEqualIsPassedUnknown_WithMessageSecond_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsFalseIsPassedFalse_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsFalseIsPassedFalse_WithMessage_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsFalseIsPassedFalse_WithMessageFirst_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsFalseIsPassedTrue_Diagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsFalseIsPassedTrue_WithMessage_Diagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsFalseIsPassedTrue_WithMessageFirst_Diagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsFalseIsPassedUnknown_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsFalseIsPassedUnknown_WithMessage_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsFalseIsPassedUnknown_WithMessageFirst_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsNotNullIsPassedNull_Diagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsNotNullIsPassedNull_WithMessage_Diagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsNotNullIsPassedNull_WithMessageFirst_Diagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsNotNullIsPassedUnknown_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsNotNullIsPassedUnknown_WithMessage_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsNotNullIsPassedUnknown_WithMessageFirst_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsTrueIsPassedFalse_Diagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsTrueIsPassedFalse_WithMessage_Diagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsTrueIsPassedFalse_WithMessageFirst_Diagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsTrueIsPassedTrue_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsTrueIsPassedTrue_WithMessage_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsTrueIsPassedTrue_WithMessageFirst_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsTrueIsPassedUnknown_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsTrueIsPassedUnknown_WithMessage_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferAssertFailOverAlwaysFalseConditionsAnalyzerTests.WhenAssertIsTrueIsPassedUnknown_WithMessageFirst_NoDiagnostic() MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferConstructorOverTestInitializeAnalyzerTests.WhenTestClassHasCtor_NoDiagnostic() MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferConstructorOverTestInitializeAnalyzerTests.WhenTestClassHasTestInitialize_Diagnostic() MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.PreferConstructorOverTestInitializeAnalyzerTests.WhenTestClassHasTestInitializeAndCtor_Diagnostic() @@ -130,14 +178,14 @@ MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.TestClassShouldHaveTestMethodAn MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.TestClassShouldHaveTestMethodAnalyzerTests.WhenStaticTestClassWithoutAssemblyAttributes_DoesNotHaveTestMethod_Diagnostic() MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.TestClassShouldHaveTestMethodAnalyzerTests.WhenTestClassDoesNotHaveTestMethod_Diagnostic() MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.TestClassShouldHaveTestMethodAnalyzerTests.WhenTestClassHasTestMethod_NoDiagnostic() -MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.TestClassShouldHaveTestMethodAnalyzerTests.WhenTestClassWithoutAssemblyAttributesAndTestMethod_InheritsFromBaseBaseClassHasAssemblyCleanup_Diagnostic() MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.TestClassShouldHaveTestMethodAnalyzerTests.WhenTestClassWithoutAssemblyAttributesAndTestMethod_InheritsFromAbstractClassHasTestMethod_NoDiagnostic() -MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.TestClassShouldHaveTestMethodAnalyzerTests.WhenTestClassWithoutAssemblyAttributesAndTestMethod_InheritsFromClassHasTestMethod_NoDiagnostic() -MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.TestClassShouldHaveTestMethodAnalyzerTests.WhenTestClassWithoutAssemblyAttributesAndTestMethod_InheritsFromTestClassHasTestMethod_NoDiagnostic() MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.TestClassShouldHaveTestMethodAnalyzerTests.WhenTestClassWithoutAssemblyAttributesAndTestMethod_InheritsFromAbstractTestClassHasTestMethod_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.TestClassShouldHaveTestMethodAnalyzerTests.WhenTestClassWithoutAssemblyAttributesAndTestMethod_InheritsFromBaseBaseClassHasAssemblyCleanup_Diagnostic() MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.TestClassShouldHaveTestMethodAnalyzerTests.WhenTestClassWithoutAssemblyAttributesAndTestMethod_InheritsFromBaseBaseClassHasTestMethod_NoDiagnostic() MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.TestClassShouldHaveTestMethodAnalyzerTests.WhenTestClassWithoutAssemblyAttributesAndTestMethod_InheritsFromClassDoesNotHaveTestMethod_Diagnostic() MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.TestClassShouldHaveTestMethodAnalyzerTests.WhenTestClassWithoutAssemblyAttributesAndTestMethod_InheritsFromClassHasAssemblyInitialize_Diagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.TestClassShouldHaveTestMethodAnalyzerTests.WhenTestClassWithoutAssemblyAttributesAndTestMethod_InheritsFromClassHasTestMethod_NoDiagnostic() +MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.TestClassShouldHaveTestMethodAnalyzerTests.WhenTestClassWithoutAssemblyAttributesAndTestMethod_InheritsFromTestClassHasTestMethod_NoDiagnostic() MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.TestCleanupShouldBeValidAnalyzerTests.WhenTestCleanupHasParameters_Diagnostic() MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.TestCleanupShouldBeValidAnalyzerTests.WhenTestCleanupIsAbstract_Diagnostic() MSTest.Analyzers.UnitTests.MSTest.Analyzers.Test.TestCleanupShouldBeValidAnalyzerTests.WhenTestCleanupIsAsyncVoid_Diagnostic()