@@ -8,6 +8,14 @@ public class CollectionTests
8
8
{
9
9
public TestContext TestContext { get ; set ; }
10
10
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
+
11
19
[ AssertionDataTestMethod ]
12
20
[ AssertionDiagnostic ( "actual.Any().Should().BeTrue({0});" ) ]
13
21
[ AssertionDiagnostic ( "actual.AsEnumerable().Any().Should().BeTrue({0}).And.ToString();" ) ]
@@ -375,6 +383,8 @@ public class CollectionTests
375
383
[ AssertionDiagnostic ( "actual.Should().NotBeEmpty().And.NotBeNull({0});" ) ]
376
384
[ AssertionDiagnostic ( "actual.AsEnumerable().Should().NotBeNull().And.NotBeEmpty({0}).And.ToString();" ) ]
377
385
[ 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();" ) ]
378
388
[ Implemented ]
379
389
public void CollectionShouldNotBeNullOrEmpty_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnosticCodeBlock < CollectionShouldNotBeNullOrEmptyAnalyzer > ( assertion ) ;
380
390
@@ -390,7 +400,7 @@ public class CollectionTests
390
400
newAssertion : "actual.Should().NotBeNullOrEmpty({0});" ) ]
391
401
[ AssertionCodeFix (
392
402
oldAssertion : "actual.Should().NotBeEmpty({0}).And.NotBeNull();" ,
393
- newAssertion : "actual.Should().NotBeNullOrEmpty({0});" ) ]
403
+ newAssertion : "actual.Should().NotBeNullOrEmpty({0});" ) ]
394
404
[ AssertionCodeFix (
395
405
oldAssertion : "actual.AsEnumerable().Should().NotBeNull().And.HaveCount(2).And.NotBeEmpty({0}).And.ToString();" ,
396
406
newAssertion : "actual.AsEnumerable().Should().NotBeNullOrEmpty({0}).And.HaveCount(2).And.ToString();" ) ]
@@ -400,8 +410,6 @@ public class CollectionTests
400
410
[ Implemented ]
401
411
public void CollectionShouldNotBeNullOrEmpty_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFixCodeBlock < CollectionShouldNotBeNullOrEmptyCodeFix , CollectionShouldNotBeNullOrEmptyAnalyzer > ( oldAssertion , newAssertion ) ;
402
412
403
- public void CollectionShouldNotBeNullOrEmptyMultipleReasons_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFixCodeBlock < CollectionShouldNotBeNullOrEmptyCodeFix , CollectionShouldNotBeNullOrEmptyAnalyzer > ( oldAssertion , newAssertion ) ;
404
-
405
413
[ AssertionDataTestMethod ]
406
414
[ AssertionDiagnostic ( "actual.ElementAt(k).Should().Be(expectedItem{0});" ) ]
407
415
[ AssertionDiagnostic ( "actual.ElementAt(6).Should().Be(expectedItem{0});" ) ]
@@ -604,7 +612,7 @@ public class CollectionTests
604
612
newAssertion : "actual.AsEnumerable().Should().HaveElementAt(0, null{0}).And.ToString();" ) ]
605
613
[ Ignore ( "What Should Happen?" ) ]
606
614
public void CollectionShouldHaveElementAt0Null_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFixCodeBlock < CollectionShouldHaveElementAt0NullCodeFix , CollectionShouldHaveElementAt0NullAnalyzer > ( oldAssertion , newAssertion ) ;
607
-
615
+
608
616
private void VerifyCSharpDiagnosticCodeBlock < TDiagnosticAnalyzer > ( string sourceAssertion ) where TDiagnosticAnalyzer : Microsoft . CodeAnalysis . Diagnostics . DiagnosticAnalyzer , new ( )
609
617
{
610
618
var source = GenerateCode . EnumerableCodeBlockAssertion ( sourceAssertion ) ;
@@ -616,7 +624,7 @@ public class CollectionTests
616
624
DiagnosticVerifier . VerifyCSharpDiagnosticUsingAllAnalyzers ( source , new DiagnosticResult
617
625
{
618
626
Id = diagnosticId ,
619
- Message = string . Format ( message , GenerateCode . ActualVariableName ) ,
627
+ Message = message ,
620
628
Locations = new DiagnosticResultLocation [ ]
621
629
{
622
630
new DiagnosticResultLocation ( "Test0.cs" , 11 , 13 )
@@ -636,7 +644,7 @@ public class CollectionTests
636
644
DiagnosticVerifier . VerifyCSharpDiagnosticUsingAllAnalyzers ( source , new DiagnosticResult
637
645
{
638
646
Id = diagnosticId ,
639
- Message = string . Format ( message , GenerateCode . ActualVariableName ) ,
647
+ Message = message ,
640
648
Locations = new DiagnosticResultLocation [ ]
641
649
{
642
650
new DiagnosticResultLocation ( "Test0.cs" , 10 , 16 )
@@ -664,5 +672,11 @@ private void VerifyCSharpFixExpressionBody<TCodeFixProvider, TDiagnosticAnalyzer
664
672
665
673
DiagnosticVerifier . VerifyCSharpFix < TCodeFixProvider , TDiagnosticAnalyzer > ( oldSource , newSource ) ;
666
674
}
675
+
676
+ private void VerifyCSharpNoDiagnosticsCodeBlock ( string assertion )
677
+ {
678
+ var source = GenerateCode . EnumerableCodeBlockAssertion ( assertion ) ;
679
+ DiagnosticVerifier . VerifyCSharpDiagnosticUsingAllAnalyzers ( source ) ;
680
+ }
667
681
}
668
682
}
0 commit comments