-
-
Notifications
You must be signed in to change notification settings - Fork 130
Expand file tree
/
Copy pathInterface_With_Async_Methods.verified.txt
More file actions
641 lines (555 loc) · 34.4 KB
/
Copy pathInterface_With_Async_Methods.verified.txt
File metadata and controls
641 lines (555 loc) · 34.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
// <auto-generated/>
#pragma warning disable
#nullable enable
public sealed class IAsyncServiceMock : global::TUnit.Mocks.Mock<global::IAsyncService>, global::IAsyncService
{
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
internal IAsyncServiceMock(global::IAsyncService mockObject, global::TUnit.Mocks.MockEngine<global::IAsyncService> engine)
: base(mockObject, engine) { }
global::System.Threading.Tasks.Task<string> global::IAsyncService.GetValueAsync(string key) => Object.GetValueAsync(key);
global::System.Threading.Tasks.Task global::IAsyncService.DoWorkAsync() => Object.DoWorkAsync();
global::System.Threading.Tasks.ValueTask<int> global::IAsyncService.ComputeAsync(int input) => Object.ComputeAsync(input);
global::System.Threading.Tasks.ValueTask global::IAsyncService.InitializeAsync(global::System.Threading.CancellationToken ct) => Object.InitializeAsync(ct);
}
// ===== FILE SEPARATOR =====
// <auto-generated/>
#pragma warning disable
#nullable enable
file sealed class IAsyncServiceMockImpl : global::IAsyncService, global::TUnit.Mocks.IRaisable, global::TUnit.Mocks.IMockObject
{
private readonly global::TUnit.Mocks.MockEngine<global::IAsyncService> _engine;
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
global::TUnit.Mocks.IMock? global::TUnit.Mocks.IMockObject.MockWrapper { get; set; }
internal IAsyncServiceMockImpl(global::TUnit.Mocks.MockEngine<global::IAsyncService> engine)
{
_engine = engine;
}
public global::System.Threading.Tasks.Task<string> GetValueAsync(string key)
{
try
{
var __result = _engine.HandleCallWithReturn<string, string>(0, "GetValueAsync", key, "");
if (global::TUnit.Mocks.Setup.RawReturnContext.TryConsume(out var __rawAsync))
{
if (__rawAsync is global::System.Threading.Tasks.Task<string> __typedAsync) return __typedAsync;
throw new global::System.InvalidOperationException($"ReturnsAsync: expected global::System.Threading.Tasks.Task<string> but got {__rawAsync?.GetType().Name ?? "null"}");
}
return global::System.Threading.Tasks.Task.FromResult<string>(__result);
}
catch (global::System.Exception __ex)
{
return global::System.Threading.Tasks.Task.FromException<string>(__ex);
}
}
public global::System.Threading.Tasks.Task DoWorkAsync()
{
try
{
_engine.HandleCall(1, "DoWorkAsync", global::System.Array.Empty<object?>());
if (global::TUnit.Mocks.Setup.RawReturnContext.TryConsume(out var __rawAsync))
{
if (__rawAsync is global::System.Threading.Tasks.Task __typedAsync) return __typedAsync;
throw new global::System.InvalidOperationException($"ReturnsAsync: expected global::System.Threading.Tasks.Task but got {__rawAsync?.GetType().Name ?? "null"}");
}
return global::System.Threading.Tasks.Task.CompletedTask;
}
catch (global::System.Exception __ex)
{
return global::System.Threading.Tasks.Task.FromException(__ex);
}
}
public global::System.Threading.Tasks.ValueTask<int> ComputeAsync(int input)
{
try
{
var __result = _engine.HandleCallWithReturn<int, int>(2, "ComputeAsync", input, default);
if (global::TUnit.Mocks.Setup.RawReturnContext.TryConsume(out var __rawAsync))
{
if (__rawAsync is global::System.Threading.Tasks.ValueTask<int> __typedAsync) return __typedAsync;
throw new global::System.InvalidOperationException($"ReturnsAsync: expected global::System.Threading.Tasks.ValueTask<int> but got {__rawAsync?.GetType().Name ?? "null"}");
}
return new global::System.Threading.Tasks.ValueTask<int>(__result);
}
catch (global::System.Exception __ex)
{
return new global::System.Threading.Tasks.ValueTask<int>(global::System.Threading.Tasks.Task.FromException<int>(__ex));
}
}
public global::System.Threading.Tasks.ValueTask InitializeAsync(global::System.Threading.CancellationToken ct)
{
try
{
_engine.HandleCall<global::System.Threading.CancellationToken>(3, "InitializeAsync", ct);
if (global::TUnit.Mocks.Setup.RawReturnContext.TryConsume(out var __rawAsync))
{
if (__rawAsync is global::System.Threading.Tasks.ValueTask __typedAsync) return __typedAsync;
throw new global::System.InvalidOperationException($"ReturnsAsync: expected global::System.Threading.Tasks.ValueTask but got {__rawAsync?.GetType().Name ?? "null"}");
}
return default(global::System.Threading.Tasks.ValueTask);
}
catch (global::System.Exception __ex)
{
return new global::System.Threading.Tasks.ValueTask(global::System.Threading.Tasks.Task.FromException(__ex));
}
}
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
public void RaiseEvent(string eventName, object? args)
{
throw new global::System.InvalidOperationException($"No event named '{eventName}' exists on this mock.");
}
}
internal static class IAsyncServiceMockFactory
{
[global::System.Runtime.CompilerServices.ModuleInitializer]
internal static void Register()
{
global::TUnit.Mocks.MockRegistry.RegisterFactory<global::IAsyncService>(Create);
}
internal static global::TUnit.Mocks.Mock<global::IAsyncService> CreateAutoMock(global::TUnit.Mocks.MockBehavior behavior)
{
var engine = new global::TUnit.Mocks.MockEngine<global::IAsyncService>(behavior);
var impl = new IAsyncServiceMockImpl(engine);
engine.Raisable = impl;
var mock = new IAsyncServiceMock(impl, engine);
return mock;
}
internal static global::TUnit.Mocks.Mock<global::IAsyncService> Create(global::TUnit.Mocks.MockBehavior behavior, object[] constructorArgs)
{
if (constructorArgs.Length > 0) throw new global::System.ArgumentException($"Interface mock 'global::IAsyncService' does not support constructor arguments, but {constructorArgs.Length} were provided.");
var engine = new global::TUnit.Mocks.MockEngine<global::IAsyncService>(behavior);
var impl = new IAsyncServiceMockImpl(engine);
engine.Raisable = impl;
var mock = new IAsyncServiceMock(impl, engine);
return mock;
}
}
// ===== FILE SEPARATOR =====
// <auto-generated/>
#pragma warning disable
#nullable enable
public static class IAsyncService_MockMemberExtensions
{
public static IAsyncService_GetValueAsync_M0_MockCall GetValueAsync(this global::TUnit.Mocks.Mock<global::IAsyncService> mock, global::TUnit.Mocks.Arguments.Arg<string> key)
{
var matchers = new global::TUnit.Mocks.Arguments.IArgumentMatcher[] { key.Matcher };
return new IAsyncService_GetValueAsync_M0_MockCall(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 0, "GetValueAsync", matchers);
}
public static IAsyncService_GetValueAsync_M0_MockCall GetValueAsync(this global::TUnit.Mocks.Mock<global::IAsyncService> mock, global::System.Func<string, bool> key)
{
global::TUnit.Mocks.Arguments.Arg<string> __fa_key = key;
var matchers = new global::TUnit.Mocks.Arguments.IArgumentMatcher[] { __fa_key.Matcher };
return new IAsyncService_GetValueAsync_M0_MockCall(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 0, "GetValueAsync", matchers);
}
public static IAsyncService_DoWorkAsync_M1_MockCall DoWorkAsync(this global::TUnit.Mocks.Mock<global::IAsyncService> mock)
{
var matchers = global::System.Array.Empty<global::TUnit.Mocks.Arguments.IArgumentMatcher>();
return new IAsyncService_DoWorkAsync_M1_MockCall(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 1, "DoWorkAsync", matchers);
}
public static IAsyncService_ComputeAsync_M2_MockCall ComputeAsync(this global::TUnit.Mocks.Mock<global::IAsyncService> mock, global::TUnit.Mocks.Arguments.Arg<int> input)
{
var matchers = new global::TUnit.Mocks.Arguments.IArgumentMatcher[] { input.Matcher };
return new IAsyncService_ComputeAsync_M2_MockCall(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 2, "ComputeAsync", matchers);
}
public static IAsyncService_ComputeAsync_M2_MockCall ComputeAsync(this global::TUnit.Mocks.Mock<global::IAsyncService> mock, global::System.Func<int, bool> input)
{
global::TUnit.Mocks.Arguments.Arg<int> __fa_input = input;
var matchers = new global::TUnit.Mocks.Arguments.IArgumentMatcher[] { __fa_input.Matcher };
return new IAsyncService_ComputeAsync_M2_MockCall(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 2, "ComputeAsync", matchers);
}
public static IAsyncService_InitializeAsync_M3_MockCall InitializeAsync(this global::TUnit.Mocks.Mock<global::IAsyncService> mock, global::TUnit.Mocks.Arguments.Arg<global::System.Threading.CancellationToken> ct)
{
var matchers = new global::TUnit.Mocks.Arguments.IArgumentMatcher[] { ct.Matcher };
return new IAsyncService_InitializeAsync_M3_MockCall(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 3, "InitializeAsync", matchers);
}
public static IAsyncService_InitializeAsync_M3_MockCall InitializeAsync(this global::TUnit.Mocks.Mock<global::IAsyncService> mock, global::System.Func<global::System.Threading.CancellationToken, bool> ct)
{
global::TUnit.Mocks.Arguments.Arg<global::System.Threading.CancellationToken> __fa_ct = ct;
var matchers = new global::TUnit.Mocks.Arguments.IArgumentMatcher[] { __fa_ct.Matcher };
return new IAsyncService_InitializeAsync_M3_MockCall(global::TUnit.Mocks.MockRegistry.GetEngine(mock), 3, "InitializeAsync", matchers);
}
#if NET9_0_OR_GREATER
[global::System.Runtime.CompilerServices.OverloadResolutionPriority(-1)]
public static void Reset(this global::TUnit.Mocks.Mock<global::IAsyncService> mock)
=> global::TUnit.Mocks.Mock.Reset(mock);
[global::System.Runtime.CompilerServices.OverloadResolutionPriority(-1)]
public static void VerifyAll(this global::TUnit.Mocks.Mock<global::IAsyncService> mock)
=> global::TUnit.Mocks.Mock.VerifyAll(mock);
[global::System.Runtime.CompilerServices.OverloadResolutionPriority(-1)]
public static void VerifyNoOtherCalls(this global::TUnit.Mocks.Mock<global::IAsyncService> mock)
=> global::TUnit.Mocks.Mock.VerifyNoOtherCalls(mock);
[global::System.Runtime.CompilerServices.OverloadResolutionPriority(-1)]
public static void SetupAllProperties(this global::TUnit.Mocks.Mock<global::IAsyncService> mock)
=> global::TUnit.Mocks.Mock.SetupAllProperties(mock);
[global::System.Runtime.CompilerServices.OverloadResolutionPriority(-1)]
public static global::TUnit.Mocks.Diagnostics.MockDiagnostics GetDiagnostics(this global::TUnit.Mocks.Mock<global::IAsyncService> mock)
=> global::TUnit.Mocks.Mock.GetDiagnostics(mock);
[global::System.Runtime.CompilerServices.OverloadResolutionPriority(-1)]
public static void SetState(this global::TUnit.Mocks.Mock<global::IAsyncService> mock, string? stateName)
=> global::TUnit.Mocks.Mock.SetState(mock, stateName);
[global::System.Runtime.CompilerServices.OverloadResolutionPriority(-1)]
public static void InState(this global::TUnit.Mocks.Mock<global::IAsyncService> mock, string stateName, global::System.Action<global::TUnit.Mocks.Mock<global::IAsyncService>> configure)
=> global::TUnit.Mocks.Mock.InState(mock, stateName, configure);
extension(global::TUnit.Mocks.Mock<global::IAsyncService> mock)
{
public global::System.Collections.Generic.IReadOnlyList<global::TUnit.Mocks.Verification.CallRecord> Invocations => global::TUnit.Mocks.Mock.Invocations(mock);
public global::TUnit.Mocks.MockBehavior Behavior => global::TUnit.Mocks.Mock.Behavior(mock);
public global::TUnit.Mocks.IDefaultValueProvider? DefaultValueProvider
{
get => global::TUnit.Mocks.Mock.GetDefaultValueProvider(mock);
set => global::TUnit.Mocks.Mock.SetDefaultValueProvider(mock, value);
}
}
#endif
}
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
public sealed class IAsyncService_GetValueAsync_M0_MockCall : global::TUnit.Mocks.Verification.ICallVerification
{
private readonly global::TUnit.Mocks.IMockEngineAccess _engine;
private readonly int _memberId;
private readonly string _memberName;
private readonly global::TUnit.Mocks.Arguments.IArgumentMatcher[] _matchers;
private global::TUnit.Mocks.Setup.MethodSetupBuilder<string>? _builder;
internal IAsyncService_GetValueAsync_M0_MockCall(global::TUnit.Mocks.IMockEngineAccess engine, int memberId, string memberName, global::TUnit.Mocks.Arguments.IArgumentMatcher[] matchers)
{
_engine = engine;
_memberId = memberId;
_memberName = memberName;
_matchers = matchers;
}
private global::TUnit.Mocks.Setup.MethodSetupBuilder<string> EnsureSetup()
{
var existing = global::System.Threading.Volatile.Read(ref _builder);
if (existing is not null) return existing;
return EnsureSetupSlow();
}
[global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private global::TUnit.Mocks.Setup.MethodSetupBuilder<string> EnsureSetupSlow()
{
var setup = new global::TUnit.Mocks.Setup.MethodSetup(_memberId, _matchers, _memberName);
var fresh = new global::TUnit.Mocks.Setup.MethodSetupBuilder<string>(setup);
var prev = global::System.Threading.Interlocked.CompareExchange(ref _builder, fresh, null);
if (prev is not null) return prev;
// AddSetup runs only on the CAS winner. Setup is sequential in practice,
// so a concurrent loser observing the builder before registration is benign.
_engine.AddSetup(setup);
return fresh;
}
/// <inheritdoc />
public IAsyncService_GetValueAsync_M0_MockCall Returns(string value) { EnsureSetup().Returns(value); return this; }
/// <inheritdoc />
public IAsyncService_GetValueAsync_M0_MockCall Returns(global::System.Func<string> factory) { EnsureSetup().Returns(factory); return this; }
/// <inheritdoc />
public IAsyncService_GetValueAsync_M0_MockCall ReturnsSequentially(params string[] values) { EnsureSetup().ReturnsSequentially(values); return this; }
/// <inheritdoc />
public IAsyncService_GetValueAsync_M0_MockCall Throws<TException>() where TException : global::System.Exception, new() { EnsureSetup().Throws<TException>(); return this; }
/// <inheritdoc />
public IAsyncService_GetValueAsync_M0_MockCall Throws(global::System.Exception exception) { EnsureSetup().Throws(exception); return this; }
/// <inheritdoc />
public IAsyncService_GetValueAsync_M0_MockCall Callback(global::System.Action callback) { EnsureSetup().Callback(callback); return this; }
/// <inheritdoc />
public IAsyncService_GetValueAsync_M0_MockCall TransitionsTo(string stateName) { EnsureSetup().TransitionsTo(stateName); return this; }
/// <inheritdoc />
public IAsyncService_GetValueAsync_M0_MockCall Then() { EnsureSetup().Then(); return this; }
/// <summary>Return a pre-built Task directly (e.g., from a TaskCompletionSource).</summary>
public IAsyncService_GetValueAsync_M0_MockCall ReturnsAsync(global::System.Threading.Tasks.Task<string> task) { EnsureSetup().ReturnsRaw(task); return this; }
/// <summary>Return a pre-built Task from a factory, invoked on each call.</summary>
public IAsyncService_GetValueAsync_M0_MockCall ReturnsAsync(global::System.Func<global::System.Threading.Tasks.Task<string>> taskFactory) { EnsureSetup().ReturnsRaw(() => (object?)taskFactory()); return this; }
/// <summary>Configure a typed computed return value using the actual method parameters.</summary>
public IAsyncService_GetValueAsync_M0_MockCall Returns(global::System.Func<string, string> factory)
{
EnsureSetup().Returns(args => factory((string)args[0]!));
return this;
}
/// <summary>Configure a typed computed async return value using the actual method parameters.</summary>
public IAsyncService_GetValueAsync_M0_MockCall ReturnsAsync(global::System.Func<string, global::System.Threading.Tasks.Task<string>> factory)
{
EnsureSetup().ReturnsRaw(args => (object?)factory((string)args[0]!));
return this;
}
/// <summary>Execute a typed callback using the actual method parameters.</summary>
public IAsyncService_GetValueAsync_M0_MockCall Callback(global::System.Action<string> callback)
{
EnsureSetup().Callback(callback);
return this;
}
/// <summary>Configure a typed computed exception using the actual method parameters.</summary>
public IAsyncService_GetValueAsync_M0_MockCall Throws(global::System.Func<string, global::System.Exception> exceptionFactory)
{
EnsureSetup().Throws(args => exceptionFactory((string)args[0]!));
return this;
}
// ICallVerification
/// <inheritdoc />
public void WasCalled() => _engine.CreateVerification(_memberId, _memberName, _matchers).WasCalled();
/// <inheritdoc />
public void WasCalled(global::TUnit.Mocks.Times times) => _engine.CreateVerification(_memberId, _memberName, _matchers).WasCalled(times);
/// <inheritdoc />
public void WasCalled(global::TUnit.Mocks.Times times, string? message) => _engine.CreateVerification(_memberId, _memberName, _matchers).WasCalled(times, message);
/// <inheritdoc />
public void WasCalled(string? message) => _engine.CreateVerification(_memberId, _memberName, _matchers).WasCalled(message);
/// <inheritdoc />
public void WasNeverCalled() => _engine.CreateVerification(_memberId, _memberName, _matchers).WasNeverCalled();
/// <inheritdoc />
public void WasNeverCalled(string? message) => _engine.CreateVerification(_memberId, _memberName, _matchers).WasNeverCalled(message);
}
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
public sealed class IAsyncService_DoWorkAsync_M1_MockCall : global::TUnit.Mocks.Verification.ICallVerification
{
private readonly global::TUnit.Mocks.IMockEngineAccess _engine;
private readonly int _memberId;
private readonly string _memberName;
private readonly global::TUnit.Mocks.Arguments.IArgumentMatcher[] _matchers;
private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder? _builder;
internal IAsyncService_DoWorkAsync_M1_MockCall(global::TUnit.Mocks.IMockEngineAccess engine, int memberId, string memberName, global::TUnit.Mocks.Arguments.IArgumentMatcher[] matchers)
{
_engine = engine;
_memberId = memberId;
_memberName = memberName;
_matchers = matchers;
_ = EnsureSetup();
}
private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder EnsureSetup()
{
var existing = global::System.Threading.Volatile.Read(ref _builder);
if (existing is not null) return existing;
return EnsureSetupSlow();
}
[global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder EnsureSetupSlow()
{
var setup = new global::TUnit.Mocks.Setup.MethodSetup(_memberId, _matchers, _memberName);
var fresh = new global::TUnit.Mocks.Setup.VoidMethodSetupBuilder(setup);
var prev = global::System.Threading.Interlocked.CompareExchange(ref _builder, fresh, null);
if (prev is not null) return prev;
// AddSetup runs only on the CAS winner. Setup is sequential in practice,
// so a concurrent loser observing the builder before registration is benign.
_engine.AddSetup(setup);
return fresh;
}
/// <inheritdoc />
public IAsyncService_DoWorkAsync_M1_MockCall Returns() { EnsureSetup().Returns(); return this; }
/// <inheritdoc />
public IAsyncService_DoWorkAsync_M1_MockCall Throws<TException>() where TException : global::System.Exception, new() { EnsureSetup().Throws<TException>(); return this; }
/// <inheritdoc />
public IAsyncService_DoWorkAsync_M1_MockCall Throws(global::System.Exception exception) { EnsureSetup().Throws(exception); return this; }
/// <inheritdoc />
public IAsyncService_DoWorkAsync_M1_MockCall Callback(global::System.Action callback) { EnsureSetup().Callback(callback); return this; }
/// <inheritdoc />
public IAsyncService_DoWorkAsync_M1_MockCall TransitionsTo(string stateName) { EnsureSetup().TransitionsTo(stateName); return this; }
/// <inheritdoc />
public IAsyncService_DoWorkAsync_M1_MockCall Then() { EnsureSetup().Then(); return this; }
/// <summary>Return a pre-built Task directly (e.g., from a TaskCompletionSource).</summary>
public IAsyncService_DoWorkAsync_M1_MockCall ReturnsAsync(global::System.Threading.Tasks.Task task) { EnsureSetup().ReturnsRaw(task); return this; }
/// <summary>Return a pre-built Task from a factory, invoked on each call.</summary>
public IAsyncService_DoWorkAsync_M1_MockCall ReturnsAsync(global::System.Func<global::System.Threading.Tasks.Task> taskFactory) { EnsureSetup().ReturnsRaw(() => (object?)taskFactory()); return this; }
// ICallVerification
/// <inheritdoc />
public void WasCalled() => _engine.CreateVerification(_memberId, _memberName, _matchers).WasCalled();
/// <inheritdoc />
public void WasCalled(global::TUnit.Mocks.Times times) => _engine.CreateVerification(_memberId, _memberName, _matchers).WasCalled(times);
/// <inheritdoc />
public void WasCalled(global::TUnit.Mocks.Times times, string? message) => _engine.CreateVerification(_memberId, _memberName, _matchers).WasCalled(times, message);
/// <inheritdoc />
public void WasCalled(string? message) => _engine.CreateVerification(_memberId, _memberName, _matchers).WasCalled(message);
/// <inheritdoc />
public void WasNeverCalled() => _engine.CreateVerification(_memberId, _memberName, _matchers).WasNeverCalled();
/// <inheritdoc />
public void WasNeverCalled(string? message) => _engine.CreateVerification(_memberId, _memberName, _matchers).WasNeverCalled(message);
}
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
public sealed class IAsyncService_ComputeAsync_M2_MockCall : global::TUnit.Mocks.Verification.ICallVerification
{
private readonly global::TUnit.Mocks.IMockEngineAccess _engine;
private readonly int _memberId;
private readonly string _memberName;
private readonly global::TUnit.Mocks.Arguments.IArgumentMatcher[] _matchers;
private global::TUnit.Mocks.Setup.MethodSetupBuilder<int>? _builder;
internal IAsyncService_ComputeAsync_M2_MockCall(global::TUnit.Mocks.IMockEngineAccess engine, int memberId, string memberName, global::TUnit.Mocks.Arguments.IArgumentMatcher[] matchers)
{
_engine = engine;
_memberId = memberId;
_memberName = memberName;
_matchers = matchers;
}
private global::TUnit.Mocks.Setup.MethodSetupBuilder<int> EnsureSetup()
{
var existing = global::System.Threading.Volatile.Read(ref _builder);
if (existing is not null) return existing;
return EnsureSetupSlow();
}
[global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private global::TUnit.Mocks.Setup.MethodSetupBuilder<int> EnsureSetupSlow()
{
var setup = new global::TUnit.Mocks.Setup.MethodSetup(_memberId, _matchers, _memberName);
var fresh = new global::TUnit.Mocks.Setup.MethodSetupBuilder<int>(setup);
var prev = global::System.Threading.Interlocked.CompareExchange(ref _builder, fresh, null);
if (prev is not null) return prev;
// AddSetup runs only on the CAS winner. Setup is sequential in practice,
// so a concurrent loser observing the builder before registration is benign.
_engine.AddSetup(setup);
return fresh;
}
/// <inheritdoc />
public IAsyncService_ComputeAsync_M2_MockCall Returns(int value) { EnsureSetup().Returns(value); return this; }
/// <inheritdoc />
public IAsyncService_ComputeAsync_M2_MockCall Returns(global::System.Func<int> factory) { EnsureSetup().Returns(factory); return this; }
/// <inheritdoc />
public IAsyncService_ComputeAsync_M2_MockCall ReturnsSequentially(params int[] values) { EnsureSetup().ReturnsSequentially(values); return this; }
/// <inheritdoc />
public IAsyncService_ComputeAsync_M2_MockCall Throws<TException>() where TException : global::System.Exception, new() { EnsureSetup().Throws<TException>(); return this; }
/// <inheritdoc />
public IAsyncService_ComputeAsync_M2_MockCall Throws(global::System.Exception exception) { EnsureSetup().Throws(exception); return this; }
/// <inheritdoc />
public IAsyncService_ComputeAsync_M2_MockCall Callback(global::System.Action callback) { EnsureSetup().Callback(callback); return this; }
/// <inheritdoc />
public IAsyncService_ComputeAsync_M2_MockCall TransitionsTo(string stateName) { EnsureSetup().TransitionsTo(stateName); return this; }
/// <inheritdoc />
public IAsyncService_ComputeAsync_M2_MockCall Then() { EnsureSetup().Then(); return this; }
/// <summary>Return a pre-built ValueTask directly (e.g., from a TaskCompletionSource).</summary>
/// <remarks>The same ValueTask instance is returned on every call. Since ValueTask may only be awaited once,
/// use the factory overload if the mock will be called multiple times, or ensure the ValueTask is backed by a Task.</remarks>
public IAsyncService_ComputeAsync_M2_MockCall ReturnsAsync(global::System.Threading.Tasks.ValueTask<int> task) { EnsureSetup().ReturnsRaw(task); return this; }
/// <summary>Return a pre-built ValueTask from a factory, invoked on each call.</summary>
public IAsyncService_ComputeAsync_M2_MockCall ReturnsAsync(global::System.Func<global::System.Threading.Tasks.ValueTask<int>> taskFactory) { EnsureSetup().ReturnsRaw(() => (object?)taskFactory()); return this; }
/// <summary>Configure a typed computed return value using the actual method parameters.</summary>
public IAsyncService_ComputeAsync_M2_MockCall Returns(global::System.Func<int, int> factory)
{
EnsureSetup().Returns(args => factory((int)args[0]!));
return this;
}
/// <summary>Configure a typed computed async return value using the actual method parameters.</summary>
public IAsyncService_ComputeAsync_M2_MockCall ReturnsAsync(global::System.Func<int, global::System.Threading.Tasks.ValueTask<int>> factory)
{
EnsureSetup().ReturnsRaw(args => (object?)factory((int)args[0]!));
return this;
}
/// <summary>Execute a typed callback using the actual method parameters.</summary>
public IAsyncService_ComputeAsync_M2_MockCall Callback(global::System.Action<int> callback)
{
EnsureSetup().Callback(callback);
return this;
}
/// <summary>Configure a typed computed exception using the actual method parameters.</summary>
public IAsyncService_ComputeAsync_M2_MockCall Throws(global::System.Func<int, global::System.Exception> exceptionFactory)
{
EnsureSetup().Throws(args => exceptionFactory((int)args[0]!));
return this;
}
// ICallVerification
/// <inheritdoc />
public void WasCalled() => _engine.CreateVerification(_memberId, _memberName, _matchers).WasCalled();
/// <inheritdoc />
public void WasCalled(global::TUnit.Mocks.Times times) => _engine.CreateVerification(_memberId, _memberName, _matchers).WasCalled(times);
/// <inheritdoc />
public void WasCalled(global::TUnit.Mocks.Times times, string? message) => _engine.CreateVerification(_memberId, _memberName, _matchers).WasCalled(times, message);
/// <inheritdoc />
public void WasCalled(string? message) => _engine.CreateVerification(_memberId, _memberName, _matchers).WasCalled(message);
/// <inheritdoc />
public void WasNeverCalled() => _engine.CreateVerification(_memberId, _memberName, _matchers).WasNeverCalled();
/// <inheritdoc />
public void WasNeverCalled(string? message) => _engine.CreateVerification(_memberId, _memberName, _matchers).WasNeverCalled(message);
}
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
public sealed class IAsyncService_InitializeAsync_M3_MockCall : global::TUnit.Mocks.Verification.ICallVerification
{
private readonly global::TUnit.Mocks.IMockEngineAccess _engine;
private readonly int _memberId;
private readonly string _memberName;
private readonly global::TUnit.Mocks.Arguments.IArgumentMatcher[] _matchers;
private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder? _builder;
internal IAsyncService_InitializeAsync_M3_MockCall(global::TUnit.Mocks.IMockEngineAccess engine, int memberId, string memberName, global::TUnit.Mocks.Arguments.IArgumentMatcher[] matchers)
{
_engine = engine;
_memberId = memberId;
_memberName = memberName;
_matchers = matchers;
_ = EnsureSetup();
}
private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder EnsureSetup()
{
var existing = global::System.Threading.Volatile.Read(ref _builder);
if (existing is not null) return existing;
return EnsureSetupSlow();
}
[global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder EnsureSetupSlow()
{
var setup = new global::TUnit.Mocks.Setup.MethodSetup(_memberId, _matchers, _memberName);
var fresh = new global::TUnit.Mocks.Setup.VoidMethodSetupBuilder(setup);
var prev = global::System.Threading.Interlocked.CompareExchange(ref _builder, fresh, null);
if (prev is not null) return prev;
// AddSetup runs only on the CAS winner. Setup is sequential in practice,
// so a concurrent loser observing the builder before registration is benign.
_engine.AddSetup(setup);
return fresh;
}
/// <inheritdoc />
public IAsyncService_InitializeAsync_M3_MockCall Returns() { EnsureSetup().Returns(); return this; }
/// <inheritdoc />
public IAsyncService_InitializeAsync_M3_MockCall Throws<TException>() where TException : global::System.Exception, new() { EnsureSetup().Throws<TException>(); return this; }
/// <inheritdoc />
public IAsyncService_InitializeAsync_M3_MockCall Throws(global::System.Exception exception) { EnsureSetup().Throws(exception); return this; }
/// <inheritdoc />
public IAsyncService_InitializeAsync_M3_MockCall Callback(global::System.Action callback) { EnsureSetup().Callback(callback); return this; }
/// <inheritdoc />
public IAsyncService_InitializeAsync_M3_MockCall TransitionsTo(string stateName) { EnsureSetup().TransitionsTo(stateName); return this; }
/// <inheritdoc />
public IAsyncService_InitializeAsync_M3_MockCall Then() { EnsureSetup().Then(); return this; }
/// <summary>Return a pre-built ValueTask directly (e.g., from a TaskCompletionSource).</summary>
/// <remarks>The same ValueTask instance is returned on every call. Since ValueTask may only be awaited once,
/// use the factory overload if the mock will be called multiple times, or ensure the ValueTask is backed by a Task.</remarks>
public IAsyncService_InitializeAsync_M3_MockCall ReturnsAsync(global::System.Threading.Tasks.ValueTask task) { EnsureSetup().ReturnsRaw(task); return this; }
/// <summary>Return a pre-built ValueTask from a factory, invoked on each call.</summary>
public IAsyncService_InitializeAsync_M3_MockCall ReturnsAsync(global::System.Func<global::System.Threading.Tasks.ValueTask> taskFactory) { EnsureSetup().ReturnsRaw(() => (object?)taskFactory()); return this; }
/// <summary>Execute a typed callback using the actual method parameters.</summary>
public IAsyncService_InitializeAsync_M3_MockCall Callback(global::System.Action<global::System.Threading.CancellationToken> callback)
{
EnsureSetup().Callback(callback);
return this;
}
/// <summary>Configure a typed computed exception using the actual method parameters.</summary>
public IAsyncService_InitializeAsync_M3_MockCall Throws(global::System.Func<global::System.Threading.CancellationToken, global::System.Exception> exceptionFactory)
{
EnsureSetup().Throws(args => exceptionFactory((global::System.Threading.CancellationToken)args[0]!));
return this;
}
// ICallVerification
/// <inheritdoc />
public void WasCalled() => _engine.CreateVerification(_memberId, _memberName, _matchers).WasCalled();
/// <inheritdoc />
public void WasCalled(global::TUnit.Mocks.Times times) => _engine.CreateVerification(_memberId, _memberName, _matchers).WasCalled(times);
/// <inheritdoc />
public void WasCalled(global::TUnit.Mocks.Times times, string? message) => _engine.CreateVerification(_memberId, _memberName, _matchers).WasCalled(times, message);
/// <inheritdoc />
public void WasCalled(string? message) => _engine.CreateVerification(_memberId, _memberName, _matchers).WasCalled(message);
/// <inheritdoc />
public void WasNeverCalled() => _engine.CreateVerification(_memberId, _memberName, _matchers).WasNeverCalled();
/// <inheritdoc />
public void WasNeverCalled(string? message) => _engine.CreateVerification(_memberId, _memberName, _matchers).WasNeverCalled(message);
}
// ===== FILE SEPARATOR =====
// <auto-generated/>
#pragma warning disable
#nullable enable
namespace TUnit.Mocks
{
public static class IAsyncService_MockStaticExtension
{
extension(global::IAsyncService _)
{
public static global::IAsyncServiceMock Mock()
{
return (global::IAsyncServiceMock)global::IAsyncServiceMockFactory.CreateAutoMock(global::TUnit.Mocks.Mock.DefaultBehavior);
}
public static global::IAsyncServiceMock Mock(global::TUnit.Mocks.MockBehavior behavior)
{
return (global::IAsyncServiceMock)global::IAsyncServiceMockFactory.CreateAutoMock(behavior);
}
}
}
}
// ===== FILE SEPARATOR =====
// <auto-generated/>
#pragma warning disable
#nullable enable
namespace TUnit.Mocks.Generated;