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

Unified Diff: pkg/analysis_server/test/typed_mock_test.dart

Issue 250813003: verifyNoMoreInteractions() and verifyZeroInteractions() (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/test/typed_mock.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/typed_mock_test.dart
diff --git a/pkg/analysis_server/test/typed_mock_test.dart b/pkg/analysis_server/test/typed_mock_test.dart
index 57ddc730b342648edde4fb5a0096cc9300a806f1..3b120f53d3484b166aed548c6dd5c9c3ac24c8c5 100644
--- a/pkg/analysis_server/test/typed_mock_test.dart
+++ b/pkg/analysis_server/test/typed_mock_test.dart
@@ -192,7 +192,7 @@ main() {
});
group('verify', () {
- TestInterface obj;
+ TestInterfaceMock obj;
setUp(() {
obj = new TestInterfaceMock();
});
@@ -259,6 +259,16 @@ main() {
});
});
+ group('any', () {
+ test('OK, 0', () {
+ verify(obj.testProperty).any();
+ });
+ test('OK, 1', () {
+ obj.testProperty;
+ verify(obj.testProperty).any();
+ });
+ });
+
group('once', () {
test('OK', () {
obj.testProperty;
@@ -298,6 +308,23 @@ main() {
});
});
+ group('atLeastOnce', () {
+ test('OK, 1', () {
+ obj.testProperty;
+ verify(obj.testProperty).atLeastOnce();
+ });
+ test('OK, 2', () {
+ obj.testProperty;
+ obj.testProperty;
+ verify(obj.testProperty).atLeastOnce();
+ });
+ test('fail', () {
+ expect(() {
+ verify(obj.testProperty).atLeastOnce();
+ }, throwsA(_isVerifyError));
+ });
+ });
+
group('atMost', () {
test('OK, 0', () {
verify(obj.testProperty).atMost(5);
@@ -319,6 +346,48 @@ main() {
}, throwsA(_isVerifyError));
});
});
+
+ group('verifyNoMoreInteractions', () {
+ test('OK, 0', () {
+ verifyNoMoreInteractions(obj);
+ });
+ test('OK, single method, 1', () {
+ obj.testMethod1(10);
+ verify(obj.testMethod1(anyInt)).any();
+ verifyNoMoreInteractions(obj);
+ });
+ test('fail, 3', () {
+ obj.testMethod1(10);
+ obj.testMethod2('foo', 20);
+ obj.testMethod1(30);
+ expect(() {
+ verifyNoMoreInteractions(obj);
+ }, throwsA(_isVerifyError));
+ });
+ });
+
+ group('verifyZeroInteractions', () {
+ test('OK, 0', () {
+ verifyZeroInteractions(obj);
+ });
+ test('OK, 0, local var', () {
+ var obj = new TestInterfaceMock();
+ verifyZeroInteractions(obj);
+ });
+ test('fail, 1, no verify()', () {
+ obj.testMethod1(10);
+ expect(() {
+ verifyZeroInteractions(obj);
+ }, throwsA(_isVerifyError));
+ });
+ test('fail, 1, with verify()', () {
+ obj.testMethod1(10);
+ verify(obj.testMethod1(anyInt)).any();
+ expect(() {
+ verifyZeroInteractions(obj);
+ }, throwsA(_isVerifyError));
+ });
+ });
});
}
« no previous file with comments | « pkg/analysis_server/test/typed_mock.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698