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

Side by Side Diff: tests/lib/unittest/mock_test.dart

Issue 10855128: Added ability to reset Mocks. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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 | « lib/unittest/mock.dart ('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 // 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('unittestTest'); 5 #library('unittestTest');
6 #import('../../../lib/unittest/unittest.dart'); 6 #import('../../../lib/unittest/unittest.dart');
7 7
8 class MockList extends Mock implements List { 8 class MockList extends Mock implements List {
9 } 9 }
10 10
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 logList.add(e); 595 logList.add(e);
596 } 596 }
597 int total = 0; 597 int total = 0;
598 logList.stepwiseValidate((log, pos) { 598 logList.stepwiseValidate((log, pos) {
599 total += log[pos].args[0] * log[pos + 1].args[0]; 599 total += log[pos].args[0] * log[pos + 1].args[0];
600 expect(log[pos + 1].args[0] - log[pos].args[0], equals(1)); 600 expect(log[pos + 1].args[0] - log[pos].args[0], equals(1));
601 return 2; 601 return 2;
602 }); 602 });
603 expect(total, equals((0 * 1) + (2 * 3) + (4 * 5) + (6 * 7) + (8 * 9))); 603 expect(total, equals((0 * 1) + (2 * 3) + (4 * 5) + (6 * 7) + (8 * 9)));
604 }); 604 });
605
606 test('Mocking: clearLogs', () {
607 var m = new Mock();
608 m.foo();
609 m.foo();
610 m.foo();
611 expect(m.log.logs, hasLength(3));
612 m.clearLogs();
613 expect(m.log.logs, hasLength(0));
614 LogEntryList log = new LogEntryList();
615 var m1 = new Mock.custom(name: 'm1', log: log);
616 var m2 = new Mock.custom(name: 'm2', log: log);
617 var m3 = new Mock.custom(name: 'm3', log: log);
618 for (var i = 0; i < 3; i++) {
619 m1.foo();
620 m2.bar();
621 m3.pow();
622 }
623 expect(log.logs, hasLength(9));
624 m1.clearLogs();
625 expect(log.logs, hasLength(6));
626 m1.clearLogs();
627 expect(log.logs, hasLength(6));
628 expect(log.logs.every((e) => e.mockName == 'm2' || e.mockName == 'm3'),
629 isTrue);
630 m2.clearLogs();
631 expect(log.logs, hasLength(3));
632 expect(log.logs.every((e) => e.mockName =='m3'), isTrue);
633 m3.clearLogs();
634 expect(log.logs, hasLength(0));
635 });
605 } 636 }
OLDNEW
« no previous file with comments | « lib/unittest/mock.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698