@@ -46,6 +46,19 @@ public void Should_mock_and_verify_protected_method_with_multiple_args()
46
46
sub . Received ( 1 ) . Protected ( "ProtectedMethod" , Arg . Any < string > ( ) , Arg . Any < int > ( ) , Arg . Any < char > ( ) ) ;
47
47
}
48
48
49
+ [ Test ]
50
+ public void Should_mock_and_verify_protected_method_with_params_arg ( )
51
+ {
52
+ var expectedMsg = "unit test message" ;
53
+ var sub = Substitute . For < AnotherClass > ( ) ;
54
+ var worker = new Worker ( ) ;
55
+
56
+ sub . Protected ( "ProtectedMethod" , Arg . Any < string > ( ) , Arg . Any < int [ ] > ( ) ) . Returns ( expectedMsg ) ;
57
+
58
+ Assert . That ( worker . DoWorkWithParams ( sub , 3 , 5 ) , Is . EqualTo ( expectedMsg ) ) ;
59
+ sub . Received ( 1 ) . Protected ( "ProtectedMethod" , Arg . Any < string > ( ) , Arg . Any < int [ ] > ( ) ) ;
60
+ }
61
+
49
62
[ Test ]
50
63
public void Should_throw_on_mock_null_substitute ( )
51
64
{
@@ -136,6 +149,20 @@ public void Should_mock_and_verify_void_method_with_multiple_args()
136
149
sub . Received ( 1 ) . Protected ( "ProtectedMethodWithNoReturn" , Arg . Any < string > ( ) , Arg . Any < int > ( ) , Arg . Any < char > ( ) ) ;
137
150
}
138
151
152
+ [ Test ]
153
+ public void Should_mock_and_verify_void_method_with_params_arg ( )
154
+ {
155
+ var count = 0 ;
156
+ var sub = Substitute . For < AnotherClass > ( ) ;
157
+ var worker = new Worker ( ) ;
158
+
159
+ sub . When ( "ProtectedMethodWithNoReturn" , Arg . Any < string > ( ) , Arg . Any < int [ ] > ( ) ) . Do ( x => count ++ ) ;
160
+
161
+ worker . DoVoidWork ( sub , 6 , 9 ) ;
162
+ Assert . That ( count , Is . EqualTo ( 1 ) ) ;
163
+ sub . Received ( 1 ) . Protected ( "ProtectedMethodWithNoReturn" , Arg . Any < string > ( ) , Arg . Any < int [ ] > ( ) ) ;
164
+ }
165
+
139
166
[ Test ]
140
167
public void Should_throw_on_void_method_null_substitute ( )
141
168
{
@@ -201,6 +228,11 @@ internal string DoEvenMoreWork(AnotherClass worker, int i, char j)
201
228
return worker . DoWork ( "worker" , i , j ) ;
202
229
}
203
230
231
+ internal string DoWorkWithParams ( AnotherClass worker , params int [ ] numb )
232
+ {
233
+ return worker . DoWork ( "worker" , numb ) ;
234
+ }
235
+
204
236
internal void DoVoidWork ( AnotherClass worker )
205
237
{
206
238
worker . DoVoidWork ( ) ;
@@ -215,5 +247,10 @@ internal void DoVoidWork(AnotherClass worker, int i, char j)
215
247
{
216
248
worker . DoVoidWork ( "void worker" , i , j ) ;
217
249
}
250
+
251
+ internal void DoVoidWork ( AnotherClass worker , params int [ ] numb )
252
+ {
253
+ worker . DoVoidWork ( "void worker" , numb ) ;
254
+ }
218
255
}
219
256
}
0 commit comments