@@ -11,7 +11,7 @@ public class DictionaryTests
11
11
[ AssertionDiagnostic ( "actual.ContainsKey(expectedKey).Should().BeTrue({0});" ) ]
12
12
[ AssertionDiagnostic ( "actual.ToDictionary(p => p.Key, p=> p.Value).ContainsKey(expectedKey).Should().BeTrue({0}).And.ToString();" ) ]
13
13
[ Implemented ]
14
- public void DictionaryShouldContainKey_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic < DictionaryShouldContainKeyAnalyzer > ( assertion ) ;
14
+ public void DictionaryShouldContainKey_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . DictionaryShouldContainKey_ContainsKeyShouldBeTrue ) ;
15
15
16
16
[ DataTestMethod ]
17
17
[ AssertionCodeFix (
@@ -21,13 +21,13 @@ public class DictionaryTests
21
21
oldAssertion : "actual.ToDictionary(p => p.Key, p=> p.Value).ContainsKey(expectedKey).Should().BeTrue({0}).And.ToString();" ,
22
22
newAssertion : "actual.ToDictionary(p => p.Key, p=> p.Value).Should().ContainKey(expectedKey{0}).And.ToString();" ) ]
23
23
[ Implemented ]
24
- public void DictionaryShouldContainKey_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < DictionaryShouldContainKeyCodeFix , DictionaryShouldContainKeyAnalyzer > ( oldAssertion , newAssertion ) ;
24
+ public void DictionaryShouldContainKey_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldAssertion , newAssertion ) ;
25
25
26
26
[ DataTestMethod ]
27
27
[ AssertionDiagnostic ( "actual.ContainsKey(expectedKey).Should().BeFalse({0});" ) ]
28
28
[ AssertionDiagnostic ( "actual.ToDictionary(p => p.Key, p=> p.Value).ContainsKey(expectedKey).Should().BeFalse({0}).And.ToString();" ) ]
29
29
[ Implemented ]
30
- public void DictionaryShouldNotContainKey_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic < DictionaryShouldNotContainKeyAnalyzer > ( assertion ) ;
30
+ public void DictionaryShouldNotContainKey_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . DictionaryShouldNotContainKey_ContainsKeyShouldBeFalse ) ;
31
31
32
32
[ DataTestMethod ]
33
33
[ AssertionCodeFix (
@@ -37,13 +37,13 @@ public class DictionaryTests
37
37
oldAssertion : "actual.ToDictionary(p => p.Key, p=> p.Value).ContainsKey(expectedKey).Should().BeFalse({0}).And.ToString();" ,
38
38
newAssertion : "actual.ToDictionary(p => p.Key, p=> p.Value).Should().NotContainKey(expectedKey{0}).And.ToString();" ) ]
39
39
[ Implemented ]
40
- public void DictionaryShouldNotContainKey_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < DictionaryShouldNotContainKeyCodeFix , DictionaryShouldNotContainKeyAnalyzer > ( oldAssertion , newAssertion ) ;
40
+ public void DictionaryShouldNotContainKey_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldAssertion , newAssertion ) ;
41
41
42
42
[ DataTestMethod ]
43
43
[ AssertionDiagnostic ( "actual.ContainsValue(expectedValue).Should().BeTrue({0});" ) ]
44
44
[ AssertionDiagnostic ( "actual.ToDictionary(p => p.Key, p=> p.Value).ContainsValue(expectedValue).Should().BeTrue({0}).And.ToString();" ) ]
45
45
[ Implemented ]
46
- public void DictionaryShouldContainValue_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic < DictionaryShouldContainValueAnalyzer > ( assertion ) ;
46
+ public void DictionaryShouldContainValue_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . DictionaryShouldContainValue_ContainsValueShouldBeTrue ) ;
47
47
48
48
[ DataTestMethod ]
49
49
[ AssertionCodeFix (
@@ -53,13 +53,13 @@ public class DictionaryTests
53
53
oldAssertion : "actual.ToDictionary(p => p.Key, p=> p.Value).ContainsValue(expectedValue).Should().BeTrue({0}).And.ToString();" ,
54
54
newAssertion : "actual.ToDictionary(p => p.Key, p=> p.Value).Should().ContainValue(expectedValue{0}).And.ToString();" ) ]
55
55
[ Implemented ]
56
- public void DictionaryShouldContainValue_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < DictionaryShouldContainValueCodeFix , DictionaryShouldContainValueAnalyzer > ( oldAssertion , newAssertion ) ;
56
+ public void DictionaryShouldContainValue_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldAssertion , newAssertion ) ;
57
57
58
58
[ DataTestMethod ]
59
59
[ AssertionDiagnostic ( "actual.ContainsValue(expectedValue).Should().BeFalse({0});" ) ]
60
60
[ AssertionDiagnostic ( "actual.ToDictionary(p => p.Key, p=> p.Value).ContainsValue(expectedValue).Should().BeFalse({0}).And.ToString();" ) ]
61
61
[ Implemented ]
62
- public void DictionaryShouldNotContainValue_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic < DictionaryShouldNotContainValueAnalyzer > ( assertion ) ;
62
+ public void DictionaryShouldNotContainValue_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . DictionaryShouldNotContainValue_ContainsValueShouldBeFalse ) ;
63
63
64
64
[ DataTestMethod ]
65
65
[ AssertionCodeFix (
@@ -69,19 +69,23 @@ public class DictionaryTests
69
69
oldAssertion : "actual.ToDictionary(p => p.Key, p=> p.Value).ContainsValue(expectedValue).Should().BeFalse({0}).And.ToString();" ,
70
70
newAssertion : "actual.ToDictionary(p => p.Key, p=> p.Value).Should().NotContainValue(expectedValue{0}).And.ToString();" ) ]
71
71
[ Implemented ]
72
- public void DictionaryShouldNotContainValue_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < DictionaryShouldNotContainValueCodeFix , DictionaryShouldNotContainValueAnalyzer > ( oldAssertion , newAssertion ) ;
72
+ public void DictionaryShouldNotContainValue_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldAssertion , newAssertion ) ;
73
73
74
74
[ DataTestMethod ]
75
75
[ AssertionDiagnostic ( "actual.Should().ContainKey(expectedKey{0}).And.ContainValue(expectedValue);" ) ]
76
76
[ AssertionDiagnostic ( "actual.Should().ContainKey(expectedKey).And.ContainValue(expectedValue{0});" ) ]
77
77
[ AssertionDiagnostic ( "actual.ToDictionary(p => p.Key, p=> p.Value).Should().ContainKey(expectedKey{0}).And.ContainValue(expectedValue).And.ToString();" ) ]
78
78
[ AssertionDiagnostic ( "actual.ToDictionary(p => p.Key, p=> p.Value).Should().ContainKey(expectedKey).And.ContainValue(expectedValue{0}).And.ToString();" ) ]
79
+ [ Implemented ]
80
+ public void DictionaryShouldContainKeyAndValue_ShouldContainKeyAndContainValue_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . DictionaryShouldContainKeyAndValue_ShouldContainKeyAndContainValue ) ;
81
+
82
+ [ DataTestMethod ]
79
83
[ AssertionDiagnostic ( "actual.Should().ContainValue(expectedValue{0}).And.ContainKey(expectedKey);" ) ]
80
84
[ AssertionDiagnostic ( "actual.Should().ContainValue(expectedValue).And.ContainKey(expectedKey{0});" ) ]
81
85
[ AssertionDiagnostic ( "actual.ToDictionary(p => p.Key, p=> p.Value).Should().ContainValue(expectedValue{0}).And.ContainKey(expectedKey).And.ToString();" ) ]
82
86
[ AssertionDiagnostic ( "actual.ToDictionary(p => p.Key, p=> p.Value).Should().ContainValue(expectedValue).And.ContainKey(expectedKey{0}).And.ToString();" ) ]
83
87
[ Implemented ]
84
- public void DictionaryShouldContainKeyAndValue_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic < DictionaryShouldContainKeyAndValueAnalyzer > ( assertion ) ;
88
+ public void DictionaryShouldContainKeyAndValue_ShouldContainValueAndContainKey_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . DictionaryShouldContainKeyAndValue_ShouldContainValueAndContainKey ) ;
85
89
86
90
[ DataTestMethod ]
87
91
[ AssertionCodeFix (
@@ -109,19 +113,23 @@ public class DictionaryTests
109
113
oldAssertion : "actual.ToDictionary(p => p.Key, p=> p.Value).Should().ContainValue(expectedValue{0}).And.ContainKey(expectedKey).And.ToString();" ,
110
114
newAssertion : "actual.ToDictionary(p => p.Key, p=> p.Value).Should().Contain(expectedKey, expectedValue{0}).And.ToString();" ) ]
111
115
[ Implemented ]
112
- public void DictionaryShouldContainKeyAndValue_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < DictionaryShouldContainKeyAndValueCodeFix , DictionaryShouldContainKeyAndValueAnalyzer > ( oldAssertion , newAssertion ) ;
116
+ public void DictionaryShouldContainKeyAndValue_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldAssertion , newAssertion ) ;
113
117
114
118
[ DataTestMethod ]
115
119
[ AssertionDiagnostic ( "actual.Should().ContainKey(pair.Key{0}).And.ContainValue(pair.Value);" ) ]
116
120
[ AssertionDiagnostic ( "actual.Should().ContainKey(pair.Key).And.ContainValue(pair.Value{0});" ) ]
117
- [ AssertionDiagnostic ( "actual.Should().ContainValue(pair.Value{0}).And.ContainKey(pair.Key);" ) ]
118
- [ AssertionDiagnostic ( "actual.Should().ContainValue(pair.Value).And.ContainKey(pair.Key{0});" ) ]
119
121
[ AssertionDiagnostic ( "actual.ToDictionary(p => p.Key, p=> p.Value).Should().ContainKey(pair.Key{0}).And.ContainValue(pair.Value).And.ToString();" ) ]
120
122
[ AssertionDiagnostic ( "actual.ToDictionary(p => p.Key, p=> p.Value).Should().ContainKey(pair.Key).And.ContainValue(pair.Value{0}).And.ToString();" ) ]
123
+ [ Implemented ]
124
+ public void DictionaryShouldContainPair_ShouldContainKeyAndContainValue_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . DictionaryShouldContainPair_ShouldContainKeyAndContainValue ) ;
125
+
126
+ [ DataTestMethod ]
127
+ [ AssertionDiagnostic ( "actual.Should().ContainValue(pair.Value{0}).And.ContainKey(pair.Key);" ) ]
128
+ [ AssertionDiagnostic ( "actual.Should().ContainValue(pair.Value).And.ContainKey(pair.Key{0});" ) ]
121
129
[ AssertionDiagnostic ( "actual.ToDictionary(p => p.Key, p=> p.Value).Should().ContainValue(pair.Value{0}).And.ContainKey(pair.Key).And.ToString();" ) ]
122
130
[ AssertionDiagnostic ( "actual.ToDictionary(p => p.Key, p=> p.Value).Should().ContainValue(pair.Value).And.ContainKey(pair.Key{0}).And.ToString();" ) ]
123
131
[ Implemented ]
124
- public void DictionaryShouldContainPair_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic < DictionaryShouldContainPairAnalyzer > ( assertion ) ;
132
+ public void DictionaryShouldContainPair_ShouldContainValueAndContainKey_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . DictionaryShouldContainPair_ShouldContainValueAndContainKey ) ;
125
133
126
134
[ DataTestMethod ]
127
135
[ AssertionCodeFix (
@@ -149,20 +157,17 @@ public class DictionaryTests
149
157
oldAssertion : "actual.ToDictionary(p => p.Key, p=> p.Value).Should().ContainValue(pair.Value).And.ContainKey(pair.Key{0}).And.ToString();" ,
150
158
newAssertion : "actual.ToDictionary(p => p.Key, p=> p.Value).Should().Contain(pair{0}).And.ToString();" ) ]
151
159
[ Implemented ]
152
- public void DictionaryShouldContainPair_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < DictionaryShouldContainPairCodeFix , DictionaryShouldContainPairAnalyzer > ( oldAssertion , newAssertion ) ;
160
+ public void DictionaryShouldContainPair_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldAssertion , newAssertion ) ;
153
161
154
- private void VerifyCSharpDiagnostic < TDiagnosticAnalyzer > ( string sourceAssersion ) where TDiagnosticAnalyzer : Microsoft . CodeAnalysis . Diagnostics . DiagnosticAnalyzer , new ( )
162
+ private void VerifyCSharpDiagnostic ( string sourceAssersion , DiagnosticMetadata metadata )
155
163
{
156
164
var source = GenerateCode . GenericIDictionaryAssertion ( sourceAssersion ) ;
157
165
158
- var type = typeof ( TDiagnosticAnalyzer ) ;
159
- var diagnosticId = ( string ) type . GetField ( "DiagnosticId" ) . GetValue ( null ) ;
160
- var message = ( string ) type . GetField ( "Message" ) . GetValue ( null ) ;
161
-
162
166
DiagnosticVerifier . VerifyCSharpDiagnosticUsingAllAnalyzers ( source , new DiagnosticResult
163
167
{
164
- Id = diagnosticId ,
165
- Message = message ,
168
+ Id = FluentAssertionsOperationAnalyzer . DiagnosticId ,
169
+ Message = metadata . Message ,
170
+ VisitorName = metadata . Name ,
166
171
Locations = new DiagnosticResultLocation [ ]
167
172
{
168
173
new DiagnosticResultLocation ( "Test0.cs" , 12 , 13 )
0 commit comments