Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: pkg/typed_mock/lib/typed_mock.dart

Issue 324083005: Add 'resetInteractions' into typed_mock. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/typed_mock/pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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;
OLDNEW
« no previous file with comments | « no previous file | pkg/typed_mock/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698