@@ -8,6 +8,14 @@ public class CollectionTests
88 {
99 public TestContext TestContext { get ; set ; }
1010
11+ [ AssertionDataTestMethod ]
12+ [ AssertionDiagnostic ( "nestedList.Should().NotBeNull({0}).And.ContainSingle().Which.Should().NotBeEmpty();" ) ]
13+ [ AssertionDiagnostic ( "nestedList.Should().NotBeNull().And.ContainSingle().Which.Should().NotBeEmpty({0});" ) ]
14+ [ AssertionDiagnostic ( "nestedList.Should().NotBeNull().And.ContainSingle({0}).Which.Should().NotBeEmpty();" ) ]
15+ [ NotImplemented ]
16+ public void NoDiagnostics ( string assertion ) => VerifyCSharpNoDiagnosticsCodeBlock ( assertion ) ;
17+
18+
1119 [ AssertionDataTestMethod ]
1220 [ AssertionDiagnostic ( "actual.Any().Should().BeTrue({0});" ) ]
1321 [ AssertionDiagnostic ( "actual.AsEnumerable().Any().Should().BeTrue({0}).And.ToString();" ) ]
@@ -375,6 +383,8 @@ public class CollectionTests
375383 [ AssertionDiagnostic ( "actual.Should().NotBeEmpty().And.NotBeNull({0});" ) ]
376384 [ AssertionDiagnostic ( "actual.AsEnumerable().Should().NotBeNull().And.NotBeEmpty({0}).And.ToString();" ) ]
377385 [ AssertionDiagnostic ( "actual.AsEnumerable().Should().NotBeEmpty().And.NotBeNull({0}).And.ToString();" ) ]
386+ [ AssertionDiagnostic ( "actual.AsEnumerable().Should().NotBeNull().And.HaveCount(2).And.NotBeEmpty({0}).And.ToString();" ) ]
387+ [ AssertionDiagnostic ( "actual.AsEnumerable().Should().NotBeEmpty().And.HaveCount(2).And.NotBeNull({0}).And.ToString();" ) ]
378388 [ Implemented ]
379389 public void CollectionShouldNotBeNullOrEmpty_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnosticCodeBlock < CollectionShouldNotBeNullOrEmptyAnalyzer > ( assertion ) ;
380390
@@ -390,7 +400,7 @@ public class CollectionTests
390400 newAssertion : "actual.Should().NotBeNullOrEmpty({0});" ) ]
391401 [ AssertionCodeFix (
392402 oldAssertion : "actual.Should().NotBeEmpty({0}).And.NotBeNull();" ,
393- newAssertion : "actual.Should().NotBeNullOrEmpty({0});" ) ]
403+ newAssertion : "actual.Should().NotBeNullOrEmpty({0});" ) ]
394404 [ AssertionCodeFix (
395405 oldAssertion : "actual.AsEnumerable().Should().NotBeNull().And.HaveCount(2).And.NotBeEmpty({0}).And.ToString();" ,
396406 newAssertion : "actual.AsEnumerable().Should().NotBeNullOrEmpty({0}).And.HaveCount(2).And.ToString();" ) ]
@@ -400,8 +410,6 @@ public class CollectionTests
400410 [ Implemented ]
401411 public void CollectionShouldNotBeNullOrEmpty_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFixCodeBlock < CollectionShouldNotBeNullOrEmptyCodeFix , CollectionShouldNotBeNullOrEmptyAnalyzer > ( oldAssertion , newAssertion ) ;
402412
403- public void CollectionShouldNotBeNullOrEmptyMultipleReasons_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFixCodeBlock < CollectionShouldNotBeNullOrEmptyCodeFix , CollectionShouldNotBeNullOrEmptyAnalyzer > ( oldAssertion , newAssertion ) ;
404-
405413 [ AssertionDataTestMethod ]
406414 [ AssertionDiagnostic ( "actual.ElementAt(k).Should().Be(expectedItem{0});" ) ]
407415 [ AssertionDiagnostic ( "actual.ElementAt(6).Should().Be(expectedItem{0});" ) ]
@@ -604,7 +612,7 @@ public class CollectionTests
604612 newAssertion : "actual.AsEnumerable().Should().HaveElementAt(0, null{0}).And.ToString();" ) ]
605613 [ Ignore ( "What Should Happen?" ) ]
606614 public void CollectionShouldHaveElementAt0Null_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFixCodeBlock < CollectionShouldHaveElementAt0NullCodeFix , CollectionShouldHaveElementAt0NullAnalyzer > ( oldAssertion , newAssertion ) ;
607-
615+
608616 private void VerifyCSharpDiagnosticCodeBlock < TDiagnosticAnalyzer > ( string sourceAssertion ) where TDiagnosticAnalyzer : Microsoft . CodeAnalysis . Diagnostics . DiagnosticAnalyzer , new ( )
609617 {
610618 var source = GenerateCode . EnumerableCodeBlockAssertion ( sourceAssertion ) ;
@@ -616,7 +624,7 @@ public class CollectionTests
616624 DiagnosticVerifier . VerifyCSharpDiagnosticUsingAllAnalyzers ( source , new DiagnosticResult
617625 {
618626 Id = diagnosticId ,
619- Message = string . Format ( message , GenerateCode . ActualVariableName ) ,
627+ Message = message ,
620628 Locations = new DiagnosticResultLocation [ ]
621629 {
622630 new DiagnosticResultLocation ( "Test0.cs" , 11 , 13 )
@@ -636,7 +644,7 @@ public class CollectionTests
636644 DiagnosticVerifier . VerifyCSharpDiagnosticUsingAllAnalyzers ( source , new DiagnosticResult
637645 {
638646 Id = diagnosticId ,
639- Message = string . Format ( message , GenerateCode . ActualVariableName ) ,
647+ Message = message ,
640648 Locations = new DiagnosticResultLocation [ ]
641649 {
642650 new DiagnosticResultLocation ( "Test0.cs" , 10 , 16 )
@@ -664,5 +672,11 @@ private void VerifyCSharpFixExpressionBody<TCodeFixProvider, TDiagnosticAnalyzer
664672
665673 DiagnosticVerifier . VerifyCSharpFix < TCodeFixProvider , TDiagnosticAnalyzer > ( oldSource , newSource ) ;
666674 }
675+
676+ private void VerifyCSharpNoDiagnosticsCodeBlock ( string assertion )
677+ {
678+ var source = GenerateCode . EnumerableCodeBlockAssertion ( assertion ) ;
679+ DiagnosticVerifier . VerifyCSharpDiagnosticUsingAllAnalyzers ( source ) ;
680+ }
667681 }
668682}
0 commit comments