@@ -22,6 +22,7 @@ public class AssertEqualAnalyzer : XunitAnalyzer
2222 protected override DiagnosticDescriptor Rule => new ( DiagnosticId , Title , Message , Category , DiagnosticSeverity . Info , true ) ;
2323 protected override IEnumerable < FluentAssertionsCSharpSyntaxVisitor > Visitors => new FluentAssertionsCSharpSyntaxVisitor [ ]
2424 {
25+ new AssertStringEqualSyntaxVisitor ( ) ,
2526 new AssertFloatEqualWithToleranceSyntaxVisitor ( ) ,
2627 new AssertDoubleEqualWithToleranceSyntaxVisitor ( ) ,
2728 new AssertDoubleEqualWithPrecisionSyntaxVisitor ( ) ,
@@ -30,7 +31,18 @@ public class AssertEqualAnalyzer : XunitAnalyzer
3031 new AssertObjectEqualWithComparerSyntaxVisitor ( ) ,
3132 new AssertObjectEqualSyntaxVisitor ( )
3233 } ;
33-
34+
35+ // public static void Equal(string? expected, string? actual)
36+ public class AssertStringEqualSyntaxVisitor : FluentAssertionsCSharpSyntaxVisitor
37+ {
38+ public AssertStringEqualSyntaxVisitor ( ) : base (
39+ MemberValidator . ArgumentsMatch ( "Equal" ,
40+ ArgumentValidator . IsType ( TypeSelector . GetStringType ) ,
41+ ArgumentValidator . IsType ( TypeSelector . GetStringType ) ) )
42+ {
43+ }
44+ }
45+
3446 // public static void Equal(float expected, float actual, float tolerance)
3547 public class AssertFloatEqualWithToleranceSyntaxVisitor : FluentAssertionsCSharpSyntaxVisitor
3648 {
@@ -137,6 +149,7 @@ protected override ExpressionSyntax GetNewExpression(
137149 case nameof ( AssertEqualAnalyzer . AssertDateTimeEqualSyntaxVisitor ) :
138150 return RenameMethodAndReorderActualExpectedAndReplaceWithSubjectShould ( expression , "Equal" , "BeCloseTo" ) ;
139151 case nameof ( AssertEqualAnalyzer . AssertObjectEqualSyntaxVisitor ) :
152+ case nameof ( AssertEqualAnalyzer . AssertStringEqualSyntaxVisitor ) :
140153 return RenameMethodAndReorderActualExpectedAndReplaceWithSubjectShould ( expression , "Equal" , "Be" ) ;
141154 default :
142155 throw new System . InvalidOperationException ( $ "Invalid visitor name - { properties . VisitorName } ") ;
0 commit comments