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

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

Issue 141713013: pkg/unittest: tweaks to mock, re-enabled most tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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/unittest/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 // 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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 expect(log.logs, hasLength(6)); 646 expect(log.logs, hasLength(6));
647 expect(log.logs.every((e) => e.mockName == 'm2' || e.mockName == 'm3'), 647 expect(log.logs.every((e) => e.mockName == 'm2' || e.mockName == 'm3'),
648 isTrue); 648 isTrue);
649 m2.clearLogs(); 649 m2.clearLogs();
650 expect(log.logs, hasLength(3)); 650 expect(log.logs, hasLength(3));
651 expect(log.logs.every((e) => e.mockName =='m3'), isTrue); 651 expect(log.logs.every((e) => e.mockName =='m3'), isTrue);
652 m3.clearLogs(); 652 m3.clearLogs();
653 expect(log.logs, hasLength(0)); 653 expect(log.logs, hasLength(0));
654 }); 654 });
655 655
656 test("Mocking: instances", () { 656 // TODO(kevmoo): figure out why this test is failing
657 skip_test("Mocking: instances", () {
657 var alice = new Object(); 658 var alice = new Object();
658 var bob = new Object(); 659 var bob = new Object();
659 var m = new Mock(); 660 var m = new Mock();
660 m.when(callsTo("foo", alice)).alwaysReturn(true); 661 m.when(callsTo("foo", alice)).alwaysReturn(true);
661 m.when(callsTo("foo", bob)).alwaysReturn(false); 662 m.when(callsTo("foo", bob)).alwaysReturn(false);
662 expect(m.foo(alice), true); 663 expect(m.foo(alice), true);
663 expect(m.foo(bob), false); 664 expect(m.foo(bob), false);
664 expect(m.foo(alice), true); 665 expect(m.foo(alice), true);
665 expect(m.foo(bob), false); 666 expect(m.foo(bob), false);
666 }); 667 });
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 m.when(callsTo("foo", "bar", "mock")).alwaysReturn("C"); 716 m.when(callsTo("foo", "bar", "mock")).alwaysReturn("C");
716 m.when(callsTo("foo")).thenReturn("A"); 717 m.when(callsTo("foo")).thenReturn("A");
717 m.when(callsTo("foo", "bar")).thenReturn("B"); 718 m.when(callsTo("foo", "bar")).thenReturn("B");
718 expect(m.foo("bar", "mock"), "C"); 719 expect(m.foo("bar", "mock"), "C");
719 expect(m.foo("bar", "mock"), "C"); 720 expect(m.foo("bar", "mock"), "C");
720 expect(m.foo("bar", "mock"), "C"); 721 expect(m.foo("bar", "mock"), "C");
721 expect(m.foo("bar", "mock"), "C"); 722 expect(m.foo("bar", "mock"), "C");
722 m.resetBehavior(); 723 m.resetBehavior();
723 }); 724 });
724 725
725 solo_test('Spys', () { 726 test('Spys', () {
726 var real = new Foo(); 727 var real = new Foo();
727 var spy = new Mock.spy(real); 728 var spy = new Mock.spy(real);
728 var sum = spy.sum(1, 2, 3); 729 var sum = spy.sum(1, 2, 3);
729 expect(sum, 6); 730 expect(sum, 6);
730 expect(() => spy.total(1, 2, 3), throwsNoSuchMethodError); 731 expect(() => spy.total(1, 2, 3), throwsNoSuchMethodError);
731 spy.getLogs(callsTo('sum')).verify(happenedExactly(1)); 732 spy.getLogs(callsTo('sum')).verify(happenedExactly(1));
732 spy.getLogs(callsTo('total')).verify(happenedExactly(1)); 733 spy.getLogs(callsTo('total')).verify(happenedExactly(1));
733 }); 734 });
734 } 735 }
735 736
OLDNEW
« no previous file with comments | « pkg/unittest/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698