diff --git a/TUnit.Mocks.Assertions/MockAssertionExtensions.cs b/TUnit.Mocks.Assertions/MockAssertionExtensions.cs
index 296582627f..98dd817347 100644
--- a/TUnit.Mocks.Assertions/MockAssertionExtensions.cs
+++ b/TUnit.Mocks.Assertions/MockAssertionExtensions.cs
@@ -6,7 +6,7 @@ namespace TUnit.Mocks.Assertions;
///
/// Extension methods for asserting mock call verification through the TUnit assertion pipeline.
-/// Enables: await Assert.That(mock.Verify.Method()).WasCalled(Times.Once);
+/// Enables: await Assert.That(mock.Method()).WasCalled(Times.Once);
///
public static class MockAssertionExtensions
{
@@ -24,7 +24,7 @@ public static WasCalledAssertion WasCalled(
///
/// Asserts that the mock member was called the specified number of times.
- /// Generic overload for types implementing (e.g. PropertyVerifyAccessor).
+ /// Generic overload for types implementing (e.g. PropertyMockCall).
///
public static WasCalledAssertion WasCalled(
this IAssertionSource source,
@@ -48,7 +48,7 @@ public static WasNeverCalledAssertion WasNeverCalled(
///
/// Asserts that the mock member was never called.
- /// Generic overload for types implementing (e.g. PropertyVerifyAccessor).
+ /// Generic overload for types implementing (e.g. PropertyMockCall).
///
public static WasNeverCalledAssertion WasNeverCalled(
this IAssertionSource source) where T : ICallVerification
diff --git a/TUnit.Mocks.SourceGenerator.Tests/Snapshots/Interface_Inheriting_Multiple_Interfaces.verified.txt b/TUnit.Mocks.SourceGenerator.Tests/Snapshots/Interface_Inheriting_Multiple_Interfaces.verified.txt
index 76d191b179..519639f46b 100644
--- a/TUnit.Mocks.SourceGenerator.Tests/Snapshots/Interface_Inheriting_Multiple_Interfaces.verified.txt
+++ b/TUnit.Mocks.SourceGenerator.Tests/Snapshots/Interface_Inheriting_Multiple_Interfaces.verified.txt
@@ -16,9 +16,7 @@ namespace TUnit.Mocks.Generated
var engine = new global::TUnit.Mocks.MockEngine(behavior);
var impl = new IReadWriter_MockImpl(engine);
engine.Raisable = impl;
- var setup = new IReadWriter_MockSetup(engine);
- var verify = new IReadWriter_MockVerify(engine);
- var mock = new global::TUnit.Mocks.Mock(impl, setup, verify, engine);
+ var mock = new global::TUnit.Mocks.Mock(impl, engine);
return mock;
}
}
@@ -72,121 +70,99 @@ namespace TUnit.Mocks.Generated
namespace TUnit.Mocks.Generated
{
- public sealed class IReadWriter_MockSetup : global::TUnit.Mocks.IMockSetup
+ public static class IReadWriter_MockMemberExtensions
{
- internal readonly global::TUnit.Mocks.MockEngine Engine;
-
- internal IReadWriter_MockSetup(global::TUnit.Mocks.MockEngine engine) => Engine = engine;
- }
-
- public static class IReadWriter_MockSetupExtensions
- {
- public static global::TUnit.Mocks.Setup.IVoidMethodSetup Flush(this global::TUnit.Mocks.IMockSetup setup)
+ public static global::TUnit.Mocks.VoidMockMethodCall Flush(this global::TUnit.Mocks.Mock mock)
{
- var s = (IReadWriter_MockSetup)setup;
var matchers = global::System.Array.Empty();
- var methodSetup = new global::TUnit.Mocks.Setup.MethodSetup(0, matchers, "Flush");
- s.Engine.AddSetup(methodSetup);
- return new global::TUnit.Mocks.Setup.VoidMethodSetupBuilder(methodSetup);
+ return new global::TUnit.Mocks.VoidMockMethodCall(mock.Engine, 0, "Flush", matchers);
}
- public static global::TUnit.Mocks.Setup.IMethodSetup Read(this global::TUnit.Mocks.IMockSetup setup)
+ public static global::TUnit.Mocks.MockMethodCall Read(this global::TUnit.Mocks.Mock mock)
{
- var s = (IReadWriter_MockSetup)setup;
var matchers = global::System.Array.Empty();
- var methodSetup = new global::TUnit.Mocks.Setup.MethodSetup(1, matchers, "Read");
- s.Engine.AddSetup(methodSetup);
- return new global::TUnit.Mocks.Setup.MethodSetupBuilder(methodSetup);
+ return new global::TUnit.Mocks.MockMethodCall(mock.Engine, 1, "Read", matchers);
}
- public static IReadWriter_Write_M2_TypedSetup Write(this global::TUnit.Mocks.IMockSetup setup, global::TUnit.Mocks.Arguments.Arg data)
+ public static IReadWriter_Write_M2_MockCall Write(this global::TUnit.Mocks.Mock mock, global::TUnit.Mocks.Arguments.Arg data)
{
- var s = (IReadWriter_MockSetup)setup;
var matchers = new global::TUnit.Mocks.Arguments.IArgumentMatcher[] { data.Matcher };
- var methodSetup = new global::TUnit.Mocks.Setup.MethodSetup(2, matchers, "Write");
- s.Engine.AddSetup(methodSetup);
- return new IReadWriter_Write_M2_TypedSetup(new global::TUnit.Mocks.Setup.VoidMethodSetupBuilder(methodSetup));
+ return new IReadWriter_Write_M2_MockCall(mock.Engine, 2, "Write", matchers);
}
}
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
- public readonly struct IReadWriter_Write_M2_TypedSetup
+ public sealed class IReadWriter_Write_M2_MockCall : global::TUnit.Mocks.Verification.ICallVerification
{
- private readonly global::TUnit.Mocks.Setup.VoidMethodSetupBuilder _inner;
+ private readonly global::TUnit.Mocks.IMockEngineAccess _engine;
+ private readonly int _memberId;
+ private readonly string _memberName;
+ private readonly global::TUnit.Mocks.Arguments.IArgumentMatcher[] _matchers;
+ private readonly global::System.Lazy _lazyBuilder;
+
+ internal IReadWriter_Write_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;
+ _lazyBuilder = new global::System.Lazy(() =>
+ {
+ var setup = new global::TUnit.Mocks.Setup.MethodSetup(_memberId, _matchers, _memberName);
+ _engine.AddSetup(setup);
+ return new global::TUnit.Mocks.Setup.VoidMethodSetupBuilder(setup);
+ }
+ );
+ _ = _lazyBuilder.Value;
+ }
- internal IReadWriter_Write_M2_TypedSetup(global::TUnit.Mocks.Setup.VoidMethodSetupBuilder inner) => _inner = inner;
+ private global::TUnit.Mocks.Setup.VoidMethodSetupBuilder EnsureSetup() => _lazyBuilder.Value;
///
- public IReadWriter_Write_M2_TypedSetup Throws() where TException : global::System.Exception, new() { _inner.Throws(); return this; }
+ public IReadWriter_Write_M2_MockCall Throws() where TException : global::System.Exception, new() { EnsureSetup().Throws(); return this; }
///
- public IReadWriter_Write_M2_TypedSetup Throws(global::System.Exception exception) { _inner.Throws(exception); return this; }
+ public IReadWriter_Write_M2_MockCall Throws(global::System.Exception exception) { EnsureSetup().Throws(exception); return this; }
///
- public IReadWriter_Write_M2_TypedSetup Callback(global::System.Action callback) { _inner.Callback(callback); return this; }
+ public IReadWriter_Write_M2_MockCall Callback(global::System.Action callback) { EnsureSetup().Callback(callback); return this; }
///
- public IReadWriter_Write_M2_TypedSetup Callback(global::System.Action