@@ -22,6 +22,53 @@ public void ShouldEquals_ShouldBe_ObjectType_TestCodeFix()
2222 DiagnosticVerifier . VerifyCSharpFix < ShouldEqualsCodeFix , ShouldEqualsAnalyzer > ( oldSource , newSource ) ;
2323 }
2424
25+ [ TestMethod ]
26+ [ Implemented ]
27+ public void ShouldEquals_NestedInsideIfBlock_TestAnalyzer ( )
28+ => VerifyCSharpDiagnosticExpressionBody ( "if(true) { actual.Should().Equals(expected); }" , 10 , 24 ) ;
29+
30+ [ TestMethod ]
31+ [ Implemented ]
32+ public void ShouldEquals_NestedInsideIfBlock_ShouldBe_ObjectType_TestCodeFix ( )
33+ {
34+ var oldSource = GenerateCode . ObjectStatement ( "if(true) { actual.Should().Equals(expected); }" ) ;
35+ var newSource = GenerateCode . ObjectStatement ( "if(true) { actual.Should().Be(expected); }" ) ;
36+
37+ DiagnosticVerifier . VerifyCSharpFix < ShouldEqualsCodeFix , ShouldEqualsAnalyzer > ( oldSource , newSource ) ;
38+ }
39+
40+ [ TestMethod ]
41+ [ Implemented ]
42+ public void ShouldEquals_NestedInsideWhileBlock_TestAnalyzer ( )
43+ => VerifyCSharpDiagnosticExpressionBody ( "while(true) { actual.Should().Equals(expected); }" , 10 , 27 ) ;
44+
45+ [ TestMethod ]
46+ [ Implemented ]
47+ public void ShouldEquals_NestedInsideWhileBlock_ShouldBe_ObjectType_TestCodeFix ( )
48+ {
49+ var oldSource = GenerateCode . ObjectStatement ( "while(true) { actual.Should().Equals(expected); }" ) ;
50+ var newSource = GenerateCode . ObjectStatement ( "while(true) { actual.Should().Be(expected); }" ) ;
51+
52+ DiagnosticVerifier . VerifyCSharpFix < ShouldEqualsCodeFix , ShouldEqualsAnalyzer > ( oldSource , newSource ) ;
53+ }
54+
55+ [ TestMethod ]
56+ [ Implemented ]
57+ public void ShouldEquals_ActualIsMethodInvoaction_TestAnalyzer ( )
58+ => VerifyCSharpDiagnosticExpressionBody ( "object ResultSupplier() { return null; } \n "
59+ + "ResultSupplier().Should().Equals(expected);" , 11 , 0 ) ;
60+
61+ [ TestMethod ]
62+ [ Implemented ]
63+ public void ShouldEquals_ActualIsMethodInvoaction_ShouldBe_ObjectType_TestCodeFix ( )
64+ {
65+ const string methodInvocation = "object ResultSupplier() { return null; } \n " ;
66+ var oldSource = GenerateCode . ObjectStatement ( methodInvocation + "ResultSupplier().Should().Equals(expected);" ) ;
67+ var newSource = GenerateCode . ObjectStatement ( methodInvocation + "ResultSupplier().Should().Be(expected);" ) ;
68+
69+ DiagnosticVerifier . VerifyCSharpFix < ShouldEqualsCodeFix , ShouldEqualsAnalyzer > ( oldSource , newSource ) ;
70+ }
71+
2572 [ TestMethod ]
2673 [ Implemented ]
2774 public void ShouldEquals_ShouldBe_NumberType_TestCodeFix ( )
@@ -52,7 +99,8 @@ public void ShouldEquals_ShouldEqual_EnumerableType_TestCodeFix()
5299 DiagnosticVerifier . VerifyCSharpFix < ShouldEqualsCodeFix , ShouldEqualsAnalyzer > ( oldSource , newSource ) ;
53100 }
54101
55- private void VerifyCSharpDiagnosticExpressionBody ( string sourceAssertion )
102+ private void VerifyCSharpDiagnosticExpressionBody ( string sourceAssertion ) => VerifyCSharpDiagnosticExpressionBody ( sourceAssertion , 10 , 13 ) ;
103+ private void VerifyCSharpDiagnosticExpressionBody ( string sourceAssertion , int line , int column )
56104 {
57105 var source = GenerateCode . ObjectStatement ( sourceAssertion ) ;
58106 DiagnosticVerifier . VerifyCSharpDiagnosticUsingAllAnalyzers ( source , new DiagnosticResult
@@ -61,7 +109,7 @@ private void VerifyCSharpDiagnosticExpressionBody(string sourceAssertion)
61109 Message = ShouldEqualsAnalyzer . Message ,
62110 Locations = new DiagnosticResultLocation [ ]
63111 {
64- new DiagnosticResultLocation ( "Test0.cs" , 10 , 13 )
112+ new DiagnosticResultLocation ( "Test0.cs" , line , column )
65113 } ,
66114 Severity = DiagnosticSeverity . Info
67115 } ) ;
0 commit comments