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

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

Issue 14734004: Spys with mirrors! (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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/unittest/lib/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 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 } 10 }
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 711
712 m.when(callsTo("foo", "bar", "mock")).alwaysReturn("C"); 712 m.when(callsTo("foo", "bar", "mock")).alwaysReturn("C");
713 m.when(callsTo("foo")).thenReturn("A"); 713 m.when(callsTo("foo")).thenReturn("A");
714 m.when(callsTo("foo", "bar")).thenReturn("B"); 714 m.when(callsTo("foo", "bar")).thenReturn("B");
715 expect(m.foo("bar", "mock"), "C"); 715 expect(m.foo("bar", "mock"), "C");
716 expect(m.foo("bar", "mock"), "C"); 716 expect(m.foo("bar", "mock"), "C");
717 expect(m.foo("bar", "mock"), "C"); 717 expect(m.foo("bar", "mock"), "C");
718 expect(m.foo("bar", "mock"), "C"); 718 expect(m.foo("bar", "mock"), "C");
719 m.resetBehavior(); 719 m.resetBehavior();
720 }); 720 });
721
722 solo_test('Spys', () {
723 var real = new Foo();
724 var spy = new Mock.spy(real);
725 var sum = spy.sum(1, 2, 3);
726 expect(sum, 6);
727 expect(() => spy.total(1, 2, 3), throwsNoSuchMethodError);
728 spy.getLogs(callsTo('sum')).verify(happenedExactly(1));
729 spy.getLogs(callsTo('total')).verify(happenedExactly(1));
730 });
721 } 731 }
722 732
OLDNEW
« no previous file with comments | « pkg/unittest/lib/mock.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698