@@ -10,6 +10,35 @@ namespace FluentAssertions.Analyzers.Tests.Tips;
10
10
[ TestClass ]
11
11
public class NunitTests
12
12
{
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
+
13
42
#region Assert.Conditions.cs
14
43
15
44
[ DataTestMethod ]
@@ -1660,13 +1689,17 @@ public void Nunit4_CollectionAssertDoesNotContain_WithCasting_TestCodeFix(string
1660
1689
1661
1690
private void Nunit3VerifyDiagnostic ( string methodArguments , string assertion )
1662
1691
=> 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 ) ;
1663
1694
private void Nunit3VerifyFix ( string methodArguments , string oldAssertion , string newAssertion )
1664
1695
=> VerifyFix ( GenerateCode . Nunit3Assertion ( methodArguments , oldAssertion ) , GenerateCode . Nunit3Assertion ( methodArguments , newAssertion ) , PackageReference . Nunit_3_14_0 ) ;
1665
1696
private void Nunit3VerifyNoFix ( string methodArguments , string assertion )
1666
1697
=> VerifyNoFix ( GenerateCode . Nunit3Assertion ( methodArguments , assertion ) , PackageReference . Nunit_3_14_0 ) ;
1667
1698
1668
1699
private void Nunit4VerifyDiagnostic ( string methodArguments , string assertion )
1669
1700
=> 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 ) ;
1670
1703
private void Nunit4VerifyFix ( string methodArguments , string oldAssertion , string newAssertion )
1671
1704
=> VerifyFix ( GenerateCode . Nunit4Assertion ( methodArguments , oldAssertion ) , GenerateCode . Nunit4Assertion ( methodArguments , newAssertion ) , PackageReference . Nunit_4_0_1 ) ;
1672
1705
private void Nunit4VerifyNoFix ( string methodArguments , string assertion )
@@ -1709,4 +1742,12 @@ private void VerifyNoFix(string source, PackageReference nunit)
1709
1742
. WithPackageReferences ( PackageReference . FluentAssertions_6_12_0 , nunit )
1710
1743
) ;
1711
1744
}
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
+ }
1712
1753
}
0 commit comments