Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <auto-generated/>
// <auto-generated/>
#nullable enable

namespace TUnit.Mocks.Generated
Expand Down Expand Up @@ -129,6 +129,8 @@ namespace TUnit.Mocks.Generated
return new global::TUnit.Mocks.Setup.VoidMethodSetupBuilder(setup);
})!;

/// <inheritdoc />
public IReadWriter_Write_M2_MockCall Returns() { EnsureSetup().Returns(); return this; }
/// <inheritdoc />
public IReadWriter_Write_M2_MockCall Throws<TException>() where TException : global::System.Exception, new() { EnsureSetup().Throws<TException>(); return this; }
/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <auto-generated/>
// <auto-generated/>
#nullable enable

namespace TUnit.Mocks.Generated
Expand Down Expand Up @@ -47,6 +47,11 @@ namespace TUnit.Mocks.Generated
try
{
var __result = _engine.HandleCallWithReturn<string>(0, "GetValueAsync", new object?[] { 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)
Expand All @@ -60,6 +65,11 @@ namespace TUnit.Mocks.Generated
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)
Expand All @@ -73,6 +83,11 @@ namespace TUnit.Mocks.Generated
try
{
var __result = _engine.HandleCallWithReturn<int>(2, "ComputeAsync", new object?[] { 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)
Expand All @@ -86,6 +101,11 @@ namespace TUnit.Mocks.Generated
try
{
_engine.HandleCall(3, "InitializeAsync", new object?[] { 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)
Expand Down Expand Up @@ -125,10 +145,10 @@ namespace TUnit.Mocks.Generated
return new IAsyncService_GetValueAsync_M0_MockCall(global::TUnit.Mocks.Mock.GetEngine(mock), 0, "GetValueAsync", matchers);
}

public static global::TUnit.Mocks.VoidMockMethodCall DoWorkAsync(this global::TUnit.Mocks.Mock<global::IAsyncService> mock)
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 global::TUnit.Mocks.VoidMockMethodCall(global::TUnit.Mocks.Mock.GetEngine(mock), 1, "DoWorkAsync", matchers);
return new IAsyncService_DoWorkAsync_M1_MockCall(global::TUnit.Mocks.Mock.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)
Expand Down Expand Up @@ -212,6 +232,11 @@ namespace TUnit.Mocks.Generated
/// <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)
{
Expand Down Expand Up @@ -248,6 +273,75 @@ namespace TUnit.Mocks.Generated
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;
private bool _builderInitialized;
private object? _builderLock;

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() =>
global::System.Threading.LazyInitializer.EnsureInitialized(ref _builder, ref _builderInitialized, ref _builderLock, () =>
{
var setup = new global::TUnit.Mocks.Setup.MethodSetup(_memberId, _matchers, _memberName);
_engine.AddSetup(setup);
return new global::TUnit.Mocks.Setup.VoidMethodSetupBuilder(setup);
})!;

/// <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 Callback(global::System.Action<object?[]> callback) { EnsureSetup().Callback(callback); return this; }
/// <inheritdoc />
public IAsyncService_DoWorkAsync_M1_MockCall Throws(global::System.Func<object?[], global::System.Exception> exceptionFactory) { EnsureSetup().Throws(exceptionFactory); return this; }
/// <inheritdoc />
public IAsyncService_DoWorkAsync_M1_MockCall Raises(string eventName, object? args = null) { EnsureSetup().Raises(eventName, args); return this; }
/// <inheritdoc />
public IAsyncService_DoWorkAsync_M1_MockCall SetsOutParameter(int paramIndex, object? value) { EnsureSetup().SetsOutParameter(paramIndex, value); 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
{
Expand Down Expand Up @@ -302,6 +396,13 @@ namespace TUnit.Mocks.Generated
/// <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)
{
Expand Down Expand Up @@ -366,6 +467,8 @@ namespace TUnit.Mocks.Generated
return new global::TUnit.Mocks.Setup.VoidMethodSetupBuilder(setup);
})!;

/// <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 />
Expand All @@ -385,6 +488,13 @@ namespace TUnit.Mocks.Generated
/// <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)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <auto-generated/>
// <auto-generated/>
#nullable enable

namespace TUnit.Mocks.Generated
Expand Down Expand Up @@ -164,6 +164,8 @@ namespace TUnit.Mocks.Generated
return new global::TUnit.Mocks.Setup.VoidMethodSetupBuilder(setup);
})!;

/// <inheritdoc />
public INotifier_Notify_M0_MockCall Returns() { EnsureSetup().Returns(); return this; }
/// <inheritdoc />
public INotifier_Notify_M0_MockCall Throws<TException>() where TException : global::System.Exception, new() { EnsureSetup().Throws<TException>(); return this; }
/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <auto-generated/>
// <auto-generated/>
#nullable enable

namespace TUnit.Mocks.Generated
Expand Down Expand Up @@ -140,6 +140,8 @@ namespace TUnit.Mocks.Generated
return new global::TUnit.Mocks.Setup.VoidMethodSetupBuilder(setup);
})!;

/// <inheritdoc />
public ITest_Test_M0_MockCall Returns() { EnsureSetup().Returns(); return this; }
/// <inheritdoc />
public ITest_Test_M0_MockCall Throws<TException>() where TException : global::System.Exception, new() { EnsureSetup().Throws<TException>(); return this; }
/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <auto-generated/>
// <auto-generated/>
#nullable enable

namespace TUnit.Mocks.Generated
Expand Down Expand Up @@ -78,6 +78,11 @@ namespace TUnit.Mocks.Generated
try
{
var __result = _engine.HandleCallWithReturn<string>(3, "GetAsync", new object?[] { id }, "");
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)
Expand Down Expand Up @@ -236,6 +241,11 @@ namespace TUnit.Mocks.Generated
/// <inheritdoc />
public IService_GetAsync_M3_MockCall Then() { EnsureSetup().Then(); return this; }

/// <summary>Return a pre-built Task directly (e.g., from a TaskCompletionSource).</summary>
public IService_GetAsync_M3_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 IService_GetAsync_M3_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 IService_GetAsync_M3_MockCall Returns(global::System.Func<int, string> factory)
{
Expand Down Expand Up @@ -303,6 +313,8 @@ namespace TUnit.Mocks.Generated
return new global::TUnit.Mocks.Setup.VoidMethodSetupBuilder(setup);
})!;

/// <inheritdoc />
public IService_Process_M4_MockCall Returns() { EnsureSetup().Returns(); return this; }
/// <inheritdoc />
public IService_Process_M4_MockCall Throws<TException>() where TException : global::System.Exception, new() { EnsureSetup().Throws<TException>(); return this; }
/// <inheritdoc />
Expand Down
Loading
Loading