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

Side by Side Diff: pkg/mock/lib/src/behavior.dart

Issue 278613003: pkg/mock: fixes for v0.11 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: status file fix for mismatched version constraints Created 6 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/mock/lib/mock.dart ('k') | pkg/mock/lib/src/log_entry_list.dart » ('j') | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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.behavior; 5 library mock.behavior;
6 6
7 import 'action.dart'; 7 import 'action.dart';
8 import 'call_matcher.dart'; 8 import 'call_matcher.dart';
9 import 'responder.dart'; 9 import 'responder.dart';
10 10
11 /** 11 /**
12 * A [Behavior] represents how a [Mock] will respond to one particular 12 * A [Behavior] represents how a [Mock] will respond to one particular
13 * type of method call. 13 * type of method call.
14 */ 14 */
15 class Behavior { 15 class Behavior {
16 CallMatcher matcher; // The method call matcher. 16 CallMatcher matcher; // The method call matcher.
17 List<Responder> actions; // The values to return/throw or proxies to call. 17 List<Responder> actions; // The values to return/throw or proxies to call.
18 bool logging = true; 18 bool logging = true;
19 19
20 Behavior (this.matcher) { 20 Behavior(this.matcher) {
21 actions = new List<Responder>(); 21 actions = new List<Responder>();
22 } 22 }
23 23
24 /** 24 /**
25 * Adds a [Responder] that returns a [value] for [count] calls 25 * Adds a [Responder] that returns a [value] for [count] calls
26 * (1 by default). 26 * (1 by default).
27 */ 27 */
28 Behavior thenReturn(value, [count = 1]) { 28 Behavior thenReturn(value, [count = 1]) {
29 actions.add(new Responder(value, count, Action.RETURN)); 29 actions.add(new Responder(value, count, Action.RETURN));
30 return this; // For chaining calls. 30 return this; // For chaining calls.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 Behavior alwaysCall(value) { 74 Behavior alwaysCall(value) {
75 return thenCall(value, 0); 75 return thenCall(value, 0);
76 } 76 }
77 77
78 /** Returns true if a method call matches the [Behavior]. */ 78 /** Returns true if a method call matches the [Behavior]. */
79 bool matches(String method, List args) => matcher.matches(method, args); 79 bool matches(String method, List args) => matcher.matches(method, args);
80 80
81 /** Returns the [matcher]'s representation. */ 81 /** Returns the [matcher]'s representation. */
82 String toString() => matcher.toString(); 82 String toString() => matcher.toString();
83 } 83 }
OLDNEW
« no previous file with comments | « pkg/mock/lib/mock.dart ('k') | pkg/mock/lib/src/log_entry_list.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698