| Index: pkg/mock/test/mock_test.dart
|
| diff --git a/pkg/unittest/test/mock_test.dart b/pkg/mock/test/mock_test.dart
|
| similarity index 97%
|
| copy from pkg/unittest/test/mock_test.dart
|
| copy to pkg/mock/test/mock_test.dart
|
| index bd04c7955ca7f330c8d3c67ce12d567d42a1e694..df8400f2af9666b9d606ed80639115ef60133f68 100644
|
| --- a/pkg/unittest/test/mock_test.dart
|
| +++ b/pkg/mock/test/mock_test.dart
|
| @@ -2,9 +2,11 @@
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| -library mock_test;
|
| -import 'package:unittest/unittest.dart';
|
| -import 'package:unittest/mock.dart';
|
| +library mock.test;
|
| +
|
| +import 'package:unittest/unittest.dart' show test, group, skip_test;
|
| +import 'package:matcher/matcher.dart';
|
| +import 'package:mock/mock.dart';
|
|
|
| class MockList extends Mock implements List {
|
| dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
| @@ -15,35 +17,35 @@ class Foo {
|
| }
|
|
|
| class FooSpy extends Mock implements Foo {
|
| - Foo real;
|
| + final Foo real = new Foo();
|
| +
|
| FooSpy() {
|
| - real = new Foo();
|
| this.when(callsTo('sum')).alwaysCall(real.sum);
|
| }
|
|
|
| dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
| }
|
|
|
| -makeTestLogEntry(String methodName, List args, int time,
|
| +LogEntry makeTestLogEntry(String methodName, List args, int time,
|
| [String mockName]) {
|
| LogEntry e = new LogEntry(mockName, methodName, args, Action.IGNORE);
|
| e.time = new DateTime.fromMillisecondsSinceEpoch(time, isUtc: true);
|
| return e;
|
| }
|
|
|
| -makeTestLog() {
|
| - LogEntryList logList = new LogEntryList('test');
|
| - List args = new List();
|
| - logList.add(makeTestLogEntry('a', args, 1000));
|
| - logList.add(makeTestLogEntry('b', args, 2000));
|
| - logList.add(makeTestLogEntry('c', args, 3000));
|
| - return logList;
|
| +LogEntryList makeTestLog() {
|
| + var args = new List();
|
| + return new LogEntryList('test')
|
| + ..add(makeTestLogEntry('a', args, 1000))
|
| + ..add(makeTestLogEntry('b', args, 2000))
|
| + ..add(makeTestLogEntry('c', args, 3000));
|
| }
|
|
|
| -main() {
|
| +void main() {
|
| test('Mocking: Basics', () {
|
| var m = new Mock();
|
| - print(m.length);
|
| + // intentional no-opp access to m.length
|
| + var foo = m.length;
|
| m.getLogs(callsTo('get length')).verify(happenedOnce);
|
|
|
| m.when(callsTo('foo', 1, 2)).thenReturn('A').thenReturn('B');
|
| @@ -733,4 +735,3 @@ main() {
|
| spy.getLogs(callsTo('total')).verify(happenedExactly(1));
|
| });
|
| }
|
| -
|
|
|