Add 'resetInteractions' into typed_mock.

1. I decided not to change the verifyZeroInteractions(TypedMock) API.
   There is an advantage in having it typed, such as (potentially) improved code completion.

   The drawback is that tests have to use MyClassMock type annotatino instead of MyClass.
   But TypedMock does not have any API, so it should not be a big problem.

2. It is impossible to distinguish 'get:foo' access from taking a reference to a method or property invocation.
   I guess it is intentional.
   We could probably distinguish them using mirrors, but typed_mock should work without mirrors.
   So, resetInteractions() should be used.

R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org//324083005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37191 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
scheglov@google.com 2014-06-10 18:23:25 +00:00
parent 476278985c
commit f133e5eded
3 changed files with 17 additions and 1 deletions

View file

@ -39,6 +39,14 @@ Behavior when(_ignored) {
}
}
/// Clears all interactions remembered so far.
resetInteractions(TypedMock mock) {
mock._invocations.clear();
mock._verifiedInvocations.clear();
}
/// Verifies certain behavior happened a specified number of times.
Verifier verify(_ignored) {
try {

View file

@ -1,5 +1,5 @@
name: typed_mock
version: 0.0.3
version: 0.0.4
author: Dart Team <misc@dartlang.org>
description: A library for mocking classes using Mockito-like syntax
homepage: http://www.dartlang.org

View file

@ -183,6 +183,14 @@ main() {
});
});
test('resetInteractions', () {
TestInterfaceMock obj = new TestInterfaceMock();
obj.testProperty;
obj.testMethod0();
resetInteractions(obj);
verifyZeroInteractions(obj);
});
group('verify', () {
TestInterfaceMock obj;
setUp(() {