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

Unified Diff: pkg/mock/test/mock_test.dart

Issue 209333003: pkg/mock - NEW! (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: nit Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/mock/test/mock_stepwise_negative_test.dart ('k') | pkg/pkg.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
});
}
-
« no previous file with comments | « pkg/mock/test/mock_stepwise_negative_test.dart ('k') | pkg/pkg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698