11using FluentAssertions . Analyzers . TestUtils ;
2- using FluentAssertions . Analyzers . Tips ;
32using Microsoft . CodeAnalysis ;
43using Microsoft . VisualStudio . TestTools . UnitTesting ;
54
@@ -11,7 +10,7 @@ public class ShouldEqualsTests
1110 [ TestMethod ]
1211 [ Implemented ]
1312 public void ShouldEquals_TestAnalyzer ( )
14- => VerifyCSharpDiagnosticExpressionBody ( "actual.Should().Equals(expected);" ) ;
13+ => VerifyCSharpDiagnosticExpressionBody ( "actual.Should().Equals(expected);" , DiagnosticMetadata . ShouldBe_ShouldEquals ) ;
1514
1615 [ TestMethod ]
1716 [ Implemented ]
@@ -20,13 +19,13 @@ public void ShouldEquals_ShouldBe_ObjectType_TestCodeFix()
2019 var oldSource = GenerateCode . ObjectStatement ( "actual.Should().Equals(expected);" ) ;
2120 var newSource = GenerateCode . ObjectStatement ( "actual.Should().Be(expected);" ) ;
2221
23- DiagnosticVerifier . VerifyCSharpFix < ShouldEqualsCodeFix , ShouldEqualsAnalyzer > ( oldSource , newSource ) ;
22+ DiagnosticVerifier . VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldSource , newSource ) ;
2423 }
2524
2625 [ TestMethod ]
2726 [ Implemented ]
2827 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 ) ;
3029
3130 [ TestMethod ]
3231 [ Implemented ]
@@ -35,13 +34,13 @@ public void ShouldEquals_NestedInsideIfBlock_ShouldBe_ObjectType_TestCodeFix()
3534 var oldSource = GenerateCode . ObjectStatement ( "if(true) { actual.Should().Equals(expected); }" ) ;
3635 var newSource = GenerateCode . ObjectStatement ( "if(true) { actual.Should().Be(expected); }" ) ;
3736
38- DiagnosticVerifier . VerifyCSharpFix < ShouldEqualsCodeFix , ShouldEqualsAnalyzer > ( oldSource , newSource ) ;
37+ DiagnosticVerifier . VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldSource , newSource ) ;
3938 }
4039
4140 [ TestMethod ]
4241 [ Implemented ]
4342 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 ) ;
4544
4645 [ TestMethod ]
4746 [ Implemented ]
@@ -50,14 +49,14 @@ public void ShouldEquals_NestedInsideWhileBlock_ShouldBe_ObjectType_TestCodeFix(
5049 var oldSource = GenerateCode . ObjectStatement ( "while(true) { actual.Should().Equals(expected); }" ) ;
5150 var newSource = GenerateCode . ObjectStatement ( "while(true) { actual.Should().Be(expected); }" ) ;
5251
53- DiagnosticVerifier . VerifyCSharpFix < ShouldEqualsCodeFix , ShouldEqualsAnalyzer > ( oldSource , newSource ) ;
52+ DiagnosticVerifier . VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldSource , newSource ) ;
5453 }
5554
5655 [ TestMethod ]
5756 [ Implemented ]
5857 public void ShouldEquals_ActualIsMethodInvoaction_TestAnalyzer ( )
5958 => VerifyCSharpDiagnosticExpressionBody ( "object ResultSupplier() { return null; } \n "
60- + "ResultSupplier().Should().Equals(expected);" , 11 , 0 ) ;
59+ + "ResultSupplier().Should().Equals(expected);" , 11 , 0 , DiagnosticMetadata . ShouldBe_ShouldEquals ) ;
6160
6261 [ TestMethod ]
6362 [ Implemented ]
@@ -67,7 +66,7 @@ public void ShouldEquals_ActualIsMethodInvoaction_ShouldBe_ObjectType_TestCodeFi
6766 var oldSource = GenerateCode . ObjectStatement ( methodInvocation + "ResultSupplier().Should().Equals(expected);" ) ;
6867 var newSource = GenerateCode . ObjectStatement ( methodInvocation + "ResultSupplier().Should().Be(expected);" ) ;
6968
70- DiagnosticVerifier . VerifyCSharpFix < ShouldEqualsCodeFix , ShouldEqualsAnalyzer > ( oldSource , newSource ) ;
69+ DiagnosticVerifier . VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldSource , newSource ) ;
7170 }
7271
7372 [ TestMethod ]
@@ -77,7 +76,7 @@ public void ShouldEquals_ShouldBe_NumberType_TestCodeFix()
7776 var oldSource = GenerateCode . DoubleAssertion ( "actual.Should().Equals(expected);" ) ;
7877 var newSource = GenerateCode . DoubleAssertion ( "actual.Should().Be(expected);" ) ;
7978
80- DiagnosticVerifier . VerifyCSharpFix < ShouldEqualsCodeFix , ShouldEqualsAnalyzer > ( oldSource , newSource ) ;
79+ DiagnosticVerifier . VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldSource , newSource ) ;
8180 }
8281
8382 [ TestMethod ]
@@ -87,7 +86,7 @@ public void ShouldEquals_ShouldBe_StringType_TestCodeFix()
8786 var oldSource = GenerateCode . StringAssertion ( "actual.Should().Equals(expected);" ) ;
8887 var newSource = GenerateCode . StringAssertion ( "actual.Should().Be(expected);" ) ;
8988
90- DiagnosticVerifier . VerifyCSharpFix < ShouldEqualsCodeFix , ShouldEqualsAnalyzer > ( oldSource , newSource ) ;
89+ DiagnosticVerifier . VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldSource , newSource ) ;
9190 }
9291
9392 [ TestMethod ]
@@ -97,17 +96,18 @@ public void ShouldEquals_ShouldEqual_EnumerableType_TestCodeFix()
9796 var oldSource = GenerateCode . GenericIListCodeBlockAssertion ( "actual.Should().Equals(expected);" ) ;
9897 var newSource = GenerateCode . GenericIListCodeBlockAssertion ( "actual.Should().Equal(expected);" ) ;
9998
100- DiagnosticVerifier . VerifyCSharpFix < ShouldEqualsCodeFix , ShouldEqualsAnalyzer > ( oldSource , newSource ) ;
99+ DiagnosticVerifier . VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldSource , newSource ) ;
101100 }
102101
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 )
105104 {
106105 var source = GenerateCode . ObjectStatement ( sourceAssertion ) ;
107106 DiagnosticVerifier . VerifyCSharpDiagnosticUsingAllAnalyzers ( source , new DiagnosticResult
108107 {
109- Id = ShouldEqualsAnalyzer . DiagnosticId ,
110- Message = ShouldEqualsAnalyzer . Message ,
108+ Id = FluentAssertionsOperationAnalyzer . DiagnosticId ,
109+ Message = metadata . Message ,
110+ VisitorName = metadata . Name ,
111111 Locations = new DiagnosticResultLocation [ ]
112112 {
113113 new DiagnosticResultLocation ( "Test0.cs" , line , column )
0 commit comments