@@ -22,6 +22,53 @@ public void ShouldEquals_ShouldBe_ObjectType_TestCodeFix()
22
22
DiagnosticVerifier . VerifyCSharpFix < ShouldEqualsCodeFix , ShouldEqualsAnalyzer > ( oldSource , newSource ) ;
23
23
}
24
24
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
+
25
72
[ TestMethod ]
26
73
[ Implemented ]
27
74
public void ShouldEquals_ShouldBe_NumberType_TestCodeFix ( )
@@ -52,7 +99,8 @@ public void ShouldEquals_ShouldEqual_EnumerableType_TestCodeFix()
52
99
DiagnosticVerifier . VerifyCSharpFix < ShouldEqualsCodeFix , ShouldEqualsAnalyzer > ( oldSource , newSource ) ;
53
100
}
54
101
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 )
56
104
{
57
105
var source = GenerateCode . ObjectStatement ( sourceAssertion ) ;
58
106
DiagnosticVerifier . VerifyCSharpDiagnosticUsingAllAnalyzers ( source , new DiagnosticResult
@@ -61,7 +109,7 @@ private void VerifyCSharpDiagnosticExpressionBody(string sourceAssertion)
61
109
Message = ShouldEqualsAnalyzer . Message ,
62
110
Locations = new DiagnosticResultLocation [ ]
63
111
{
64
- new DiagnosticResultLocation ( "Test0.cs" , 10 , 13 )
112
+ new DiagnosticResultLocation ( "Test0.cs" , line , column )
65
113
} ,
66
114
Severity = DiagnosticSeverity . Info
67
115
} ) ;
0 commit comments