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

Side by Side Diff: pkg/typed_mock/test/typed_mock_test.dart

Issue 281943002: Add a top-level typed_mock package. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 6 years, 7 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 | « pkg/typed_mock/pubspec.yaml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 library test.typed_mock; 1 library test.typed_mock;
2 2
3 import 'package:unittest/unittest.dart'; 3 import 'package:unittest/unittest.dart';
4 4
5 import 'typed_mock.dart' hide equals; 5 import 'package:typed_mock/typed_mock.dart' hide equals;
6 import 'typed_mock.dart' as typed_mocks show equals; 6 import 'package:typed_mock/typed_mock.dart' as typed_mocks show equals;
7 7
8 8
9 abstract class TestInterface { 9 abstract class TestInterface {
10 int get testProperty; 10 int get testProperty;
11 set testProperty(x); 11 set testProperty(x);
12 int get testPropertyB; 12 int get testPropertyB;
13 String testMethod0(); 13 String testMethod0();
14 String testMethod1(a); 14 String testMethod1(a);
15 String testMethod2(String a, int b); 15 String testMethod2(String a, int b);
16 void testMethodVoid(a); 16 void testMethodVoid(a);
(...skipping 13 matching lines...) Expand all
30 group('VerifyError', () { 30 group('VerifyError', () {
31 test('VerifyError', () { 31 test('VerifyError', () {
32 var error = new VerifyError('msg'); 32 var error = new VerifyError('msg');
33 expect(error.message, 'msg'); 33 expect(error.message, 'msg');
34 expect(error.toString(), 'VerifyError: msg'); 34 expect(error.toString(), 'VerifyError: msg');
35 }); 35 });
36 }); 36 });
37 37
38 group('Matchers', () { 38 group('Matchers', () {
39 test('equals', () { 39 test('equals', () {
40 expect(typed_mocks.equals(10).match(10), true); 40 expect(typed_mocks.equals(10).matches(10), true);
41 expect(typed_mocks.equals(10).match(20), false); 41 expect(typed_mocks.equals(10).matches(20), false);
42 expect(typed_mocks.equals('abc').match('abc'), true); 42 expect(typed_mocks.equals('abc').matches('abc'), true);
43 expect(typed_mocks.equals('abc').match('xyz'), false); 43 expect(typed_mocks.equals('abc').matches('xyz'), false);
44 }); 44 });
45 45
46 test('anyBool', () { 46 test('anyBool', () {
47 expect(anyBool.match(true), true); 47 expect(anyBool.matches(true), true);
48 expect(anyBool.match(false), true); 48 expect(anyBool.matches(false), true);
49 expect(anyBool.match(0), false); 49 expect(anyBool.matches(0), false);
50 expect(anyBool.match('0'), false); 50 expect(anyBool.matches('0'), false);
51 }); 51 });
52 52
53 test('anyInt', () { 53 test('anyInt', () {
54 expect(anyInt.match(true), false); 54 expect(anyInt.matches(true), false);
55 expect(anyInt.match(-99), true); 55 expect(anyInt.matches(-99), true);
56 expect(anyInt.match(0), true); 56 expect(anyInt.matches(0), true);
57 expect(anyInt.match(42), true); 57 expect(anyInt.matches(42), true);
58 expect(anyInt.match('0'), false); 58 expect(anyInt.matches('0'), false);
59 }); 59 });
60 60
61 test('anyObject', () { 61 test('anyObject', () {
62 expect(anyObject.match(true), true); 62 expect(anyObject.matches(true), true);
63 expect(anyObject.match(0), true); 63 expect(anyObject.matches(0), true);
64 expect(anyObject.match('0'), true); 64 expect(anyObject.matches('0'), true);
65 }); 65 });
66 66
67 test('anyString', () { 67 test('anyString', () {
68 expect(anyString.match(true), false); 68 expect(anyString.matches(true), false);
69 expect(anyString.match(0), false); 69 expect(anyString.matches(0), false);
70 expect(anyString.match(''), true); 70 expect(anyString.matches(''), true);
71 expect(anyString.match('0'), true); 71 expect(anyString.matches('0'), true);
72 expect(anyString.match('abc'), true); 72 expect(anyString.matches('abc'), true);
73 }); 73 });
74 }); 74 });
75 75
76 group('when', () { 76 group('when', () {
77 TestInterface obj; 77 TestInterface obj;
78 setUp(() { 78 setUp(() {
79 obj = new TestInterfaceMock(); 79 obj = new TestInterfaceMock();
80 }); 80 });
81 81
82 test('thenInvoke for getter', () { 82 test('thenInvoke for getter', () {
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 verify(obj.testMethod1(anyInt)).any(); 385 verify(obj.testMethod1(anyInt)).any();
386 expect(() { 386 expect(() {
387 verifyZeroInteractions(obj); 387 verifyZeroInteractions(obj);
388 }, throwsA(_isVerifyError)); 388 }, throwsA(_isVerifyError));
389 }); 389 });
390 }); 390 });
391 }); 391 });
392 } 392 }
393 393
394 const _isVerifyError = const isInstanceOf<VerifyError>(); 394 const _isVerifyError = const isInstanceOf<VerifyError>();
OLDNEW
« no previous file with comments | « pkg/typed_mock/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698