@@ -22,15 +22,15 @@ protected override CreateChangedDocument TryComputeFixCore(IInvocationOperation
2222
2323 return assertType . Name switch
2424 {
25- "Assert" when isNunit3 => TryComputeFixForNunit3Assert ( invocation , context , t ) ,
26- "ClassicAssert" when isNunit4 => TryComputeFixForNunit4ClassicAssert ( invocation , context , t ) ,
25+ "Assert" when isNunit3 => TryComputeFixForNunitClassicAssert ( invocation , context , t ) ,
26+ "ClassicAssert" when isNunit4 => TryComputeFixForNunitClassicAssert ( invocation , context , t ) ,
2727 //"StringAssert" => TryComputeFixForStringAssert(invocation, context, testContext),
2828 //"CollectionAssert" => TryComputeFixForCollectionAssert(invocation, context, testContext),
2929 _ => null
3030 } ;
3131 }
3232
33- private CreateChangedDocument TryComputeFixForNunit3Assert ( IInvocationOperation invocation , CodeFixContext context , TestingFrameworkCodeFixContext t )
33+ private CreateChangedDocument TryComputeFixForNunitClassicAssert ( IInvocationOperation invocation , CodeFixContext context , TestingFrameworkCodeFixContext t )
3434 {
3535 switch ( invocation . TargetMethod . Name )
3636 {
@@ -46,29 +46,67 @@ private CreateChangedDocument TryComputeFixForNunit3Assert(IInvocationOperation
4646 case "NotNull" : // Assert.NotNull(object anObject)
4747 case "IsNotNull" : // Assert.IsNotNull(object anObject)
4848 return DocumentEditorUtils . RenameMethodToSubjectShouldAssertion ( invocation , context , "NotBeNull" , subjectIndex : 0 , argumentsToRemove : [ ] ) ;
49+ case "Greater" when ArgumentsAreTypeOf ( invocation , t . Int32 , t . Int32 ) : // Assert.Greater(int arg1, int arg2)
50+ case "Greater" when ArgumentsAreTypeOf ( invocation , t . UInt32 , t . UInt32 ) : // Assert.Greater(uint arg1, uint arg2)
51+ case "Greater" when ArgumentsAreTypeOf ( invocation , t . Long , t . Long ) : // Assert.Greater(long arg1, long arg2)
52+ case "Greater" when ArgumentsAreTypeOf ( invocation , t . ULong , t . ULong ) : // Assert.Greater(ulong arg1, ulong arg2)
53+ case "Greater" when ArgumentsAreTypeOf ( invocation , t . Float , t . Float ) : // Assert.Greater(float arg1, float arg2)
54+ case "Greater" when ArgumentsAreTypeOf ( invocation , t . Double , t . Double ) : // Assert.Greater(double arg1, double arg2)
55+ case "Greater" when ArgumentsAreTypeOf ( invocation , t . Decimal , t . Decimal ) : // Assert.Greater(decimal arg1, decimal arg2)
56+ case "Greater" when ArgumentsAreTypeOf ( invocation , t . Int32 , t . Int32 , t . String , t . ObjectArray ) : // Assert.Greater(int arg1, int arg2, string message, params object[] parms)
57+ case "Greater" when ArgumentsAreTypeOf ( invocation , t . UInt32 , t . UInt32 , t . String , t . ObjectArray ) : // Assert.Greater(uint arg1, uint arg2, string message, params object[] parms)
58+ case "Greater" when ArgumentsAreTypeOf ( invocation , t . Long , t . Long , t . String , t . ObjectArray ) : // Assert.Greater(long arg1, long arg2, string message, params object[] parms)
59+ case "Greater" when ArgumentsAreTypeOf ( invocation , t . ULong , t . ULong , t . String , t . ObjectArray ) : // Assert.Greater(ulong arg1, ulong arg2, string message, params object[] parms)
60+ case "Greater" when ArgumentsAreTypeOf ( invocation , t . Float , t . Float , t . String , t . ObjectArray ) : // Assert.Greater(float arg1, float arg2, string message, params object[] parms)
61+ case "Greater" when ArgumentsAreTypeOf ( invocation , t . Double , t . Double , t . String , t . ObjectArray ) : // Assert.Greater(double arg1, double arg2, string message, params object[] parms)
62+ case "Greater" when ArgumentsAreTypeOf ( invocation , t . Decimal , t . Decimal , t . String , t . ObjectArray ) : // Assert.Greater(decimal arg1, decimal arg2, string message, params object[] parms)
63+ return DocumentEditorUtils . RenameMethodToSubjectShouldAssertion ( invocation , context , "BeGreaterThan" , subjectIndex : 0 , argumentsToRemove : [ ] ) ;
64+ case "GreaterOrEqual" when ArgumentsAreTypeOf ( invocation , t . Int32 , t . Int32 ) : // Assert.GreaterOrEqual(int arg1, int arg2)
65+ case "GreaterOrEqual" when ArgumentsAreTypeOf ( invocation , t . UInt32 , t . UInt32 ) : // Assert.GreaterOrEqual(uint arg1, uint arg2)
66+ case "GreaterOrEqual" when ArgumentsAreTypeOf ( invocation , t . Long , t . Long ) : // Assert.GreaterOrEqual(long arg1, long arg2)
67+ case "GreaterOrEqual" when ArgumentsAreTypeOf ( invocation , t . ULong , t . ULong ) : // Assert.GreaterOrEqual(ulong arg1, ulong arg2)
68+ case "GreaterOrEqual" when ArgumentsAreTypeOf ( invocation , t . Float , t . Float ) : // Assert.GreaterOrEqual(float arg1, float arg2)
69+ case "GreaterOrEqual" when ArgumentsAreTypeOf ( invocation , t . Double , t . Double ) : // Assert.GreaterOrEqual(double arg1, double arg2)
70+ case "GreaterOrEqual" when ArgumentsAreTypeOf ( invocation , t . Decimal , t . Decimal ) : // Assert.GreaterOrEqual(decimal arg1, decimal arg2)
71+ case "GreaterOrEqual" when ArgumentsAreTypeOf ( invocation , t . Int32 , t . Int32 , t . String , t . ObjectArray ) : // Assert.GreaterOrEqual(int arg1, int arg2, string message, params object[] parms)
72+ case "GreaterOrEqual" when ArgumentsAreTypeOf ( invocation , t . UInt32 , t . UInt32 , t . String , t . ObjectArray ) : // Assert.GreaterOrEqual(uint arg1, uint arg2, string message, params object[] parms)
73+ case "GreaterOrEqual" when ArgumentsAreTypeOf ( invocation , t . Long , t . Long , t . String , t . ObjectArray ) : // Assert.GreaterOrEqual(long arg1, long arg2, string message, params object[] parms)
74+ case "GreaterOrEqual" when ArgumentsAreTypeOf ( invocation , t . ULong , t . ULong , t . String , t . ObjectArray ) : // Assert.GreaterOrEqual(ulong arg1, ulong arg2, string message, params object[] parms)
75+ case "GreaterOrEqual" when ArgumentsAreTypeOf ( invocation , t . Float , t . Float , t . String , t . ObjectArray ) : // Assert.GreaterOrEqual(float arg1, float arg2, string message, params object[] parms)
76+ case "GreaterOrEqual" when ArgumentsAreTypeOf ( invocation , t . Double , t . Double , t . String , t . ObjectArray ) : // Assert.GreaterOrEqual(double arg1, double arg2, string message, params object[] parms)
77+ case "GreaterOrEqual" when ArgumentsAreTypeOf ( invocation , t . Decimal , t . Decimal , t . String , t . ObjectArray ) : // Assert.GreaterOrEqual(decimal arg1, decimal arg2, string message, params object[] parms)
78+ return DocumentEditorUtils . RenameMethodToSubjectShouldAssertion ( invocation , context , "BeGreaterOrEqualTo" , subjectIndex : 0 , argumentsToRemove : [ ] ) ;
79+ case "Less" when ArgumentsAreTypeOf ( invocation , t . Int32 , t . Int32 ) : // Assert.Less(int arg1, int arg2)
80+ case "Less" when ArgumentsAreTypeOf ( invocation , t . UInt32 , t . UInt32 ) : // Assert.Less(uint arg1, uint arg2)
81+ case "Less" when ArgumentsAreTypeOf ( invocation , t . Long , t . Long ) : // Assert.Less(long arg1, long arg2)
82+ case "Less" when ArgumentsAreTypeOf ( invocation , t . ULong , t . ULong ) : // Assert.Less(ulong arg1, ulong arg2)
83+ case "Less" when ArgumentsAreTypeOf ( invocation , t . Float , t . Float ) : // Assert.Less(float arg1, float arg2)
84+ case "Less" when ArgumentsAreTypeOf ( invocation , t . Double , t . Double ) : // Assert.Less(double arg1, double arg2)
85+ case "Less" when ArgumentsAreTypeOf ( invocation , t . Decimal , t . Decimal ) : // Assert.Less(decimal arg1, decimal arg2)
86+ case "Less" when ArgumentsAreTypeOf ( invocation , t . Int32 , t . Int32 , t . String , t . ObjectArray ) : // Assert.Less(int arg1, int arg2, string message, params object[] parms)
87+ case "Less" when ArgumentsAreTypeOf ( invocation , t . UInt32 , t . UInt32 , t . String , t . ObjectArray ) : // Assert.Less(uint arg1, uint arg2, string message, params object[] parms)
88+ case "Less" when ArgumentsAreTypeOf ( invocation , t . Long , t . Long , t . String , t . ObjectArray ) : // Assert.Less(long arg1, long arg2, string message, params object[] parms)
89+ case "Less" when ArgumentsAreTypeOf ( invocation , t . ULong , t . ULong , t . String , t . ObjectArray ) : // Assert.Less(ulong arg1, ulong arg2, string message, params object[] parms)
90+ case "Less" when ArgumentsAreTypeOf ( invocation , t . Float , t . Float , t . String , t . ObjectArray ) : // Assert.Less(float arg1, float arg2, string message, params object[] parms)
91+ case "Less" when ArgumentsAreTypeOf ( invocation , t . Double , t . Double , t . String , t . ObjectArray ) : // Assert.Less(double arg1, double arg2, string message, params object[] parms)
92+ case "Less" when ArgumentsAreTypeOf ( invocation , t . Decimal , t . Decimal , t . String , t . ObjectArray ) : // Assert.Less(decimal arg1, decimal arg2, string message, params object[] parms)
93+ return DocumentEditorUtils . RenameMethodToSubjectShouldAssertion ( invocation , context , "BeLessThan" , subjectIndex : 0 , argumentsToRemove : [ ] ) ;
94+ case "LessOrEqual" when ArgumentsAreTypeOf ( invocation , t . Int32 , t . Int32 ) : // Assert.LessOrEqual(int arg1, int arg2)
95+ case "LessOrEqual" when ArgumentsAreTypeOf ( invocation , t . UInt32 , t . UInt32 ) : // Assert.LessOrEqual(uint arg1, uint arg2)
96+ case "LessOrEqual" when ArgumentsAreTypeOf ( invocation , t . Long , t . Long ) : // Assert.LessOrEqual(long arg1, long arg2)
97+ case "LessOrEqual" when ArgumentsAreTypeOf ( invocation , t . ULong , t . ULong ) : // Assert.LessOrEqual(ulong arg1, ulong arg2)
98+ case "LessOrEqual" when ArgumentsAreTypeOf ( invocation , t . Float , t . Float ) : // Assert.LessOrEqual(float arg1, float arg2)
99+ case "LessOrEqual" when ArgumentsAreTypeOf ( invocation , t . Double , t . Double ) : // Assert.LessOrEqual(double arg1, double arg2)
100+ case "LessOrEqual" when ArgumentsAreTypeOf ( invocation , t . Decimal , t . Decimal ) : // Assert.LessOrEqual(decimal arg1, decimal arg2)
101+ case "LessOrEqual" when ArgumentsAreTypeOf ( invocation , t . Int32 , t . Int32 , t . String , t . ObjectArray ) : // Assert.LessOrEqual(int arg1, int arg2, string message, params object[] parms)
102+ case "LessOrEqual" when ArgumentsAreTypeOf ( invocation , t . UInt32 , t . UInt32 , t . String , t . ObjectArray ) : // Assert.LessOrEqual(uint arg1, uint arg2, string message, params object[] parms)
103+ case "LessOrEqual" when ArgumentsAreTypeOf ( invocation , t . Long , t . Long , t . String , t . ObjectArray ) : // Assert.LessOrEqual(long arg1, long arg2, string message, params object[] parms)
104+ case "LessOrEqual" when ArgumentsAreTypeOf ( invocation , t . ULong , t . ULong , t . String , t . ObjectArray ) : // Assert.LessOrEqual(ulong arg1, ulong arg2, string message, params object[] parms)
105+ case "LessOrEqual" when ArgumentsAreTypeOf ( invocation , t . Float , t . Float , t . String , t . ObjectArray ) : // Assert.LessOrEqual(float arg1, float arg2, string message, params object[] parms)
106+ case "LessOrEqual" when ArgumentsAreTypeOf ( invocation , t . Double , t . Double , t . String , t . ObjectArray ) : // Assert.LessOrEqual(double arg1, double arg2, string message, params object[] parms)
107+ case "LessOrEqual" when ArgumentsAreTypeOf ( invocation , t . Decimal , t . Decimal , t . String , t . ObjectArray ) : // Assert.LessOrEqual(decimal arg1, decimal arg2, string message, params object[] parms)
108+ return DocumentEditorUtils . RenameMethodToSubjectShouldAssertion ( invocation , context , "BeLessOrEqualTo" , subjectIndex : 0 , argumentsToRemove : [ ] ) ;
49109 }
50-
51- return null ;
52- }
53-
54- private CreateChangedDocument TryComputeFixForNunit4ClassicAssert ( IInvocationOperation invocation , CodeFixContext context , TestingFrameworkCodeFixContext t )
55- {
56- switch ( invocation . TargetMethod . Name )
57- {
58- case "True" : // Assert.True(bool condition)
59- case "IsTrue" : // Assert.IsTrue(bool condition)
60- return DocumentEditorUtils . RenameMethodToSubjectShouldAssertion ( invocation , context , "BeTrue" , subjectIndex : 0 , argumentsToRemove : [ ] ) ;
61- case "False" : // Assert.False(bool condition)
62- case "IsFalse" : // Assert.IsFalse(bool condition)
63- return DocumentEditorUtils . RenameMethodToSubjectShouldAssertion ( invocation , context , "BeFalse" , subjectIndex : 0 , argumentsToRemove : [ ] ) ;
64- case "Null" : // Assert.Null(object anObject)
65- case "IsNull" : // Assert.IsNull(object anObject)
66- return DocumentEditorUtils . RenameMethodToSubjectShouldAssertion ( invocation , context , "BeNull" , subjectIndex : 0 , argumentsToRemove : [ ] ) ;
67- case "NotNull" : // Assert.NotNull(object anObject)
68- case "IsNotNull" : // Assert.IsNotNull(object anObject)
69- return DocumentEditorUtils . RenameMethodToSubjectShouldAssertion ( invocation , context , "NotBeNull" , subjectIndex : 0 , argumentsToRemove : [ ] ) ;
70- }
71-
72110 return null ;
73111 }
74112}
0 commit comments