moq 3.1.416.3-universal-dotnet-2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/gems/moq/docs/Moq.chm +0 -0
- data/gems/moq/lib/Moq.dll +0 -0
- data/gems/moq/lib/Moq.pdb +0 -0
- data/gems/moq/lib/Moq.xml +3467 -0
- metadata +72 -0
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,3467 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<doc>
|
3
|
+
<assembly>
|
4
|
+
<name>Moq</name>
|
5
|
+
</assembly>
|
6
|
+
<members>
|
7
|
+
<member name="T:Moq.EmptyDefaultValueProvider">
|
8
|
+
<summary>
|
9
|
+
A <see cref="T:Moq.IDefaultValueProvider"/> that returns an empty default value
|
10
|
+
for invocations that do not have setups or return values, with loose mocks.
|
11
|
+
This is the default behavior for a mock.
|
12
|
+
</summary>
|
13
|
+
</member>
|
14
|
+
<member name="T:Moq.IDefaultValueProvider">
|
15
|
+
<summary>
|
16
|
+
Interface to be implemented by classes that determine the
|
17
|
+
default value of non-expected invocations.
|
18
|
+
</summary>
|
19
|
+
</member>
|
20
|
+
<member name="M:Moq.IDefaultValueProvider.ProvideDefault(System.Reflection.MethodInfo,System.Object[])">
|
21
|
+
<summary>
|
22
|
+
Provides a value for the given member and arguments.
|
23
|
+
</summary>
|
24
|
+
<param name="member">The member to provide a default
|
25
|
+
value for.</param>
|
26
|
+
<param name="arguments">Optional arguments passed in
|
27
|
+
to the call that requires a default value.</param>
|
28
|
+
</member>
|
29
|
+
<member name="T:Moq.Language.Flow.IReturnsResult`1">
|
30
|
+
<summary>
|
31
|
+
Implements the fluent API.
|
32
|
+
</summary>
|
33
|
+
</member>
|
34
|
+
<member name="T:Moq.Language.ICallback">
|
35
|
+
<summary>
|
36
|
+
Defines the <c>Callback</c> verb and overloads.
|
37
|
+
</summary>
|
38
|
+
</member>
|
39
|
+
<member name="T:Moq.IHideObjectMembers">
|
40
|
+
<summary>
|
41
|
+
Helper interface used to hide the base <see cref="T:System.Object"/>
|
42
|
+
members from the fluent API to make it much cleaner
|
43
|
+
in Visual Studio intellisense.
|
44
|
+
</summary>
|
45
|
+
</member>
|
46
|
+
<member name="M:Moq.IHideObjectMembers.GetType">
|
47
|
+
<summary/>
|
48
|
+
</member>
|
49
|
+
<member name="M:Moq.IHideObjectMembers.GetHashCode">
|
50
|
+
<summary/>
|
51
|
+
</member>
|
52
|
+
<member name="M:Moq.IHideObjectMembers.ToString">
|
53
|
+
<summary/>
|
54
|
+
</member>
|
55
|
+
<member name="M:Moq.IHideObjectMembers.Equals(System.Object)">
|
56
|
+
<summary/>
|
57
|
+
</member>
|
58
|
+
<member name="M:Moq.Language.ICallback.Callback(System.Action)">
|
59
|
+
<summary>
|
60
|
+
Specifies a callback to invoke when the method is called.
|
61
|
+
</summary>
|
62
|
+
<param name="action">Callback method to invoke.</param>
|
63
|
+
<example>
|
64
|
+
The following example specifies a callback to set a boolean
|
65
|
+
value that can be used later:
|
66
|
+
<code>
|
67
|
+
bool called = false;
|
68
|
+
mock.Setup(x => x.Execute())
|
69
|
+
.Callback(() => called = true);
|
70
|
+
</code>
|
71
|
+
</example>
|
72
|
+
</member>
|
73
|
+
<member name="M:Moq.Language.ICallback.Callback``1(System.Action{``0})">
|
74
|
+
<summary>
|
75
|
+
Specifies a callback to invoke when the method is called that receives the original
|
76
|
+
arguments.
|
77
|
+
</summary>
|
78
|
+
<typeparam name="T">Argument type of the invoked method.</typeparam>
|
79
|
+
<param name="action">Callback method to invoke.</param>
|
80
|
+
<example>
|
81
|
+
Invokes the given callback with the concrete invocation argument value.
|
82
|
+
<para>
|
83
|
+
Notice how the specific string argument is retrieved by simply declaring
|
84
|
+
it as part of the lambda expression for the callback:
|
85
|
+
</para>
|
86
|
+
<code>
|
87
|
+
mock.Setup(x => x.Execute(It.IsAny<string>()))
|
88
|
+
.Callback((string command) => Console.WriteLine(command));
|
89
|
+
</code>
|
90
|
+
</example>
|
91
|
+
</member>
|
92
|
+
<member name="M:Moq.Language.ICallback.Callback``2(System.Action{``0,``1})">
|
93
|
+
<summary>
|
94
|
+
Specifies a callback to invoke when the method is called that receives the original
|
95
|
+
arguments.
|
96
|
+
</summary>
|
97
|
+
<typeparam name="T1">Type of the first argument of the invoked method.</typeparam>
|
98
|
+
<typeparam name="T2">Type of the second argument of the invoked method.</typeparam>
|
99
|
+
<param name="action">Callback method to invoke.</param>
|
100
|
+
<example>
|
101
|
+
Invokes the given callback with the concrete invocation arguments values.
|
102
|
+
<para>
|
103
|
+
Notice how the specific arguments are retrieved by simply declaring
|
104
|
+
them as part of the lambda expression for the callback:
|
105
|
+
</para>
|
106
|
+
<code>
|
107
|
+
mock.Setup(x => x.Execute(
|
108
|
+
It.IsAny<string>(),
|
109
|
+
It.IsAny<string>()))
|
110
|
+
.Callback((string arg1, string arg2) => Console.WriteLine(arg1 + arg2));
|
111
|
+
</code>
|
112
|
+
</example>
|
113
|
+
</member>
|
114
|
+
<member name="M:Moq.Language.ICallback.Callback``3(System.Action{``0,``1,``2})">
|
115
|
+
<summary>
|
116
|
+
Specifies a callback to invoke when the method is called that receives the original
|
117
|
+
arguments.
|
118
|
+
</summary>
|
119
|
+
<typeparam name="T1">Type of the first argument of the invoked method.</typeparam>
|
120
|
+
<typeparam name="T2">Type of the second argument of the invoked method.</typeparam>
|
121
|
+
<typeparam name="T3">Type of the third argument of the invoked method.</typeparam>
|
122
|
+
<param name="action">Callback method to invoke.</param>
|
123
|
+
<example>
|
124
|
+
Invokes the given callback with the concrete invocation arguments values.
|
125
|
+
<para>
|
126
|
+
Notice how the specific arguments are retrieved by simply declaring
|
127
|
+
them as part of the lambda expression for the callback:
|
128
|
+
</para>
|
129
|
+
<code>
|
130
|
+
mock.Setup(x => x.Execute(
|
131
|
+
It.IsAny<string>(),
|
132
|
+
It.IsAny<string>(),
|
133
|
+
It.IsAny<int>()))
|
134
|
+
.Callback((string arg1, string arg2, int arg3) => Console.WriteLine(arg1 + arg2 + arg3));
|
135
|
+
</code>
|
136
|
+
</example>
|
137
|
+
</member>
|
138
|
+
<member name="M:Moq.Language.ICallback.Callback``4(System.Action{``0,``1,``2,``3})">
|
139
|
+
<summary>
|
140
|
+
Specifies a callback to invoke when the method is called that receives the original
|
141
|
+
arguments.
|
142
|
+
</summary>
|
143
|
+
<typeparam name="T1">Type of the first argument of the invoked method.</typeparam>
|
144
|
+
<typeparam name="T2">Type of the second argument of the invoked method.</typeparam>
|
145
|
+
<typeparam name="T3">Type of the third argument of the invoked method.</typeparam>
|
146
|
+
<typeparam name="T4">Type of the fourth argument of the invoked method.</typeparam>
|
147
|
+
<param name="action">Callback method to invoke.</param>
|
148
|
+
<example>
|
149
|
+
Invokes the given callback with the concrete invocation arguments values.
|
150
|
+
<para>
|
151
|
+
Notice how the specific arguments are retrieved by simply declaring
|
152
|
+
them as part of the lambda expression for the callback:
|
153
|
+
</para>
|
154
|
+
<code>
|
155
|
+
mock.Setup(x => x.Execute(
|
156
|
+
It.IsAny<string>(),
|
157
|
+
It.IsAny<string>(),
|
158
|
+
It.IsAny<int>(),
|
159
|
+
It.IsAny<bool>()))
|
160
|
+
.Callback((string arg1, string arg2, int arg3, bool arg4) => Console.WriteLine(arg1 + arg2 + arg3 + arg4));
|
161
|
+
</code>
|
162
|
+
</example>
|
163
|
+
</member>
|
164
|
+
<member name="T:Moq.Language.IOccurrence">
|
165
|
+
<summary>
|
166
|
+
Defines occurrence members to constraint setups.
|
167
|
+
</summary>
|
168
|
+
</member>
|
169
|
+
<member name="M:Moq.Language.IOccurrence.AtMostOnce">
|
170
|
+
<summary>
|
171
|
+
The expected invocation can happen at most once.
|
172
|
+
</summary>
|
173
|
+
<example>
|
174
|
+
<code>
|
175
|
+
var mock = new Mock<ICommand>();
|
176
|
+
mock.Setup(foo => foo.Execute("ping"))
|
177
|
+
.AtMostOnce();
|
178
|
+
</code>
|
179
|
+
</example>
|
180
|
+
</member>
|
181
|
+
<member name="M:Moq.Language.IOccurrence.AtMost(System.Int32)">
|
182
|
+
<summary>
|
183
|
+
The expected invocation can happen at most specified number of times.
|
184
|
+
</summary>
|
185
|
+
<param name="callCount">The number of times to accept calls.</param>
|
186
|
+
<example>
|
187
|
+
<code>
|
188
|
+
var mock = new Mock<ICommand>();
|
189
|
+
mock.Setup(foo => foo.Execute("ping"))
|
190
|
+
.AtMost( 5 );
|
191
|
+
</code>
|
192
|
+
</example>
|
193
|
+
</member>
|
194
|
+
<member name="T:Moq.Language.IRaise`1">
|
195
|
+
<summary>
|
196
|
+
Defines the <c>Raises</c> verb.
|
197
|
+
</summary>
|
198
|
+
</member>
|
199
|
+
<member name="M:Moq.Language.IRaise`1.Raises(System.Action{`0},System.EventArgs)">
|
200
|
+
<summary>
|
201
|
+
Specifies the event that will be raised
|
202
|
+
when the setup is met.
|
203
|
+
</summary>
|
204
|
+
<param name="eventExpression">An expression that represents an event attach or detach action.</param>
|
205
|
+
<param name="args">The event arguments to pass for the raised event.</param>
|
206
|
+
<example>
|
207
|
+
The following example shows how to raise an event when
|
208
|
+
the setup is met:
|
209
|
+
<code>
|
210
|
+
var mock = new Mock<IContainer>();
|
211
|
+
|
212
|
+
mock.Setup(add => add.Add(It.IsAny<string>(), It.IsAny<object>()))
|
213
|
+
.Raises(add => add.Added += null, EventArgs.Empty);
|
214
|
+
</code>
|
215
|
+
</example>
|
216
|
+
</member>
|
217
|
+
<member name="M:Moq.Language.IRaise`1.Raises(System.Action{`0},System.Func{System.EventArgs})">
|
218
|
+
<summary>
|
219
|
+
Specifies the event that will be raised
|
220
|
+
when the setup is matched.
|
221
|
+
</summary>
|
222
|
+
<param name="eventExpression">An expression that represents an event attach or detach action.</param>
|
223
|
+
<param name="func">A function that will build the <see cref="T:System.EventArgs"/>
|
224
|
+
to pass when raising the event.</param>
|
225
|
+
<seealso cref="M:Moq.Language.IRaise`1.Raises(System.Action{`0},System.EventArgs)"/>
|
226
|
+
</member>
|
227
|
+
<member name="M:Moq.Language.IRaise`1.Raises``1(System.Action{`0},System.Func{``0,System.EventArgs})">
|
228
|
+
<summary>
|
229
|
+
Specifies the event that will be raised
|
230
|
+
when the setup is matched.
|
231
|
+
</summary>
|
232
|
+
<param name="eventExpression">An expression that represents an event attach or detach action.</param>
|
233
|
+
<param name="func">A function that will build the <see cref="T:System.EventArgs"/>
|
234
|
+
to pass when raising the event.</param>
|
235
|
+
<typeparam name="T1">Type of the argument received by the expected invocation.</typeparam>
|
236
|
+
<seealso cref="M:Moq.Language.IRaise`1.Raises(System.Action{`0},System.EventArgs)"/>
|
237
|
+
</member>
|
238
|
+
<member name="M:Moq.Language.IRaise`1.Raises``2(System.Action{`0},System.Func{``0,``1,System.EventArgs})">
|
239
|
+
<summary>
|
240
|
+
Specifies the event that will be raised
|
241
|
+
when the setup is matched.
|
242
|
+
</summary>
|
243
|
+
<param name="eventExpression">An expression that represents an event attach or detach action.</param>
|
244
|
+
<param name="func">A function that will build the <see cref="T:System.EventArgs"/>
|
245
|
+
to pass when raising the event.</param>
|
246
|
+
<typeparam name="T1">Type of the first argument received by the expected invocation.</typeparam>
|
247
|
+
<typeparam name="T2">Type of the second argument received by the expected invocation.</typeparam>
|
248
|
+
<seealso cref="M:Moq.Language.IRaise`1.Raises(System.Action{`0},System.EventArgs)"/>
|
249
|
+
</member>
|
250
|
+
<member name="M:Moq.Language.IRaise`1.Raises``3(System.Action{`0},System.Func{``0,``1,``2,System.EventArgs})">
|
251
|
+
<summary>
|
252
|
+
Specifies the event that will be raised
|
253
|
+
when the setup is matched.
|
254
|
+
</summary>
|
255
|
+
<param name="eventExpression">An expression that represents an event attach or detach action.</param>
|
256
|
+
<param name="func">A function that will build the <see cref="T:System.EventArgs"/>
|
257
|
+
to pass when raising the event.</param>
|
258
|
+
<typeparam name="T1">Type of the first argument received by the expected invocation.</typeparam>
|
259
|
+
<typeparam name="T2">Type of the second argument received by the expected invocation.</typeparam>
|
260
|
+
<typeparam name="T3">Type of the third argument received by the expected invocation.</typeparam>
|
261
|
+
<seealso cref="M:Moq.Language.IRaise`1.Raises(System.Action{`0},System.EventArgs)"/>
|
262
|
+
</member>
|
263
|
+
<member name="M:Moq.Language.IRaise`1.Raises``4(System.Action{`0},System.Func{``0,``1,``2,``3,System.EventArgs})">
|
264
|
+
<summary>
|
265
|
+
Specifies the event that will be raised
|
266
|
+
when the setup is matched.
|
267
|
+
</summary>
|
268
|
+
<param name="eventExpression">An expression that represents an event attach or detach action.</param>
|
269
|
+
<param name="func">A function that will build the <see cref="T:System.EventArgs"/>
|
270
|
+
to pass when raising the event.</param>
|
271
|
+
<typeparam name="T1">Type of the first argument received by the expected invocation.</typeparam>
|
272
|
+
<typeparam name="T2">Type of the second argument received by the expected invocation.</typeparam>
|
273
|
+
<typeparam name="T3">Type of the third argument received by the expected invocation.</typeparam>
|
274
|
+
<typeparam name="T4">Type of the fourth argument received by the expected invocation.</typeparam>
|
275
|
+
<seealso cref="M:Moq.Language.IRaise`1.Raises(System.Action{`0},System.EventArgs)"/>
|
276
|
+
</member>
|
277
|
+
<member name="M:Moq.Language.IRaise`1.Raises(System.Action{`0},System.Object[])">
|
278
|
+
<summary>
|
279
|
+
Specifies the custom event that will be raised
|
280
|
+
when the setup is matched.
|
281
|
+
</summary>
|
282
|
+
<param name="eventExpression">An expression that represents an event attach or detach action.</param>
|
283
|
+
<param name="args">The arguments to pass to the custom delegate (non EventHandler-compatible).</param>
|
284
|
+
</member>
|
285
|
+
<member name="T:Moq.Language.IRaise">
|
286
|
+
<summary>
|
287
|
+
Defines the <c>Raises</c> verb.
|
288
|
+
</summary>
|
289
|
+
</member>
|
290
|
+
<member name="M:Moq.Language.IRaise.Raises(Moq.MockedEvent,System.EventArgs)">
|
291
|
+
<summary>
|
292
|
+
Specifies the mocked event that will be raised
|
293
|
+
when the setup is met.
|
294
|
+
</summary>
|
295
|
+
<param name="eventHandler">The mocked event, retrieved from
|
296
|
+
<see cref="M:Moq.Mock.CreateEventHandler"/> or <see cref="M:Moq.Mock.CreateEventHandler``1"/>.
|
297
|
+
</param>
|
298
|
+
<param name="args">The event args to pass when raising the event.</param>
|
299
|
+
<example>
|
300
|
+
The following example shows how to raise an event when
|
301
|
+
the setup is met:
|
302
|
+
<code>
|
303
|
+
var mock = new Mock<IContainer>();
|
304
|
+
// create handler to associate with the event to raise
|
305
|
+
var handler = mock.CreateEventHandler();
|
306
|
+
// associate the handler with the event to raise
|
307
|
+
mock.Object.Added += handler;
|
308
|
+
// setup the invocation and the handler to raise
|
309
|
+
mock.Setup(add => add.Add(It.IsAny<string>(), It.IsAny<object>()))
|
310
|
+
.Raises(handler, EventArgs.Empty);
|
311
|
+
</code>
|
312
|
+
</example>
|
313
|
+
</member>
|
314
|
+
<member name="M:Moq.Language.IRaise.Raises(Moq.MockedEvent,System.Func{System.EventArgs})">
|
315
|
+
<summary>
|
316
|
+
Specifies the mocked event that will be raised
|
317
|
+
when the setup is matched.
|
318
|
+
</summary>
|
319
|
+
<param name="eventHandler">The mocked event, retrieved from
|
320
|
+
<see cref="M:Moq.Mock.CreateEventHandler"/> or <see cref="M:Moq.Mock.CreateEventHandler``1"/>.
|
321
|
+
</param>
|
322
|
+
<param name="func">A function that will build the <see cref="T:System.EventArgs"/>
|
323
|
+
to pass when raising the event.</param>
|
324
|
+
<seealso cref="M:Moq.Language.IRaise.Raises(Moq.MockedEvent,System.EventArgs)"/>
|
325
|
+
</member>
|
326
|
+
<member name="M:Moq.Language.IRaise.Raises``1(Moq.MockedEvent,System.Func{``0,System.EventArgs})">
|
327
|
+
<summary>
|
328
|
+
Specifies the mocked event that will be raised
|
329
|
+
when the setup is matched.
|
330
|
+
</summary>
|
331
|
+
<param name="eventHandler">The mocked event, retrieved from
|
332
|
+
<see cref="M:Moq.Mock.CreateEventHandler"/> or <see cref="M:Moq.Mock.CreateEventHandler``1"/>.
|
333
|
+
</param>
|
334
|
+
<param name="func">A function that will build the <see cref="T:System.EventArgs"/>
|
335
|
+
to pass when raising the event.</param>
|
336
|
+
<typeparam name="T">Type of the argument received by the expected invocation.</typeparam>
|
337
|
+
<seealso cref="M:Moq.Language.IRaise.Raises(Moq.MockedEvent,System.EventArgs)"/>
|
338
|
+
</member>
|
339
|
+
<member name="M:Moq.Language.IRaise.Raises``2(Moq.MockedEvent,System.Func{``0,``1,System.EventArgs})">
|
340
|
+
<summary>
|
341
|
+
Specifies the mocked event that will be raised
|
342
|
+
when the setup is matched.
|
343
|
+
</summary>
|
344
|
+
<param name="eventHandler">The mocked event, retrieved from
|
345
|
+
<see cref="M:Moq.Mock.CreateEventHandler"/> or <see cref="M:Moq.Mock.CreateEventHandler``1"/>.
|
346
|
+
</param>
|
347
|
+
<param name="func">A function that will build the <see cref="T:System.EventArgs"/>
|
348
|
+
to pass when raising the event.</param>
|
349
|
+
<typeparam name="T1">Type of the first argument received by the expected invocation.</typeparam>
|
350
|
+
<typeparam name="T2">Type of the second argument received by the expected invocation.</typeparam>
|
351
|
+
<seealso cref="M:Moq.Language.IRaise.Raises(Moq.MockedEvent,System.EventArgs)"/>
|
352
|
+
</member>
|
353
|
+
<member name="M:Moq.Language.IRaise.Raises``3(Moq.MockedEvent,System.Func{``0,``1,``2,System.EventArgs})">
|
354
|
+
<summary>
|
355
|
+
Specifies the mocked event that will be raised
|
356
|
+
when the setup is matched.
|
357
|
+
</summary>
|
358
|
+
<param name="eventHandler">The mocked event, retrieved from
|
359
|
+
<see cref="M:Moq.Mock.CreateEventHandler"/> or <see cref="M:Moq.Mock.CreateEventHandler``1"/>.
|
360
|
+
</param>
|
361
|
+
<param name="func">A function that will build the <see cref="T:System.EventArgs"/>
|
362
|
+
to pass when raising the event.</param>
|
363
|
+
<typeparam name="T1">Type of the first argument received by the expected invocation.</typeparam>
|
364
|
+
<typeparam name="T2">Type of the second argument received by the expected invocation.</typeparam>
|
365
|
+
<typeparam name="T3">Type of the third argument received by the expected invocation.</typeparam>
|
366
|
+
<seealso cref="M:Moq.Language.IRaise.Raises(Moq.MockedEvent,System.EventArgs)"/>
|
367
|
+
</member>
|
368
|
+
<member name="M:Moq.Language.IRaise.Raises``4(Moq.MockedEvent,System.Func{``0,``1,``2,``3,System.EventArgs})">
|
369
|
+
<summary>
|
370
|
+
Specifies the mocked event that will be raised
|
371
|
+
when the setup is matched.
|
372
|
+
</summary>
|
373
|
+
<param name="eventHandler">The mocked event, retrieved from
|
374
|
+
<see cref="M:Moq.Mock.CreateEventHandler"/> or <see cref="M:Moq.Mock.CreateEventHandler``1"/>.
|
375
|
+
</param>
|
376
|
+
<param name="func">A function that will build the <see cref="T:System.EventArgs"/>
|
377
|
+
to pass when raising the event.</param>
|
378
|
+
<typeparam name="T1">Type of the first argument received by the expected invocation.</typeparam>
|
379
|
+
<typeparam name="T2">Type of the second argument received by the expected invocation.</typeparam>
|
380
|
+
<typeparam name="T3">Type of the third argument received by the expected invocation.</typeparam>
|
381
|
+
<typeparam name="T4">Type of the fourth argument received by the expected invocation.</typeparam>
|
382
|
+
<seealso cref="M:Moq.Language.IRaise.Raises(Moq.MockedEvent,System.EventArgs)"/>
|
383
|
+
</member>
|
384
|
+
<member name="T:Moq.Language.IVerifies">
|
385
|
+
<summary>
|
386
|
+
Defines the <c>Verifiable</c> verb.
|
387
|
+
</summary>
|
388
|
+
</member>
|
389
|
+
<member name="M:Moq.Language.IVerifies.Verifiable">
|
390
|
+
<summary>
|
391
|
+
Marks the expectation as verifiable, meaning that a call
|
392
|
+
to <see cref="M:Moq.Mock.Verify"/> will check if this particular
|
393
|
+
expectation was met.
|
394
|
+
</summary>
|
395
|
+
<example>
|
396
|
+
The following example marks the expectation as verifiable:
|
397
|
+
<code>
|
398
|
+
mock.Expect(x => x.Execute("ping"))
|
399
|
+
.Returns(true)
|
400
|
+
.Verifiable();
|
401
|
+
</code>
|
402
|
+
</example>
|
403
|
+
</member>
|
404
|
+
<member name="M:Moq.Language.IVerifies.Verifiable(System.String)">
|
405
|
+
<summary>
|
406
|
+
Marks the expectation as verifiable, meaning that a call
|
407
|
+
to <see cref="M:Moq.Mock.Verify"/> will check if this particular
|
408
|
+
expectation was met, and specifies a message for failures.
|
409
|
+
</summary>
|
410
|
+
<example>
|
411
|
+
The following example marks the expectation as verifiable:
|
412
|
+
<code>
|
413
|
+
mock.Expect(x => x.Execute("ping"))
|
414
|
+
.Returns(true)
|
415
|
+
.Verifiable("Ping should be executed always!");
|
416
|
+
</code>
|
417
|
+
</example>
|
418
|
+
</member>
|
419
|
+
<member name="T:Moq.MatcherAttribute">
|
420
|
+
<summary>
|
421
|
+
Marks a method as a matcher, which allows complete replacement
|
422
|
+
of the built-in <see cref="T:Moq.It"/> class with your own argument
|
423
|
+
matching rules.
|
424
|
+
</summary>
|
425
|
+
<remarks>
|
426
|
+
<b>This feature has been deprecated in favor of the new
|
427
|
+
and simpler <see cref="T:Moq.Match`1"/>.
|
428
|
+
</b>
|
429
|
+
<para>
|
430
|
+
The argument matching is used to determine whether a concrete
|
431
|
+
invocation in the mock matches a given setup. This
|
432
|
+
matching mechanism is fully extensible.
|
433
|
+
</para>
|
434
|
+
<para>
|
435
|
+
There are two parts of a matcher: the compiler matcher
|
436
|
+
and the runtime matcher.
|
437
|
+
<list type="bullet">
|
438
|
+
<item>
|
439
|
+
<term>Compiler matcher</term>
|
440
|
+
<description>Used to satisfy the compiler requirements for the
|
441
|
+
argument. Needs to be a method optionally receiving any arguments
|
442
|
+
you might need for the matching, but with a return type that
|
443
|
+
matches that of the argument.
|
444
|
+
<para>
|
445
|
+
Let's say I want to match a lists of orders that contains
|
446
|
+
a particular one. I might create a compiler matcher like the following:
|
447
|
+
</para>
|
448
|
+
<code>
|
449
|
+
public static class Orders
|
450
|
+
{
|
451
|
+
[Matcher]
|
452
|
+
public static IEnumerable<Order> Contains(Order order)
|
453
|
+
{
|
454
|
+
return null;
|
455
|
+
}
|
456
|
+
}
|
457
|
+
</code>
|
458
|
+
Now we can invoke this static method instead of an argument in an
|
459
|
+
invocation:
|
460
|
+
<code>
|
461
|
+
var order = new Order { ... };
|
462
|
+
var mock = new Mock<IRepository<Order>>();
|
463
|
+
|
464
|
+
mock.Setup(x => x.Save(Orders.Contains(order)))
|
465
|
+
.Throws<ArgumentException>();
|
466
|
+
</code>
|
467
|
+
Note that the return value from the compiler matcher is irrelevant.
|
468
|
+
This method will never be called, and is just used to satisfy the
|
469
|
+
compiler and to signal Moq that this is not a method that we want
|
470
|
+
to be invoked at runtime.
|
471
|
+
</description>
|
472
|
+
</item>
|
473
|
+
<item>
|
474
|
+
<term>Runtime matcher</term>
|
475
|
+
<description>
|
476
|
+
The runtime matcher is the one that will actually perform evaluation
|
477
|
+
when the test is run, and is defined by convention to have the
|
478
|
+
same signature as the compiler matcher, but where the return
|
479
|
+
value is the first argument to the call, which contains the
|
480
|
+
object received by the actual invocation at runtime:
|
481
|
+
<code>
|
482
|
+
public static bool Contains(IEnumerable<Order> orders, Order order)
|
483
|
+
{
|
484
|
+
return orders.Contains(order);
|
485
|
+
}
|
486
|
+
</code>
|
487
|
+
At runtime, the mocked method will be invoked with a specific
|
488
|
+
list of orders. This value will be passed to this runtime
|
489
|
+
matcher as the first argument, while the second argument is the
|
490
|
+
one specified in the setup (<c>x.Save(Orders.Contains(order))</c>).
|
491
|
+
<para>
|
492
|
+
The boolean returned determines whether the given argument has been
|
493
|
+
matched. If all arguments to the expected method are matched, then
|
494
|
+
the setup matches and is evaluated.
|
495
|
+
</para>
|
496
|
+
</description>
|
497
|
+
</item>
|
498
|
+
</list>
|
499
|
+
</para>
|
500
|
+
Using this extensible infrastructure, you can easily replace the entire
|
501
|
+
<see cref="T:Moq.It"/> set of matchers with your own. You can also avoid the
|
502
|
+
typical (and annoying) lengthy expressions that result when you have
|
503
|
+
multiple arguments that use generics.
|
504
|
+
</remarks>
|
505
|
+
<example>
|
506
|
+
The following is the complete example explained above:
|
507
|
+
<code>
|
508
|
+
public static class Orders
|
509
|
+
{
|
510
|
+
[Matcher]
|
511
|
+
public static IEnumerable<Order> Contains(Order order)
|
512
|
+
{
|
513
|
+
return null;
|
514
|
+
}
|
515
|
+
|
516
|
+
public static bool Contains(IEnumerable<Order> orders, Order order)
|
517
|
+
{
|
518
|
+
return orders.Contains(order);
|
519
|
+
}
|
520
|
+
}
|
521
|
+
</code>
|
522
|
+
And the concrete test using this matcher:
|
523
|
+
<code>
|
524
|
+
var order = new Order { ... };
|
525
|
+
var mock = new Mock<IRepository<Order>>();
|
526
|
+
|
527
|
+
mock.Setup(x => x.Save(Orders.Contains(order)))
|
528
|
+
.Throws<ArgumentException>();
|
529
|
+
|
530
|
+
// use mock, invoke Save, and have the matcher filter.
|
531
|
+
</code>
|
532
|
+
</example>
|
533
|
+
</member>
|
534
|
+
<member name="M:Moq.ExpressionExtensions.ToLambda(System.Linq.Expressions.Expression)">
|
535
|
+
<summary>
|
536
|
+
Casts the expression to a lambda expression, removing
|
537
|
+
a cast if there's any.
|
538
|
+
</summary>
|
539
|
+
</member>
|
540
|
+
<member name="M:Moq.ExpressionExtensions.ToMethodCall(System.Linq.Expressions.LambdaExpression)">
|
541
|
+
<summary>
|
542
|
+
Casts the body of the lambda expression to a <see cref="T:System.Linq.Expressions.MethodCallExpression"/>.
|
543
|
+
</summary>
|
544
|
+
<exception cref="T:System.ArgumentException">If the body is not a method call.</exception>
|
545
|
+
</member>
|
546
|
+
<member name="M:Moq.ExpressionExtensions.ToPropertyInfo(System.Linq.Expressions.LambdaExpression)">
|
547
|
+
<summary>
|
548
|
+
Converts the body of the lambda expression into the <see cref="T:System.Reflection.PropertyInfo"/> referenced by it.
|
549
|
+
</summary>
|
550
|
+
</member>
|
551
|
+
<member name="M:Moq.ExpressionExtensions.IsProperty(System.Linq.Expressions.LambdaExpression)">
|
552
|
+
<summary>
|
553
|
+
Checks whether the body of the lambda expression is a property access.
|
554
|
+
</summary>
|
555
|
+
</member>
|
556
|
+
<member name="M:Moq.ExpressionExtensions.IsProperty(System.Linq.Expressions.Expression)">
|
557
|
+
<summary>
|
558
|
+
Checks whether the expression is a property access.
|
559
|
+
</summary>
|
560
|
+
</member>
|
561
|
+
<member name="M:Moq.ExpressionExtensions.IsPropertyIndexer(System.Linq.Expressions.LambdaExpression)">
|
562
|
+
<summary>
|
563
|
+
Checks whether the body of the lambda expression is a property indexer, which is true
|
564
|
+
when the expression is an <see cref="T:System.Linq.Expressions.MethodCallExpression"/> whose
|
565
|
+
<see cref="P:System.Linq.Expressions.MethodCallExpression.Method"/> has <see cref="P:System.Reflection.MethodBase.IsSpecialName"/>
|
566
|
+
equal to <see langword="true"/>.
|
567
|
+
</summary>
|
568
|
+
</member>
|
569
|
+
<member name="M:Moq.ExpressionExtensions.IsPropertyIndexer(System.Linq.Expressions.Expression)">
|
570
|
+
<summary>
|
571
|
+
Checks whether the expression is a property indexer, which is true
|
572
|
+
when the expression is an <see cref="T:System.Linq.Expressions.MethodCallExpression"/> whose
|
573
|
+
<see cref="P:System.Linq.Expressions.MethodCallExpression.Method"/> has <see cref="P:System.Reflection.MethodBase.IsSpecialName"/>
|
574
|
+
equal to <see langword="true"/>.
|
575
|
+
</summary>
|
576
|
+
</member>
|
577
|
+
<member name="M:Moq.ExpressionExtensions.CastTo``1(System.Linq.Expressions.Expression)">
|
578
|
+
<summary>
|
579
|
+
Creates an expression that casts the given expression to the <typeparamref name="T"/>
|
580
|
+
type.
|
581
|
+
</summary>
|
582
|
+
</member>
|
583
|
+
<member name="M:Moq.ExpressionExtensions.ToStringFixed(System.Linq.Expressions.Expression)">
|
584
|
+
<devdoc>
|
585
|
+
TODO: remove this code when https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=331583
|
586
|
+
is fixed.
|
587
|
+
</devdoc>
|
588
|
+
</member>
|
589
|
+
<member name="T:Moq.ExpressionVisitor">
|
590
|
+
<summary>
|
591
|
+
Base class for visitors of expression trees.
|
592
|
+
</summary>
|
593
|
+
<remarks>
|
594
|
+
<para>Provides the functionality of the internal visitor base class that
|
595
|
+
comes with Linq.</para>
|
596
|
+
<para>Matt's comments on the implementation:</para>
|
597
|
+
<para>
|
598
|
+
In this variant there is only one visitor class that dispatches calls to the general
|
599
|
+
Visit function out to specific VisitXXX methods corresponding to different node types.
|
600
|
+
Note not every node type gets it own method, for example all binary operators are
|
601
|
+
treated in one VisitBinary method. The nodes themselves do not directly participate
|
602
|
+
in the visitation process. They are treated as just data.
|
603
|
+
The reason for this is that the quantity of visitors is actually open ended.
|
604
|
+
You can write your own. Therefore no semantics of visiting is coupled into the node classes.
|
605
|
+
It’s all in the visitors. The default visit behavior for node XXX is baked into the base
|
606
|
+
class’s version of VisitXXX.
|
607
|
+
</para>
|
608
|
+
<para>
|
609
|
+
Another variant is that all VisitXXX methods return a node.
|
610
|
+
The Expression tree nodes are immutable. In order to change the tree you must construct
|
611
|
+
a new one. The default VisitXXX methods will construct a new node if any of its sub-trees change.
|
612
|
+
If no changes are made then the same node is returned. That way if you make a change
|
613
|
+
to a node (by making a new node) deep down in a tree, the rest of the tree is rebuilt
|
614
|
+
automatically for you.
|
615
|
+
</para>
|
616
|
+
See: http://blogs.msdn.com/mattwar/archive/2007/07/31/linq-building-an-iqueryable-provider-part-ii.aspx.
|
617
|
+
</remarks>
|
618
|
+
<author>Matt Warren: http://blogs.msdn.com/mattwar</author>
|
619
|
+
<contributor>Documented by InSTEDD: http://www.instedd.org</contributor>
|
620
|
+
</member>
|
621
|
+
<member name="M:Moq.ExpressionVisitor.#ctor">
|
622
|
+
<summary>
|
623
|
+
Default constructor used by derived visitors.
|
624
|
+
</summary>
|
625
|
+
</member>
|
626
|
+
<member name="M:Moq.ExpressionVisitor.Visit(System.Linq.Expressions.Expression)">
|
627
|
+
<summary>
|
628
|
+
Visits the <see cref="T:System.Linq.Expressions.Expression"/>, determining which
|
629
|
+
of the concrete Visit methods to call.
|
630
|
+
</summary>
|
631
|
+
</member>
|
632
|
+
<member name="M:Moq.ExpressionVisitor.VisitBinding(System.Linq.Expressions.MemberBinding)">
|
633
|
+
<summary>
|
634
|
+
Visits the generic <see cref="T:System.Linq.Expressions.MemberBinding"/>, determining and
|
635
|
+
calling the appropriate Visit method according to the
|
636
|
+
<see cref="P:System.Linq.Expressions.MemberBinding.BindingType"/>, which will result
|
637
|
+
in calls to <see cref="M:Moq.ExpressionVisitor.VisitMemberAssignment(System.Linq.Expressions.MemberAssignment)"/>,
|
638
|
+
<see cref="M:Moq.ExpressionVisitor.VisitMemberMemberBinding(System.Linq.Expressions.MemberMemberBinding)"/> or <see cref="M:Moq.ExpressionVisitor.VisitMemberListBinding(System.Linq.Expressions.MemberListBinding)"/>.
|
639
|
+
</summary>
|
640
|
+
<param name="binding"></param>
|
641
|
+
<returns></returns>
|
642
|
+
</member>
|
643
|
+
<member name="M:Moq.ExpressionVisitor.VisitElementInitializer(System.Linq.Expressions.ElementInit)">
|
644
|
+
<summary>
|
645
|
+
Visits the <see cref="T:System.Linq.Expressions.ElementInit"/> initializer by
|
646
|
+
calling the <see cref="M:Moq.ExpressionVisitor.VisitExpressionList(System.Collections.ObjectModel.ReadOnlyCollection{System.Linq.Expressions.Expression})"/> for the
|
647
|
+
<see cref="P:System.Linq.Expressions.ElementInit.Arguments"/>.
|
648
|
+
</summary>
|
649
|
+
</member>
|
650
|
+
<member name="M:Moq.ExpressionVisitor.VisitUnary(System.Linq.Expressions.UnaryExpression)">
|
651
|
+
<summary>
|
652
|
+
Visits the <see cref="T:System.Linq.Expressions.UnaryExpression"/> expression by
|
653
|
+
calling <see cref="M:Moq.ExpressionVisitor.Visit(System.Linq.Expressions.Expression)"/> with the <see cref="P:System.Linq.Expressions.UnaryExpression.Operand"/> expression.
|
654
|
+
</summary>
|
655
|
+
</member>
|
656
|
+
<member name="M:Moq.ExpressionVisitor.VisitBinary(System.Linq.Expressions.BinaryExpression)">
|
657
|
+
<summary>
|
658
|
+
Visits the <see cref="T:System.Linq.Expressions.BinaryExpression"/> by calling
|
659
|
+
<see cref="M:Moq.ExpressionVisitor.Visit(System.Linq.Expressions.Expression)"/> with the <see cref="P:System.Linq.Expressions.BinaryExpression.Left"/>,
|
660
|
+
<see cref="P:System.Linq.Expressions.BinaryExpression.Right"/> and <see cref="P:System.Linq.Expressions.BinaryExpression.Conversion"/>
|
661
|
+
expressions.
|
662
|
+
</summary>
|
663
|
+
</member>
|
664
|
+
<member name="M:Moq.ExpressionVisitor.VisitTypeIs(System.Linq.Expressions.TypeBinaryExpression)">
|
665
|
+
<summary>
|
666
|
+
Visits the <see cref="T:System.Linq.Expressions.TypeBinaryExpression"/> by calling
|
667
|
+
<see cref="M:Moq.ExpressionVisitor.Visit(System.Linq.Expressions.Expression)"/> with the <see cref="P:System.Linq.Expressions.TypeBinaryExpression.Expression"/>
|
668
|
+
expression.
|
669
|
+
</summary>
|
670
|
+
</member>
|
671
|
+
<member name="M:Moq.ExpressionVisitor.VisitConstant(System.Linq.Expressions.ConstantExpression)">
|
672
|
+
<summary>
|
673
|
+
Visits the <see cref="T:System.Linq.Expressions.ConstantExpression"/>, by default returning the
|
674
|
+
same <see cref="T:System.Linq.Expressions.ConstantExpression"/> without further behavior.
|
675
|
+
</summary>
|
676
|
+
</member>
|
677
|
+
<member name="M:Moq.ExpressionVisitor.VisitConditional(System.Linq.Expressions.ConditionalExpression)">
|
678
|
+
<summary>
|
679
|
+
Visits the <see cref="T:System.Linq.Expressions.ConditionalExpression"/> by calling
|
680
|
+
<see cref="M:Moq.ExpressionVisitor.Visit(System.Linq.Expressions.Expression)"/> with the <see cref="P:System.Linq.Expressions.ConditionalExpression.Test"/>,
|
681
|
+
<see cref="P:System.Linq.Expressions.ConditionalExpression.IfTrue"/> and <see cref="P:System.Linq.Expressions.ConditionalExpression.IfFalse"/>
|
682
|
+
expressions.
|
683
|
+
</summary>
|
684
|
+
</member>
|
685
|
+
<member name="M:Moq.ExpressionVisitor.VisitParameter(System.Linq.Expressions.ParameterExpression)">
|
686
|
+
<summary>
|
687
|
+
Visits the <see cref="T:System.Linq.Expressions.ParameterExpression"/> returning it
|
688
|
+
by default without further behavior.
|
689
|
+
</summary>
|
690
|
+
</member>
|
691
|
+
<member name="M:Moq.ExpressionVisitor.VisitMemberAccess(System.Linq.Expressions.MemberExpression)">
|
692
|
+
<summary>
|
693
|
+
Visits the <see cref="T:System.Linq.Expressions.MemberExpression"/> by calling
|
694
|
+
<see cref="M:Moq.ExpressionVisitor.Visit(System.Linq.Expressions.Expression)"/> with the <see cref="P:System.Linq.Expressions.MemberExpression.Expression"/>
|
695
|
+
expression.
|
696
|
+
</summary>
|
697
|
+
</member>
|
698
|
+
<member name="M:Moq.ExpressionVisitor.VisitMethodCall(System.Linq.Expressions.MethodCallExpression)">
|
699
|
+
<summary>
|
700
|
+
Visits the <see cref="T:System.Linq.Expressions.MethodCallExpression"/> by calling
|
701
|
+
<see cref="M:Moq.ExpressionVisitor.Visit(System.Linq.Expressions.Expression)"/> with the <see cref="P:System.Linq.Expressions.MethodCallExpression.Object"/> expression,
|
702
|
+
and then <see cref="M:Moq.ExpressionVisitor.VisitExpressionList(System.Collections.ObjectModel.ReadOnlyCollection{System.Linq.Expressions.Expression})"/> with the <see cref="P:System.Linq.Expressions.MethodCallExpression.Arguments"/>.
|
703
|
+
</summary>
|
704
|
+
<param name="m"></param>
|
705
|
+
<returns></returns>
|
706
|
+
</member>
|
707
|
+
<member name="M:Moq.ExpressionVisitor.VisitExpressionList(System.Collections.ObjectModel.ReadOnlyCollection{System.Linq.Expressions.Expression})">
|
708
|
+
<summary>
|
709
|
+
Visits the <see cref="T:System.Collections.ObjectModel.ReadOnlyCollection`1"/> by iterating
|
710
|
+
the list and visiting each <see cref="T:System.Linq.Expressions.Expression"/> in it.
|
711
|
+
</summary>
|
712
|
+
<param name="original"></param>
|
713
|
+
<returns></returns>
|
714
|
+
</member>
|
715
|
+
<member name="M:Moq.ExpressionVisitor.VisitMemberAssignment(System.Linq.Expressions.MemberAssignment)">
|
716
|
+
<summary>
|
717
|
+
Visits the <see cref="T:System.Linq.Expressions.MemberAssignment"/> by calling
|
718
|
+
<see cref="M:Moq.ExpressionVisitor.Visit(System.Linq.Expressions.Expression)"/> with the <see cref="P:System.Linq.Expressions.MemberAssignment.Expression"/> expression.
|
719
|
+
</summary>
|
720
|
+
<param name="assignment"></param>
|
721
|
+
<returns></returns>
|
722
|
+
</member>
|
723
|
+
<member name="M:Moq.ExpressionVisitor.VisitMemberMemberBinding(System.Linq.Expressions.MemberMemberBinding)">
|
724
|
+
<summary>
|
725
|
+
Visits the <see cref="T:System.Linq.Expressions.MemberMemberBinding"/> by calling
|
726
|
+
<see cref="M:Moq.ExpressionVisitor.VisitBindingList(System.Collections.ObjectModel.ReadOnlyCollection{System.Linq.Expressions.MemberBinding})"/> with the <see cref="P:System.Linq.Expressions.MemberMemberBinding.Bindings"/>.
|
727
|
+
</summary>
|
728
|
+
<param name="binding"></param>
|
729
|
+
<returns></returns>
|
730
|
+
</member>
|
731
|
+
<member name="M:Moq.ExpressionVisitor.VisitMemberListBinding(System.Linq.Expressions.MemberListBinding)">
|
732
|
+
<summary>
|
733
|
+
Visits the <see cref="T:System.Linq.Expressions.MemberListBinding"/> by calling
|
734
|
+
<see cref="M:Moq.ExpressionVisitor.VisitElementInitializerList(System.Collections.ObjectModel.ReadOnlyCollection{System.Linq.Expressions.ElementInit})"/> with the
|
735
|
+
<see cref="P:System.Linq.Expressions.MemberListBinding.Initializers"/>.
|
736
|
+
</summary>
|
737
|
+
<param name="binding"></param>
|
738
|
+
<returns></returns>
|
739
|
+
</member>
|
740
|
+
<member name="M:Moq.ExpressionVisitor.VisitBindingList(System.Collections.ObjectModel.ReadOnlyCollection{System.Linq.Expressions.MemberBinding})">
|
741
|
+
<summary>
|
742
|
+
Visits the <see cref="T:System.Collections.ObjectModel.ReadOnlyCollection`1"/> by
|
743
|
+
calling <see cref="M:Moq.ExpressionVisitor.VisitBinding(System.Linq.Expressions.MemberBinding)"/> for each <see cref="T:System.Linq.Expressions.MemberBinding"/> in the
|
744
|
+
collection.
|
745
|
+
</summary>
|
746
|
+
<param name="original"></param>
|
747
|
+
<returns></returns>
|
748
|
+
</member>
|
749
|
+
<member name="M:Moq.ExpressionVisitor.VisitElementInitializerList(System.Collections.ObjectModel.ReadOnlyCollection{System.Linq.Expressions.ElementInit})">
|
750
|
+
<summary>
|
751
|
+
Visits the <see cref="T:System.Collections.ObjectModel.ReadOnlyCollection`1"/> by
|
752
|
+
calling <see cref="M:Moq.ExpressionVisitor.VisitElementInitializer(System.Linq.Expressions.ElementInit)"/> for each
|
753
|
+
<see cref="T:System.Linq.Expressions.ElementInit"/> in the collection.
|
754
|
+
</summary>
|
755
|
+
<param name="original"></param>
|
756
|
+
<returns></returns>
|
757
|
+
</member>
|
758
|
+
<member name="M:Moq.ExpressionVisitor.VisitLambda(System.Linq.Expressions.LambdaExpression)">
|
759
|
+
<summary>
|
760
|
+
Visits the <see cref="T:System.Linq.Expressions.LambdaExpression"/> by calling
|
761
|
+
<see cref="M:Moq.ExpressionVisitor.Visit(System.Linq.Expressions.Expression)"/> with the <see cref="P:System.Linq.Expressions.LambdaExpression.Body"/> expression.
|
762
|
+
</summary>
|
763
|
+
<param name="lambda"></param>
|
764
|
+
<returns></returns>
|
765
|
+
</member>
|
766
|
+
<member name="M:Moq.ExpressionVisitor.VisitNew(System.Linq.Expressions.NewExpression)">
|
767
|
+
<summary>
|
768
|
+
Visits the <see cref="T:System.Linq.Expressions.NewExpression"/> by calling
|
769
|
+
<see cref="M:Moq.ExpressionVisitor.VisitExpressionList(System.Collections.ObjectModel.ReadOnlyCollection{System.Linq.Expressions.Expression})"/> with the <see cref="P:System.Linq.Expressions.NewExpression.Arguments"/>
|
770
|
+
expressions.
|
771
|
+
</summary>
|
772
|
+
<param name="nex"></param>
|
773
|
+
<returns></returns>
|
774
|
+
</member>
|
775
|
+
<member name="M:Moq.ExpressionVisitor.VisitMemberInit(System.Linq.Expressions.MemberInitExpression)">
|
776
|
+
<summary>
|
777
|
+
Visits the <see cref="T:System.Linq.Expressions.MemberInitExpression"/> by calling
|
778
|
+
<see cref="M:Moq.ExpressionVisitor.VisitNew(System.Linq.Expressions.NewExpression)"/> with the <see cref="P:System.Linq.Expressions.MemberInitExpression.NewExpression"/>
|
779
|
+
expression, then <see cref="M:Moq.ExpressionVisitor.VisitBindingList(System.Collections.ObjectModel.ReadOnlyCollection{System.Linq.Expressions.MemberBinding})"/> with the
|
780
|
+
<see cref="P:System.Linq.Expressions.MemberInitExpression.Bindings"/>.
|
781
|
+
</summary>
|
782
|
+
</member>
|
783
|
+
<member name="M:Moq.ExpressionVisitor.VisitListInit(System.Linq.Expressions.ListInitExpression)">
|
784
|
+
<summary>
|
785
|
+
Visits the <see cref="T:System.Linq.Expressions.ListInitExpression"/> by calling
|
786
|
+
<see cref="M:Moq.ExpressionVisitor.VisitNew(System.Linq.Expressions.NewExpression)"/> with the <see cref="P:System.Linq.Expressions.ListInitExpression.NewExpression"/>
|
787
|
+
expression, and then <see cref="M:Moq.ExpressionVisitor.VisitElementInitializerList(System.Collections.ObjectModel.ReadOnlyCollection{System.Linq.Expressions.ElementInit})"/> with the
|
788
|
+
<see cref="P:System.Linq.Expressions.ListInitExpression.Initializers"/>.
|
789
|
+
</summary>
|
790
|
+
<param name="init"></param>
|
791
|
+
<returns></returns>
|
792
|
+
</member>
|
793
|
+
<member name="M:Moq.ExpressionVisitor.VisitNewArray(System.Linq.Expressions.NewArrayExpression)">
|
794
|
+
<summary>
|
795
|
+
Visits the <see cref="T:System.Linq.Expressions.NewArrayExpression"/> by calling
|
796
|
+
<see cref="M:Moq.ExpressionVisitor.VisitExpressionList(System.Collections.ObjectModel.ReadOnlyCollection{System.Linq.Expressions.Expression})"/> with the <see cref="P:System.Linq.Expressions.NewArrayExpression.Expressions"/>
|
797
|
+
expressions.
|
798
|
+
</summary>
|
799
|
+
<param name="na"></param>
|
800
|
+
<returns></returns>
|
801
|
+
</member>
|
802
|
+
<member name="M:Moq.ExpressionVisitor.VisitInvocation(System.Linq.Expressions.InvocationExpression)">
|
803
|
+
<summary>
|
804
|
+
Visits the <see cref="T:System.Linq.Expressions.InvocationExpression"/> by calling
|
805
|
+
<see cref="M:Moq.ExpressionVisitor.VisitExpressionList(System.Collections.ObjectModel.ReadOnlyCollection{System.Linq.Expressions.Expression})"/> with the <see cref="P:System.Linq.Expressions.InvocationExpression.Arguments"/>
|
806
|
+
expressions.
|
807
|
+
</summary>
|
808
|
+
<param name="iv"></param>
|
809
|
+
<returns></returns>
|
810
|
+
</member>
|
811
|
+
<member name="T:Moq.Evaluator">
|
812
|
+
<summary>
|
813
|
+
Provides partial evaluation of subtrees, whenever they can be evaluated locally.
|
814
|
+
</summary>
|
815
|
+
<author>Matt Warren: http://blogs.msdn.com/mattwar</author>
|
816
|
+
<contributor>Documented by InSTEDD: http://www.instedd.org</contributor>
|
817
|
+
</member>
|
818
|
+
<member name="M:Moq.Evaluator.PartialEval(System.Linq.Expressions.Expression,System.Func{System.Linq.Expressions.Expression,System.Boolean})">
|
819
|
+
<summary>
|
820
|
+
Performs evaluation and replacement of independent sub-trees
|
821
|
+
</summary>
|
822
|
+
<param name="expression">The root of the expression tree.</param>
|
823
|
+
<param name="fnCanBeEvaluated">A function that decides whether a given expression
|
824
|
+
node can be part of the local function.</param>
|
825
|
+
<returns>A new tree with sub-trees evaluated and replaced.</returns>
|
826
|
+
</member>
|
827
|
+
<member name="M:Moq.Evaluator.PartialEval(System.Linq.Expressions.Expression)">
|
828
|
+
<summary>
|
829
|
+
Performs evaluation and replacement of independent sub-trees
|
830
|
+
</summary>
|
831
|
+
<param name="expression">The root of the expression tree.</param>
|
832
|
+
<returns>A new tree with sub-trees evaluated and replaced.</returns>
|
833
|
+
</member>
|
834
|
+
<member name="T:Moq.Evaluator.SubtreeEvaluator">
|
835
|
+
<summary>
|
836
|
+
Evaluates and replaces sub-trees when first candidate is reached (top-down)
|
837
|
+
</summary>
|
838
|
+
</member>
|
839
|
+
<member name="T:Moq.Evaluator.Nominator">
|
840
|
+
<summary>
|
841
|
+
Performs bottom-up analysis to determine which nodes can possibly
|
842
|
+
be part of an evaluated sub-tree.
|
843
|
+
</summary>
|
844
|
+
</member>
|
845
|
+
<member name="M:Guard.ArgumentNotNull(System.Object,System.String)">
|
846
|
+
<summary>
|
847
|
+
Checks an argument to ensure it isn't null.
|
848
|
+
</summary>
|
849
|
+
<param name="value">The argument value to check.</param>
|
850
|
+
<param name="argumentName">The name of the argument.</param>
|
851
|
+
</member>
|
852
|
+
<member name="M:Guard.ArgumentNotNullOrEmptyString(System.String,System.String)">
|
853
|
+
<summary>
|
854
|
+
Checks a string argument to ensure it isn't null or empty.
|
855
|
+
</summary>
|
856
|
+
<param name="argumentValue">The argument value to check.</param>
|
857
|
+
<param name="argumentName">The name of the argument.</param>
|
858
|
+
</member>
|
859
|
+
<member name="M:Guard.ArgumentNotOutOfRangeInclusive``1(``0,``0,``0,System.String)">
|
860
|
+
<summary>
|
861
|
+
Checks an argument to ensure it is in the specified range including the edges.
|
862
|
+
</summary>
|
863
|
+
<typeparam name="T">Type of the argument to check, it must be an <see cref="T:System.IComparable"/> type.
|
864
|
+
</typeparam>
|
865
|
+
<param name="value">The argument value to check.</param>
|
866
|
+
<param name="from">The minimun allowed value for the argument.</param>
|
867
|
+
<param name="to">The maximun allowed value for the argument.</param>
|
868
|
+
<param name="argumentName">The name of the argument.</param>
|
869
|
+
</member>
|
870
|
+
<member name="M:Guard.ArgumentNotOutOfRangeExclusive``1(``0,``0,``0,System.String)">
|
871
|
+
<summary>
|
872
|
+
Checks an argument to ensure it is in the specified range excluding the edges.
|
873
|
+
</summary>
|
874
|
+
<typeparam name="T">Type of the argument to check, it must be an <see cref="T:System.IComparable"/> type.
|
875
|
+
</typeparam>
|
876
|
+
<param name="value">The argument value to check.</param>
|
877
|
+
<param name="from">The minimun allowed value for the argument.</param>
|
878
|
+
<param name="to">The maximun allowed value for the argument.</param>
|
879
|
+
<param name="argumentName">The name of the argument.</param>
|
880
|
+
</member>
|
881
|
+
<member name="T:Moq.Language.IReturnsGetter`2">
|
882
|
+
<summary>
|
883
|
+
Defines the <c>Returns</c> verb for property get setups.
|
884
|
+
</summary>
|
885
|
+
<typeparam name="TMock">Mocked type.</typeparam>
|
886
|
+
<typeparam name="TProperty">Type of the property.</typeparam>
|
887
|
+
</member>
|
888
|
+
<member name="M:Moq.Language.IReturnsGetter`2.Returns(`1)">
|
889
|
+
<summary>
|
890
|
+
Specifies the value to return.
|
891
|
+
</summary>
|
892
|
+
<param name="value">The value to return, or <see langword="null"/>.</param>
|
893
|
+
<example>
|
894
|
+
Return a <c>true</c> value from the property getter call:
|
895
|
+
<code>
|
896
|
+
mock.SetupGet(x => x.Suspended)
|
897
|
+
.Returns(true);
|
898
|
+
</code>
|
899
|
+
</example>
|
900
|
+
</member>
|
901
|
+
<member name="M:Moq.Language.IReturnsGetter`2.Returns(System.Func{`1})">
|
902
|
+
<summary>
|
903
|
+
Specifies a function that will calculate the value to return for the property.
|
904
|
+
</summary>
|
905
|
+
<param name="valueFunction">The function that will calculate the return value.</param>
|
906
|
+
<example>
|
907
|
+
Return a calculated value when the property is retrieved:
|
908
|
+
<code>
|
909
|
+
mock.SetupGet(x => x.Suspended)
|
910
|
+
.Returns(() => returnValues[0]);
|
911
|
+
</code>
|
912
|
+
The lambda expression to retrieve the return value is lazy-executed,
|
913
|
+
meaning that its value may change depending on the moment the property
|
914
|
+
is retrieved and the value the <c>returnValues</c> array has at
|
915
|
+
that moment.
|
916
|
+
</example>
|
917
|
+
</member>
|
918
|
+
<member name="T:Moq.Language.ICallbackGetter`2">
|
919
|
+
<summary>
|
920
|
+
Defines the <c>Callback</c> verb for property getter setups.
|
921
|
+
</summary>
|
922
|
+
<seealso cref="M:Moq.Mock`1.SetupGet``1(System.Linq.Expressions.Expression{System.Func{`0,``0}})"/>
|
923
|
+
<typeparam name="TMock">Mocked type.</typeparam>
|
924
|
+
<typeparam name="TProperty">Type of the property.</typeparam>
|
925
|
+
</member>
|
926
|
+
<member name="M:Moq.Language.ICallbackGetter`2.Callback(System.Action)">
|
927
|
+
<summary>
|
928
|
+
Specifies a callback to invoke when the property is retrieved.
|
929
|
+
</summary>
|
930
|
+
<param name="action">Callback method to invoke.</param>
|
931
|
+
<example>
|
932
|
+
Invokes the given callback with the property value being set.
|
933
|
+
<code>
|
934
|
+
mock.SetupGet(x => x.Suspended)
|
935
|
+
.Callback(() => called = true)
|
936
|
+
.Returns(true);
|
937
|
+
</code>
|
938
|
+
</example>
|
939
|
+
</member>
|
940
|
+
<member name="T:Moq.Language.Flow.IThrowsResult">
|
941
|
+
<summary>
|
942
|
+
Implements the fluent API.
|
943
|
+
</summary>
|
944
|
+
</member>
|
945
|
+
<member name="T:Moq.Language.Flow.IReturnsThrows`2">
|
946
|
+
<summary>
|
947
|
+
Implements the fluent API.
|
948
|
+
</summary>
|
949
|
+
</member>
|
950
|
+
<member name="T:Moq.Language.IReturns`2">
|
951
|
+
<summary>
|
952
|
+
Defines the <c>Returns</c> verb.
|
953
|
+
</summary>
|
954
|
+
<typeparam name="TMock">Mocked type.</typeparam>
|
955
|
+
<typeparam name="TResult">Type of the return value from the expression.</typeparam>
|
956
|
+
</member>
|
957
|
+
<member name="M:Moq.Language.IReturns`2.Returns(`1)">
|
958
|
+
<summary>
|
959
|
+
Specifies the value to return.
|
960
|
+
</summary>
|
961
|
+
<param name="value">The value to return, or <see langword="null"/>.</param>
|
962
|
+
<example>
|
963
|
+
Return a <c>true</c> value from the method call:
|
964
|
+
<code>
|
965
|
+
mock.Setup(x => x.Execute("ping"))
|
966
|
+
.Returns(true);
|
967
|
+
</code>
|
968
|
+
</example>
|
969
|
+
</member>
|
970
|
+
<member name="M:Moq.Language.IReturns`2.Returns(System.Func{`1})">
|
971
|
+
<summary>
|
972
|
+
Specifies a function that will calculate the value to return from the method.
|
973
|
+
</summary>
|
974
|
+
<param name="valueFunction">The function that will calculate the return value.</param>
|
975
|
+
<example group="returns">
|
976
|
+
Return a calculated value when the method is called:
|
977
|
+
<code>
|
978
|
+
mock.Setup(x => x.Execute("ping"))
|
979
|
+
.Returns(() => returnValues[0]);
|
980
|
+
</code>
|
981
|
+
The lambda expression to retrieve the return value is lazy-executed,
|
982
|
+
meaning that its value may change depending on the moment the method
|
983
|
+
is executed and the value the <c>returnValues</c> array has at
|
984
|
+
that moment.
|
985
|
+
</example>
|
986
|
+
</member>
|
987
|
+
<member name="M:Moq.Language.IReturns`2.Returns``1(System.Func{``0,`1})">
|
988
|
+
<summary>
|
989
|
+
Specifies a function that will calculate the value to return from the method,
|
990
|
+
retrieving the arguments for the invocation.
|
991
|
+
</summary>
|
992
|
+
<typeparam name="T">Type of the argument of the invoked method.</typeparam>
|
993
|
+
<param name="valueFunction">The function that will calculate the return value.</param>
|
994
|
+
<example group="returns">
|
995
|
+
Return a calculated value which is evaluated lazily at the time of the invocation.
|
996
|
+
<para>
|
997
|
+
The lookup list can change between invocations and the setup
|
998
|
+
will return different values accordingly. Also, notice how the specific
|
999
|
+
string argument is retrieved by simply declaring it as part of the lambda
|
1000
|
+
expression:
|
1001
|
+
</para>
|
1002
|
+
<code>
|
1003
|
+
mock.Setup(x => x.Execute(It.IsAny<string>()))
|
1004
|
+
.Returns((string command) => returnValues[command]);
|
1005
|
+
</code>
|
1006
|
+
</example>
|
1007
|
+
</member>
|
1008
|
+
<member name="M:Moq.Language.IReturns`2.Returns``2(System.Func{``0,``1,`1})">
|
1009
|
+
<summary>
|
1010
|
+
Specifies a function that will calculate the value to return from the method,
|
1011
|
+
retrieving the arguments for the invocation.
|
1012
|
+
</summary>
|
1013
|
+
<typeparam name="T1">Type of the first argument of the invoked method.</typeparam>
|
1014
|
+
<typeparam name="T2">Type of the second argument of the invoked method.</typeparam>
|
1015
|
+
<param name="valueFunction">The function that will calculate the return value.</param>
|
1016
|
+
<example group="returns">
|
1017
|
+
Return a calculated value which is evaluated lazily at the time of the invocation.
|
1018
|
+
<para>
|
1019
|
+
The return value is calculated from the value of the actual method invocation arguments.
|
1020
|
+
Notice how the arguments are retrieved by simply declaring them as part of the lambda
|
1021
|
+
expression:
|
1022
|
+
</para>
|
1023
|
+
<code>
|
1024
|
+
mock.Setup(x => x.Execute(
|
1025
|
+
It.IsAny<string>(),
|
1026
|
+
It.IsAny<string>()))
|
1027
|
+
.Returns((string arg1, string arg2) => arg1 + arg2);
|
1028
|
+
</code>
|
1029
|
+
</example>
|
1030
|
+
</member>
|
1031
|
+
<member name="M:Moq.Language.IReturns`2.Returns``3(System.Func{``0,``1,``2,`1})">
|
1032
|
+
<summary>
|
1033
|
+
Specifies a function that will calculate the value to return from the method,
|
1034
|
+
retrieving the arguments for the invocation.
|
1035
|
+
</summary>
|
1036
|
+
<typeparam name="T1">Type of the first argument of the invoked method.</typeparam>
|
1037
|
+
<typeparam name="T2">Type of the second argument of the invoked method.</typeparam>
|
1038
|
+
<typeparam name="T3">Type of the third argument of the invoked method.</typeparam>
|
1039
|
+
<param name="valueFunction">The function that will calculate the return value.</param>
|
1040
|
+
<example group="returns">
|
1041
|
+
Return a calculated value which is evaluated lazily at the time of the invocation.
|
1042
|
+
<para>
|
1043
|
+
The return value is calculated from the value of the actual method invocation arguments.
|
1044
|
+
Notice how the arguments are retrieved by simply declaring them as part of the lambda
|
1045
|
+
expression:
|
1046
|
+
</para>
|
1047
|
+
<code>
|
1048
|
+
mock.Setup(x => x.Execute(
|
1049
|
+
It.IsAny<string>(),
|
1050
|
+
It.IsAny<string>(),
|
1051
|
+
It.IsAny<int>()))
|
1052
|
+
.Returns((string arg1, string arg2, int arg3) => arg1 + arg2 + arg3);
|
1053
|
+
</code>
|
1054
|
+
</example>
|
1055
|
+
</member>
|
1056
|
+
<member name="M:Moq.Language.IReturns`2.Returns``4(System.Func{``0,``1,``2,``3,`1})">
|
1057
|
+
<summary>
|
1058
|
+
Specifies a function that will calculate the value to return from the method,
|
1059
|
+
retrieving the arguments for the invocation.
|
1060
|
+
</summary>
|
1061
|
+
<typeparam name="T1">Type of the first argument of the invoked method.</typeparam>
|
1062
|
+
<typeparam name="T2">Type of the second argument of the invoked method.</typeparam>
|
1063
|
+
<typeparam name="T3">Type of the third argument of the invoked method.</typeparam>
|
1064
|
+
<typeparam name="T4">Type of the fourth argument of the invoked method.</typeparam>
|
1065
|
+
<param name="valueFunction">The function that will calculate the return value.</param>
|
1066
|
+
<example group="returns">
|
1067
|
+
Return a calculated value which is evaluated lazily at the time of the invocation.
|
1068
|
+
<para>
|
1069
|
+
The return value is calculated from the value of the actual method invocation arguments.
|
1070
|
+
Notice how the arguments are retrieved by simply declaring them as part of the lambda
|
1071
|
+
expression:
|
1072
|
+
</para>
|
1073
|
+
<code>
|
1074
|
+
mock.Setup(x => x.Execute(
|
1075
|
+
It.IsAny<string>(),
|
1076
|
+
It.IsAny<string>(),
|
1077
|
+
It.IsAny<int>(),
|
1078
|
+
It.IsAny<bool>()))
|
1079
|
+
.Returns((string arg1, string arg2, int arg3, bool arg4) => arg1 + arg2 + arg3 + arg4);
|
1080
|
+
</code>
|
1081
|
+
</example>
|
1082
|
+
</member>
|
1083
|
+
<member name="T:Moq.Language.IThrows">
|
1084
|
+
<summary>
|
1085
|
+
Defines the <c>Throws</c> verb.
|
1086
|
+
</summary>
|
1087
|
+
</member>
|
1088
|
+
<member name="M:Moq.Language.IThrows.Throws(System.Exception)">
|
1089
|
+
<summary>
|
1090
|
+
Specifies the exception to throw when the method is invoked.
|
1091
|
+
</summary>
|
1092
|
+
<param name="exception">Exception instance to throw.</param>
|
1093
|
+
<example>
|
1094
|
+
This example shows how to throw an exception when the method is
|
1095
|
+
invoked with an empty string argument:
|
1096
|
+
<code>
|
1097
|
+
mock.Setup(x => x.Execute(""))
|
1098
|
+
.Throws(new ArgumentException());
|
1099
|
+
</code>
|
1100
|
+
</example>
|
1101
|
+
</member>
|
1102
|
+
<member name="M:Moq.Language.IThrows.Throws``1">
|
1103
|
+
<summary>
|
1104
|
+
Specifies the type of exception to throw when the method is invoked.
|
1105
|
+
</summary>
|
1106
|
+
<typeparam name="TException">Type of exception to instantiate and throw when the setup is matched.</typeparam>
|
1107
|
+
<example>
|
1108
|
+
This example shows how to throw an exception when the method is
|
1109
|
+
invoked with an empty string argument:
|
1110
|
+
<code>
|
1111
|
+
mock.Setup(x => x.Execute(""))
|
1112
|
+
.Throws<ArgumentException>();
|
1113
|
+
</code>
|
1114
|
+
</example>
|
1115
|
+
</member>
|
1116
|
+
<member name="T:Moq.Language.Flow.IReturnsThrowsGetter`2">
|
1117
|
+
<summary>
|
1118
|
+
Implements the fluent API.
|
1119
|
+
</summary>
|
1120
|
+
</member>
|
1121
|
+
<member name="T:Moq.Language.Flow.ICallbackResult">
|
1122
|
+
<summary>
|
1123
|
+
Implements the fluent API.
|
1124
|
+
</summary>
|
1125
|
+
</member>
|
1126
|
+
<member name="T:Moq.Language.ICallback`2">
|
1127
|
+
<summary>
|
1128
|
+
Defines the <c>Callback</c> verb and overloads for callbacks on
|
1129
|
+
setups that return a value.
|
1130
|
+
</summary>
|
1131
|
+
<typeparam name="TMock">Mocked type.</typeparam>
|
1132
|
+
<typeparam name="TResult">Type of the return value of the setup.</typeparam>
|
1133
|
+
</member>
|
1134
|
+
<member name="M:Moq.Language.ICallback`2.Callback(System.Action)">
|
1135
|
+
<summary>
|
1136
|
+
Specifies a callback to invoke when the method is called.
|
1137
|
+
</summary>
|
1138
|
+
<param name="action">Callback method to invoke.</param>
|
1139
|
+
<example>
|
1140
|
+
The following example specifies a callback to set a boolean
|
1141
|
+
value that can be used later:
|
1142
|
+
<code>
|
1143
|
+
bool called = false;
|
1144
|
+
mock.Setup(x => x.Execute())
|
1145
|
+
.Callback(() => called = true)
|
1146
|
+
.Returns(true);
|
1147
|
+
</code>
|
1148
|
+
Note that in the case of value-returning methods, after the <c>Callback</c>
|
1149
|
+
call you can still specify the return value.
|
1150
|
+
</example>
|
1151
|
+
</member>
|
1152
|
+
<member name="M:Moq.Language.ICallback`2.Callback``1(System.Action{``0})">
|
1153
|
+
<summary>
|
1154
|
+
Specifies a callback to invoke when the method is called that receives the original
|
1155
|
+
arguments.
|
1156
|
+
</summary>
|
1157
|
+
<typeparam name="T">Type of the argument of the invoked method.</typeparam>
|
1158
|
+
<param name="action">Callback method to invoke.</param>
|
1159
|
+
<example>
|
1160
|
+
Invokes the given callback with the concrete invocation argument value.
|
1161
|
+
<para>
|
1162
|
+
Notice how the specific string argument is retrieved by simply declaring
|
1163
|
+
it as part of the lambda expression for the callback:
|
1164
|
+
</para>
|
1165
|
+
<code>
|
1166
|
+
mock.Setup(x => x.Execute(It.IsAny<string>()))
|
1167
|
+
.Callback((string command) => Console.WriteLine(command))
|
1168
|
+
.Returns(true);
|
1169
|
+
</code>
|
1170
|
+
</example>
|
1171
|
+
</member>
|
1172
|
+
<member name="M:Moq.Language.ICallback`2.Callback``2(System.Action{``0,``1})">
|
1173
|
+
<summary>
|
1174
|
+
Specifies a callback to invoke when the method is called that receives the original
|
1175
|
+
arguments.
|
1176
|
+
</summary>
|
1177
|
+
<typeparam name="T1">Type of the first argument of the invoked method.</typeparam>
|
1178
|
+
<typeparam name="T2">Type of the second argument of the invoked method.</typeparam>
|
1179
|
+
<param name="action">Callback method to invoke.</param>
|
1180
|
+
<example>
|
1181
|
+
Invokes the given callback with the concrete invocation arguments values.
|
1182
|
+
<para>
|
1183
|
+
Notice how the specific arguments are retrieved by simply declaring
|
1184
|
+
them as part of the lambda expression for the callback:
|
1185
|
+
</para>
|
1186
|
+
<code>
|
1187
|
+
mock.Setup(x => x.Execute(
|
1188
|
+
It.IsAny<string>(),
|
1189
|
+
It.IsAny<string>()))
|
1190
|
+
.Callback((string arg1, string arg2) => Console.WriteLine(arg1 + arg2))
|
1191
|
+
.Returns(true);
|
1192
|
+
</code>
|
1193
|
+
</example>
|
1194
|
+
</member>
|
1195
|
+
<member name="M:Moq.Language.ICallback`2.Callback``3(System.Action{``0,``1,``2})">
|
1196
|
+
<summary>
|
1197
|
+
Specifies a callback to invoke when the method is called that receives the original
|
1198
|
+
arguments.
|
1199
|
+
</summary>
|
1200
|
+
<typeparam name="T1">Type of the first argument of the invoked method.</typeparam>
|
1201
|
+
<typeparam name="T2">Type of the second argument of the invoked method.</typeparam>
|
1202
|
+
<typeparam name="T3">Type of the third argument of the invoked method.</typeparam>
|
1203
|
+
<param name="action">Callback method to invoke.</param>
|
1204
|
+
<example>
|
1205
|
+
Invokes the given callback with the concrete invocation arguments values.
|
1206
|
+
<para>
|
1207
|
+
Notice how the specific arguments are retrieved by simply declaring
|
1208
|
+
them as part of the lambda expression for the callback:
|
1209
|
+
</para>
|
1210
|
+
<code>
|
1211
|
+
mock.Setup(x => x.Execute(
|
1212
|
+
It.IsAny<string>(),
|
1213
|
+
It.IsAny<string>(),
|
1214
|
+
It.IsAny<int>()))
|
1215
|
+
.Callback((string arg1, string arg2, int arg3) => Console.WriteLine(arg1 + arg2 + arg3))
|
1216
|
+
.Returns(true);
|
1217
|
+
</code>
|
1218
|
+
</example>
|
1219
|
+
</member>
|
1220
|
+
<member name="M:Moq.Language.ICallback`2.Callback``4(System.Action{``0,``1,``2,``3})">
|
1221
|
+
<summary>
|
1222
|
+
Specifies a callback to invoke when the method is called that receives the original
|
1223
|
+
arguments.
|
1224
|
+
</summary>
|
1225
|
+
<typeparam name="T1">Type of the first argument of the invoked method.</typeparam>
|
1226
|
+
<typeparam name="T2">Type of the second argument of the invoked method.</typeparam>
|
1227
|
+
<typeparam name="T3">Type of the third argument of the invoked method.</typeparam>
|
1228
|
+
<typeparam name="T4">Type of the fourth argument of the invoked method.</typeparam>
|
1229
|
+
<param name="action">Callback method to invoke.</param>
|
1230
|
+
<example>
|
1231
|
+
Invokes the given callback with the concrete invocation arguments values.
|
1232
|
+
<para>
|
1233
|
+
Notice how the specific arguments are retrieved by simply declaring
|
1234
|
+
them as part of the lambda expression for the callback:
|
1235
|
+
</para>
|
1236
|
+
<code>
|
1237
|
+
mock.Setup(x => x.Execute(
|
1238
|
+
It.IsAny<string>(),
|
1239
|
+
It.IsAny<string>(),
|
1240
|
+
It.IsAny<int>(),
|
1241
|
+
It.IsAny<bool>()))
|
1242
|
+
.Callback((string arg1, string arg2, int arg3, bool arg4) => Console.WriteLine(arg1 + arg2 + arg3 + arg4))
|
1243
|
+
.Returns(true);
|
1244
|
+
</code>
|
1245
|
+
</example>
|
1246
|
+
</member>
|
1247
|
+
<member name="T:Moq.IMocked`1">
|
1248
|
+
<summary>
|
1249
|
+
Implemented by all generated mock object instances.
|
1250
|
+
</summary>
|
1251
|
+
</member>
|
1252
|
+
<member name="T:Moq.IMocked">
|
1253
|
+
<summary>
|
1254
|
+
Implemented by all generated mock object instances.
|
1255
|
+
</summary>
|
1256
|
+
</member>
|
1257
|
+
<member name="P:Moq.IMocked.Mock">
|
1258
|
+
<summary>
|
1259
|
+
Reference the Mock that contains this as the <c>mock.Object</c> value.
|
1260
|
+
</summary>
|
1261
|
+
</member>
|
1262
|
+
<member name="P:Moq.IMocked`1.Mock">
|
1263
|
+
<summary>
|
1264
|
+
Reference the Mock that contains this as the <c>mock.Object</c> value.
|
1265
|
+
</summary>
|
1266
|
+
</member>
|
1267
|
+
<member name="T:Moq.Interceptor">
|
1268
|
+
<summary>
|
1269
|
+
Implements the actual interception and method invocation for
|
1270
|
+
all mocks.
|
1271
|
+
</summary>
|
1272
|
+
</member>
|
1273
|
+
<member name="M:Moq.Interceptor.GetEventFromName(System.String)">
|
1274
|
+
<summary>
|
1275
|
+
Get an eventInfo for a given event name. Search type ancestors depth first if necessary.
|
1276
|
+
</summary>
|
1277
|
+
<param name="eventName">Name of the event, with the set_ or get_ prefix already removed</param>
|
1278
|
+
</member>
|
1279
|
+
<member name="M:Moq.Interceptor.GetAncestorTypes(System.Type)">
|
1280
|
+
<summary>
|
1281
|
+
Given a type return all of its ancestors, both types and interfaces.
|
1282
|
+
</summary>
|
1283
|
+
<param name="initialType">The type to find immediate ancestors of</param>
|
1284
|
+
</member>
|
1285
|
+
<member name="T:Moq.Language.Flow.ISetup`1">
|
1286
|
+
<summary>
|
1287
|
+
Implements the fluent API.
|
1288
|
+
</summary>
|
1289
|
+
</member>
|
1290
|
+
<member name="T:Moq.Language.INever">
|
1291
|
+
<summary>
|
1292
|
+
Defines the <c>Never</c> verb.
|
1293
|
+
</summary>
|
1294
|
+
</member>
|
1295
|
+
<member name="M:Moq.Language.INever.Never">
|
1296
|
+
<summary>
|
1297
|
+
The expected invocation is never expected to happen.
|
1298
|
+
</summary>
|
1299
|
+
<example>
|
1300
|
+
<code>
|
1301
|
+
var mock = new Mock<ICommand>();
|
1302
|
+
mock.Setup(foo => foo.Execute("ping"))
|
1303
|
+
.Never();
|
1304
|
+
</code>
|
1305
|
+
</example>
|
1306
|
+
<remarks>
|
1307
|
+
<see cref="M:Moq.Language.INever.Never"/> is always verified inmediately as
|
1308
|
+
the invocations are performed, like strict mocks do
|
1309
|
+
with unexpected invocations.
|
1310
|
+
</remarks>
|
1311
|
+
</member>
|
1312
|
+
<member name="T:Moq.Language.Flow.ISetup`2">
|
1313
|
+
<summary>
|
1314
|
+
Implements the fluent API.
|
1315
|
+
</summary>
|
1316
|
+
</member>
|
1317
|
+
<member name="T:Moq.Language.Flow.ISetupGetter`2">
|
1318
|
+
<summary>
|
1319
|
+
Implements the fluent API.
|
1320
|
+
</summary>
|
1321
|
+
</member>
|
1322
|
+
<member name="T:Moq.Language.Flow.ISetupSetter`2">
|
1323
|
+
<summary>
|
1324
|
+
Implements the fluent API.
|
1325
|
+
</summary>
|
1326
|
+
</member>
|
1327
|
+
<member name="T:Moq.Language.ICallbackSetter`1">
|
1328
|
+
<summary>
|
1329
|
+
Defines the <c>Callback</c> verb for property setter setups.
|
1330
|
+
</summary>
|
1331
|
+
<typeparam name="TProperty">Type of the property.</typeparam>
|
1332
|
+
</member>
|
1333
|
+
<member name="M:Moq.Language.ICallbackSetter`1.Callback(System.Action{`0})">
|
1334
|
+
<summary>
|
1335
|
+
Specifies a callback to invoke when the property is set that receives the
|
1336
|
+
property value being set.
|
1337
|
+
</summary>
|
1338
|
+
<param name="action">Callback method to invoke.</param>
|
1339
|
+
<example>
|
1340
|
+
Invokes the given callback with the property value being set.
|
1341
|
+
<code>
|
1342
|
+
mock.SetupSet(x => x.Suspended)
|
1343
|
+
.Callback((bool state) => Console.WriteLine(state));
|
1344
|
+
</code>
|
1345
|
+
</example>
|
1346
|
+
</member>
|
1347
|
+
<member name="T:Moq.It">
|
1348
|
+
<summary>
|
1349
|
+
Allows the specification of a matching condition for an
|
1350
|
+
argument in a method invocation, rather than a specific
|
1351
|
+
argument value. "It" refers to the argument being matched.
|
1352
|
+
</summary><remarks>
|
1353
|
+
This class allows the setup to match a method invocation
|
1354
|
+
with an arbitrary value, with a value in a specified range, or
|
1355
|
+
even one that matches a given predicate.
|
1356
|
+
</remarks>
|
1357
|
+
</member>
|
1358
|
+
<member name="M:Moq.It.IsAny``1">
|
1359
|
+
<summary>
|
1360
|
+
Matches any value of the given <paramref name="TValue"/> type.
|
1361
|
+
</summary><remarks>
|
1362
|
+
Typically used when the actual argument value for a method
|
1363
|
+
call is not relevant.
|
1364
|
+
</remarks><example>
|
1365
|
+
<code>
|
1366
|
+
// Throws an exception for a call to Remove with any string value.
|
1367
|
+
mock.Setup(x => x.Remove(It.IsAny<string>())).Throws(new InvalidOperationException());
|
1368
|
+
</code>
|
1369
|
+
</example><typeparam name="TValue">Type of the value.</typeparam>
|
1370
|
+
</member>
|
1371
|
+
<member name="M:Moq.It.Is``1(System.Linq.Expressions.Expression{System.Predicate{``0}})">
|
1372
|
+
<summary>
|
1373
|
+
Matches any value that satisfies the given predicate.
|
1374
|
+
</summary><typeparam name="TValue">Type of the argument to check.</typeparam><param name="match">The predicate used to match the method argument.</param><remarks>
|
1375
|
+
Allows the specification of a predicate to perform matching
|
1376
|
+
of method call arguments.
|
1377
|
+
</remarks><example>
|
1378
|
+
This example shows how to return the value <c>1</c> whenever the argument to the
|
1379
|
+
<c>Do</c> method is an even number.
|
1380
|
+
<code>
|
1381
|
+
mock.Setup(x => x.Do(It.Is<int>(i => i % 2 == 0)))
|
1382
|
+
.Returns(1);
|
1383
|
+
</code>
|
1384
|
+
This example shows how to throw an exception if the argument to the
|
1385
|
+
method is a negative number:
|
1386
|
+
<code>
|
1387
|
+
mock.Setup(x => x.GetUser(It.Is<int>(i => i < 0)))
|
1388
|
+
.Throws(new ArgumentException());
|
1389
|
+
</code>
|
1390
|
+
</example>
|
1391
|
+
</member>
|
1392
|
+
<member name="M:Moq.It.IsInRange``1(``0,``0,Moq.Range)">
|
1393
|
+
<summary>
|
1394
|
+
Matches any value that is in the range specified.
|
1395
|
+
</summary><typeparam name="TValue">Type of the argument to check.</typeparam><param name="from">The lower bound of the range.</param><param name="to">The upper bound of the range.</param><param name="rangeKind">
|
1396
|
+
The kind of range. See <see cref="T:Moq.Range"/>.
|
1397
|
+
</param><example>
|
1398
|
+
The following example shows how to expect a method call
|
1399
|
+
with an integer argument within the 0..100 range.
|
1400
|
+
<code>
|
1401
|
+
mock.Setup(x => x.HasInventory(
|
1402
|
+
It.IsAny<string>(),
|
1403
|
+
It.IsInRange(0, 100, Range.Inclusive)))
|
1404
|
+
.Returns(false);
|
1405
|
+
</code>
|
1406
|
+
</example>
|
1407
|
+
</member>
|
1408
|
+
<member name="M:Moq.It.IsRegex(System.String)">
|
1409
|
+
<summary>
|
1410
|
+
Matches a string argument if it matches the given regular expression pattern.
|
1411
|
+
</summary><param name="regex">The pattern to use to match the string argument value.</param><example>
|
1412
|
+
The following example shows how to expect a call to a method where the
|
1413
|
+
string argument matches the given regular expression:
|
1414
|
+
<code>
|
1415
|
+
mock.Setup(x => x.Check(It.IsRegex("[a-z]+"))).Returns(1);
|
1416
|
+
</code>
|
1417
|
+
</example>
|
1418
|
+
</member>
|
1419
|
+
<member name="M:Moq.It.IsRegex(System.String,System.Text.RegularExpressions.RegexOptions)">
|
1420
|
+
<summary>
|
1421
|
+
Matches a string argument if it matches the given regular expression pattern.
|
1422
|
+
</summary><param name="regex">The pattern to use to match the string argument value.</param><param name="options">The options used to interpret the pattern.</param><example>
|
1423
|
+
The following example shows how to expect a call to a method where the
|
1424
|
+
string argument matches the given regular expression, in a case insensitive way:
|
1425
|
+
<code>
|
1426
|
+
mock.Setup(x => x.Check(It.IsRegex("[a-z]+", RegexOptions.IgnoreCase))).Returns(1);
|
1427
|
+
</code>
|
1428
|
+
</example>
|
1429
|
+
</member>
|
1430
|
+
<member name="T:Moq.Matchers.MatcherAttributeMatcher">
|
1431
|
+
<summary>
|
1432
|
+
Matcher to treat static functions as matchers.
|
1433
|
+
|
1434
|
+
mock.Setup(x => x.StringMethod(A.MagicString()));
|
1435
|
+
|
1436
|
+
pbulic static class A
|
1437
|
+
{
|
1438
|
+
[Matcher]
|
1439
|
+
public static string MagicString() { return null; }
|
1440
|
+
public static bool MagicString(string arg)
|
1441
|
+
{
|
1442
|
+
return arg == "magic";
|
1443
|
+
}
|
1444
|
+
}
|
1445
|
+
|
1446
|
+
Will success if: mock.Object.StringMethod("magic");
|
1447
|
+
and fail with any other call.
|
1448
|
+
</summary>
|
1449
|
+
</member>
|
1450
|
+
<member name="T:Moq.MethodCallReturn">
|
1451
|
+
<devdoc>
|
1452
|
+
We need this non-generics base class so that
|
1453
|
+
we can use <see cref="P:Moq.MethodCallReturn.HasReturnValue"/> from
|
1454
|
+
generic code.
|
1455
|
+
</devdoc>
|
1456
|
+
</member>
|
1457
|
+
<member name="T:Moq.Mock">
|
1458
|
+
<summary>
|
1459
|
+
Base class for mocks and static helper class with methods that
|
1460
|
+
apply to mocked objects, such as <see cref="M:Moq.Mock.Get``1(``0)"/> to
|
1461
|
+
retrieve a <see cref="T:Moq.Mock`1"/> from an object instance.
|
1462
|
+
</summary>
|
1463
|
+
</member>
|
1464
|
+
<member name="M:Moq.Mock.Get``1(``0)">
|
1465
|
+
<summary>
|
1466
|
+
Retrieves the mock object for the given object instance.
|
1467
|
+
</summary><typeparam name="T">
|
1468
|
+
Type of the mock to retrieve. Can be omitted as it's inferred
|
1469
|
+
from the object instance passed in as the <paramref name="mocked"/> instance.
|
1470
|
+
</typeparam><param name="mocked">The instance of the mocked object.</param><returns>The mock associated with the mocked object.</returns><exception cref="T:System.ArgumentException">
|
1471
|
+
The received <paramref name="mocked"/> instance
|
1472
|
+
was not created by Moq.
|
1473
|
+
</exception><example group="advanced">
|
1474
|
+
The following example shows how to add a new setup to an object
|
1475
|
+
instance which is not the original <see cref="T:Moq.Mock`1"/> but rather
|
1476
|
+
the object associated with it:
|
1477
|
+
<code>
|
1478
|
+
// Typed instance, not the mock, is retrieved from some test API.
|
1479
|
+
HttpContextBase context = GetMockContext();
|
1480
|
+
|
1481
|
+
// context.Request is the typed object from the "real" API
|
1482
|
+
// so in order to add a setup to it, we need to get
|
1483
|
+
// the mock that "owns" it
|
1484
|
+
Mock<HttpRequestBase> request = Mock.Get(context.Request);
|
1485
|
+
mock.Setup(req => req.AppRelativeCurrentExecutionFilePath)
|
1486
|
+
.Returns(tempUrl);
|
1487
|
+
</code>
|
1488
|
+
</example>
|
1489
|
+
</member>
|
1490
|
+
<member name="M:Moq.Mock.GetObject">
|
1491
|
+
<summary>
|
1492
|
+
Returns the mocked object value.
|
1493
|
+
</summary>
|
1494
|
+
</member>
|
1495
|
+
<member name="M:Moq.Mock.Verify">
|
1496
|
+
<summary>
|
1497
|
+
Verifies that all verifiable expectations have been met.
|
1498
|
+
</summary><example group="verification">
|
1499
|
+
This example sets up an expectation and marks it as verifiable. After
|
1500
|
+
the mock is used, a <c>Verify()</c> call is issued on the mock
|
1501
|
+
to ensure the method in the setup was invoked:
|
1502
|
+
<code>
|
1503
|
+
var mock = new Mock<IWarehouse>();
|
1504
|
+
this.Setup(x => x.HasInventory(TALISKER, 50)).Verifiable().Returns(true);
|
1505
|
+
...
|
1506
|
+
// other test code
|
1507
|
+
...
|
1508
|
+
// Will throw if the test code has didn't call HasInventory.
|
1509
|
+
this.Verify();
|
1510
|
+
</code>
|
1511
|
+
</example><exception cref="T:Moq.MockException">Not all verifiable expectations were met.</exception>
|
1512
|
+
</member>
|
1513
|
+
<member name="M:Moq.Mock.VerifyAll">
|
1514
|
+
<summary>
|
1515
|
+
Verifies all expectations regardless of whether they have
|
1516
|
+
been flagged as verifiable.
|
1517
|
+
</summary><example group="verification">
|
1518
|
+
This example sets up an expectation without marking it as verifiable. After
|
1519
|
+
the mock is used, a <see cref="M:Moq.Mock.VerifyAll"/> call is issued on the mock
|
1520
|
+
to ensure that all expectations are met:
|
1521
|
+
<code>
|
1522
|
+
var mock = new Mock<IWarehouse>();
|
1523
|
+
this.Setup(x => x.HasInventory(TALISKER, 50)).Returns(true);
|
1524
|
+
...
|
1525
|
+
// other test code
|
1526
|
+
...
|
1527
|
+
// Will throw if the test code has didn't call HasInventory, even
|
1528
|
+
// that expectation was not marked as verifiable.
|
1529
|
+
this.VerifyAll();
|
1530
|
+
</code>
|
1531
|
+
</example><exception cref="T:Moq.MockException">At least one expectation was not met.</exception>
|
1532
|
+
</member>
|
1533
|
+
<member name="M:Moq.Mock.GetInterceptor(System.Linq.Expressions.LambdaExpression,Moq.Mock)">
|
1534
|
+
<summary>
|
1535
|
+
Gets the interceptor target for the given expression and root mock,
|
1536
|
+
building the intermediate hierarchy of mock objects if necessary.
|
1537
|
+
</summary>
|
1538
|
+
</member>
|
1539
|
+
<member name="M:Moq.Mock.CreateEventHandler``1">
|
1540
|
+
<summary>
|
1541
|
+
Creates a handler that can be associated to an event receiving
|
1542
|
+
the given <typeparamref name="TEventArgs"/> and can be used
|
1543
|
+
to raise the event.
|
1544
|
+
</summary><typeparam name="TEventArgs">
|
1545
|
+
Type of <see cref="T:System.EventArgs"/>
|
1546
|
+
data passed in to the event.
|
1547
|
+
</typeparam><example>
|
1548
|
+
This example shows how to invoke an event with a custom event arguments
|
1549
|
+
class in a view that will cause its corresponding presenter to
|
1550
|
+
react by changing its state:
|
1551
|
+
<code>
|
1552
|
+
var mockView = new Mock<IOrdersView>();
|
1553
|
+
var mockedEvent = mockView.CreateEventHandler<OrderEventArgs>();
|
1554
|
+
|
1555
|
+
var presenter = new OrdersPresenter(mockView.Object);
|
1556
|
+
|
1557
|
+
// Check that the presenter has no selection by default
|
1558
|
+
Assert.Null(presenter.SelectedOrder);
|
1559
|
+
|
1560
|
+
// Create a mock event handler of the appropriate type
|
1561
|
+
var handler = mockView.CreateEventHandler<OrderEventArgs>();
|
1562
|
+
// Associate it with the event we want to raise
|
1563
|
+
mockView.Object.Cancel += handler;
|
1564
|
+
// Finally raise the event with a specific arguments data
|
1565
|
+
handler.Raise(new OrderEventArgs { Order = new Order("moq", 500) });
|
1566
|
+
|
1567
|
+
// Now the presenter reacted to the event, and we have a selected order
|
1568
|
+
Assert.NotNull(presenter.SelectedOrder);
|
1569
|
+
Assert.Equal("moq", presenter.SelectedOrder.ProductName);
|
1570
|
+
</code>
|
1571
|
+
</example>
|
1572
|
+
</member>
|
1573
|
+
<member name="M:Moq.Mock.CreateEventHandler">
|
1574
|
+
<summary>
|
1575
|
+
Creates a handler that can be associated to an event receiving
|
1576
|
+
a generic <see cref="T:System.EventArgs"/> and can be used
|
1577
|
+
to raise the event.
|
1578
|
+
</summary><example>
|
1579
|
+
This example shows how to invoke a generic event in a view that will
|
1580
|
+
cause its corresponding presenter to react by changing its state:
|
1581
|
+
<code>
|
1582
|
+
var mockView = new Mock<IOrdersView>();
|
1583
|
+
var mockedEvent = mockView.CreateEventHandler();
|
1584
|
+
|
1585
|
+
var presenter = new OrdersPresenter(mockView.Object);
|
1586
|
+
|
1587
|
+
// Check that the presenter is not in the "Canceled" state
|
1588
|
+
Assert.False(presenter.IsCanceled);
|
1589
|
+
|
1590
|
+
// Create a mock event handler of the appropriate type
|
1591
|
+
var handler = mockView.CreateEventHandler();
|
1592
|
+
// Associate it with the event we want to raise
|
1593
|
+
mockView.Object.Cancel += handler;
|
1594
|
+
// Finally raise the event
|
1595
|
+
handler.Raise(EventArgs.Empty);
|
1596
|
+
|
1597
|
+
// Now the presenter reacted to the event, and changed its state
|
1598
|
+
Assert.True(presenter.IsCanceled);
|
1599
|
+
</code>
|
1600
|
+
</example>
|
1601
|
+
</member>
|
1602
|
+
<member name="M:Moq.Mock.Moq#IHideObjectMembers#GetType">
|
1603
|
+
<summary>
|
1604
|
+
Base class for mocks and static helper class with methods that
|
1605
|
+
apply to mocked objects, such as <see cref="M:Moq.Mock.Get``1(``0)"/> to
|
1606
|
+
retrieve a <see cref="T:Moq.Mock`1"/> from an object instance.
|
1607
|
+
</summary>
|
1608
|
+
</member>
|
1609
|
+
<member name="P:Moq.Mock.Behavior">
|
1610
|
+
<summary>
|
1611
|
+
Behavior of the mock, according to the value set in the constructor.
|
1612
|
+
</summary>
|
1613
|
+
</member>
|
1614
|
+
<member name="P:Moq.Mock.CallBase">
|
1615
|
+
<summary>
|
1616
|
+
Whether the base member virtual implementation will be called
|
1617
|
+
for mocked classes if no setup is matched. Defaults to <see langword="false"/>.
|
1618
|
+
</summary>
|
1619
|
+
</member>
|
1620
|
+
<member name="P:Moq.Mock.DefaultValue">
|
1621
|
+
<summary>
|
1622
|
+
Specifies the behavior to use when returning default values for
|
1623
|
+
unexpected invocations on loose mocks.
|
1624
|
+
</summary>
|
1625
|
+
</member>
|
1626
|
+
<member name="P:Moq.Mock.Object">
|
1627
|
+
<summary>
|
1628
|
+
Gets the mocked object instance, which is of the mocked type <typeparamref name="T"/>.
|
1629
|
+
</summary>
|
1630
|
+
</member>
|
1631
|
+
<member name="P:Moq.Mock.MockedType">
|
1632
|
+
<summary>
|
1633
|
+
Retrieves the type of the mocked object, its generic type argument.
|
1634
|
+
This is used in the auto-mocking of hierarchy access.
|
1635
|
+
</summary>
|
1636
|
+
</member>
|
1637
|
+
<member name="P:Moq.Mock.DefaultValueProvider">
|
1638
|
+
<summary>
|
1639
|
+
Specifies the class that will determine the default
|
1640
|
+
value to return when invocations are made that
|
1641
|
+
have no setups and need to return a default
|
1642
|
+
value (for loose mocks).
|
1643
|
+
</summary>
|
1644
|
+
</member>
|
1645
|
+
<member name="P:Moq.Mock.ImplementedInterfaces">
|
1646
|
+
<summary>
|
1647
|
+
Exposes the list of extra interfaces implemented by the mock.
|
1648
|
+
</summary>
|
1649
|
+
</member>
|
1650
|
+
<member name="T:Moq.MockBehavior">
|
1651
|
+
<summary>
|
1652
|
+
Options to customize the behavior of the mock.
|
1653
|
+
</summary>
|
1654
|
+
</member>
|
1655
|
+
<member name="F:Moq.MockBehavior.Strict">
|
1656
|
+
<summary>
|
1657
|
+
Causes the mock to always throw
|
1658
|
+
an exception for invocations that don't have a
|
1659
|
+
corresponding setup.
|
1660
|
+
</summary>
|
1661
|
+
</member>
|
1662
|
+
<member name="F:Moq.MockBehavior.Loose">
|
1663
|
+
<summary>
|
1664
|
+
Will never throw exceptions, returning default
|
1665
|
+
values when necessary (null for reference types,
|
1666
|
+
zero for value types or empty enumerables and arrays).
|
1667
|
+
</summary>
|
1668
|
+
</member>
|
1669
|
+
<member name="F:Moq.MockBehavior.Default">
|
1670
|
+
<summary>
|
1671
|
+
Default mock behavior, which equals <see cref="F:Moq.MockBehavior.Loose"/>.
|
1672
|
+
</summary>
|
1673
|
+
</member>
|
1674
|
+
<member name="T:Moq.MockedEvent">
|
1675
|
+
<summary>
|
1676
|
+
Represents a generic event that has been mocked and can
|
1677
|
+
be rised.
|
1678
|
+
</summary>
|
1679
|
+
</member>
|
1680
|
+
<member name="M:Moq.MockedEvent.Handle(System.Object,System.EventArgs)">
|
1681
|
+
<summary>
|
1682
|
+
Provided solely to allow the interceptor to determine when the attached
|
1683
|
+
handler is coming from this mocked event so we can assign the
|
1684
|
+
corresponding EventInfo for it.
|
1685
|
+
</summary>
|
1686
|
+
</member>
|
1687
|
+
<member name="M:Moq.MockedEvent.DoRaise(System.EventArgs)">
|
1688
|
+
<summary>
|
1689
|
+
Raises the associated event with the given
|
1690
|
+
event argument data.
|
1691
|
+
</summary>
|
1692
|
+
</member>
|
1693
|
+
<member name="M:Moq.MockedEvent.DoRaise(System.Object[])">
|
1694
|
+
<summary>
|
1695
|
+
Raises the associated event with the given
|
1696
|
+
event argument data.
|
1697
|
+
</summary>
|
1698
|
+
</member>
|
1699
|
+
<member name="M:Moq.MockedEvent.op_Implicit(Moq.MockedEvent)~System.EventHandler">
|
1700
|
+
<summary>
|
1701
|
+
Provides support for attaching a <see cref="T:Moq.MockedEvent"/> to
|
1702
|
+
a generic <see cref="T:System.EventHandler"/> event.
|
1703
|
+
</summary>
|
1704
|
+
<param name="mockEvent">Event to convert.</param>
|
1705
|
+
</member>
|
1706
|
+
<member name="E:Moq.MockedEvent.Raised">
|
1707
|
+
<summary>
|
1708
|
+
Event raised whenever the mocked event is rised.
|
1709
|
+
</summary>
|
1710
|
+
</member>
|
1711
|
+
<member name="T:Moq.MockException">
|
1712
|
+
<summary>
|
1713
|
+
Exception thrown by mocks when setups are not matched,
|
1714
|
+
the mock is not properly setup, etc.
|
1715
|
+
</summary>
|
1716
|
+
<remarks>
|
1717
|
+
A distinct exception type is provided so that exceptions
|
1718
|
+
thrown by the mock can be differentiated in tests that
|
1719
|
+
expect other exceptions to be thrown (i.e. ArgumentException).
|
1720
|
+
<para>
|
1721
|
+
Richer exception hierarchy/types are not provided as
|
1722
|
+
tests typically should <b>not</b> catch or expect exceptions
|
1723
|
+
from the mocks. These are typically the result of changes
|
1724
|
+
in the tested class or its collaborators implementation, and
|
1725
|
+
result in fixes in the mock setup so that they dissapear and
|
1726
|
+
allow the test to pass.
|
1727
|
+
</para>
|
1728
|
+
</remarks>
|
1729
|
+
</member>
|
1730
|
+
<member name="M:Moq.MockException.#ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)">
|
1731
|
+
<summary>
|
1732
|
+
Supports the serialization infrastructure.
|
1733
|
+
</summary>
|
1734
|
+
<param name="info">Serialization information.</param>
|
1735
|
+
<param name="context">Streaming context.</param>
|
1736
|
+
</member>
|
1737
|
+
<member name="M:Moq.MockException.GetObjectData(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)">
|
1738
|
+
<summary>
|
1739
|
+
Supports the serialization infrastructure.
|
1740
|
+
</summary>
|
1741
|
+
<param name="info">Serialization information.</param>
|
1742
|
+
<param name="context">Streaming context.</param>
|
1743
|
+
</member>
|
1744
|
+
<member name="T:Moq.MockException.ExceptionReason">
|
1745
|
+
<summary>
|
1746
|
+
Made internal as it's of no use for
|
1747
|
+
consumers, but it's important for
|
1748
|
+
our own tests.
|
1749
|
+
</summary>
|
1750
|
+
</member>
|
1751
|
+
<member name="T:Moq.MockVerificationException">
|
1752
|
+
<devdoc>
|
1753
|
+
Used by the mock factory to accumulate verification
|
1754
|
+
failures.
|
1755
|
+
</devdoc>
|
1756
|
+
</member>
|
1757
|
+
<member name="M:Moq.MockVerificationException.#ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)">
|
1758
|
+
<summary>
|
1759
|
+
Supports the serialization infrastructure.
|
1760
|
+
</summary>
|
1761
|
+
</member>
|
1762
|
+
<member name="T:Moq.MockFactory">
|
1763
|
+
<summary>
|
1764
|
+
Utility factory class to use to construct multiple
|
1765
|
+
mocks when consistent verification is
|
1766
|
+
desired for all of them.
|
1767
|
+
</summary>
|
1768
|
+
<remarks>
|
1769
|
+
If multiple mocks will be created during a test, passing
|
1770
|
+
the desired <see cref="T:Moq.MockBehavior"/> (if different than the
|
1771
|
+
<see cref="F:Moq.MockBehavior.Default"/> or the one
|
1772
|
+
passed to the factory constructor) and later verifying each
|
1773
|
+
mock can become repetitive and tedious.
|
1774
|
+
<para>
|
1775
|
+
This factory class helps in that scenario by providing a
|
1776
|
+
simplified creation of multiple mocks with a default
|
1777
|
+
<see cref="T:Moq.MockBehavior"/> (unless overriden by calling
|
1778
|
+
<see cref="M:Moq.MockFactory.Create``1(Moq.MockBehavior)"/>) and posterior verification.
|
1779
|
+
</para>
|
1780
|
+
</remarks>
|
1781
|
+
<example group="factory">
|
1782
|
+
The following is a straightforward example on how to
|
1783
|
+
create and automatically verify strict mocks using a <see cref="T:Moq.MockFactory"/>:
|
1784
|
+
<code>
|
1785
|
+
var factory = new MockFactory(MockBehavior.Strict);
|
1786
|
+
|
1787
|
+
var foo = factory.Create<IFoo>();
|
1788
|
+
var bar = factory.Create<IBar>();
|
1789
|
+
|
1790
|
+
// no need to call Verifiable() on the setup
|
1791
|
+
// as we'll be validating all of them anyway.
|
1792
|
+
foo.Setup(f => f.Do());
|
1793
|
+
bar.Setup(b => b.Redo());
|
1794
|
+
|
1795
|
+
// exercise the mocks here
|
1796
|
+
|
1797
|
+
factory.VerifyAll();
|
1798
|
+
// At this point all setups are already checked
|
1799
|
+
// and an optional MockException might be thrown.
|
1800
|
+
// Note also that because the mocks are strict, any invocation
|
1801
|
+
// that doesn't have a matching setup will also throw a MockException.
|
1802
|
+
</code>
|
1803
|
+
The following examples shows how to setup the factory
|
1804
|
+
to create loose mocks and later verify only verifiable setups:
|
1805
|
+
<code>
|
1806
|
+
var factory = new MockFactory(MockBehavior.Loose);
|
1807
|
+
|
1808
|
+
var foo = factory.Create<IFoo>();
|
1809
|
+
var bar = factory.Create<IBar>();
|
1810
|
+
|
1811
|
+
// this setup will be verified when we verify the factory
|
1812
|
+
foo.Setup(f => f.Do()).Verifiable();
|
1813
|
+
|
1814
|
+
// this setup will NOT be verified
|
1815
|
+
foo.Setup(f => f.Calculate());
|
1816
|
+
|
1817
|
+
// this setup will be verified when we verify the factory
|
1818
|
+
bar.Setup(b => b.Redo()).Verifiable();
|
1819
|
+
|
1820
|
+
// exercise the mocks here
|
1821
|
+
// note that because the mocks are Loose, members
|
1822
|
+
// called in the interfaces for which no matching
|
1823
|
+
// setups exist will NOT throw exceptions,
|
1824
|
+
// and will rather return default values.
|
1825
|
+
|
1826
|
+
factory.Verify();
|
1827
|
+
// At this point verifiable setups are already checked
|
1828
|
+
// and an optional MockException might be thrown.
|
1829
|
+
</code>
|
1830
|
+
The following examples shows how to setup the factory with a
|
1831
|
+
default strict behavior, overriding that default for a
|
1832
|
+
specific mock:
|
1833
|
+
<code>
|
1834
|
+
var factory = new MockFactory(MockBehavior.Strict);
|
1835
|
+
|
1836
|
+
// this particular one we want loose
|
1837
|
+
var foo = factory.Create<IFoo>(MockBehavior.Loose);
|
1838
|
+
var bar = factory.Create<IBar>();
|
1839
|
+
|
1840
|
+
// specify setups
|
1841
|
+
|
1842
|
+
// exercise the mocks here
|
1843
|
+
|
1844
|
+
factory.Verify();
|
1845
|
+
</code>
|
1846
|
+
</example>
|
1847
|
+
<seealso cref="T:Moq.MockBehavior"/>
|
1848
|
+
</member>
|
1849
|
+
<member name="M:Moq.MockFactory.#ctor(Moq.MockBehavior)">
|
1850
|
+
<summary>
|
1851
|
+
Initializes the factory with the given <paramref name="defaultBehavior"/>
|
1852
|
+
for newly created mocks from the factory.
|
1853
|
+
</summary>
|
1854
|
+
<param name="defaultBehavior">The behavior to use for mocks created
|
1855
|
+
using the <see cref="M:Moq.MockFactory.Create``1"/> factory method if not overriden
|
1856
|
+
by using the <see cref="M:Moq.MockFactory.Create``1(Moq.MockBehavior)"/> overload.</param>
|
1857
|
+
</member>
|
1858
|
+
<member name="M:Moq.MockFactory.Create``1">
|
1859
|
+
<summary>
|
1860
|
+
Creates a new mock with the default <see cref="T:Moq.MockBehavior"/>
|
1861
|
+
specified at factory construction time.
|
1862
|
+
</summary>
|
1863
|
+
<typeparam name="T">Type to mock.</typeparam>
|
1864
|
+
<returns>A new <see cref="T:Moq.Mock`1"/>.</returns>
|
1865
|
+
<example ignore="true">
|
1866
|
+
<code>
|
1867
|
+
var factory = new MockFactory(MockBehavior.Strict);
|
1868
|
+
|
1869
|
+
var foo = factory.Create<IFoo>();
|
1870
|
+
// use mock on tests
|
1871
|
+
|
1872
|
+
factory.VerifyAll();
|
1873
|
+
</code>
|
1874
|
+
</example>
|
1875
|
+
</member>
|
1876
|
+
<member name="M:Moq.MockFactory.Create``1(System.Object[])">
|
1877
|
+
<summary>
|
1878
|
+
Creates a new mock with the default <see cref="T:Moq.MockBehavior"/>
|
1879
|
+
specified at factory construction time and with the
|
1880
|
+
the given constructor arguments for the class.
|
1881
|
+
</summary>
|
1882
|
+
<remarks>
|
1883
|
+
The mock will try to find the best match constructor given the
|
1884
|
+
constructor arguments, and invoke that to initialize the instance.
|
1885
|
+
This applies only to classes, not interfaces.
|
1886
|
+
</remarks>
|
1887
|
+
<typeparam name="T">Type to mock.</typeparam>
|
1888
|
+
<param name="args">Constructor arguments for mocked classes.</param>
|
1889
|
+
<returns>A new <see cref="T:Moq.Mock`1"/>.</returns>
|
1890
|
+
<example ignore="true">
|
1891
|
+
<code>
|
1892
|
+
var factory = new MockFactory(MockBehavior.Default);
|
1893
|
+
|
1894
|
+
var mock = factory.Create<MyBase>("Foo", 25, true);
|
1895
|
+
// use mock on tests
|
1896
|
+
|
1897
|
+
factory.Verify();
|
1898
|
+
</code>
|
1899
|
+
</example>
|
1900
|
+
</member>
|
1901
|
+
<member name="M:Moq.MockFactory.Create``1(Moq.MockBehavior)">
|
1902
|
+
<summary>
|
1903
|
+
Creates a new mock with the given <paramref name="behavior"/>.
|
1904
|
+
</summary>
|
1905
|
+
<typeparam name="T">Type to mock.</typeparam>
|
1906
|
+
<param name="behavior">Behavior to use for the mock, which overrides
|
1907
|
+
the default behavior specified at factory construction time.</param>
|
1908
|
+
<returns>A new <see cref="T:Moq.Mock`1"/>.</returns>
|
1909
|
+
<example group="factory">
|
1910
|
+
The following example shows how to create a mock with a different
|
1911
|
+
behavior to that specified as the default for the factory:
|
1912
|
+
<code>
|
1913
|
+
var factory = new MockFactory(MockBehavior.Strict);
|
1914
|
+
|
1915
|
+
var foo = factory.Create<IFoo>(MockBehavior.Loose);
|
1916
|
+
</code>
|
1917
|
+
</example>
|
1918
|
+
</member>
|
1919
|
+
<member name="M:Moq.MockFactory.Create``1(Moq.MockBehavior,System.Object[])">
|
1920
|
+
<summary>
|
1921
|
+
Creates a new mock with the given <paramref name="behavior"/>
|
1922
|
+
and with the the given constructor arguments for the class.
|
1923
|
+
</summary>
|
1924
|
+
<remarks>
|
1925
|
+
The mock will try to find the best match constructor given the
|
1926
|
+
constructor arguments, and invoke that to initialize the instance.
|
1927
|
+
This applies only to classes, not interfaces.
|
1928
|
+
</remarks>
|
1929
|
+
<typeparam name="T">Type to mock.</typeparam>
|
1930
|
+
<param name="behavior">Behavior to use for the mock, which overrides
|
1931
|
+
the default behavior specified at factory construction time.</param>
|
1932
|
+
<param name="args">Constructor arguments for mocked classes.</param>
|
1933
|
+
<returns>A new <see cref="T:Moq.Mock`1"/>.</returns>
|
1934
|
+
<example group="factory">
|
1935
|
+
The following example shows how to create a mock with a different
|
1936
|
+
behavior to that specified as the default for the factory, passing
|
1937
|
+
constructor arguments:
|
1938
|
+
<code>
|
1939
|
+
var factory = new MockFactory(MockBehavior.Default);
|
1940
|
+
|
1941
|
+
var mock = factory.Create<MyBase>(MockBehavior.Strict, "Foo", 25, true);
|
1942
|
+
</code>
|
1943
|
+
</example>
|
1944
|
+
</member>
|
1945
|
+
<member name="M:Moq.MockFactory.CreateMock``1(Moq.MockBehavior,System.Object[])">
|
1946
|
+
<summary>
|
1947
|
+
Implements creation of a new mock within the factory.
|
1948
|
+
</summary>
|
1949
|
+
<typeparam name="T">Type to mock.</typeparam>
|
1950
|
+
<param name="behavior">The behavior for the new mock.</param>
|
1951
|
+
<param name="args">Optional arguments for the construction of the mock.</param>
|
1952
|
+
</member>
|
1953
|
+
<member name="M:Moq.MockFactory.Verify">
|
1954
|
+
<summary>
|
1955
|
+
Verifies all verifiable expectations on all mocks created
|
1956
|
+
by this factory.
|
1957
|
+
</summary>
|
1958
|
+
<seealso cref="M:Moq.Mock.Verify"/>
|
1959
|
+
<exception cref="T:Moq.MockException">One or more mocks had expectations that were not satisfied.</exception>
|
1960
|
+
</member>
|
1961
|
+
<member name="M:Moq.MockFactory.VerifyAll">
|
1962
|
+
<summary>
|
1963
|
+
Verifies all verifiable expectations on all mocks created
|
1964
|
+
by this factory.
|
1965
|
+
</summary>
|
1966
|
+
<seealso cref="M:Moq.Mock.Verify"/>
|
1967
|
+
<exception cref="T:Moq.MockException">One or more mocks had expectations that were not satisfied.</exception>
|
1968
|
+
</member>
|
1969
|
+
<member name="M:Moq.MockFactory.VerifyMocks(System.Action{Moq.Mock})">
|
1970
|
+
<summary>
|
1971
|
+
Invokes <paramref name="verifyAction"/> for each mock
|
1972
|
+
in <see cref="P:Moq.MockFactory.Mocks"/>, and accumulates the resulting
|
1973
|
+
<see cref="T:Moq.MockVerificationException"/> that might be
|
1974
|
+
thrown from the action.
|
1975
|
+
</summary>
|
1976
|
+
<param name="verifyAction">The action to execute against
|
1977
|
+
each mock.</param>
|
1978
|
+
</member>
|
1979
|
+
<member name="P:Moq.MockFactory.CallBase">
|
1980
|
+
<summary>
|
1981
|
+
Whether the base member virtual implementation will be called
|
1982
|
+
for mocked classes if no setup is matched. Defaults to <see langword="false"/>.
|
1983
|
+
</summary>
|
1984
|
+
</member>
|
1985
|
+
<member name="P:Moq.MockFactory.DefaultValue">
|
1986
|
+
<summary>
|
1987
|
+
Specifies the behavior to use when returning default values for
|
1988
|
+
unexpected invocations on loose mocks.
|
1989
|
+
</summary>
|
1990
|
+
</member>
|
1991
|
+
<member name="P:Moq.MockFactory.Mocks">
|
1992
|
+
<summary>
|
1993
|
+
Gets the mocks that have been created by this factory and
|
1994
|
+
that will get verified together.
|
1995
|
+
</summary>
|
1996
|
+
</member>
|
1997
|
+
<member name="T:Moq.Properties.Resources">
|
1998
|
+
<summary>
|
1999
|
+
A strongly-typed resource class, for looking up localized strings, etc.
|
2000
|
+
</summary>
|
2001
|
+
</member>
|
2002
|
+
<member name="P:Moq.Properties.Resources.ResourceManager">
|
2003
|
+
<summary>
|
2004
|
+
Returns the cached ResourceManager instance used by this class.
|
2005
|
+
</summary>
|
2006
|
+
</member>
|
2007
|
+
<member name="P:Moq.Properties.Resources.Culture">
|
2008
|
+
<summary>
|
2009
|
+
Overrides the current thread's CurrentUICulture property for all
|
2010
|
+
resource lookups using this strongly typed resource class.
|
2011
|
+
</summary>
|
2012
|
+
</member>
|
2013
|
+
<member name="P:Moq.Properties.Resources.AlreadyInitialized">
|
2014
|
+
<summary>
|
2015
|
+
Looks up a localized string similar to Mock type has already been initialized by accessing its Object property. Adding interfaces must be done before that..
|
2016
|
+
</summary>
|
2017
|
+
</member>
|
2018
|
+
<member name="P:Moq.Properties.Resources.ArgumentCannotBeEmpty">
|
2019
|
+
<summary>
|
2020
|
+
Looks up a localized string similar to Value cannot be an empty string..
|
2021
|
+
</summary>
|
2022
|
+
</member>
|
2023
|
+
<member name="P:Moq.Properties.Resources.AsMustBeInterface">
|
2024
|
+
<summary>
|
2025
|
+
Looks up a localized string similar to Can only add interfaces to the mock..
|
2026
|
+
</summary>
|
2027
|
+
</member>
|
2028
|
+
<member name="P:Moq.Properties.Resources.CantSetReturnValueForVoid">
|
2029
|
+
<summary>
|
2030
|
+
Looks up a localized string similar to Can't set return value for void method {0}..
|
2031
|
+
</summary>
|
2032
|
+
</member>
|
2033
|
+
<member name="P:Moq.Properties.Resources.ConstructorArgsForInterface">
|
2034
|
+
<summary>
|
2035
|
+
Looks up a localized string similar to Constructor arguments cannot be passed for interface mocks..
|
2036
|
+
</summary>
|
2037
|
+
</member>
|
2038
|
+
<member name="P:Moq.Properties.Resources.ConstructorNotFound">
|
2039
|
+
<summary>
|
2040
|
+
Looks up a localized string similar to A matching constructor for the given arguments was not found on the mocked type..
|
2041
|
+
</summary>
|
2042
|
+
</member>
|
2043
|
+
<member name="P:Moq.Properties.Resources.FieldsNotSupported">
|
2044
|
+
<summary>
|
2045
|
+
Looks up a localized string similar to Expression {0} involves a field access, which is not supported. Use properties instead..
|
2046
|
+
</summary>
|
2047
|
+
</member>
|
2048
|
+
<member name="P:Moq.Properties.Resources.InvalidMockClass">
|
2049
|
+
<summary>
|
2050
|
+
Looks up a localized string similar to Type to mock must be an interface or an abstract or non-sealed class. .
|
2051
|
+
</summary>
|
2052
|
+
</member>
|
2053
|
+
<member name="P:Moq.Properties.Resources.InvalidMockGetType">
|
2054
|
+
<summary>
|
2055
|
+
Looks up a localized string similar to Cannot retrieve a mock with the given object type {0} as it's not the main type of the mock or any of its additional interfaces.
|
2056
|
+
Please cast the argument to one of the supported types: {1}.
|
2057
|
+
Remember that there's no generics covariance in the CLR, so your object must be one of these types in order for the call to succeed..
|
2058
|
+
</summary>
|
2059
|
+
</member>
|
2060
|
+
<member name="P:Moq.Properties.Resources.MemberMissing">
|
2061
|
+
<summary>
|
2062
|
+
Looks up a localized string similar to Member {0}.{1} does not exist..
|
2063
|
+
</summary>
|
2064
|
+
</member>
|
2065
|
+
<member name="P:Moq.Properties.Resources.MethodIsPublic">
|
2066
|
+
<summary>
|
2067
|
+
Looks up a localized string similar to Method {0}.{1} is public. Use strong-typed Expect overload instead:
|
2068
|
+
mock.Setup(x => x.{1}());
|
2069
|
+
.
|
2070
|
+
</summary>
|
2071
|
+
</member>
|
2072
|
+
<member name="P:Moq.Properties.Resources.MockExceptionMessage">
|
2073
|
+
<summary>
|
2074
|
+
Looks up a localized string similar to {0} invocation failed with mock behavior {1}.
|
2075
|
+
{2}.
|
2076
|
+
</summary>
|
2077
|
+
</member>
|
2078
|
+
<member name="P:Moq.Properties.Resources.MoreThanNCalls">
|
2079
|
+
<summary>
|
2080
|
+
Looks up a localized string similar to Expected only {0} calls to {1}..
|
2081
|
+
</summary>
|
2082
|
+
</member>
|
2083
|
+
<member name="P:Moq.Properties.Resources.MoreThanOneCall">
|
2084
|
+
<summary>
|
2085
|
+
Looks up a localized string similar to Expected only one call to {0}..
|
2086
|
+
</summary>
|
2087
|
+
</member>
|
2088
|
+
<member name="P:Moq.Properties.Resources.NoMatchingCallsAtLeast">
|
2089
|
+
<summary>
|
2090
|
+
Looks up a localized string similar to {0}
|
2091
|
+
Invocation was performed on the mock less than {2} times: {1}.
|
2092
|
+
</summary>
|
2093
|
+
</member>
|
2094
|
+
<member name="P:Moq.Properties.Resources.NoMatchingCallsAtLeastOnce">
|
2095
|
+
<summary>
|
2096
|
+
Looks up a localized string similar to {0}
|
2097
|
+
Invocation was not performed on the mock: {1}.
|
2098
|
+
</summary>
|
2099
|
+
</member>
|
2100
|
+
<member name="P:Moq.Properties.Resources.NoMatchingCallsAtMost">
|
2101
|
+
<summary>
|
2102
|
+
Looks up a localized string similar to {0}
|
2103
|
+
Invocation was performed on the mock more than {3} times: {1}.
|
2104
|
+
</summary>
|
2105
|
+
</member>
|
2106
|
+
<member name="P:Moq.Properties.Resources.NoMatchingCallsAtMostOnce">
|
2107
|
+
<summary>
|
2108
|
+
Looks up a localized string similar to {0}
|
2109
|
+
Invocation was performed on the mock more than once: {1}.
|
2110
|
+
</summary>
|
2111
|
+
</member>
|
2112
|
+
<member name="P:Moq.Properties.Resources.NoMatchingCallsBetweenExclusive">
|
2113
|
+
<summary>
|
2114
|
+
Looks up a localized string similar to {0}
|
2115
|
+
Invocation was performed on the mock less or equal than {2} times or more or equal than {3} times: {1}.
|
2116
|
+
</summary>
|
2117
|
+
</member>
|
2118
|
+
<member name="P:Moq.Properties.Resources.NoMatchingCallsBetweenInclusive">
|
2119
|
+
<summary>
|
2120
|
+
Looks up a localized string similar to {0}
|
2121
|
+
Invocation was performed on the mock less than {2} times or more than {3} times: {1}.
|
2122
|
+
</summary>
|
2123
|
+
</member>
|
2124
|
+
<member name="P:Moq.Properties.Resources.NoMatchingCallsExactly">
|
2125
|
+
<summary>
|
2126
|
+
Looks up a localized string similar to {0}
|
2127
|
+
Invocation was not performed on the mock {2} times: {1}.
|
2128
|
+
</summary>
|
2129
|
+
</member>
|
2130
|
+
<member name="P:Moq.Properties.Resources.NoMatchingCallsNever">
|
2131
|
+
<summary>
|
2132
|
+
Looks up a localized string similar to {0}
|
2133
|
+
Invocation should not have been performed on the mock: {1}.
|
2134
|
+
</summary>
|
2135
|
+
</member>
|
2136
|
+
<member name="P:Moq.Properties.Resources.NoMatchingCallsOnce">
|
2137
|
+
<summary>
|
2138
|
+
Looks up a localized string similar to {0}
|
2139
|
+
Invocation was performed more than once on the mock: {1}.
|
2140
|
+
</summary>
|
2141
|
+
</member>
|
2142
|
+
<member name="P:Moq.Properties.Resources.NoSetup">
|
2143
|
+
<summary>
|
2144
|
+
Looks up a localized string similar to All invocations on the mock must have a corresponding setup..
|
2145
|
+
</summary>
|
2146
|
+
</member>
|
2147
|
+
<member name="P:Moq.Properties.Resources.ObjectInstanceNotMock">
|
2148
|
+
<summary>
|
2149
|
+
Looks up a localized string similar to Object instance was not created by Moq..
|
2150
|
+
</summary>
|
2151
|
+
</member>
|
2152
|
+
<member name="P:Moq.Properties.Resources.PropertyMissing">
|
2153
|
+
<summary>
|
2154
|
+
Looks up a localized string similar to Property {0}.{1} does not exist..
|
2155
|
+
</summary>
|
2156
|
+
</member>
|
2157
|
+
<member name="P:Moq.Properties.Resources.PropertyNotReadable">
|
2158
|
+
<summary>
|
2159
|
+
Looks up a localized string similar to Property {0}.{1} is write-only..
|
2160
|
+
</summary>
|
2161
|
+
</member>
|
2162
|
+
<member name="P:Moq.Properties.Resources.PropertyNotWritable">
|
2163
|
+
<summary>
|
2164
|
+
Looks up a localized string similar to Property {0}.{1} is read-only..
|
2165
|
+
</summary>
|
2166
|
+
</member>
|
2167
|
+
<member name="P:Moq.Properties.Resources.RaisedUnassociatedEvent">
|
2168
|
+
<summary>
|
2169
|
+
Looks up a localized string similar to Cannot raise a mocked event unless it has been associated (attached) to a concrete event in a mocked object..
|
2170
|
+
</summary>
|
2171
|
+
</member>
|
2172
|
+
<member name="P:Moq.Properties.Resources.ReturnValueRequired">
|
2173
|
+
<summary>
|
2174
|
+
Looks up a localized string similar to Invocation needs to return a value and therefore must have a corresponding setup that provides it..
|
2175
|
+
</summary>
|
2176
|
+
</member>
|
2177
|
+
<member name="P:Moq.Properties.Resources.SetupLambda">
|
2178
|
+
<summary>
|
2179
|
+
Looks up a localized string similar to A lambda expression is expected as the argument to It.Is<T>..
|
2180
|
+
</summary>
|
2181
|
+
</member>
|
2182
|
+
<member name="P:Moq.Properties.Resources.SetupNever">
|
2183
|
+
<summary>
|
2184
|
+
Looks up a localized string similar to Invocation {0} should not have been made..
|
2185
|
+
</summary>
|
2186
|
+
</member>
|
2187
|
+
<member name="P:Moq.Properties.Resources.SetupNotMethod">
|
2188
|
+
<summary>
|
2189
|
+
Looks up a localized string similar to Expression is not a method invocation: {0}.
|
2190
|
+
</summary>
|
2191
|
+
</member>
|
2192
|
+
<member name="P:Moq.Properties.Resources.SetupNotProperty">
|
2193
|
+
<summary>
|
2194
|
+
Looks up a localized string similar to Expression is not a property access: {0}.
|
2195
|
+
</summary>
|
2196
|
+
</member>
|
2197
|
+
<member name="P:Moq.Properties.Resources.SetupNotSetter">
|
2198
|
+
<summary>
|
2199
|
+
Looks up a localized string similar to Expression is not a property setter invocation..
|
2200
|
+
</summary>
|
2201
|
+
</member>
|
2202
|
+
<member name="P:Moq.Properties.Resources.SetupOnNonOverridableMember">
|
2203
|
+
<summary>
|
2204
|
+
Looks up a localized string similar to Invalid setup on a non-overridable member:
|
2205
|
+
{0}.
|
2206
|
+
</summary>
|
2207
|
+
</member>
|
2208
|
+
<member name="P:Moq.Properties.Resources.TypeNotImplementInterface">
|
2209
|
+
<summary>
|
2210
|
+
Looks up a localized string similar to Type {0} does not implement required interface {1}.
|
2211
|
+
</summary>
|
2212
|
+
</member>
|
2213
|
+
<member name="P:Moq.Properties.Resources.TypeNotInheritFromType">
|
2214
|
+
<summary>
|
2215
|
+
Looks up a localized string similar to Type {0} does not from required type {1}.
|
2216
|
+
</summary>
|
2217
|
+
</member>
|
2218
|
+
<member name="P:Moq.Properties.Resources.UnexpectedPublicProperty">
|
2219
|
+
<summary>
|
2220
|
+
Looks up a localized string similar to To specify a setup for public property {0}.{1}, use the typed overloads, such as:
|
2221
|
+
mock.Setup(x => x.{1}).Returns(value);
|
2222
|
+
mock.SetupGet(x => x.{1}).Returns(value); //equivalent to previous one
|
2223
|
+
mock.SetupSet(x => x.{1}).Callback(callbackDelegate);
|
2224
|
+
.
|
2225
|
+
</summary>
|
2226
|
+
</member>
|
2227
|
+
<member name="P:Moq.Properties.Resources.UnsupportedExpression">
|
2228
|
+
<summary>
|
2229
|
+
Looks up a localized string similar to Expression {0} is not supported..
|
2230
|
+
</summary>
|
2231
|
+
</member>
|
2232
|
+
<member name="P:Moq.Properties.Resources.UnsupportedIntermediateExpression">
|
2233
|
+
<summary>
|
2234
|
+
Looks up a localized string similar to Only property accesses are supported in intermediate invocations on a setup. Unsupported expression {0}..
|
2235
|
+
</summary>
|
2236
|
+
</member>
|
2237
|
+
<member name="P:Moq.Properties.Resources.UnsupportedIntermediateType">
|
2238
|
+
<summary>
|
2239
|
+
Looks up a localized string similar to Expression contains intermediate property access {0}.{1} which is of type {2} and cannot be mocked. Unsupported expression {3}..
|
2240
|
+
</summary>
|
2241
|
+
</member>
|
2242
|
+
<member name="P:Moq.Properties.Resources.UnsupportedMatcherParamsForSetter">
|
2243
|
+
<summary>
|
2244
|
+
Looks up a localized string similar to Setter expression cannot use argument matchers that receive parameters..
|
2245
|
+
</summary>
|
2246
|
+
</member>
|
2247
|
+
<member name="P:Moq.Properties.Resources.UnsupportedMember">
|
2248
|
+
<summary>
|
2249
|
+
Looks up a localized string similar to Member {0} is not supported for protected mocking..
|
2250
|
+
</summary>
|
2251
|
+
</member>
|
2252
|
+
<member name="P:Moq.Properties.Resources.UnsupportedNonStaticMatcherForSetter">
|
2253
|
+
<summary>
|
2254
|
+
Looks up a localized string similar to Setter expression can only use static custom matchers..
|
2255
|
+
</summary>
|
2256
|
+
</member>
|
2257
|
+
<member name="P:Moq.Properties.Resources.UnsupportedProtectedProperty">
|
2258
|
+
<summary>
|
2259
|
+
Looks up a localized string similar to To specify a setup for protected property {0}.{1}, use:
|
2260
|
+
mock.Setup<{2}>(x => x.{1}).Returns(value);
|
2261
|
+
mock.SetupGet(x => x.{1}).Returns(value); //equivalent to previous one
|
2262
|
+
mock.SetupSet(x => x.{1}).Callback(callbackDelegate);.
|
2263
|
+
</summary>
|
2264
|
+
</member>
|
2265
|
+
<member name="P:Moq.Properties.Resources.VerficationFailed">
|
2266
|
+
<summary>
|
2267
|
+
Looks up a localized string similar to The following setups were not matched:
|
2268
|
+
{0}.
|
2269
|
+
</summary>
|
2270
|
+
</member>
|
2271
|
+
<member name="T:Moq.Protected.IProtectedMock`1">
|
2272
|
+
<summary>
|
2273
|
+
Allows setups to be specified for protected members by using their
|
2274
|
+
name as a string, rather than strong-typing them which is not possible
|
2275
|
+
due to their visibility.
|
2276
|
+
</summary>
|
2277
|
+
</member>
|
2278
|
+
<member name="M:Moq.Protected.IProtectedMock`1.Setup(System.String,System.Object[])">
|
2279
|
+
<summary>
|
2280
|
+
Specifies a setup for a void method invocation with the given
|
2281
|
+
<paramref name="voidMethodName"/>, optionally specifying
|
2282
|
+
arguments for the method call.
|
2283
|
+
</summary>
|
2284
|
+
<param name="voidMethodName">Name of the void method to be invoke.</param>
|
2285
|
+
<param name="args">Optional arguments for the invocation. If argument matchers are used,
|
2286
|
+
remember to use <see cref="T:Moq.Protected.ItExpr"/> rather than <see cref="T:Moq.It"/>.</param>
|
2287
|
+
</member>
|
2288
|
+
<member name="M:Moq.Protected.IProtectedMock`1.Setup``1(System.String,System.Object[])">
|
2289
|
+
<summary>
|
2290
|
+
Specifies a setup for an invocation on a property or a non void method with the given
|
2291
|
+
<paramref name="methodOrPropertyName"/>, optionally specifying
|
2292
|
+
arguments for the method call.
|
2293
|
+
</summary>
|
2294
|
+
<param name="methodOrPropertyName">Name of the method or property to be invoke.</param>
|
2295
|
+
<param name="args">Optional arguments for the invocation. If argument matchers are used,
|
2296
|
+
remember to use <see cref="T:Moq.Protected.ItExpr"/> rather than <see cref="T:Moq.It"/>.</param>
|
2297
|
+
<typeparam name="TResult">Return type of the method or property.</typeparam>
|
2298
|
+
</member>
|
2299
|
+
<member name="M:Moq.Protected.IProtectedMock`1.SetupGet``1(System.String)">
|
2300
|
+
<summary>
|
2301
|
+
Specifies a setup for an invocation on a property getter with the given
|
2302
|
+
<paramref name="propertyName"/>.
|
2303
|
+
</summary>
|
2304
|
+
<param name="propertyName">Name of the property.</param>
|
2305
|
+
<typeparam name="TProperty">Type of the property.</typeparam>
|
2306
|
+
</member>
|
2307
|
+
<member name="M:Moq.Protected.IProtectedMock`1.SetupSet``1(System.String)">
|
2308
|
+
<summary>
|
2309
|
+
Specifies a setup for an invocation on a property setter with the given
|
2310
|
+
<paramref name="propertyName"/>.
|
2311
|
+
</summary>
|
2312
|
+
<param name="propertyName">Name of the property.</param>
|
2313
|
+
<typeparam name="TProperty">Type of the property.</typeparam>
|
2314
|
+
</member>
|
2315
|
+
<member name="T:Moq.Protected.ItExpr">
|
2316
|
+
<summary>
|
2317
|
+
Allows the specification of a matching condition for an
|
2318
|
+
argument in a protected member setup, rather than a specific
|
2319
|
+
argument value. "ItExpr" refers to the argument being matched.
|
2320
|
+
</summary>
|
2321
|
+
<remarks>
|
2322
|
+
<para>Use this variant of argument matching instead of
|
2323
|
+
<see cref="T:Moq.It"/> for protected setups.</para>
|
2324
|
+
This class allows the setup to match a method invocation
|
2325
|
+
with an arbitrary value, with a value in a specified range, or
|
2326
|
+
even one that matches a given predicate, or null.
|
2327
|
+
</remarks>
|
2328
|
+
</member>
|
2329
|
+
<member name="M:Moq.Protected.ItExpr.IsNull``1">
|
2330
|
+
<summary>
|
2331
|
+
Matches a null value of the given <paramref name="TValue"/> type.
|
2332
|
+
</summary>
|
2333
|
+
<remarks>
|
2334
|
+
Required for protected mocks as the null value cannot be used
|
2335
|
+
directly as it prevents proper method overload selection.
|
2336
|
+
</remarks>
|
2337
|
+
<example>
|
2338
|
+
<code>
|
2339
|
+
// Throws an exception for a call to Remove with a null string value.
|
2340
|
+
mock.Protected()
|
2341
|
+
.Setup("Remove", ItExpr.IsNull<string>())
|
2342
|
+
.Throws(new InvalidOperationException());
|
2343
|
+
</code>
|
2344
|
+
</example>
|
2345
|
+
<typeparam name="TValue">Type of the value.</typeparam>
|
2346
|
+
</member>
|
2347
|
+
<member name="M:Moq.Protected.ItExpr.IsAny``1">
|
2348
|
+
<summary>
|
2349
|
+
Matches any value of the given <paramref name="TValue"/> type.
|
2350
|
+
</summary>
|
2351
|
+
<remarks>
|
2352
|
+
Typically used when the actual argument value for a method
|
2353
|
+
call is not relevant.
|
2354
|
+
</remarks>
|
2355
|
+
<example>
|
2356
|
+
<code>
|
2357
|
+
// Throws an exception for a call to Remove with any string value.
|
2358
|
+
mock.Protected()
|
2359
|
+
.Setup("Remove", ItExpr.IsAny<string>())
|
2360
|
+
.Throws(new InvalidOperationException());
|
2361
|
+
</code>
|
2362
|
+
</example>
|
2363
|
+
<typeparam name="TValue">Type of the value.</typeparam>
|
2364
|
+
</member>
|
2365
|
+
<member name="M:Moq.Protected.ItExpr.Is``1(System.Linq.Expressions.Expression{System.Predicate{``0}})">
|
2366
|
+
<summary>
|
2367
|
+
Matches any value that satisfies the given predicate.
|
2368
|
+
</summary>
|
2369
|
+
<typeparam name="TValue">Type of the argument to check.</typeparam>
|
2370
|
+
<param name="match">The predicate used to match the method argument.</param>
|
2371
|
+
<remarks>
|
2372
|
+
Allows the specification of a predicate to perform matching
|
2373
|
+
of method call arguments.
|
2374
|
+
</remarks>
|
2375
|
+
<example>
|
2376
|
+
This example shows how to return the value <c>1</c> whenever the argument to the
|
2377
|
+
<c>Do</c> method is an even number.
|
2378
|
+
<code>
|
2379
|
+
mock.Protected()
|
2380
|
+
.Setup("Do", ItExpr.Is<int>(i => i % 2 == 0))
|
2381
|
+
.Returns(1);
|
2382
|
+
</code>
|
2383
|
+
This example shows how to throw an exception if the argument to the
|
2384
|
+
method is a negative number:
|
2385
|
+
<code>
|
2386
|
+
mock.Protected()
|
2387
|
+
.Setup("GetUser", ItExpr.Is<int>(i => i < 0))
|
2388
|
+
.Throws(new ArgumentException());
|
2389
|
+
</code>
|
2390
|
+
</example>
|
2391
|
+
</member>
|
2392
|
+
<member name="M:Moq.Protected.ItExpr.IsInRange``1(``0,``0,Moq.Range)">
|
2393
|
+
<summary>
|
2394
|
+
Matches any value that is in the range specified.
|
2395
|
+
</summary>
|
2396
|
+
<typeparam name="TValue">Type of the argument to check.</typeparam>
|
2397
|
+
<param name="from">The lower bound of the range.</param>
|
2398
|
+
<param name="to">The upper bound of the range.</param>
|
2399
|
+
<param name="rangeKind">The kind of range. See <see cref="T:Moq.Range"/>.</param>
|
2400
|
+
<example>
|
2401
|
+
The following example shows how to expect a method call
|
2402
|
+
with an integer argument within the 0..100 range.
|
2403
|
+
<code>
|
2404
|
+
mock.Protected()
|
2405
|
+
.Setup("HasInventory",
|
2406
|
+
ItExpr.IsAny<string>(),
|
2407
|
+
ItExpr.IsInRange(0, 100, Range.Inclusive))
|
2408
|
+
.Returns(false);
|
2409
|
+
</code>
|
2410
|
+
</example>
|
2411
|
+
</member>
|
2412
|
+
<member name="M:Moq.Protected.ItExpr.IsRegex(System.String)">
|
2413
|
+
<summary>
|
2414
|
+
Matches a string argument if it matches the given regular expression pattern.
|
2415
|
+
</summary>
|
2416
|
+
<param name="regex">The pattern to use to match the string argument value.</param>
|
2417
|
+
<example>
|
2418
|
+
The following example shows how to expect a call to a method where the
|
2419
|
+
string argument matches the given regular expression:
|
2420
|
+
<code>
|
2421
|
+
mock.Protected()
|
2422
|
+
.Setup("Check", ItExpr.IsRegex("[a-z]+"))
|
2423
|
+
.Returns(1);
|
2424
|
+
</code>
|
2425
|
+
</example>
|
2426
|
+
</member>
|
2427
|
+
<member name="M:Moq.Protected.ItExpr.IsRegex(System.String,System.Text.RegularExpressions.RegexOptions)">
|
2428
|
+
<summary>
|
2429
|
+
Matches a string argument if it matches the given regular expression pattern.
|
2430
|
+
</summary>
|
2431
|
+
<param name="regex">The pattern to use to match the string argument value.</param>
|
2432
|
+
<param name="options">The options used to interpret the pattern.</param>
|
2433
|
+
<example>
|
2434
|
+
The following example shows how to expect a call to a method where the
|
2435
|
+
string argument matches the given regular expression, in a case insensitive way:
|
2436
|
+
<code>
|
2437
|
+
mock.Protected()
|
2438
|
+
.Setup("Check", ItExpr.IsRegex("[a-z]+", RegexOptions.IgnoreCase))
|
2439
|
+
.Returns(1);
|
2440
|
+
</code>
|
2441
|
+
</example>
|
2442
|
+
</member>
|
2443
|
+
<member name="T:Moq.Protected.ProtectedExtension">
|
2444
|
+
<summary>
|
2445
|
+
Enables the <c>Protected()</c> method on <see cref="T:Moq.Mock`1"/>,
|
2446
|
+
allowing setups to be set for protected members by using their
|
2447
|
+
name as a string, rather than strong-typing them which is not possible
|
2448
|
+
due to their visibility.
|
2449
|
+
</summary>
|
2450
|
+
</member>
|
2451
|
+
<member name="M:Moq.Protected.ProtectedExtension.Protected``1(Moq.Mock{``0})">
|
2452
|
+
<summary>
|
2453
|
+
Enable protected setups for the mock.
|
2454
|
+
</summary>
|
2455
|
+
<typeparam name="T">Mocked object type. Typically omitted as it can be inferred from the mock instance.</typeparam>
|
2456
|
+
<param name="mock">The mock to set the protected setups on.</param>
|
2457
|
+
</member>
|
2458
|
+
<member name="T:ThisAssembly">
|
2459
|
+
<group name="overview" title="Overview" order="0" />
|
2460
|
+
<group name="setups" title="Specifying setups" order="1" />
|
2461
|
+
<group name="returns" title="Returning values from members" order="2" />
|
2462
|
+
<group name="verification" title="Verifying setups" order="3" />
|
2463
|
+
<group name="advanced" title="Advanced scenarios" order="99" />
|
2464
|
+
<group name="factory" title="Using MockFactory for consistency across mocks" order="4" />
|
2465
|
+
</member>
|
2466
|
+
<member name="T:Moq.Range">
|
2467
|
+
<summary>
|
2468
|
+
Kind of range to use in a filter specified through
|
2469
|
+
<see cref="M:Moq.It.IsInRange``1(``0,``0,Moq.Range)"/>.
|
2470
|
+
</summary>
|
2471
|
+
</member>
|
2472
|
+
<member name="F:Moq.Range.Inclusive">
|
2473
|
+
<summary>
|
2474
|
+
The range includes the <c>to</c> and
|
2475
|
+
<c>from</c> values.
|
2476
|
+
</summary>
|
2477
|
+
</member>
|
2478
|
+
<member name="F:Moq.Range.Exclusive">
|
2479
|
+
<summary>
|
2480
|
+
The range does not include the <c>to</c> and
|
2481
|
+
<c>from</c> values.
|
2482
|
+
</summary>
|
2483
|
+
</member>
|
2484
|
+
<member name="T:Moq.DefaultValue">
|
2485
|
+
<summary>
|
2486
|
+
Determines the way default values are generated
|
2487
|
+
calculated for loose mocks.
|
2488
|
+
</summary>
|
2489
|
+
</member>
|
2490
|
+
<member name="F:Moq.DefaultValue.Empty">
|
2491
|
+
<summary>
|
2492
|
+
Default behavior, which generates empty values for
|
2493
|
+
value types (i.e. default(int)), empty array and
|
2494
|
+
enumerables, and nulls for all other reference types.
|
2495
|
+
</summary>
|
2496
|
+
</member>
|
2497
|
+
<member name="F:Moq.DefaultValue.Mock">
|
2498
|
+
<summary>
|
2499
|
+
Whenever the default value generated by <see cref="F:Moq.DefaultValue.Empty"/>
|
2500
|
+
is null, replaces this value with a mock (if the type
|
2501
|
+
can be mocked).
|
2502
|
+
</summary>
|
2503
|
+
<remarks>
|
2504
|
+
For sealed classes, a null value will be generated.
|
2505
|
+
</remarks>
|
2506
|
+
</member>
|
2507
|
+
<member name="T:Moq.Match">
|
2508
|
+
<summary>
|
2509
|
+
Allows creation custom value matchers that can be used on setups and verification,
|
2510
|
+
completely replacing the built-in <see cref="T:Moq.It"/> class with your own argument
|
2511
|
+
matching rules.
|
2512
|
+
</summary>
|
2513
|
+
</member>
|
2514
|
+
<member name="M:Moq.Match.Matcher``1">
|
2515
|
+
<devdoc>
|
2516
|
+
Provided for the sole purpose of rendering the delegate passed to the
|
2517
|
+
matcher constructor if no friendly render lambda is provided.
|
2518
|
+
</devdoc>
|
2519
|
+
</member>
|
2520
|
+
<member name="T:Moq.Match`1">
|
2521
|
+
<summary>
|
2522
|
+
Allows creation custom value matchers that can be used on setups and verification,
|
2523
|
+
completely replacing the built-in <see cref="T:Moq.It"/> class with your own argument
|
2524
|
+
matching rules.
|
2525
|
+
</summary><typeparam name="T">Type of the value to match.</typeparam><remarks>
|
2526
|
+
The argument matching is used to determine whether a concrete
|
2527
|
+
invocation in the mock matches a given setup. This
|
2528
|
+
matching mechanism is fully extensible.
|
2529
|
+
</remarks><example>
|
2530
|
+
Creating a custom matcher is straightforward. You just need to create a method
|
2531
|
+
that returns a value from a call to <see cref="M:Moq.Match`1.Create(System.Predicate{`0})"/> with
|
2532
|
+
your matching condition and optional friendly render expression:
|
2533
|
+
<code>
|
2534
|
+
public Order IsBigOrder()
|
2535
|
+
{
|
2536
|
+
return Match<Order>.Create(
|
2537
|
+
o => o.GrandTotal >= 5000,
|
2538
|
+
/* a friendly expression to render on failures */
|
2539
|
+
() => IsBigOrder());
|
2540
|
+
}
|
2541
|
+
</code>
|
2542
|
+
This method can be used in any mock setup invocation:
|
2543
|
+
<code>
|
2544
|
+
mock.Setup(m => m.Submit(IsBigOrder()).Throws<UnauthorizedAccessException>();
|
2545
|
+
</code>
|
2546
|
+
At runtime, Moq knows that the return value was a matcher and
|
2547
|
+
evaluates your predicate with the actual value passed into your predicate.
|
2548
|
+
<para>
|
2549
|
+
Another example might be a case where you want to match a lists of orders
|
2550
|
+
that contains a particular one. You might create matcher like the following:
|
2551
|
+
</para>
|
2552
|
+
<code>
|
2553
|
+
public static class Orders
|
2554
|
+
{
|
2555
|
+
public static IEnumerable<Order> Contains(Order order)
|
2556
|
+
{
|
2557
|
+
return Match<IEnumerable<Order>>.Create(orders => orders.Contains(order));
|
2558
|
+
}
|
2559
|
+
}
|
2560
|
+
</code>
|
2561
|
+
Now we can invoke this static method instead of an argument in an
|
2562
|
+
invocation:
|
2563
|
+
<code>
|
2564
|
+
var order = new Order { ... };
|
2565
|
+
var mock = new Mock<IRepository<Order>>();
|
2566
|
+
|
2567
|
+
mock.Setup(x => x.Save(Orders.Contains(order)))
|
2568
|
+
.Throws<ArgumentException>();
|
2569
|
+
</code>
|
2570
|
+
</example>
|
2571
|
+
</member>
|
2572
|
+
<member name="M:Moq.Match`1.Create(System.Predicate{`0})">
|
2573
|
+
<summary>
|
2574
|
+
Initializes the match with the condition that
|
2575
|
+
will be checked in order to match invocation
|
2576
|
+
values.
|
2577
|
+
</summary><param name="condition">The condition to match against actual values.</param><remarks>
|
2578
|
+
<seealso cref="T:Moq.Match`1"/>
|
2579
|
+
</remarks>
|
2580
|
+
</member>
|
2581
|
+
<member name="M:Moq.Match`1.Create(System.Predicate{`0},System.Linq.Expressions.Expression{System.Func{`0}})">
|
2582
|
+
<!-- No matching elements were found for the following include tag --><include file="Match.xdoc" path="docs/doc[@for="Match{T}.Create(condition,renderExpression"]/*"/>
|
2583
|
+
</member>
|
2584
|
+
<member name="M:Moq.Match`1.Convert">
|
2585
|
+
<!-- No matching elements were found for the following include tag --><include file="Match.xdoc" path="docs/doc[@for="Match{T}.Convert"]/*"/>
|
2586
|
+
</member>
|
2587
|
+
<member name="M:Moq.Match`1.SetLastMatch``1(Moq.Match{``0})">
|
2588
|
+
<devdoc>
|
2589
|
+
This method is used to set an expression as the last matcher invoked,
|
2590
|
+
which is used in the SetupSet to allow matchers in the prop = value
|
2591
|
+
delegate expression. This delegate is executed in "fluent" mode in
|
2592
|
+
order to capture the value being set, and construct the corresponding
|
2593
|
+
methodcall.
|
2594
|
+
This is also used in the MatcherFactory for each argument expression.
|
2595
|
+
This method ensures that when we execute the delegate, we
|
2596
|
+
also track the matcher that was invoked, so that when we create the
|
2597
|
+
methodcall we build the expression using it, rather than the null/default
|
2598
|
+
value returned from the actual invocation.
|
2599
|
+
</devdoc>
|
2600
|
+
</member>
|
2601
|
+
<member name="T:Moq.Mock`1">
|
2602
|
+
<summary>
|
2603
|
+
Provides a mock implementation of <typeparamref name="T"/>.
|
2604
|
+
</summary><remarks>
|
2605
|
+
Any interface type can be used for mocking, but for classes, only abstract and virtual members can be mocked.
|
2606
|
+
<para>
|
2607
|
+
The behavior of the mock with regards to the setups and the actual calls is determined
|
2608
|
+
by the optional <see cref="T:Moq.MockBehavior"/> that can be passed to the <see cref="M:Moq.Mock`1.#ctor(Moq.MockBehavior)"/>
|
2609
|
+
constructor.
|
2610
|
+
</para>
|
2611
|
+
</remarks><typeparam name="T">Type to mock, which can be an interface or a class.</typeparam><example group="overview" order="0">
|
2612
|
+
The following example shows establishing setups with specific values
|
2613
|
+
for method invocations:
|
2614
|
+
<code>
|
2615
|
+
// Arrange
|
2616
|
+
var order = new Order(TALISKER, 50);
|
2617
|
+
var mock = new Mock<IWarehouse>();
|
2618
|
+
|
2619
|
+
mock.Setup(x => x.HasInventory(TALISKER, 50)).Returns(true);
|
2620
|
+
|
2621
|
+
// Act
|
2622
|
+
order.Fill(mock.Object);
|
2623
|
+
|
2624
|
+
// Assert
|
2625
|
+
Assert.True(order.IsFilled);
|
2626
|
+
</code>
|
2627
|
+
The following example shows how to use the <see cref="T:Moq.It"/> class
|
2628
|
+
to specify conditions for arguments instead of specific values:
|
2629
|
+
<code>
|
2630
|
+
// Arrange
|
2631
|
+
var order = new Order(TALISKER, 50);
|
2632
|
+
var mock = new Mock<IWarehouse>();
|
2633
|
+
|
2634
|
+
// shows how to expect a value within a range
|
2635
|
+
mock.Setup(x => x.HasInventory(
|
2636
|
+
It.IsAny<string>(),
|
2637
|
+
It.IsInRange(0, 100, Range.Inclusive)))
|
2638
|
+
.Returns(false);
|
2639
|
+
|
2640
|
+
// shows how to throw for unexpected calls.
|
2641
|
+
mock.Setup(x => x.Remove(
|
2642
|
+
It.IsAny<string>(),
|
2643
|
+
It.IsAny<int>()))
|
2644
|
+
.Throws(new InvalidOperationException());
|
2645
|
+
|
2646
|
+
// Act
|
2647
|
+
order.Fill(mock.Object);
|
2648
|
+
|
2649
|
+
// Assert
|
2650
|
+
Assert.False(order.IsFilled);
|
2651
|
+
</code>
|
2652
|
+
</example>
|
2653
|
+
</member>
|
2654
|
+
<member name="M:Moq.Mock`1.#ctor(System.Boolean)">
|
2655
|
+
<summary>
|
2656
|
+
Ctor invoked by AsTInterface exclusively.
|
2657
|
+
</summary>
|
2658
|
+
</member>
|
2659
|
+
<member name="M:Moq.Mock`1.#ctor">
|
2660
|
+
<summary>
|
2661
|
+
Initializes an instance of the mock with <see cref="F:Moq.MockBehavior.Default">default behavior</see>.
|
2662
|
+
</summary><example>
|
2663
|
+
<code>var mock = new Mock<IFormatProvider>();</code>
|
2664
|
+
</example>
|
2665
|
+
</member>
|
2666
|
+
<member name="M:Moq.Mock`1.#ctor(System.Object[])">
|
2667
|
+
<summary>
|
2668
|
+
Initializes an instance of the mock with <see cref="F:Moq.MockBehavior.Default">default behavior</see> and with
|
2669
|
+
the given constructor arguments for the class. (Only valid when <typeparamref name="T"/> is a class)
|
2670
|
+
</summary><remarks>
|
2671
|
+
The mock will try to find the best match constructor given the constructor arguments, and invoke that
|
2672
|
+
to initialize the instance. This applies only for classes, not interfaces.
|
2673
|
+
</remarks><example>
|
2674
|
+
<code>var mock = new Mock<MyProvider>(someArgument, 25);</code>
|
2675
|
+
</example><param name="args">Optional constructor arguments if the mocked type is a class.</param>
|
2676
|
+
</member>
|
2677
|
+
<member name="M:Moq.Mock`1.#ctor(Moq.MockBehavior)">
|
2678
|
+
<summary>
|
2679
|
+
Initializes an instance of the mock with the specified <see cref="T:Moq.MockBehavior">behavior</see>.
|
2680
|
+
</summary><example>
|
2681
|
+
<code>var mock = new Mock<IFormatProvider>(MockBehavior.Relaxed);</code>
|
2682
|
+
</example><param name="behavior">Behavior of the mock.</param>
|
2683
|
+
</member>
|
2684
|
+
<member name="M:Moq.Mock`1.#ctor(Moq.MockBehavior,System.Object[])">
|
2685
|
+
<summary>
|
2686
|
+
Initializes an instance of the mock with a specific <see cref="T:Moq.MockBehavior">behavior</see> with
|
2687
|
+
the given constructor arguments for the class.
|
2688
|
+
</summary><remarks>
|
2689
|
+
The mock will try to find the best match constructor given the constructor arguments, and invoke that
|
2690
|
+
to initialize the instance. This applies only to classes, not interfaces.
|
2691
|
+
</remarks><example>
|
2692
|
+
<code>var mock = new Mock<MyProvider>(someArgument, 25);</code>
|
2693
|
+
</example><param name="behavior">Behavior of the mock.</param><param name="args">Optional constructor arguments if the mocked type is a class.</param>
|
2694
|
+
</member>
|
2695
|
+
<member name="M:Moq.Mock`1.GetObject">
|
2696
|
+
<summary>
|
2697
|
+
Returns the mocked object value.
|
2698
|
+
</summary>
|
2699
|
+
</member>
|
2700
|
+
<member name="M:Moq.Mock`1.Setup(System.Linq.Expressions.Expression{System.Action{`0}})">
|
2701
|
+
<summary>
|
2702
|
+
Specifies a setup on the mocked type for a call to
|
2703
|
+
to a void method.
|
2704
|
+
</summary><remarks>
|
2705
|
+
If more than one setup is specified for the same method or property,
|
2706
|
+
the latest one wins and is the one that will be executed.
|
2707
|
+
</remarks><param name="expression">Lambda expression that specifies the expected method invocation.</param><example group="setups">
|
2708
|
+
<code>
|
2709
|
+
var mock = new Mock<IProcessor>();
|
2710
|
+
mock.Setup(x => x.Execute("ping"));
|
2711
|
+
</code>
|
2712
|
+
</example>
|
2713
|
+
</member>
|
2714
|
+
<member name="M:Moq.Mock`1.Setup``1(System.Linq.Expressions.Expression{System.Func{`0,``0}})">
|
2715
|
+
<summary>
|
2716
|
+
Specifies a setup on the mocked type for a call to
|
2717
|
+
to a value returning method.
|
2718
|
+
</summary><typeparam name="TResult">Type of the return value. Typically omitted as it can be inferred from the expression.</typeparam><remarks>
|
2719
|
+
If more than one setup is specified for the same method or property,
|
2720
|
+
the latest one wins and is the one that will be executed.
|
2721
|
+
</remarks><param name="expression">Lambda expression that specifies the method invocation.</param><example group="setups">
|
2722
|
+
<code>
|
2723
|
+
mock.Setup(x => x.HasInventory("Talisker", 50)).Returns(true);
|
2724
|
+
</code>
|
2725
|
+
</example>
|
2726
|
+
</member>
|
2727
|
+
<member name="M:Moq.Mock`1.SetupGet``1(System.Linq.Expressions.Expression{System.Func{`0,``0}})">
|
2728
|
+
<summary>
|
2729
|
+
Specifies a setup on the mocked type for a call to
|
2730
|
+
to a property getter.
|
2731
|
+
</summary><remarks>
|
2732
|
+
If more than one setup is set for the same property getter,
|
2733
|
+
the latest one wins and is the one that will be executed.
|
2734
|
+
</remarks><typeparam name="TProperty">Type of the property. Typically omitted as it can be inferred from the expression.</typeparam><param name="expression">Lambda expression that specifies the property getter.</param><example group="setups">
|
2735
|
+
<code>
|
2736
|
+
mock.SetupGet(x => x.Suspended)
|
2737
|
+
.Returns(true);
|
2738
|
+
</code>
|
2739
|
+
</example>
|
2740
|
+
</member>
|
2741
|
+
<member name="M:Moq.Mock`1.SetupSet``1(System.Action{`0})">
|
2742
|
+
<summary>
|
2743
|
+
Specifies a setup on the mocked type for a call to
|
2744
|
+
to a property setter.
|
2745
|
+
</summary><remarks>
|
2746
|
+
If more than one setup is set for the same property setter,
|
2747
|
+
the latest one wins and is the one that will be executed.
|
2748
|
+
<para>
|
2749
|
+
This overloads allows the use of a callback already
|
2750
|
+
typed for the property type.
|
2751
|
+
</para>
|
2752
|
+
</remarks><typeparam name="TProperty">Type of the property. Typically omitted as it can be inferred from the expression.</typeparam><param name="setterExpression">Lambda expression that sets a property to a value.</param><example group="setups">
|
2753
|
+
<code>
|
2754
|
+
mock.SetupSet(x => x.Suspended = true);
|
2755
|
+
</code>
|
2756
|
+
</example>
|
2757
|
+
</member>
|
2758
|
+
<member name="M:Moq.Mock`1.SetupSet(System.Action{`0})">
|
2759
|
+
<summary>
|
2760
|
+
Specifies a setup on the mocked type for a call to
|
2761
|
+
to a property setter.
|
2762
|
+
</summary><remarks>
|
2763
|
+
If more than one setup is set for the same property setter,
|
2764
|
+
the latest one wins and is the one that will be executed.
|
2765
|
+
</remarks><param name="setterExpression">Lambda expression that sets a property to a value.</param><example group="setups">
|
2766
|
+
<code>
|
2767
|
+
mock.SetupSet(x => x.Suspended = true);
|
2768
|
+
</code>
|
2769
|
+
</example>
|
2770
|
+
</member>
|
2771
|
+
<member name="M:Moq.Mock`1.SetupProperty``1(System.Linq.Expressions.Expression{System.Func{`0,``0}})">
|
2772
|
+
<summary>
|
2773
|
+
Specifies that the given property should have "property behavior",
|
2774
|
+
meaning that setting its value will cause it to be saved and
|
2775
|
+
later returned when the property is requested. (this is also
|
2776
|
+
known as "stubbing").
|
2777
|
+
</summary><typeparam name="TProperty">
|
2778
|
+
Type of the property, inferred from the property
|
2779
|
+
expression (does not need to be specified).
|
2780
|
+
</typeparam><param name="property">Property expression to stub.</param><example>
|
2781
|
+
If you have an interface with an int property <c>Value</c>, you might
|
2782
|
+
stub it using the following straightforward call:
|
2783
|
+
<code>
|
2784
|
+
var mock = new Mock<IHaveValue>();
|
2785
|
+
mock.Stub(v => v.Value);
|
2786
|
+
</code>
|
2787
|
+
After the <c>Stub</c> call has been issued, setting and
|
2788
|
+
retrieving the object value will behave as expected:
|
2789
|
+
<code>
|
2790
|
+
IHaveValue v = mock.Object;
|
2791
|
+
|
2792
|
+
v.Value = 5;
|
2793
|
+
Assert.Equal(5, v.Value);
|
2794
|
+
</code>
|
2795
|
+
</example>
|
2796
|
+
</member>
|
2797
|
+
<member name="M:Moq.Mock`1.SetupProperty``1(System.Linq.Expressions.Expression{System.Func{`0,``0}},``0)">
|
2798
|
+
<summary>
|
2799
|
+
Specifies that the given property should have "property behavior",
|
2800
|
+
meaning that setting its value will cause it to be saved and
|
2801
|
+
later returned when the property is requested. This overload
|
2802
|
+
allows setting the initial value for the property. (this is also
|
2803
|
+
known as "stubbing").
|
2804
|
+
</summary><typeparam name="TProperty">
|
2805
|
+
Type of the property, inferred from the property
|
2806
|
+
expression (does not need to be specified).
|
2807
|
+
</typeparam><param name="property">Property expression to stub.</param><param name="initialValue">Initial value for the property.</param><example>
|
2808
|
+
If you have an interface with an int property <c>Value</c>, you might
|
2809
|
+
stub it using the following straightforward call:
|
2810
|
+
<code>
|
2811
|
+
var mock = new Mock<IHaveValue>();
|
2812
|
+
mock.SetupProperty(v => v.Value, 5);
|
2813
|
+
</code>
|
2814
|
+
After the <c>SetupProperty</c> call has been issued, setting and
|
2815
|
+
retrieving the object value will behave as expected:
|
2816
|
+
<code>
|
2817
|
+
IHaveValue v = mock.Object;
|
2818
|
+
// Initial value was stored
|
2819
|
+
Assert.Equal(5, v.Value);
|
2820
|
+
|
2821
|
+
// New value set which changes the initial value
|
2822
|
+
v.Value = 6;
|
2823
|
+
Assert.Equal(6, v.Value);
|
2824
|
+
</code>
|
2825
|
+
</example>
|
2826
|
+
</member>
|
2827
|
+
<member name="M:Moq.Mock`1.SetupAllProperties">
|
2828
|
+
<summary>
|
2829
|
+
Specifies that the all properties on the mock should have "property behavior",
|
2830
|
+
meaning that setting its value will cause it to be saved and
|
2831
|
+
later returned when the property is requested. (this is also
|
2832
|
+
known as "stubbing"). The default value for each property will be the
|
2833
|
+
one generated as specified by the <see cref="P:Moq.Mock.DefaultValue"/> property for the mock.
|
2834
|
+
</summary><remarks>
|
2835
|
+
If the mock <see cref="P:Moq.Mock.DefaultValue"/> is set to <see cref="F:Moq.DefaultValue.Mock"/>,
|
2836
|
+
the mocked default values will also get all properties setup recursively.
|
2837
|
+
</remarks>
|
2838
|
+
</member>
|
2839
|
+
<member name="M:Moq.Mock`1.Verify(System.Linq.Expressions.Expression{System.Action{`0}})">
|
2840
|
+
<summary>
|
2841
|
+
Verifies that a specific invocation matching the given expression was performed on the mock. Use
|
2842
|
+
in conjuntion with the default <see cref="F:Moq.MockBehavior.Loose"/>.
|
2843
|
+
</summary><example group="verification">
|
2844
|
+
This example assumes that the mock has been used, and later we want to verify that a given
|
2845
|
+
invocation with specific parameters was performed:
|
2846
|
+
<code>
|
2847
|
+
var mock = new Mock<IProcessor>();
|
2848
|
+
// exercise mock
|
2849
|
+
//...
|
2850
|
+
// Will throw if the test code didn't call Execute with a "ping" string argument.
|
2851
|
+
mock.Verify(proc => proc.Execute("ping"));
|
2852
|
+
</code>
|
2853
|
+
</example><exception cref="T:Moq.MockException">The invocation was not performed on the mock.</exception><param name="expression">Expression to verify.</param>
|
2854
|
+
</member>
|
2855
|
+
<member name="M:Moq.Mock`1.Verify(System.Linq.Expressions.Expression{System.Action{`0}},Moq.Times)">
|
2856
|
+
<summary>
|
2857
|
+
Verifies that a specific invocation matching the given expression was performed on the mock. Use
|
2858
|
+
in conjuntion with the default <see cref="F:Moq.MockBehavior.Loose"/>.
|
2859
|
+
</summary><exception cref="T:Moq.MockException">
|
2860
|
+
The invocation was not call the times specified by
|
2861
|
+
<paramref name="times"/>.
|
2862
|
+
</exception><param name="expression">Expression to verify.</param><param name="times">The number of times a method is allowed to be called.</param>
|
2863
|
+
</member>
|
2864
|
+
<member name="M:Moq.Mock`1.Verify(System.Linq.Expressions.Expression{System.Action{`0}},System.String)">
|
2865
|
+
<summary>
|
2866
|
+
Verifies that a specific invocation matching the given expression was performed on the mock,
|
2867
|
+
specifying a failure error message. Use in conjuntion with the default
|
2868
|
+
<see cref="F:Moq.MockBehavior.Loose"/>.
|
2869
|
+
</summary><example group="verification">
|
2870
|
+
This example assumes that the mock has been used, and later we want to verify that a given
|
2871
|
+
invocation with specific parameters was performed:
|
2872
|
+
<code>
|
2873
|
+
var mock = new Mock<IProcessor>();
|
2874
|
+
// exercise mock
|
2875
|
+
//...
|
2876
|
+
// Will throw if the test code didn't call Execute with a "ping" string argument.
|
2877
|
+
mock.Verify(proc => proc.Execute("ping"));
|
2878
|
+
</code>
|
2879
|
+
</example><exception cref="T:Moq.MockException">The invocation was not performed on the mock.</exception><param name="expression">Expression to verify.</param><param name="failMessage">Message to show if verification fails.</param>
|
2880
|
+
</member>
|
2881
|
+
<member name="M:Moq.Mock`1.Verify(System.Linq.Expressions.Expression{System.Action{`0}},Moq.Times,System.String)">
|
2882
|
+
<summary>
|
2883
|
+
Verifies that a specific invocation matching the given expression was performed on the mock,
|
2884
|
+
specifying a failure error message. Use in conjuntion with the default
|
2885
|
+
<see cref="F:Moq.MockBehavior.Loose"/>.
|
2886
|
+
</summary><exception cref="T:Moq.MockException">
|
2887
|
+
The invocation was not call the times specified by
|
2888
|
+
<paramref name="times"/>.
|
2889
|
+
</exception><param name="expression">Expression to verify.</param><param name="times">The number of times a method is allowed to be called.</param><param name="failMessage">Message to show if verification fails.</param>
|
2890
|
+
</member>
|
2891
|
+
<member name="M:Moq.Mock`1.Verify``1(System.Linq.Expressions.Expression{System.Func{`0,``0}})">
|
2892
|
+
<summary>
|
2893
|
+
Verifies that a specific invocation matching the given expression was performed on the mock. Use
|
2894
|
+
in conjuntion with the default <see cref="F:Moq.MockBehavior.Loose"/>.
|
2895
|
+
</summary><example group="verification">
|
2896
|
+
This example assumes that the mock has been used, and later we want to verify that a given
|
2897
|
+
invocation with specific parameters was performed:
|
2898
|
+
<code>
|
2899
|
+
var mock = new Mock<IWarehouse>();
|
2900
|
+
// exercise mock
|
2901
|
+
//...
|
2902
|
+
// Will throw if the test code didn't call HasInventory.
|
2903
|
+
mock.Verify(warehouse => warehouse.HasInventory(TALISKER, 50));
|
2904
|
+
</code>
|
2905
|
+
</example><exception cref="T:Moq.MockException">The invocation was not performed on the mock.</exception><param name="expression">Expression to verify.</param><typeparam name="TResult">Type of return value from the expression.</typeparam>
|
2906
|
+
</member>
|
2907
|
+
<member name="M:Moq.Mock`1.Verify``1(System.Linq.Expressions.Expression{System.Func{`0,``0}},Moq.Times)">
|
2908
|
+
<summary>
|
2909
|
+
Verifies that a specific invocation matching the given
|
2910
|
+
expression was performed on the mock. Use in conjuntion
|
2911
|
+
with the default <see cref="F:Moq.MockBehavior.Loose"/>.
|
2912
|
+
</summary><exception cref="T:Moq.MockException">
|
2913
|
+
The invocation was not call the times specified by
|
2914
|
+
<paramref name="times"/>.
|
2915
|
+
</exception><param name="expression">Expression to verify.</param><param name="times">The number of times a method is allowed to be called.</param><typeparam name="TResult">Type of return value from the expression.</typeparam>
|
2916
|
+
</member>
|
2917
|
+
<member name="M:Moq.Mock`1.Verify``1(System.Linq.Expressions.Expression{System.Func{`0,``0}},System.String)">
|
2918
|
+
<summary>
|
2919
|
+
Verifies that a specific invocation matching the given
|
2920
|
+
expression was performed on the mock, specifying a failure
|
2921
|
+
error message.
|
2922
|
+
</summary><example group="verification">
|
2923
|
+
This example assumes that the mock has been used,
|
2924
|
+
and later we want to verify that a given invocation
|
2925
|
+
with specific parameters was performed:
|
2926
|
+
<code>
|
2927
|
+
var mock = new Mock<IWarehouse>();
|
2928
|
+
// exercise mock
|
2929
|
+
//...
|
2930
|
+
// Will throw if the test code didn't call HasInventory.
|
2931
|
+
mock.Verify(warehouse => warehouse.HasInventory(TALISKER, 50), "When filling orders, inventory has to be checked");
|
2932
|
+
</code>
|
2933
|
+
</example><exception cref="T:Moq.MockException">The invocation was not performed on the mock.</exception><param name="expression">Expression to verify.</param><param name="failMessage">Message to show if verification fails.</param><typeparam name="TResult">Type of return value from the expression.</typeparam>
|
2934
|
+
</member>
|
2935
|
+
<member name="M:Moq.Mock`1.Verify``1(System.Linq.Expressions.Expression{System.Func{`0,``0}},Moq.Times,System.String)">
|
2936
|
+
<summary>
|
2937
|
+
Verifies that a specific invocation matching the given
|
2938
|
+
expression was performed on the mock, specifying a failure
|
2939
|
+
error message.
|
2940
|
+
</summary><exception cref="T:Moq.MockException">
|
2941
|
+
The invocation was not call the times specified by
|
2942
|
+
<paramref name="times"/>.
|
2943
|
+
</exception><param name="expression">Expression to verify.</param><param name="times">The number of times a method is allowed to be called.</param><param name="failMessage">Message to show if verification fails.</param><typeparam name="TResult">Type of return value from the expression.</typeparam>
|
2944
|
+
</member>
|
2945
|
+
<member name="M:Moq.Mock`1.VerifyGet``1(System.Linq.Expressions.Expression{System.Func{`0,``0}})">
|
2946
|
+
<summary>
|
2947
|
+
Verifies that a property was read on the mock.
|
2948
|
+
</summary><example group="verification">
|
2949
|
+
This example assumes that the mock has been used,
|
2950
|
+
and later we want to verify that a given property
|
2951
|
+
was retrieved from it:
|
2952
|
+
<code>
|
2953
|
+
var mock = new Mock<IWarehouse>();
|
2954
|
+
// exercise mock
|
2955
|
+
//...
|
2956
|
+
// Will throw if the test code didn't retrieve the IsClosed property.
|
2957
|
+
mock.VerifyGet(warehouse => warehouse.IsClosed);
|
2958
|
+
</code>
|
2959
|
+
</example><exception cref="T:Moq.MockException">The invocation was not performed on the mock.</exception><param name="expression">Expression to verify.</param><typeparam name="TProperty">
|
2960
|
+
Type of the property to verify. Typically omitted as it can
|
2961
|
+
be inferred from the expression's return type.
|
2962
|
+
</typeparam>
|
2963
|
+
</member>
|
2964
|
+
<member name="M:Moq.Mock`1.VerifyGet``1(System.Linq.Expressions.Expression{System.Func{`0,``0}},Moq.Times)">
|
2965
|
+
<summary>
|
2966
|
+
Verifies that a property was read on the mock.
|
2967
|
+
</summary><exception cref="T:Moq.MockException">
|
2968
|
+
The invocation was not call the times specified by
|
2969
|
+
<paramref name="times"/>.
|
2970
|
+
</exception><param name="times">The number of times a method is allowed to be called.</param><param name="expression">Expression to verify.</param><typeparam name="TProperty">
|
2971
|
+
Type of the property to verify. Typically omitted as it can
|
2972
|
+
be inferred from the expression's return type.
|
2973
|
+
</typeparam>
|
2974
|
+
</member>
|
2975
|
+
<member name="M:Moq.Mock`1.VerifyGet``1(System.Linq.Expressions.Expression{System.Func{`0,``0}},System.String)">
|
2976
|
+
<summary>
|
2977
|
+
Verifies that a property was read on the mock, specifying a failure
|
2978
|
+
error message.
|
2979
|
+
</summary><example group="verification">
|
2980
|
+
This example assumes that the mock has been used,
|
2981
|
+
and later we want to verify that a given property
|
2982
|
+
was retrieved from it:
|
2983
|
+
<code>
|
2984
|
+
var mock = new Mock<IWarehouse>();
|
2985
|
+
// exercise mock
|
2986
|
+
//...
|
2987
|
+
// Will throw if the test code didn't retrieve the IsClosed property.
|
2988
|
+
mock.VerifyGet(warehouse => warehouse.IsClosed);
|
2989
|
+
</code>
|
2990
|
+
</example><exception cref="T:Moq.MockException">The invocation was not performed on the mock.</exception><param name="expression">Expression to verify.</param><param name="failMessage">Message to show if verification fails.</param><typeparam name="TProperty">
|
2991
|
+
Type of the property to verify. Typically omitted as it can
|
2992
|
+
be inferred from the expression's return type.
|
2993
|
+
</typeparam>
|
2994
|
+
</member>
|
2995
|
+
<member name="M:Moq.Mock`1.VerifyGet``1(System.Linq.Expressions.Expression{System.Func{`0,``0}},Moq.Times,System.String)">
|
2996
|
+
<summary>
|
2997
|
+
Verifies that a property was read on the mock, specifying a failure
|
2998
|
+
error message.
|
2999
|
+
</summary><exception cref="T:Moq.MockException">
|
3000
|
+
The invocation was not call the times specified by
|
3001
|
+
<paramref name="times"/>.
|
3002
|
+
</exception><param name="times">The number of times a method is allowed to be called.</param><param name="expression">Expression to verify.</param><param name="failMessage">Message to show if verification fails.</param><typeparam name="TProperty">
|
3003
|
+
Type of the property to verify. Typically omitted as it can
|
3004
|
+
be inferred from the expression's return type.
|
3005
|
+
</typeparam>
|
3006
|
+
</member>
|
3007
|
+
<member name="M:Moq.Mock`1.VerifySet(System.Action{`0})">
|
3008
|
+
<summary>
|
3009
|
+
Verifies that a property was set on the mock.
|
3010
|
+
</summary><example group="verification">
|
3011
|
+
This example assumes that the mock has been used,
|
3012
|
+
and later we want to verify that a given property
|
3013
|
+
was set on it:
|
3014
|
+
<code>
|
3015
|
+
var mock = new Mock<IWarehouse>();
|
3016
|
+
// exercise mock
|
3017
|
+
//...
|
3018
|
+
// Will throw if the test code didn't set the IsClosed property.
|
3019
|
+
mock.VerifySet(warehouse => warehouse.IsClosed = true);
|
3020
|
+
</code>
|
3021
|
+
</example><exception cref="T:Moq.MockException">The invocation was not performed on the mock.</exception><param name="setterExpression">Expression to verify.</param>
|
3022
|
+
</member>
|
3023
|
+
<member name="M:Moq.Mock`1.VerifySet(System.Action{`0},Moq.Times)">
|
3024
|
+
<summary>
|
3025
|
+
Verifies that a property was set on the mock.
|
3026
|
+
</summary><exception cref="T:Moq.MockException">
|
3027
|
+
The invocation was not call the times specified by
|
3028
|
+
<paramref name="times"/>.
|
3029
|
+
</exception><param name="times">The number of times a method is allowed to be called.</param><param name="setterExpression">Expression to verify.</param>
|
3030
|
+
</member>
|
3031
|
+
<member name="M:Moq.Mock`1.VerifySet(System.Action{`0},System.String)">
|
3032
|
+
<summary>
|
3033
|
+
Verifies that a property was set on the mock, specifying
|
3034
|
+
a failure message.
|
3035
|
+
</summary><example group="verification">
|
3036
|
+
This example assumes that the mock has been used,
|
3037
|
+
and later we want to verify that a given property
|
3038
|
+
was set on it:
|
3039
|
+
<code>
|
3040
|
+
var mock = new Mock<IWarehouse>();
|
3041
|
+
// exercise mock
|
3042
|
+
//...
|
3043
|
+
// Will throw if the test code didn't set the IsClosed property.
|
3044
|
+
mock.VerifySet(warehouse => warehouse.IsClosed = true, "Warehouse should always be closed after the action");
|
3045
|
+
</code>
|
3046
|
+
</example><exception cref="T:Moq.MockException">The invocation was not performed on the mock.</exception><param name="setterExpression">Expression to verify.</param><param name="failMessage">Message to show if verification fails.</param>
|
3047
|
+
</member>
|
3048
|
+
<member name="M:Moq.Mock`1.VerifySet(System.Action{`0},Moq.Times,System.String)">
|
3049
|
+
<summary>
|
3050
|
+
Verifies that a property was set on the mock, specifying
|
3051
|
+
a failure message.
|
3052
|
+
</summary><exception cref="T:Moq.MockException">
|
3053
|
+
The invocation was not call the times specified by
|
3054
|
+
<paramref name="times"/>.
|
3055
|
+
</exception><param name="times">The number of times a method is allowed to be called.</param><param name="setterExpression">Expression to verify.</param><param name="failMessage">Message to show if verification fails.</param>
|
3056
|
+
</member>
|
3057
|
+
<member name="M:Moq.Mock`1.As``1">
|
3058
|
+
<summary>
|
3059
|
+
Adds an interface implementation to the mock,
|
3060
|
+
allowing setups to be specified for it.
|
3061
|
+
</summary><remarks>
|
3062
|
+
This method can only be called before the first use
|
3063
|
+
of the mock <see cref="P:Moq.Mock`1.Object"/> property, at which
|
3064
|
+
point the runtime type has already been generated
|
3065
|
+
and no more interfaces can be added to it.
|
3066
|
+
<para>
|
3067
|
+
Also, <typeparamref name="TInterface"/> must be an
|
3068
|
+
interface and not a class, which must be specified
|
3069
|
+
when creating the mock instead.
|
3070
|
+
</para>
|
3071
|
+
</remarks><exception cref="T:System.InvalidOperationException">
|
3072
|
+
The mock type
|
3073
|
+
has already been generated by accessing the <see cref="P:Moq.Mock`1.Object"/> property.
|
3074
|
+
</exception><exception cref="T:System.ArgumentException">
|
3075
|
+
The <typeparamref name="TInterface"/> specified
|
3076
|
+
is not an interface.
|
3077
|
+
</exception><example>
|
3078
|
+
The following example creates a mock for the main interface
|
3079
|
+
and later adds <see cref="T:System.IDisposable"/> to it to verify
|
3080
|
+
it's called by the consumer code:
|
3081
|
+
<code>
|
3082
|
+
var mock = new Mock<IProcessor>();
|
3083
|
+
mock.Setup(x => x.Execute("ping"));
|
3084
|
+
|
3085
|
+
// add IDisposable interface
|
3086
|
+
var disposable = mock.As<IDisposable>();
|
3087
|
+
disposable.Setup(d => d.Dispose()).Verifiable();
|
3088
|
+
</code>
|
3089
|
+
</example><typeparam name="TInterface">Type of interface to cast the mock to.</typeparam>
|
3090
|
+
</member>
|
3091
|
+
<member name="M:Moq.Mock`1.Raise(System.Action{`0},System.EventArgs)">
|
3092
|
+
<summary>
|
3093
|
+
Raises the event referenced in <paramref name="eventExpression"/> using
|
3094
|
+
the given <paramref name="sender"/> and <paramref name="args"/> arguments.
|
3095
|
+
</summary><exception cref="T:System.ArgumentException">
|
3096
|
+
The <paramref name="args"/> argument is
|
3097
|
+
invalid for the target event invocation, or the <paramref name="eventExpression"/> is
|
3098
|
+
not an event attach or detach expression.
|
3099
|
+
</exception><example>
|
3100
|
+
The following example shows how to raise a <see cref="E:System.ComponentModel.INotifyPropertyChanged.PropertyChanged"/> event:
|
3101
|
+
<code>
|
3102
|
+
var mock = new Mock<IViewModel>();
|
3103
|
+
|
3104
|
+
mock.Raise(x => x.PropertyChanged -= null, new PropertyChangedEventArgs("Name"));
|
3105
|
+
</code>
|
3106
|
+
</example><example>
|
3107
|
+
This example shows how to invoke an event with a custom event arguments
|
3108
|
+
class in a view that will cause its corresponding presenter to
|
3109
|
+
react by changing its state:
|
3110
|
+
<code>
|
3111
|
+
var mockView = new Mock<IOrdersView>();
|
3112
|
+
var presenter = new OrdersPresenter(mockView.Object);
|
3113
|
+
|
3114
|
+
// Check that the presenter has no selection by default
|
3115
|
+
Assert.Null(presenter.SelectedOrder);
|
3116
|
+
|
3117
|
+
// Raise the event with a specific arguments data
|
3118
|
+
mockView.Raise(v => v.SelectionChanged += null, new OrderEventArgs { Order = new Order("moq", 500) });
|
3119
|
+
|
3120
|
+
// Now the presenter reacted to the event, and we have a selected order
|
3121
|
+
Assert.NotNull(presenter.SelectedOrder);
|
3122
|
+
Assert.Equal("moq", presenter.SelectedOrder.ProductName);
|
3123
|
+
</code>
|
3124
|
+
</example>
|
3125
|
+
</member>
|
3126
|
+
<member name="M:Moq.Mock`1.Raise(System.Action{`0},System.Object[])">
|
3127
|
+
<summary>
|
3128
|
+
Raises the event referenced in <paramref name="eventExpression"/> using
|
3129
|
+
the given <paramref name="sender"/> and <paramref name="args"/> arguments
|
3130
|
+
for a non-EventHandler typed event.
|
3131
|
+
</summary><exception cref="T:System.ArgumentException">
|
3132
|
+
The <paramref name="args"/> arguments are
|
3133
|
+
invalid for the target event invocation, or the <paramref name="eventExpression"/> is
|
3134
|
+
not an event attach or detach expression.
|
3135
|
+
</exception><example>
|
3136
|
+
The following example shows how to raise a custom event that does not adhere to
|
3137
|
+
the standard <c>EventHandler</c>:
|
3138
|
+
<code>
|
3139
|
+
var mock = new Mock<IViewModel>();
|
3140
|
+
|
3141
|
+
mock.Raise(x => x.MyEvent -= null, "Name", bool, 25);
|
3142
|
+
</code>
|
3143
|
+
</example>
|
3144
|
+
</member>
|
3145
|
+
<member name="M:Moq.Mock`1.Expect(System.Linq.Expressions.Expression{System.Action{`0}})">
|
3146
|
+
<summary>
|
3147
|
+
Obsolete.
|
3148
|
+
</summary>
|
3149
|
+
</member>
|
3150
|
+
<member name="M:Moq.Mock`1.Expect``1(System.Linq.Expressions.Expression{System.Func{`0,``0}})">
|
3151
|
+
<summary>
|
3152
|
+
Obsolete.
|
3153
|
+
</summary>
|
3154
|
+
</member>
|
3155
|
+
<member name="M:Moq.Mock`1.ExpectGet``1(System.Linq.Expressions.Expression{System.Func{`0,``0}})">
|
3156
|
+
<summary>
|
3157
|
+
Obsolete.
|
3158
|
+
</summary>
|
3159
|
+
</member>
|
3160
|
+
<member name="M:Moq.Mock`1.ExpectSet``1(System.Linq.Expressions.Expression{System.Func{`0,``0}})">
|
3161
|
+
<summary>
|
3162
|
+
Obsolete.
|
3163
|
+
</summary>
|
3164
|
+
</member>
|
3165
|
+
<member name="M:Moq.Mock`1.ExpectSet``1(System.Linq.Expressions.Expression{System.Func{`0,``0}},``0)">
|
3166
|
+
<summary>
|
3167
|
+
Obsolete.
|
3168
|
+
</summary>
|
3169
|
+
</member>
|
3170
|
+
<member name="P:Moq.Mock`1.Object">
|
3171
|
+
<summary>
|
3172
|
+
Exposes the mocked object instance.
|
3173
|
+
</summary>
|
3174
|
+
</member>
|
3175
|
+
<member name="T:Moq.MockLegacyExtensions">
|
3176
|
+
<summary>
|
3177
|
+
Provides legacy API members as extensions so that
|
3178
|
+
existing code continues to compile, but new code
|
3179
|
+
doesn't see then.
|
3180
|
+
</summary>
|
3181
|
+
</member>
|
3182
|
+
<member name="M:Moq.MockLegacyExtensions.SetupSet``2(Moq.Mock{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1)">
|
3183
|
+
<summary>
|
3184
|
+
Obsolete.
|
3185
|
+
</summary>
|
3186
|
+
</member>
|
3187
|
+
<member name="M:Moq.MockLegacyExtensions.VerifySet``2(Moq.Mock{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1)">
|
3188
|
+
<summary>
|
3189
|
+
Obsolete.
|
3190
|
+
</summary>
|
3191
|
+
</member>
|
3192
|
+
<member name="M:Moq.MockLegacyExtensions.VerifySet``2(Moq.Mock{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
|
3193
|
+
<summary>
|
3194
|
+
Obsolete.
|
3195
|
+
</summary>
|
3196
|
+
</member>
|
3197
|
+
<member name="T:Moq.FluentMockContext">
|
3198
|
+
<summary>
|
3199
|
+
Tracks the current mock and interception context.
|
3200
|
+
</summary>
|
3201
|
+
</member>
|
3202
|
+
<member name="P:Moq.FluentMockContext.IsActive">
|
3203
|
+
<summary>
|
3204
|
+
Having an active fluent mock context means that the invocation
|
3205
|
+
is being performed in "trial" mode, just to gather the
|
3206
|
+
target method and arguments that need to be matched later
|
3207
|
+
when the actual invocation is made.
|
3208
|
+
</summary>
|
3209
|
+
</member>
|
3210
|
+
<member name="T:Moq.MockDefaultValueProvider">
|
3211
|
+
<summary>
|
3212
|
+
A <see cref="T:Moq.IDefaultValueProvider"/> that returns an empty default value
|
3213
|
+
for non-mockeable types, and mocks for all other types (interfaces and
|
3214
|
+
non-sealed classes) that can be mocked.
|
3215
|
+
</summary>
|
3216
|
+
</member>
|
3217
|
+
<member name="T:Moq.MockedEvent`1">
|
3218
|
+
<summary>
|
3219
|
+
Provides a typed <see cref="T:Moq.MockedEvent"/> for a
|
3220
|
+
specific type of <see cref="T:System.EventArgs"/>.
|
3221
|
+
</summary>
|
3222
|
+
<typeparam name="TEventArgs">The type of event arguments required by the event.</typeparam>
|
3223
|
+
<remarks>
|
3224
|
+
The mocked event can either be a <see cref="T:System.EventHandler`1"/> or custom
|
3225
|
+
event handler which follows .NET practice of providing <c>object sender, EventArgs args</c>
|
3226
|
+
kind of signature.
|
3227
|
+
</remarks>
|
3228
|
+
</member>
|
3229
|
+
<member name="M:Moq.MockedEvent`1.Raise(`0)">
|
3230
|
+
<summary>
|
3231
|
+
Raises the associated event with the given
|
3232
|
+
event argument data.
|
3233
|
+
</summary>
|
3234
|
+
<param name="args">Data to pass to the event.</param>
|
3235
|
+
</member>
|
3236
|
+
<member name="M:Moq.MockedEvent`1.op_Implicit(Moq.MockedEvent{`0})~System.EventHandler{`0}">
|
3237
|
+
<summary>
|
3238
|
+
Provides support for attaching a <see cref="T:Moq.MockedEvent`1"/> to
|
3239
|
+
a generic <see cref="T:System.EventHandler`1"/> event.
|
3240
|
+
</summary>
|
3241
|
+
<param name="mockEvent">Event to convert.</param>
|
3242
|
+
</member>
|
3243
|
+
<member name="M:Moq.MockedEvent`1.Handle(System.Object,`0)">
|
3244
|
+
<summary>
|
3245
|
+
Provided solely to allow the interceptor to determine when the attached
|
3246
|
+
handler is coming from this mocked event so we can assign the
|
3247
|
+
corresponding EventInfo for it.
|
3248
|
+
</summary>
|
3249
|
+
</member>
|
3250
|
+
<member name="T:Moq.MockExtensions">
|
3251
|
+
<summary>
|
3252
|
+
Provides additional methods on mocks.
|
3253
|
+
</summary>
|
3254
|
+
<devdoc>
|
3255
|
+
Provided as extension methods as they confuse the compiler
|
3256
|
+
with the overloads taking Action.
|
3257
|
+
</devdoc>
|
3258
|
+
</member>
|
3259
|
+
<member name="M:Moq.MockExtensions.SetupSet``2(Moq.Mock{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}})">
|
3260
|
+
<summary>
|
3261
|
+
Specifies a setup on the mocked type for a call to
|
3262
|
+
to a property setter, regardless of its value.
|
3263
|
+
</summary>
|
3264
|
+
<remarks>
|
3265
|
+
If more than one setup is set for the same property setter,
|
3266
|
+
the latest one wins and is the one that will be executed.
|
3267
|
+
</remarks>
|
3268
|
+
<typeparam name="TProperty">Type of the property. Typically omitted as it can be inferred from the expression.</typeparam>
|
3269
|
+
<typeparam name="T">Type of the mock.</typeparam>
|
3270
|
+
<param name="mock">The target mock for the setup.</param>
|
3271
|
+
<param name="expression">Lambda expression that specifies the property setter.</param>
|
3272
|
+
<example group="setups">
|
3273
|
+
<code>
|
3274
|
+
mock.SetupSet(x => x.Suspended);
|
3275
|
+
</code>
|
3276
|
+
</example>
|
3277
|
+
<devdoc>
|
3278
|
+
This method is not legacy, but must be on an extension method to avoid
|
3279
|
+
confusing the compiler with the new Action syntax.
|
3280
|
+
</devdoc>
|
3281
|
+
</member>
|
3282
|
+
<member name="M:Moq.MockExtensions.VerifySet``2(Moq.Mock{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}})">
|
3283
|
+
<summary>
|
3284
|
+
Verifies that a property has been set on the mock, regarless of its value.
|
3285
|
+
</summary>
|
3286
|
+
<example group="verification">
|
3287
|
+
This example assumes that the mock has been used,
|
3288
|
+
and later we want to verify that a given invocation
|
3289
|
+
with specific parameters was performed:
|
3290
|
+
<code>
|
3291
|
+
var mock = new Mock<IWarehouse>();
|
3292
|
+
// exercise mock
|
3293
|
+
//...
|
3294
|
+
// Will throw if the test code didn't set the IsClosed property.
|
3295
|
+
mock.VerifySet(warehouse => warehouse.IsClosed);
|
3296
|
+
</code>
|
3297
|
+
</example>
|
3298
|
+
<exception cref="T:Moq.MockException">The invocation was not performed on the mock.</exception>
|
3299
|
+
<param name="expression">Expression to verify.</param>
|
3300
|
+
<param name="mock">The mock instance.</param>
|
3301
|
+
<typeparam name="T">Mocked type.</typeparam>
|
3302
|
+
<typeparam name="TProperty">Type of the property to verify. Typically omitted as it can
|
3303
|
+
be inferred from the expression's return type.</typeparam>
|
3304
|
+
</member>
|
3305
|
+
<member name="M:Moq.MockExtensions.VerifySet``2(Moq.Mock{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
|
3306
|
+
<summary>
|
3307
|
+
Verifies that a property has been set on the mock, specifying a failure
|
3308
|
+
error message.
|
3309
|
+
</summary>
|
3310
|
+
<example group="verification">
|
3311
|
+
This example assumes that the mock has been used,
|
3312
|
+
and later we want to verify that a given invocation
|
3313
|
+
with specific parameters was performed:
|
3314
|
+
<code>
|
3315
|
+
var mock = new Mock<IWarehouse>();
|
3316
|
+
// exercise mock
|
3317
|
+
//...
|
3318
|
+
// Will throw if the test code didn't set the IsClosed property.
|
3319
|
+
mock.VerifySet(warehouse => warehouse.IsClosed);
|
3320
|
+
</code>
|
3321
|
+
</example>
|
3322
|
+
<exception cref="T:Moq.MockException">The invocation was not performed on the mock.</exception>
|
3323
|
+
<param name="expression">Expression to verify.</param>
|
3324
|
+
<param name="failMessage">Message to show if verification fails.</param>
|
3325
|
+
<param name="mock">The mock instance.</param>
|
3326
|
+
<typeparam name="T">Mocked type.</typeparam>
|
3327
|
+
<typeparam name="TProperty">Type of the property to verify. Typically omitted as it can
|
3328
|
+
be inferred from the expression's return type.</typeparam>
|
3329
|
+
</member>
|
3330
|
+
<member name="M:Moq.MockExtensions.VerifySet``2(Moq.Mock{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},Moq.Times)">
|
3331
|
+
<summary>
|
3332
|
+
Verifies that a property has been set on the mock, regardless
|
3333
|
+
of the value but only the specified number of times.
|
3334
|
+
</summary>
|
3335
|
+
<example group="verification">
|
3336
|
+
This example assumes that the mock has been used,
|
3337
|
+
and later we want to verify that a given invocation
|
3338
|
+
with specific parameters was performed:
|
3339
|
+
<code>
|
3340
|
+
var mock = new Mock<IWarehouse>();
|
3341
|
+
// exercise mock
|
3342
|
+
//...
|
3343
|
+
// Will throw if the test code didn't set the IsClosed property.
|
3344
|
+
mock.VerifySet(warehouse => warehouse.IsClosed);
|
3345
|
+
</code>
|
3346
|
+
</example>
|
3347
|
+
<exception cref="T:Moq.MockException">The invocation was not performed on the mock.</exception>
|
3348
|
+
<exception cref="T:Moq.MockException">The invocation was not call the times specified by
|
3349
|
+
<paramref name="times"/>.</exception>
|
3350
|
+
<param name="mock">The mock instance.</param>
|
3351
|
+
<typeparam name="T">Mocked type.</typeparam>
|
3352
|
+
<param name="times">The number of times a method is allowed to be called.</param>
|
3353
|
+
<param name="expression">Expression to verify.</param>
|
3354
|
+
<typeparam name="TProperty">Type of the property to verify. Typically omitted as it can
|
3355
|
+
be inferred from the expression's return type.</typeparam>
|
3356
|
+
</member>
|
3357
|
+
<member name="M:Moq.MockExtensions.VerifySet``2(Moq.Mock{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},Moq.Times,System.String)">
|
3358
|
+
<summary>
|
3359
|
+
Verifies that a property has been set on the mock, regardless
|
3360
|
+
of the value but only the specified number of times, and specifying a failure
|
3361
|
+
error message.
|
3362
|
+
</summary>
|
3363
|
+
<example group="verification">
|
3364
|
+
This example assumes that the mock has been used,
|
3365
|
+
and later we want to verify that a given invocation
|
3366
|
+
with specific parameters was performed:
|
3367
|
+
<code>
|
3368
|
+
var mock = new Mock<IWarehouse>();
|
3369
|
+
// exercise mock
|
3370
|
+
//...
|
3371
|
+
// Will throw if the test code didn't set the IsClosed property.
|
3372
|
+
mock.VerifySet(warehouse => warehouse.IsClosed);
|
3373
|
+
</code>
|
3374
|
+
</example>
|
3375
|
+
<exception cref="T:Moq.MockException">The invocation was not performed on the mock.</exception>
|
3376
|
+
<exception cref="T:Moq.MockException">The invocation was not call the times specified by
|
3377
|
+
<paramref name="times"/>.</exception>
|
3378
|
+
<param name="mock">The mock instance.</param>
|
3379
|
+
<typeparam name="T">Mocked type.</typeparam>
|
3380
|
+
<param name="times">The number of times a method is allowed to be called.</param>
|
3381
|
+
<param name="failMessage">Message to show if verification fails.</param>
|
3382
|
+
<param name="expression">Expression to verify.</param>
|
3383
|
+
<typeparam name="TProperty">Type of the property to verify. Typically omitted as it can
|
3384
|
+
be inferred from the expression's return type.</typeparam>
|
3385
|
+
</member>
|
3386
|
+
<member name="T:Moq.Stub.StubExtensions">
|
3387
|
+
<summary>
|
3388
|
+
Legacy Stub stuff, moved to the core API.
|
3389
|
+
</summary>
|
3390
|
+
</member>
|
3391
|
+
<member name="M:Moq.Stub.StubExtensions.Stub``2(Moq.Mock{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}})">
|
3392
|
+
<summary>
|
3393
|
+
Obsolete. Use <see cref="M:Moq.Mock`1.SetupProperty``1(System.Linq.Expressions.Expression{System.Func{`0,``0}})"/>.
|
3394
|
+
</summary>
|
3395
|
+
</member>
|
3396
|
+
<member name="M:Moq.Stub.StubExtensions.Stub``2(Moq.Mock{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1)">
|
3397
|
+
<summary>
|
3398
|
+
Obsolete. Use <see cref="M:Moq.Mock`1.SetupProperty``1(System.Linq.Expressions.Expression{System.Func{`0,``0}},``0)"/>.
|
3399
|
+
</summary>
|
3400
|
+
</member>
|
3401
|
+
<member name="M:Moq.Stub.StubExtensions.StubAll``1(Moq.Mock{``0})">
|
3402
|
+
<summary>
|
3403
|
+
Obsolete. Use <see cref="M:Moq.Mock`1.SetupAllProperties"/>.
|
3404
|
+
</summary>
|
3405
|
+
</member>
|
3406
|
+
<member name="T:Moq.Times">
|
3407
|
+
<summary>
|
3408
|
+
Defines the number of invocations allowed by a mocked method.
|
3409
|
+
</summary>
|
3410
|
+
</member>
|
3411
|
+
<member name="M:Moq.Times.AtLeast(System.Int32)">
|
3412
|
+
<summary>
|
3413
|
+
Specifies that a mocked method should be invoked <paramref name="times"/> times as minimum.
|
3414
|
+
</summary>
|
3415
|
+
<param name="callCount">The minimun number of times.</param>
|
3416
|
+
<returns>An object defining the allowed number of invocations.</returns>
|
3417
|
+
</member>
|
3418
|
+
<member name="M:Moq.Times.AtLeastOnce">
|
3419
|
+
<summary>
|
3420
|
+
Specifies that a mocked method should be invoked one time as minimum.
|
3421
|
+
</summary>
|
3422
|
+
<returns>An object defining the allowed number of invocations.</returns>
|
3423
|
+
</member>
|
3424
|
+
<member name="M:Moq.Times.AtMost(System.Int32)">
|
3425
|
+
<summary>
|
3426
|
+
Specifies that a mocked method should be invoked <paramref name="times"/> time as maximun.
|
3427
|
+
</summary>
|
3428
|
+
<param name="callCount">The maximun number of times.</param>
|
3429
|
+
<returns>An object defining the allowed number of invocations.</returns>
|
3430
|
+
</member>
|
3431
|
+
<member name="M:Moq.Times.AtMostOnce">
|
3432
|
+
<summary>
|
3433
|
+
Specifies that a mocked method should be invoked one time as maximun.
|
3434
|
+
</summary>
|
3435
|
+
<returns>An object defining the allowed number of invocations.</returns>
|
3436
|
+
</member>
|
3437
|
+
<member name="M:Moq.Times.Between(System.Int32,System.Int32,Moq.Range)">
|
3438
|
+
<summary>
|
3439
|
+
Specifies that a mocked method should be invoked between <paramref name="from"/> and
|
3440
|
+
<paramref name="to"/> times.
|
3441
|
+
</summary>
|
3442
|
+
<param name="callCountFrom">The minimun number of times.</param>
|
3443
|
+
<param name="callCountTo">The maximun number of times.</param>
|
3444
|
+
<param name="rangeKind">The kind of range. See <see cref="T:Moq.Range"/>.</param>
|
3445
|
+
<returns>An object defining the allowed number of invocations.</returns>
|
3446
|
+
</member>
|
3447
|
+
<member name="M:Moq.Times.Exactly(System.Int32)">
|
3448
|
+
<summary>
|
3449
|
+
Specifies that a mocked method should be invoked exactly <paramref name="times"/> times.
|
3450
|
+
</summary>
|
3451
|
+
<param name="callCount">The times that a method or property can be called.</param>
|
3452
|
+
<returns>An object defining the allowed number of invocations.</returns>
|
3453
|
+
</member>
|
3454
|
+
<member name="M:Moq.Times.Never">
|
3455
|
+
<summary>
|
3456
|
+
Specifies that a mocked method should not be invoked.
|
3457
|
+
</summary>
|
3458
|
+
<returns>An object defining the allowed number of invocations.</returns>
|
3459
|
+
</member>
|
3460
|
+
<member name="M:Moq.Times.Once">
|
3461
|
+
<summary>
|
3462
|
+
Specifies that a mocked method should be invoked exactly one time.
|
3463
|
+
</summary>
|
3464
|
+
<returns>An object defining the allowed number of invocations.</returns>
|
3465
|
+
</member>
|
3466
|
+
</members>
|
3467
|
+
</doc>
|