11using System . Collections . Immutable ;
22using System . Composition ;
3+ using System . Runtime . InteropServices . ComTypes ;
34using Microsoft . CodeAnalysis ;
45using Microsoft . CodeAnalysis . CodeFixes ;
56using Microsoft . CodeAnalysis . Operations ;
@@ -26,6 +27,20 @@ protected override CreateChangedDocument TryComputeFix(IInvocationOperation invo
2627 return DocumentEditorUtils . RenameMethodToSubjectShouldAssertion ( invocation , context , "BeSameAs" , subjectIndex : 1 , argumentsToRemove : [ ] ) ;
2728 case "NotSame" when ArgumentsAreTypeOf ( invocation , t . Object , t . Object ) : // Assert.NotSame(object expected, object actual)
2829 return DocumentEditorUtils . RenameMethodToSubjectShouldAssertion ( invocation , context , "NotBeSameAs" , subjectIndex : 1 , argumentsToRemove : [ ] ) ;
30+ case "Equivalent" when ArgumentsCount ( invocation , 2 ) : // Assert.Equivalent(object? expected, object? actual)
31+ return DocumentEditorUtils . RenameMethodToSubjectShouldAssertion ( invocation , context , "BeEquivalentTo" , subjectIndex : 1 , argumentsToRemove : [ ] ) ;
32+ case "Equivalent" when ArgumentsCount ( invocation , 3 ) : // Assert.Equivalent(object? expected, object? actual, bool strict = false)
33+ {
34+ if ( invocation . Arguments [ 2 ] . Value is ILiteralOperation literal )
35+ {
36+ return literal . ConstantValue . Value switch {
37+ false => DocumentEditorUtils . RenameMethodToSubjectShouldAssertion ( invocation , context , "BeEquivalentTo" , subjectIndex : 1 , argumentsToRemove : literal . IsImplicit ? [ ] : [ 2 ] ) ,
38+ _ => null
39+ } ;
40+ }
41+
42+ return null ; // passing a reference for the "strict" argument
43+ }
2944 case "Equal" when ArgumentsAreTypeOf ( invocation , t . Float , t . Float , t . Float ) : // Assert.Equal(float expected, float actual, float tolerance)
3045 case "Equal" when ArgumentsAreTypeOf ( invocation , t . Double , t . Double , t . Double ) : // Assert.Equal(double expected, double actual, double tolerance)
3146 return DocumentEditorUtils . RenameMethodToSubjectShouldAssertion ( invocation , context , "BeApproximately" , subjectIndex : 1 , argumentsToRemove : [ ] ) ;
0 commit comments