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

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

Issue 12212003: Some fixes/improvements to getter/setter mocking. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/unittest/lib/mock.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/unittest/test/mock_test.dart
===================================================================
--- pkg/unittest/test/mock_test.dart (revision 18082)
+++ pkg/unittest/test/mock_test.dart (working copy)
@@ -63,6 +63,21 @@
expect(s, 'ACDEB');
});
+ test('Mocking: getters/setters', () {
+ var m = new Mock();
+ var x = 0;
+ m.when(callsTo('get foo')).alwaysReturn(3);
+ m.when(callsTo('set foo')).alwaysCall((v) { x = v; });
+ m.when(callsTo('get bar')).alwaysReturn(5);
+ m.when(callsTo('set bar')).alwaysCall((v) { x = 2 * v; });
+ expect(m.foo, 3);
+ expect(m.bar, 5);
+ m.foo = 10;
+ expect(x, 10);
+ m.bar = 8;
+ expect(x, 16);
+ });
+
test('Mocking: Mock List', () {
var l = new MockList();
l.when(callsTo('get length')).thenReturn(1);
« 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