OLD | NEW |
1 library typed_mock; | 1 library typed_mock; |
2 | 2 |
3 | 3 |
4 _InvocationMatcher _lastMatcher; | 4 _InvocationMatcher _lastMatcher; |
5 | 5 |
6 /// Enables stubbing methods. | 6 /// Enables stubbing methods. |
7 /// | 7 /// |
8 /// Use it when you want the mock to return a particular value when a particular | 8 /// Use it when you want the mock to return a particular value when a particular |
9 /// method, getter or setter is called. | 9 /// method, getter or setter is called. |
10 /// | 10 /// |
(...skipping 21 matching lines...) Expand all Loading... |
32 // set behavior | 32 // set behavior |
33 var behavior = new Behavior._(_lastMatcher); | 33 var behavior = new Behavior._(_lastMatcher); |
34 _lastMatcher._behavior = behavior; | 34 _lastMatcher._behavior = behavior; |
35 return behavior; | 35 return behavior; |
36 } finally { | 36 } finally { |
37 // clear to prevent memory leak | 37 // clear to prevent memory leak |
38 _lastMatcher = null; | 38 _lastMatcher = null; |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
| 42 |
| 43 /// Clears all interactions remembered so far. |
| 44 resetInteractions(TypedMock mock) { |
| 45 mock._invocations.clear(); |
| 46 mock._verifiedInvocations.clear(); |
| 47 } |
| 48 |
| 49 |
42 /// Verifies certain behavior happened a specified number of times. | 50 /// Verifies certain behavior happened a specified number of times. |
43 Verifier verify(_ignored) { | 51 Verifier verify(_ignored) { |
44 try { | 52 try { |
45 var mock = _lastMatcher._mock; | 53 var mock = _lastMatcher._mock; |
46 mock._removeLastInvocation(); | 54 mock._removeLastInvocation(); |
47 // set verifier | 55 // set verifier |
48 return new Verifier._(mock, _lastMatcher); | 56 return new Verifier._(mock, _lastMatcher); |
49 } finally { | 57 } finally { |
50 // clear to prevent memory leak | 58 // clear to prevent memory leak |
51 _lastMatcher = null; | 59 _lastMatcher = null; |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 const _ArgumentMatcher_anyString(); | 434 const _ArgumentMatcher_anyString(); |
427 | 435 |
428 @override | 436 @override |
429 bool matches(val) { | 437 bool matches(val) { |
430 return val is String; | 438 return val is String; |
431 } | 439 } |
432 } | 440 } |
433 | 441 |
434 /// Matches any [String] value. | 442 /// Matches any [String] value. |
435 final anyString = const _ArgumentMatcher_anyString() as dynamic; | 443 final anyString = const _ArgumentMatcher_anyString() as dynamic; |
OLD | NEW |