Commit 575c6a9 1 parent f293e9f commit 575c6a9 Copy full SHA for 575c6a9
File tree 3 files changed +35
-17
lines changed
3 files changed +35
-17
lines changed Original file line number Diff line number Diff line change @@ -343,15 +343,19 @@ private void ToStringMethodCall(MethodCallExpression node)
343
343
else if ( node . Method . IsPropertyIndexerSetter ( ) )
344
344
{
345
345
this . builder . Append ( "[" ) ;
346
- AsCommaSeparatedValues ( node . Arguments
347
- . Skip ( paramFrom )
348
- . Take ( node . Arguments . Count - paramFrom ) , ToString ) ;
346
+ AsCommaSeparatedValues ( node . Arguments . Skip ( paramFrom ) , ToString ) ;
349
347
this . builder . Append ( "] = " ) ;
350
348
ToString ( node . Arguments . Last ( ) ) ;
351
349
}
352
350
else if ( node . Method . IsPropertyGetter ( ) )
353
351
{
354
- this . builder . Append ( "." ) . Append ( node . Method . Name . Substring ( 4 ) ) ;
352
+ this . builder . Append ( "." ) . Append ( node . Method . Name . Substring ( 4 ) ) ;
353
+ if ( node . Arguments . Count > paramFrom )
354
+ {
355
+ this . builder . Append ( "[" ) ;
356
+ AsCommaSeparatedValues ( node . Arguments . Skip ( paramFrom ) , ToString ) ;
357
+ this . builder . Append ( "]" ) ;
358
+ }
355
359
}
356
360
else if ( node . Method . IsPropertySetter ( ) )
357
361
{
Original file line number Diff line number Diff line change @@ -169,20 +169,20 @@ public override bool Equals(object obj)
169
169
}
170
170
171
171
var eq = key . fixedString == this . fixedString && key . values . Count == this . values . Count ;
172
- if ( ! eq )
172
+
173
+ //the code below is broken as it uses an OR when checking the arguments, this means that if any pair of arguments match
174
+ //the result is a match.
175
+ //This is only going to hit some edge cases as for the most part the fixed string above spots arguments correctly.
176
+ //Fixing this really needs a reworking of the GetHashCode, and also some sorting out of how to compare value types that have been
177
+ //boxed correctly (another problem this code has)
178
+ var index = 0 ;
179
+ while ( eq && index < this . values . Count )
173
180
{
174
- return false ;
181
+ eq |= this . values [ index ] == key . values [ index ] ;
182
+ index ++ ;
175
183
}
176
184
177
- for ( int index = 0 ; index < values . Count ; index ++ )
178
- {
179
- if ( this . values [ index ] != key . values [ index ] )
180
- {
181
- return false ;
182
- }
183
- }
184
-
185
- return eq ;
185
+ return eq ;
186
186
}
187
187
188
188
public override int GetHashCode ( )
Original file line number Diff line number Diff line change @@ -266,7 +266,20 @@ public void MatchingNonNullableValueTypeForNullableParameterDoesNotMatchNull()
266
266
Assert . Equal ( 0 , mock . Object . TakesNullableParameter ( null ) ) ;
267
267
}
268
268
269
- private int GetToRange ( )
269
+ [ Fact ]
270
+ public void MultipleMatchingSetupsWithMultiplValueTypeArgumentsReplaceEachOtherForVerify ( )
271
+ {
272
+ var mock = new Mock < IFoo > ( ) ;
273
+
274
+ mock . Setup ( x => x . TakesTwoValueTypes ( 1 , 2 ) ) . Verifiable ( ) ;
275
+ mock . Setup ( x => x . TakesTwoValueTypes ( 1 , 2 ) ) . Verifiable ( ) ;
276
+
277
+ mock . Object . TakesTwoValueTypes ( 1 , 2 ) ;
278
+
279
+ mock . Verify ( ) ;
280
+ }
281
+
282
+ private int GetToRange ( )
270
283
{
271
284
return 5 ;
272
285
}
@@ -283,6 +296,7 @@ public interface IFoo
283
296
int DoAddition ( int [ ] numbers ) ;
284
297
int [ ] Items { get ; set ; }
285
298
int TakesNullableParameter ( int ? value ) ;
286
- }
299
+ void TakesTwoValueTypes ( int a , int b ) ;
300
+ }
287
301
}
288
302
}
You can’t perform that action at this time.
0 commit comments