1
1
using FluentAssertions . Analyzers . TestUtils ;
2
- using FluentAssertions . Analyzers . Tips ;
3
2
using Microsoft . CodeAnalysis ;
4
3
using Microsoft . VisualStudio . TestTools . UnitTesting ;
5
4
@@ -11,7 +10,7 @@ public class ShouldEqualsTests
11
10
[ TestMethod ]
12
11
[ Implemented ]
13
12
public void ShouldEquals_TestAnalyzer ( )
14
- => VerifyCSharpDiagnosticExpressionBody ( "actual.Should().Equals(expected);" ) ;
13
+ => VerifyCSharpDiagnosticExpressionBody ( "actual.Should().Equals(expected);" , DiagnosticMetadata . ShouldBe_ShouldEquals ) ;
15
14
16
15
[ TestMethod ]
17
16
[ Implemented ]
@@ -20,13 +19,13 @@ public void ShouldEquals_ShouldBe_ObjectType_TestCodeFix()
20
19
var oldSource = GenerateCode . ObjectStatement ( "actual.Should().Equals(expected);" ) ;
21
20
var newSource = GenerateCode . ObjectStatement ( "actual.Should().Be(expected);" ) ;
22
21
23
- DiagnosticVerifier . VerifyCSharpFix < ShouldEqualsCodeFix , ShouldEqualsAnalyzer > ( oldSource , newSource ) ;
22
+ DiagnosticVerifier . VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldSource , newSource ) ;
24
23
}
25
24
26
25
[ TestMethod ]
27
26
[ Implemented ]
28
27
public void ShouldEquals_NestedInsideIfBlock_TestAnalyzer ( )
29
- => VerifyCSharpDiagnosticExpressionBody ( "if(true) { actual.Should().Equals(expected); }" , 10 , 24 ) ;
28
+ => VerifyCSharpDiagnosticExpressionBody ( "if(true) { actual.Should().Equals(expected); }" , 10 , 24 , DiagnosticMetadata . ShouldBe_ShouldEquals ) ;
30
29
31
30
[ TestMethod ]
32
31
[ Implemented ]
@@ -35,13 +34,13 @@ public void ShouldEquals_NestedInsideIfBlock_ShouldBe_ObjectType_TestCodeFix()
35
34
var oldSource = GenerateCode . ObjectStatement ( "if(true) { actual.Should().Equals(expected); }" ) ;
36
35
var newSource = GenerateCode . ObjectStatement ( "if(true) { actual.Should().Be(expected); }" ) ;
37
36
38
- DiagnosticVerifier . VerifyCSharpFix < ShouldEqualsCodeFix , ShouldEqualsAnalyzer > ( oldSource , newSource ) ;
37
+ DiagnosticVerifier . VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldSource , newSource ) ;
39
38
}
40
39
41
40
[ TestMethod ]
42
41
[ Implemented ]
43
42
public void ShouldEquals_NestedInsideWhileBlock_TestAnalyzer ( )
44
- => VerifyCSharpDiagnosticExpressionBody ( "while(true) { actual.Should().Equals(expected); }" , 10 , 27 ) ;
43
+ => VerifyCSharpDiagnosticExpressionBody ( "while(true) { actual.Should().Equals(expected); }" , 10 , 27 , DiagnosticMetadata . ShouldBe_ShouldEquals ) ;
45
44
46
45
[ TestMethod ]
47
46
[ Implemented ]
@@ -50,14 +49,14 @@ public void ShouldEquals_NestedInsideWhileBlock_ShouldBe_ObjectType_TestCodeFix(
50
49
var oldSource = GenerateCode . ObjectStatement ( "while(true) { actual.Should().Equals(expected); }" ) ;
51
50
var newSource = GenerateCode . ObjectStatement ( "while(true) { actual.Should().Be(expected); }" ) ;
52
51
53
- DiagnosticVerifier . VerifyCSharpFix < ShouldEqualsCodeFix , ShouldEqualsAnalyzer > ( oldSource , newSource ) ;
52
+ DiagnosticVerifier . VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldSource , newSource ) ;
54
53
}
55
54
56
55
[ TestMethod ]
57
56
[ Implemented ]
58
57
public void ShouldEquals_ActualIsMethodInvoaction_TestAnalyzer ( )
59
58
=> VerifyCSharpDiagnosticExpressionBody ( "object ResultSupplier() { return null; } \n "
60
- + "ResultSupplier().Should().Equals(expected);" , 11 , 0 ) ;
59
+ + "ResultSupplier().Should().Equals(expected);" , 11 , 0 , DiagnosticMetadata . ShouldBe_ShouldEquals ) ;
61
60
62
61
[ TestMethod ]
63
62
[ Implemented ]
@@ -67,7 +66,7 @@ public void ShouldEquals_ActualIsMethodInvoaction_ShouldBe_ObjectType_TestCodeFi
67
66
var oldSource = GenerateCode . ObjectStatement ( methodInvocation + "ResultSupplier().Should().Equals(expected);" ) ;
68
67
var newSource = GenerateCode . ObjectStatement ( methodInvocation + "ResultSupplier().Should().Be(expected);" ) ;
69
68
70
- DiagnosticVerifier . VerifyCSharpFix < ShouldEqualsCodeFix , ShouldEqualsAnalyzer > ( oldSource , newSource ) ;
69
+ DiagnosticVerifier . VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldSource , newSource ) ;
71
70
}
72
71
73
72
[ TestMethod ]
@@ -77,7 +76,7 @@ public void ShouldEquals_ShouldBe_NumberType_TestCodeFix()
77
76
var oldSource = GenerateCode . DoubleAssertion ( "actual.Should().Equals(expected);" ) ;
78
77
var newSource = GenerateCode . DoubleAssertion ( "actual.Should().Be(expected);" ) ;
79
78
80
- DiagnosticVerifier . VerifyCSharpFix < ShouldEqualsCodeFix , ShouldEqualsAnalyzer > ( oldSource , newSource ) ;
79
+ DiagnosticVerifier . VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldSource , newSource ) ;
81
80
}
82
81
83
82
[ TestMethod ]
@@ -87,7 +86,7 @@ public void ShouldEquals_ShouldBe_StringType_TestCodeFix()
87
86
var oldSource = GenerateCode . StringAssertion ( "actual.Should().Equals(expected);" ) ;
88
87
var newSource = GenerateCode . StringAssertion ( "actual.Should().Be(expected);" ) ;
89
88
90
- DiagnosticVerifier . VerifyCSharpFix < ShouldEqualsCodeFix , ShouldEqualsAnalyzer > ( oldSource , newSource ) ;
89
+ DiagnosticVerifier . VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldSource , newSource ) ;
91
90
}
92
91
93
92
[ TestMethod ]
@@ -97,17 +96,18 @@ public void ShouldEquals_ShouldEqual_EnumerableType_TestCodeFix()
97
96
var oldSource = GenerateCode . GenericIListCodeBlockAssertion ( "actual.Should().Equals(expected);" ) ;
98
97
var newSource = GenerateCode . GenericIListCodeBlockAssertion ( "actual.Should().Equal(expected);" ) ;
99
98
100
- DiagnosticVerifier . VerifyCSharpFix < ShouldEqualsCodeFix , ShouldEqualsAnalyzer > ( oldSource , newSource ) ;
99
+ DiagnosticVerifier . VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldSource , newSource ) ;
101
100
}
102
101
103
- private void VerifyCSharpDiagnosticExpressionBody ( string sourceAssertion ) => VerifyCSharpDiagnosticExpressionBody ( sourceAssertion , 10 , 13 ) ;
104
- private void VerifyCSharpDiagnosticExpressionBody ( string sourceAssertion , int line , int column )
102
+ private void VerifyCSharpDiagnosticExpressionBody ( string sourceAssertion , DiagnosticMetadata metadata ) => VerifyCSharpDiagnosticExpressionBody ( sourceAssertion , 10 , 13 , metadata ) ;
103
+ private void VerifyCSharpDiagnosticExpressionBody ( string sourceAssertion , int line , int column , DiagnosticMetadata metadata )
105
104
{
106
105
var source = GenerateCode . ObjectStatement ( sourceAssertion ) ;
107
106
DiagnosticVerifier . VerifyCSharpDiagnosticUsingAllAnalyzers ( source , new DiagnosticResult
108
107
{
109
- Id = ShouldEqualsAnalyzer . DiagnosticId ,
110
- Message = ShouldEqualsAnalyzer . Message ,
108
+ Id = FluentAssertionsOperationAnalyzer . DiagnosticId ,
109
+ Message = metadata . Message ,
110
+ VisitorName = metadata . Name ,
111
111
Locations = new DiagnosticResultLocation [ ]
112
112
{
113
113
new DiagnosticResultLocation ( "Test0.cs" , line , column )
0 commit comments