@@ -10,6 +10,35 @@ namespace FluentAssertions.Analyzers.Tests.Tips;
1010[ TestClass ]
1111public class NunitTests
1212{
13+ #region Assert.cs
14+
15+ [ DataTestMethod ]
16+ [ AssertionDiagnostic ( "Assert.Pass({0});" ) ]
17+ [ AssertionDiagnostic ( "Assert.Inconclusive({0});" ) ]
18+ [ AssertionDiagnostic ( "Assert.Ignore({0});" ) ]
19+ [ Implemented ]
20+ public void Nunit3_NotReportedAsserts_TestAnalyzer ( string assertion ) => Nunit3VerifyNoDiagnostic ( string . Empty , assertion ) ;
21+
22+ [ DataTestMethod ]
23+ [ DataRow ( "Assert.Warn(\" warning message\" );" ) ]
24+ [ DataRow ( "Assert.Warn(\" warning message {0} and more.\" , DateTime.Now);" ) ]
25+ [ Implemented ]
26+ public void Nunit3_SpecialNotReportedAsserts_TestAnalyzer ( string assertion ) => Nunit3VerifyNoDiagnostic ( string . Empty , assertion ) ;
27+
28+ [ DataTestMethod ]
29+ [ DataRow ( "Assert.Pass();" ) ]
30+ [ DataRow ( "Assert.Pass(\" passing message\" );" ) ]
31+ [ DataRow ( "Assert.Inconclusive();" ) ]
32+ [ DataRow ( "Assert.Inconclusive(\" inconclusive message\" );" ) ]
33+ [ DataRow ( "Assert.Ignore();" ) ]
34+ [ DataRow ( "Assert.Ignore(\" ignore message\" );" ) ]
35+ [ DataRow ( "Assert.Warn(\" warning message\" );" ) ]
36+ [ DataRow ( "Assert.Charlie();" ) ]
37+ [ Implemented ]
38+ public void Nunit4_SpecialNotReportedAsserts_TestAnalyzer ( string assertion ) => Nunit4VerifyNoDiagnostic ( string . Empty , assertion ) ;
39+
40+ #endregion
41+
1342 #region Assert.Conditions.cs
1443
1544 [ DataTestMethod ]
@@ -1660,13 +1689,17 @@ public void Nunit4_CollectionAssertDoesNotContain_WithCasting_TestCodeFix(string
16601689
16611690 private void Nunit3VerifyDiagnostic ( string methodArguments , string assertion )
16621691 => VerifyDiagnostic ( GenerateCode . Nunit3Assertion ( methodArguments , assertion ) , PackageReference . Nunit_3_14_0 ) ;
1692+ private void Nunit3VerifyNoDiagnostic ( string methodArguments , string assertion )
1693+ => VerifyNoDiagnostic ( GenerateCode . Nunit3Assertion ( methodArguments , assertion ) , PackageReference . Nunit_3_14_0 ) ;
16631694 private void Nunit3VerifyFix ( string methodArguments , string oldAssertion , string newAssertion )
16641695 => VerifyFix ( GenerateCode . Nunit3Assertion ( methodArguments , oldAssertion ) , GenerateCode . Nunit3Assertion ( methodArguments , newAssertion ) , PackageReference . Nunit_3_14_0 ) ;
16651696 private void Nunit3VerifyNoFix ( string methodArguments , string assertion )
16661697 => VerifyNoFix ( GenerateCode . Nunit3Assertion ( methodArguments , assertion ) , PackageReference . Nunit_3_14_0 ) ;
16671698
16681699 private void Nunit4VerifyDiagnostic ( string methodArguments , string assertion )
16691700 => VerifyDiagnostic ( GenerateCode . Nunit4Assertion ( methodArguments , assertion ) , PackageReference . Nunit_4_0_1 ) ;
1701+ private void Nunit4VerifyNoDiagnostic ( string methodArguments , string assertion )
1702+ => VerifyNoDiagnostic ( GenerateCode . Nunit4Assertion ( methodArguments , assertion ) , PackageReference . Nunit_4_0_1 ) ;
16701703 private void Nunit4VerifyFix ( string methodArguments , string oldAssertion , string newAssertion )
16711704 => VerifyFix ( GenerateCode . Nunit4Assertion ( methodArguments , oldAssertion ) , GenerateCode . Nunit4Assertion ( methodArguments , newAssertion ) , PackageReference . Nunit_4_0_1 ) ;
16721705 private void Nunit4VerifyNoFix ( string methodArguments , string assertion )
@@ -1709,4 +1742,12 @@ private void VerifyNoFix(string source, PackageReference nunit)
17091742 . WithPackageReferences ( PackageReference . FluentAssertions_6_12_0 , nunit )
17101743 ) ;
17111744 }
1745+ private void VerifyNoDiagnostic ( string source , PackageReference nunit )
1746+ {
1747+ DiagnosticVerifier . VerifyDiagnostic ( new DiagnosticVerifierArguments ( )
1748+ . WithAllAnalyzers ( )
1749+ . WithSources ( source )
1750+ . WithPackageReferences ( PackageReference . FluentAssertions_6_12_0 , nunit )
1751+ ) ;
1752+ }
17121753}
0 commit comments