Chromium Code Reviews

Side by Side Diff: pkg/unittest/test/mock_test.dart

Issue 145403005: pkg/unittest: formatter spin (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: review nits Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « pkg/unittest/test/mock_stepwise_negative_test.dart ('k') | pkg/unittest/test/test_common.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library mock_test; 5 library mock_test;
6 import 'package:unittest/unittest.dart'; 6 import 'package:unittest/unittest.dart';
7 import 'package:unittest/mock.dart'; 7 import 'package:unittest/mock.dart';
8 8
9 class MockList extends Mock implements List { 9 class MockList extends Mock implements List {
10 dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 10 dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
(...skipping 175 matching lines...)
186 }); 186 });
187 187
188 test('Mocking: RegExp CallMatcher good', () { 188 test('Mocking: RegExp CallMatcher good', () {
189 var m = new Mock(); 189 var m = new Mock();
190 m.when(callsTo(matches('^[A-Z]'))). 190 m.when(callsTo(matches('^[A-Z]'))).
191 alwaysThrow('Method names must start with lower case.'); 191 alwaysThrow('Method names must start with lower case.');
192 m.test(); 192 m.test();
193 }); 193 });
194 194
195 test('Mocking: No logging', () { 195 test('Mocking: No logging', () {
196 var m = new Mock.custom(enableLogging:false); 196 var m = new Mock.custom(enableLogging: false);
197 m.Test(); 197 m.Test();
198 expect(() => m.getLogs(callsTo('Test')), throwsA((e) => e.toString() == 198 expect(() => m.getLogs(callsTo('Test')), throwsA((e) => e.toString() ==
199 "Exception: Can't retrieve logs when logging was never enabled.")); 199 "Exception: Can't retrieve logs when logging was never enabled."));
200 }); 200 });
201 201
202 test('Mocking: Find logList entry', () { 202 test('Mocking: Find logList entry', () {
203 LogEntryList logList = makeTestLog(); 203 LogEntryList logList = makeTestLog();
204 // Basic behavior, with call matcher. 204 // Basic behavior, with call matcher.
205 expect(logList.findLogEntry(callsTo('a')), 0); 205 expect(logList.findLogEntry(callsTo('a')), 0);
206 expect(logList.findLogEntry(callsTo('b')), 1); 206 expect(logList.findLogEntry(callsTo('b')), 1);
(...skipping 519 matching lines...)
726 var real = new Foo(); 726 var real = new Foo();
727 var spy = new Mock.spy(real); 727 var spy = new Mock.spy(real);
728 var sum = spy.sum(1, 2, 3); 728 var sum = spy.sum(1, 2, 3);
729 expect(sum, 6); 729 expect(sum, 6);
730 expect(() => spy.total(1, 2, 3), throwsNoSuchMethodError); 730 expect(() => spy.total(1, 2, 3), throwsNoSuchMethodError);
731 spy.getLogs(callsTo('sum')).verify(happenedExactly(1)); 731 spy.getLogs(callsTo('sum')).verify(happenedExactly(1));
732 spy.getLogs(callsTo('total')).verify(happenedExactly(1)); 732 spy.getLogs(callsTo('total')).verify(happenedExactly(1));
733 }); 733 });
734 } 734 }
735 735
OLDNEW
« no previous file with comments | « pkg/unittest/test/mock_stepwise_negative_test.dart ('k') | pkg/unittest/test/test_common.dart » ('j') | no next file with comments »

Powered by Google App Engine