OLD | NEW |
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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 m1.clearLogs(); | 642 m1.clearLogs(); |
643 expect(log.logs, hasLength(6)); | 643 expect(log.logs, hasLength(6)); |
644 expect(log.logs.every((e) => e.mockName == 'm2' || e.mockName == 'm3'), | 644 expect(log.logs.every((e) => e.mockName == 'm2' || e.mockName == 'm3'), |
645 isTrue); | 645 isTrue); |
646 m2.clearLogs(); | 646 m2.clearLogs(); |
647 expect(log.logs, hasLength(3)); | 647 expect(log.logs, hasLength(3)); |
648 expect(log.logs.every((e) => e.mockName =='m3'), isTrue); | 648 expect(log.logs.every((e) => e.mockName =='m3'), isTrue); |
649 m3.clearLogs(); | 649 m3.clearLogs(); |
650 expect(log.logs, hasLength(0)); | 650 expect(log.logs, hasLength(0)); |
651 }); | 651 }); |
| 652 |
| 653 test("Mocking: instances", () { |
| 654 var alice = new Object(); |
| 655 var bob = new Object(); |
| 656 var m = new Mock(); |
| 657 m.when(callsTo("foo", alice)).alwaysReturn(true); |
| 658 m.when(callsTo("foo", bob)).alwaysReturn(false); |
| 659 expect(m.foo(alice), true); |
| 660 expect(m.foo(bob), false); |
| 661 expect(m.foo(alice), true); |
| 662 expect(m.foo(bob), false); |
| 663 }); |
652 } | 664 } |
OLD | NEW |