diff --git a/Benchmarks/Mockolate.Benchmarks/CallbackBenchmarks.cs b/Benchmarks/Mockolate.Benchmarks/CallbackBenchmarks.cs index 83b401ef..ef1537b2 100644 --- a/Benchmarks/Mockolate.Benchmarks/CallbackBenchmarks.cs +++ b/Benchmarks/Mockolate.Benchmarks/CallbackBenchmarks.cs @@ -31,81 +31,81 @@ public int Callback_Mockolate() } /// - /// + /// /// [Benchmark] - public int Callback_Moq() + public int Callback_Imposter() { int count = 0; - Moq.Mock mock = new(); - mock.Setup(x => x.MyFunc(Moq.It.IsAny())).Callback(() => count++); + IMyCallbackInterfaceImposter imposter = IMyCallbackInterface.Imposter(); + imposter.MyFunc(Imposter.Abstractions.Arg.Any()).Callback(_ => count++); - IMyCallbackInterface instance = mock.Object; + IMyCallbackInterface instance = imposter.Instance(); instance.MyFunc(1); instance.MyFunc(2); return count; } /// - /// + /// /// [Benchmark] - public int Callback_NSubstitute() + public int Callback_TUnitMocks() { int count = 0; - IMyCallbackInterface mock = Substitute.For(); - mock.When(x => x.MyFunc(Arg.Any())).Do(_ => count++); + Mock mock = TUnit.Mocks.Mock.Of(); + mock.MyFunc(Any()) + .Callback(() => count++); - mock.MyFunc(1); - mock.MyFunc(2); + IMyCallbackInterface svc = mock.Object; + svc.MyFunc(1); + svc.MyFunc(2); return count; } /// - /// + /// /// [Benchmark] - public int Callback_FakeItEasy() + public int Callback_Moq() { int count = 0; - IMyCallbackInterface mock = A.Fake(); - A.CallTo(() => mock.MyFunc(A.Ignored)).Invokes(() => count++); + Moq.Mock mock = new(); + mock.Setup(x => x.MyFunc(Moq.It.IsAny())).Callback(() => count++); - mock.MyFunc(1); - mock.MyFunc(2); + IMyCallbackInterface instance = mock.Object; + instance.MyFunc(1); + instance.MyFunc(2); return count; } /// - /// + /// /// [Benchmark] - public int Callback_Imposter() + public int Callback_NSubstitute() { int count = 0; - IMyCallbackInterfaceImposter imposter = IMyCallbackInterface.Imposter(); - imposter.MyFunc(Imposter.Abstractions.Arg.Any()).Callback(_ => count++); + IMyCallbackInterface mock = Substitute.For(); + mock.When(x => x.MyFunc(Arg.Any())).Do(_ => count++); - IMyCallbackInterface instance = imposter.Instance(); - instance.MyFunc(1); - instance.MyFunc(2); + mock.MyFunc(1); + mock.MyFunc(2); return count; } /// - /// + /// /// [Benchmark] - public int Callback_TUnitMocks() + public int Callback_FakeItEasy() { int count = 0; - Mock mock = TUnit.Mocks.Mock.Of(); - mock.MyFunc(Any()) - .Callback(() => count++); + IMyCallbackInterface mock = A.Fake(); + A.CallTo(() => mock.MyFunc(A.Ignored)).Invokes(() => count++); - IMyCallbackInterface svc = mock.Object; - svc.MyFunc(1); - svc.MyFunc(2); + mock.MyFunc(1); + mock.MyFunc(2); return count; } diff --git a/Benchmarks/Mockolate.Benchmarks/CompleteEventBenchmarks.cs b/Benchmarks/Mockolate.Benchmarks/CompleteEventBenchmarks.cs index e0850d9e..5373cb70 100644 --- a/Benchmarks/Mockolate.Benchmarks/CompleteEventBenchmarks.cs +++ b/Benchmarks/Mockolate.Benchmarks/CompleteEventBenchmarks.cs @@ -5,6 +5,7 @@ using Mockolate.Verify; using NSubstitute; using Arg = NSubstitute.Arg; +using Raise = NSubstitute.Raise; using Times = Moq.Times; [assembly: GenerateImposter(typeof(CompleteEventBenchmarks.IMyEventInterface))] @@ -32,6 +33,36 @@ public void Event_Mockolate() sut.Mock.Verify.SomeEvent.Subscribed().Once(); } + /// + /// + /// + [Benchmark] + public void Event_Imposter() + { + IMyEventInterfaceImposter imposter = IMyEventInterface.Imposter(); + EventHandler handler = (_, _) => { }; + + imposter.Instance().SomeEvent += handler; + imposter.SomeEvent.Raise(null!, EventArgs.Empty); + + imposter.SomeEvent.Subscribed(handler, Count.Once()); + } + + /// + /// + /// + [Benchmark] + public void Event_TUnitMocks() + { + Mock mock = TUnit.Mocks.Mock.Of(); + EventHandler handler = (_, _) => { }; + + mock.Object.SomeEvent += handler; + mock.RaiseSomeEvent(EventArgs.Empty); + + _ = mock.Events.SomeEvent.SubscriberCount; + } + /// /// /// @@ -58,7 +89,7 @@ public void Event_NSubstitute() EventHandler handler = (_, _) => { }; mock.SomeEvent += handler; - mock.SomeEvent += NSubstitute.Raise.EventWith(null, EventArgs.Empty); + mock.SomeEvent += Raise.EventWith(null, EventArgs.Empty); mock.Received(1).SomeEvent += Arg.Any(); } @@ -81,36 +112,6 @@ public void Event_FakeItEasy() .MustHaveHappened(2, FakeItEasy.Times.Exactly); } - /// - /// - /// - [Benchmark] - public void Event_Imposter() - { - IMyEventInterfaceImposter imposter = IMyEventInterface.Imposter(); - EventHandler handler = (_, _) => { }; - - imposter.Instance().SomeEvent += handler; - imposter.SomeEvent.Raise(null!, EventArgs.Empty); - - imposter.SomeEvent.Subscribed(handler, Count.Once()); - } - - /// - /// - /// - [Benchmark] - public void Event_TUnitMocks() - { - Mock mock = TUnit.Mocks.Mock.Of(); - EventHandler handler = (_, _) => { }; - - mock.Object.SomeEvent += handler; - mock.RaiseSomeEvent(EventArgs.Empty); - - _ = mock.Events.SomeEvent.SubscriberCount; - } - public interface IMyEventInterface { event EventHandler? SomeEvent; diff --git a/Benchmarks/Mockolate.Benchmarks/CompleteIndexerBenchmarks.cs b/Benchmarks/Mockolate.Benchmarks/CompleteIndexerBenchmarks.cs index d9c18999..2fc044e5 100644 --- a/Benchmarks/Mockolate.Benchmarks/CompleteIndexerBenchmarks.cs +++ b/Benchmarks/Mockolate.Benchmarks/CompleteIndexerBenchmarks.cs @@ -17,8 +17,7 @@ namespace Mockolate.Benchmarks; /// public class CompleteIndexerBenchmarks : BenchmarksBase { - [Params(1, 10)] - public int N { get; set; } + [Params(1, 10)] public int N { get; set; } /// /// @@ -39,6 +38,46 @@ public void Indexer_Mockolate() sut.Mock.Verify[It.IsAny()].Set(It.IsAny()).Exactly(N); } + /// + /// + /// + [Benchmark] + public void Indexer_Imposter() + { + IMyIndexerInterfaceImposter imposter = IMyIndexerInterface.Imposter(); + imposter[Imposter.Abstractions.Arg.Any()].Getter().Returns("foo"); + IMyIndexerInterface sut = imposter.Instance(); + + for (int i = 0; i < N; i++) + { + _ = sut[42]; + sut[42] = "bar"; + } + + imposter[Imposter.Abstractions.Arg.Any()].Getter().Called(Count.Exactly(N)); + imposter[Imposter.Abstractions.Arg.Any()].Setter().Called(Count.Exactly(N)); + } + + /* Indexers not supported on TUnit.Mocks + /// + /// + /// + [Benchmark] + public void Indexer_TUnitMocks() + { + TUnit.Mocks.Mock mock = TUnit.Mocks.Mock.Of(); + mock[Any()].Returns("foo"); + + for (int i = 0; i < N; i++) + { + _ = mock.Object[42]; + mock.Object[42] = "bar"; + } + + mock[Any()].WasCalled(TUnit.Mocks.Times.Exactly(N)); + } + */ + /// /// /// @@ -97,46 +136,6 @@ public void Indexer_FakeItEasy() A.CallToSet(() => mock[A.Ignored]).MustHaveHappened(N, FakeItEasy.Times.Exactly); } - /// - /// - /// - [Benchmark] - public void Indexer_Imposter() - { - IMyIndexerInterfaceImposter imposter = IMyIndexerInterface.Imposter(); - imposter[Imposter.Abstractions.Arg.Any()].Getter().Returns("foo"); - IMyIndexerInterface sut = imposter.Instance(); - - for (int i = 0; i < N; i++) - { - _ = sut[42]; - sut[42] = "bar"; - } - - imposter[Imposter.Abstractions.Arg.Any()].Getter().Called(Count.Exactly(N)); - imposter[Imposter.Abstractions.Arg.Any()].Setter().Called(Count.Exactly(N)); - } - - /* Indexers not supported on TUnit.Mocks - /// - /// - /// - [Benchmark] - public void Indexer_TUnitMocks() - { - TUnit.Mocks.Mock mock = TUnit.Mocks.Mock.Of(); - mock[Any()].Returns("foo"); - - for (int i = 0; i < N; i++) - { - _ = mock.Object[42]; - mock.Object[42] = "bar"; - } - - mock[Any()].WasCalled(TUnit.Mocks.Times.Exactly(N)); - } - */ - public interface IMyIndexerInterface { string this[int index] { get; set; } diff --git a/Benchmarks/Mockolate.Benchmarks/CompleteMethodBenchmarks.cs b/Benchmarks/Mockolate.Benchmarks/CompleteMethodBenchmarks.cs index 1ec7b87d..a25cf424 100644 --- a/Benchmarks/Mockolate.Benchmarks/CompleteMethodBenchmarks.cs +++ b/Benchmarks/Mockolate.Benchmarks/CompleteMethodBenchmarks.cs @@ -17,8 +17,7 @@ namespace Mockolate.Benchmarks; /// public class CompleteMethodBenchmarks : BenchmarksBase { - [Params(1, 10)] - public int N { get; set; } + [Params(1, 10)] public int N { get; set; } /// /// @@ -38,91 +37,91 @@ public void Method_Mockolate() } /// - /// + /// /// [Benchmark] - public void Method_Moq() + public void Method_Imposter() { - Moq.Mock mock = new(); - mock.Setup(x => x.MyFunc(Moq.It.IsAny())).Returns(true); - IMyMethodInterface sut = mock.Object; + IMyMethodInterfaceImposter imposter = IMyMethodInterface.Imposter(); + imposter.MyFunc(Imposter.Abstractions.Arg.Any()).Returns(true); + IMyMethodInterface sut = imposter.Instance(); for (int i = 0; i < N; i++) { sut.MyFunc(42); } - mock.Verify(x => x.MyFunc(Moq.It.IsAny()), Times.Exactly(N)); + imposter.MyFunc(Imposter.Abstractions.Arg.Any()).Called(Count.Exactly(N)); } /// - /// + /// /// [Benchmark] - public void Method_NSubstitute() + public void Method_TUnitMocks() { - IMyMethodInterface mock = Substitute.For(); - mock.MyFunc(Arg.Any()).Returns(true); + Mock mock = TUnit.Mocks.Mock.Of(); + mock.MyFunc(Any()).Returns(true); + IMyMethodInterface sut = mock.Object; for (int i = 0; i < N; i++) { - mock.MyFunc(42); + sut.MyFunc(42); } - mock.Received(N).MyFunc(Arg.Any()); + mock.MyFunc(Any()).WasCalled(TUnit.Mocks.Times.Exactly(N)); } /// - /// + /// /// [Benchmark] - public void Method_FakeItEasy() + public void Method_Moq() { - IMyMethodInterface mock = A.Fake(); - A.CallTo(() => mock.MyFunc(A.Ignored)).Returns(true); + Moq.Mock mock = new(); + mock.Setup(x => x.MyFunc(Moq.It.IsAny())).Returns(true); + IMyMethodInterface sut = mock.Object; for (int i = 0; i < N; i++) { - mock.MyFunc(42); + sut.MyFunc(42); } - A.CallTo(() => mock.MyFunc(A.Ignored)).MustHaveHappened(N, FakeItEasy.Times.Exactly); + mock.Verify(x => x.MyFunc(Moq.It.IsAny()), Times.Exactly(N)); } /// - /// + /// /// [Benchmark] - public void Method_Imposter() + public void Method_NSubstitute() { - IMyMethodInterfaceImposter imposter = IMyMethodInterface.Imposter(); - imposter.MyFunc(Imposter.Abstractions.Arg.Any()).Returns(true); - IMyMethodInterface sut = imposter.Instance(); + IMyMethodInterface mock = Substitute.For(); + mock.MyFunc(Arg.Any()).Returns(true); for (int i = 0; i < N; i++) { - sut.MyFunc(42); + mock.MyFunc(42); } - imposter.MyFunc(Imposter.Abstractions.Arg.Any()).Called(Count.Exactly(N)); + mock.Received(N).MyFunc(Arg.Any()); } /// - /// + /// /// [Benchmark] - public void Method_TUnitMocks() + public void Method_FakeItEasy() { - Mock mock = TUnit.Mocks.Mock.Of(); - mock.MyFunc(Any()).Returns(true); - IMyMethodInterface sut = mock.Object; + IMyMethodInterface mock = A.Fake(); + A.CallTo(() => mock.MyFunc(A.Ignored)).Returns(true); for (int i = 0; i < N; i++) { - sut.MyFunc(42); + mock.MyFunc(42); } - mock.MyFunc(Any()).WasCalled(TUnit.Mocks.Times.Exactly(N)); + A.CallTo(() => mock.MyFunc(A.Ignored)).MustHaveHappened(N, FakeItEasy.Times.Exactly); } public interface IMyMethodInterface diff --git a/Benchmarks/Mockolate.Benchmarks/CompletePropertyBenchmarks.cs b/Benchmarks/Mockolate.Benchmarks/CompletePropertyBenchmarks.cs index 2799c1ba..673d9ad6 100644 --- a/Benchmarks/Mockolate.Benchmarks/CompletePropertyBenchmarks.cs +++ b/Benchmarks/Mockolate.Benchmarks/CompletePropertyBenchmarks.cs @@ -4,6 +4,7 @@ using Mockolate.Benchmarks; using Mockolate.Verify; using NSubstitute; +using Arg = NSubstitute.Arg; using Times = Moq.Times; [assembly: GenerateImposter(typeof(CompletePropertyBenchmarks.IMyPropertyInterface))] @@ -16,8 +17,7 @@ namespace Mockolate.Benchmarks; /// public class CompletePropertyBenchmarks : BenchmarksBase { - [Params(1, 10)] - public int N { get; set; } + [Params(1, 10)] public int N { get; set; } /// /// @@ -39,14 +39,14 @@ public void Property_Mockolate() } /// - /// + /// /// [Benchmark] - public void Property_Moq() + public void Property_Imposter() { - Moq.Mock mock = new(); - mock.SetupGet(x => x.Counter).Returns(42); - IMyPropertyInterface sut = mock.Object; + IMyPropertyInterfaceImposter imposter = IMyPropertyInterface.Imposter(); + imposter.Counter.Getter().Returns(42); + IMyPropertyInterface sut = imposter.Instance(); for (int i = 0; i < N; i++) { @@ -54,86 +54,86 @@ public void Property_Moq() sut.Counter = i; } - mock.VerifyGet(x => x.Counter, Times.Exactly(N)); - mock.VerifySet(x => x.Counter = Moq.It.IsAny(), Times.Exactly(N)); + imposter.Counter.Getter().Called(Count.Exactly(N)); + imposter.Counter.Setter(Imposter.Abstractions.Arg.Any()).Called(Count.Exactly(N)); } /// - /// + /// /// [Benchmark] - public void Property_NSubstitute() + public void Property_TUnitMocks() { - IMyPropertyInterface mock = Substitute.For(); + Mock mock = TUnit.Mocks.Mock.Of(); mock.Counter.Returns(42); + IMyPropertyInterface sut = mock.Object; for (int i = 0; i < N; i++) { - _ = mock.Counter; - mock.Counter = i; + _ = sut.Counter; + sut.Counter = i; } - _ = mock.Received(N).Counter; - mock.Received(N).Counter = NSubstitute.Arg.Any(); + mock.Counter.WasCalled(TUnit.Mocks.Times.Exactly(N)); + mock.Counter.Setter.WasCalled(TUnit.Mocks.Times.Exactly(N)); } /// - /// + /// /// [Benchmark] - public void Property_FakeItEasy() + public void Property_Moq() { - IMyPropertyInterface mock = A.Fake(); - A.CallTo(() => mock.Counter).Returns(42); + Moq.Mock mock = new(); + mock.SetupGet(x => x.Counter).Returns(42); + IMyPropertyInterface sut = mock.Object; for (int i = 0; i < N; i++) { - _ = mock.Counter; - mock.Counter = i; + _ = sut.Counter; + sut.Counter = i; } - A.CallTo(() => mock.Counter).MustHaveHappened(N, FakeItEasy.Times.Exactly); - A.CallToSet(() => mock.Counter).MustHaveHappened(N, FakeItEasy.Times.Exactly); + mock.VerifyGet(x => x.Counter, Times.Exactly(N)); + mock.VerifySet(x => x.Counter = Moq.It.IsAny(), Times.Exactly(N)); } /// - /// + /// /// [Benchmark] - public void Property_Imposter() + public void Property_NSubstitute() { - IMyPropertyInterfaceImposter imposter = IMyPropertyInterface.Imposter(); - imposter.Counter.Getter().Returns(42); - IMyPropertyInterface sut = imposter.Instance(); + IMyPropertyInterface mock = Substitute.For(); + mock.Counter.Returns(42); for (int i = 0; i < N; i++) { - _ = sut.Counter; - sut.Counter = i; + _ = mock.Counter; + mock.Counter = i; } - imposter.Counter.Getter().Called(Count.Exactly(N)); - imposter.Counter.Setter(Imposter.Abstractions.Arg.Any()).Called(Count.Exactly(N)); + _ = mock.Received(N).Counter; + mock.Received(N).Counter = Arg.Any(); } /// - /// + /// /// [Benchmark] - public void Property_TUnitMocks() + public void Property_FakeItEasy() { - Mock mock = TUnit.Mocks.Mock.Of(); - mock.Counter.Returns(42); - IMyPropertyInterface sut = mock.Object; + IMyPropertyInterface mock = A.Fake(); + A.CallTo(() => mock.Counter).Returns(42); for (int i = 0; i < N; i++) { - _ = sut.Counter; - sut.Counter = i; + _ = mock.Counter; + mock.Counter = i; } - mock.Counter.WasCalled(TUnit.Mocks.Times.Exactly(N)); - mock.Counter.Setter.WasCalled(TUnit.Mocks.Times.Exactly(N)); + A.CallTo(() => mock.Counter).MustHaveHappened(N, FakeItEasy.Times.Exactly); + A.CallToSet(() => mock.Counter).MustHaveHappened(N, FakeItEasy.Times.Exactly); } public interface IMyPropertyInterface @@ -141,4 +141,4 @@ public interface IMyPropertyInterface int Counter { get; set; } } } -#pragma warning restore CA1822 // Mark members as static \ No newline at end of file +#pragma warning restore CA1822 // Mark members as static diff --git a/Docs/pages/00-index.md b/Docs/pages/00-index.md index 1bdc7a9b..0fefd34e 100644 --- a/Docs/pages/00-index.md +++ b/Docs/pages/00-index.md @@ -15,12 +15,12 @@ It enables fast, compile-time validated mocking with .NET Standard 2.0, .NET 8, ## Why Mockolate -| | Reflection-based mocks (Moq, NSubstitute, …) | Mockolate | -|---|---|---| -| AOT / trimming | not supported | supported | -| Validation | runtime exceptions | analyzers + compile errors | -| Setup API | `Expression>` trees | regular method calls | -| Hot path | dynamic-proxy dispatch | direct dispatch | +| | Reflection-based mocks (Moq, NSubstitute, …) | Mockolate | +|----------------|----------------------------------------------|----------------------------| +| AOT / trimming | not supported | supported | +| Validation | runtime exceptions | analyzers + compile errors | +| Setup API | `Expression>` trees | regular method calls | +| Hot path | dynamic-proxy dispatch | direct dispatch | For side-by-side setup, usage, and verification syntax against Moq, NSubstitute, and FakeItEasy, see the [full code comparison](08-comparison.md). diff --git a/Docs/pages/01-create-mocks.md b/Docs/pages/01-create-mocks.md index b7524fa7..7dfdbc32 100644 --- a/Docs/pages/01-create-mocks.md +++ b/Docs/pages/01-create-mocks.md @@ -28,14 +28,14 @@ MyChocolateDispenser classMock = MyChocolateDispenser.CreateMock(behavior, "Dark **`MockBehavior` options** -| Option | Default | Purpose | -|---|---|---| -| `SkipBaseClass` | `false` | When `true`, the mock does not call any base class implementations. Otherwise, the base class implementation is used as the default value when no explicit setup matches. | -| `ThrowWhenNotSetup` | `false` | When `true`, the mock throws when no matching setup is found. Otherwise, it returns a default value (see `DefaultValue` below). | -| `SkipInteractionRecording` | `false` | When `true`, interactions are not recorded - setups, returns, callbacks, and base-class delegation still work, but `.Verify.X()` throws a `MockException`. Useful in performance-sensitive scenarios. | -| `DefaultValue` | sensible defaults | Customizes how default values are generated for unset methods and properties (see below). | -| `Initialize(...)` | - | Automatically applies the given setups to all mocks of type `T` when they are created. | -| `UseConstructorParametersFor(...)` | - | Configures default constructor parameters for mocks of type `T`, unless explicit parameters are supplied to `CreateMock([…])`. The `Func` overload defers parameter resolution until each mock is created. | +| Option | Default | Purpose | +|---------------------------------------|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `SkipBaseClass` | `false` | When `true`, the mock does not call any base class implementations. Otherwise, the base class implementation is used as the default value when no explicit setup matches. | +| `ThrowWhenNotSetup` | `false` | When `true`, the mock throws when no matching setup is found. Otherwise, it returns a default value (see `DefaultValue` below). | +| `SkipInteractionRecording` | `false` | When `true`, interactions are not recorded - setups, returns, callbacks, and base-class delegation still work, but `.Verify.X()` throws a `MockException`. Useful in performance-sensitive scenarios. | +| `DefaultValue` | sensible defaults | Customizes how default values are generated for unset methods and properties (see below). | +| `Initialize(...)` | - | Automatically applies the given setups to all mocks of type `T` when they are created. | +| `UseConstructorParametersFor(...)` | - | Configures default constructor parameters for mocks of type `T`, unless explicit parameters are supplied to `CreateMock([…])`. The `Func` overload defers parameter resolution until each mock is created. | **Default value generation** diff --git a/Docs/pages/setup/04-parameter-matching.md b/Docs/pages/setup/04-parameter-matching.md index 7f212ae6..1d85cc57 100644 --- a/Docs/pages/setup/04-parameter-matching.md +++ b/Docs/pages/setup/04-parameter-matching.md @@ -214,7 +214,6 @@ The following cases are rejected at compile time with diagnostic `Mockolate0003` - `out` / `ref` / `ref readonly` parameters of a ref-struct type. - Methods that return a custom ref struct. (`Span` / `ReadOnlySpan` returns are supported.) - ## Parameter Predicates When the method name is unique (no overloads), you can use argument matchers from the `Match` class for more flexible parameters matching: diff --git a/Mockolate.slnx b/Mockolate.slnx index d7ce7f19..0bffe03c 100644 --- a/Mockolate.slnx +++ b/Mockolate.slnx @@ -1,82 +1,82 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Pipeline/BenchmarkReport.cs b/Pipeline/BenchmarkReport.cs index 24a5eb5f..7ec1f514 100644 --- a/Pipeline/BenchmarkReport.cs +++ b/Pipeline/BenchmarkReport.cs @@ -299,9 +299,9 @@ internal static bool TryParseQuantity(string value, out double normalized) string unitPart = spaceIdx > 0 ? trimmed.Substring(spaceIdx + 1).Trim() : string.Empty; if (!double.TryParse(numberPart, - NumberStyles.Float | NumberStyles.AllowThousands, - CultureInfo.InvariantCulture, - out double number)) + NumberStyles.Float | NumberStyles.AllowThousands, + CultureInfo.InvariantCulture, + out double number)) { return false; } diff --git a/Pipeline/Build.cs b/Pipeline/Build.cs index ee7a4770..439c929b 100644 --- a/Pipeline/Build.cs +++ b/Pipeline/Build.cs @@ -14,8 +14,7 @@ namespace Build; )] partial class Build : NukeBuild { - [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] - readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release; + [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release; [Parameter("Github Token")] readonly string GithubToken; diff --git a/Pipeline/Directory.Build.props b/Pipeline/Directory.Build.props index 05313825..adacb2e4 100644 --- a/Pipeline/Directory.Build.props +++ b/Pipeline/Directory.Build.props @@ -1,6 +1,6 @@ - + diff --git a/Source/Mockolate.Analyzers/AnalyzerReleases.Shipped.md b/Source/Mockolate.Analyzers/AnalyzerReleases.Shipped.md index e78b34c8..9ebac30c 100644 --- a/Source/Mockolate.Analyzers/AnalyzerReleases.Shipped.md +++ b/Source/Mockolate.Analyzers/AnalyzerReleases.Shipped.md @@ -2,8 +2,8 @@ ### New Rules - Rule ID | Category | Severity | Notes ----------------|----------|----------|--------------------------------- - Mockolate0001 | Usage | Error | Verifications must be used - Mockolate0002 | Usage | Error | Mock arguments must be mockable - Mockolate0003 | Usage | Warning | Ref-struct parameter mocking not supported on this build + Rule ID | Category | Severity | Notes +---------------|----------|----------|---------------------------------------------------------- + Mockolate0001 | Usage | Error | Verifications must be used + Mockolate0002 | Usage | Error | Mock arguments must be mockable + Mockolate0003 | Usage | Warning | Ref-struct parameter mocking not supported on this build diff --git a/Source/Mockolate.Analyzers/MockabilityAnalyzer.cs b/Source/Mockolate.Analyzers/MockabilityAnalyzer.cs index 4f0e38b7..6f92f67c 100644 --- a/Source/Mockolate.Analyzers/MockabilityAnalyzer.cs +++ b/Source/Mockolate.Analyzers/MockabilityAnalyzer.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; -using System.Diagnostics.CodeAnalysis; using System.Linq; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; diff --git a/Source/Mockolate.SourceGenerators/Entities/Attribute.cs b/Source/Mockolate.SourceGenerators/Entities/Attribute.cs index 2f3415e6..7c0ce044 100644 --- a/Source/Mockolate.SourceGenerators/Entities/Attribute.cs +++ b/Source/Mockolate.SourceGenerators/Entities/Attribute.cs @@ -1,5 +1,4 @@ using Microsoft.CodeAnalysis; -using Mockolate.SourceGenerators.Internals; namespace Mockolate.SourceGenerators.Entities; diff --git a/Source/Mockolate.SourceGenerators/Entities/Class.cs b/Source/Mockolate.SourceGenerators/Entities/Class.cs index ef0110fb..dc915363 100644 --- a/Source/Mockolate.SourceGenerators/Entities/Class.cs +++ b/Source/Mockolate.SourceGenerators/Entities/Class.cs @@ -173,6 +173,25 @@ bool ShouldIncludeMember(ISymbol member) public string ClassName { get; } public string DisplayString { get; } + /// + /// Equality is keyed on plus a content-derived hash of the + /// member surface (). The full name alone is necessary + /// but not sufficient as a Roslyn incremental cache key: across edits, a target type can + /// keep its name while its members change, and a name-only comparison would let Roslyn + /// skip downstream stages and persist stale generated source. Folding the surface into a + /// precomputed hash keeps the comparison O(1) on the cache hot path while still + /// invalidating on any change to the emitted member set. Hash collisions are theoretically + /// possible but the leaf entities (, , and + /// ) are records with content-based hashes that propagate through + /// , so different surfaces almost always hash apart. + /// + public virtual bool Equals(Class? other) + => ReferenceEquals(this, other) || + (other is not null && + GetType() == other.GetType() && + _surfaceHash == other._surfaceHash && + ClassFullName == other.ClassFullName); + /// /// Folds the member surface (methods, properties, events, recursive base/interface chain, /// reserved names, kind, required-member flag) into a single content-derived integer. @@ -502,25 +521,6 @@ public string GetClassNameWithoutDots() return _classNameWithoutDots = sb.ToString(); } - /// - /// Equality is keyed on plus a content-derived hash of the - /// member surface (). The full name alone is necessary - /// but not sufficient as a Roslyn incremental cache key: across edits, a target type can - /// keep its name while its members change, and a name-only comparison would let Roslyn - /// skip downstream stages and persist stale generated source. Folding the surface into a - /// precomputed hash keeps the comparison O(1) on the cache hot path while still - /// invalidating on any change to the emitted member set. Hash collisions are theoretically - /// possible but the leaf entities (, , and - /// ) are records with content-based hashes that propagate through - /// , so different surfaces almost always hash apart. - /// - public virtual bool Equals(Class? other) - => ReferenceEquals(this, other) || - (other is not null && - GetType() == other.GetType() && - _surfaceHash == other._surfaceHash && - ClassFullName == other.ClassFullName); - public override bool Equals(object? obj) => Equals(obj as Class); public override int GetHashCode() => _surfaceHash; diff --git a/Source/Mockolate.SourceGenerators/Entities/Event.cs b/Source/Mockolate.SourceGenerators/Entities/Event.cs index f36e7119..0a63ddc5 100644 --- a/Source/Mockolate.SourceGenerators/Entities/Event.cs +++ b/Source/Mockolate.SourceGenerators/Entities/Event.cs @@ -1,6 +1,5 @@ using System.Diagnostics; using Microsoft.CodeAnalysis; -using Mockolate.SourceGenerators.Internals; namespace Mockolate.SourceGenerators.Entities; diff --git a/Source/Mockolate.SourceGenerators/Entities/GenericParameter.cs b/Source/Mockolate.SourceGenerators/Entities/GenericParameter.cs index 57784ff0..a1d968f1 100644 --- a/Source/Mockolate.SourceGenerators/Entities/GenericParameter.cs +++ b/Source/Mockolate.SourceGenerators/Entities/GenericParameter.cs @@ -1,6 +1,5 @@ using System.Text; using Microsoft.CodeAnalysis; -using Mockolate.SourceGenerators.Internals; namespace Mockolate.SourceGenerators.Entities; diff --git a/Source/Mockolate.SourceGenerators/Entities/Method.cs b/Source/Mockolate.SourceGenerators/Entities/Method.cs index b6c6d761..164f57c5 100644 --- a/Source/Mockolate.SourceGenerators/Entities/Method.cs +++ b/Source/Mockolate.SourceGenerators/Entities/Method.cs @@ -74,19 +74,6 @@ public Method(IMethodSymbol methodSymbol, List? alreadyDefinedMethods, I public string? ExplicitImplementation { get; } public EquatableArray? Attributes { get; } - internal string GetUniqueNameString() - { - if (GenericParameters != null) - { - string name = Name.Substring(0, Name.IndexOf('<')); - string parameters = string.Join(", ", - GenericParameters.Value.Select(genericParameter => $"{{typeof({genericParameter.Name})}}")); - return $"$\"{ContainingType}.{name}<{parameters}>\""; - } - - return $"\"{ContainingType}.{Name}\""; - } - /// /// A method has an unsupported allows ref struct type parameter when one of its /// own generic parameters declares the anti-constraint and is referenced in the @@ -129,6 +116,19 @@ public bool HasUnsupportedAllowsRefStructTypeParameter } } + internal string GetUniqueNameString() + { + if (GenericParameters != null) + { + string name = Name.Substring(0, Name.IndexOf('<')); + string parameters = string.Join(", ", + GenericParameters.Value.Select(genericParameter => $"{{typeof({genericParameter.Name})}}")); + return $"$\"{ContainingType}.{name}<{parameters}>\""; + } + + return $"\"{ContainingType}.{Name}\""; + } + private static bool ContainsAnyTypeParameter(string text, GenericParameter[] genericParameters) { foreach (GenericParameter gp in genericParameters) diff --git a/Source/Mockolate.SourceGenerators/Entities/MockClass.cs b/Source/Mockolate.SourceGenerators/Entities/MockClass.cs index 568e11e2..cc4f7afa 100644 --- a/Source/Mockolate.SourceGenerators/Entities/MockClass.cs +++ b/Source/Mockolate.SourceGenerators/Entities/MockClass.cs @@ -1,5 +1,4 @@ using Microsoft.CodeAnalysis; -using Mockolate.SourceGenerators.Internals; namespace Mockolate.SourceGenerators.Entities; @@ -35,15 +34,6 @@ public MockClass(ITypeSymbol[] types, IAssemblySymbol sourceAssembly) : base(typ public EquatableArray AdditionalImplementations { get; } - public IEnumerable AllImplementations() - { - yield return this; - foreach (Class additionalImplementation in AdditionalImplementations) - { - yield return additionalImplementation; - } - } - /// /// MockClass equality is keyed on plus a content-derived /// hash that folds the base surface together with the mock-only fields @@ -58,6 +48,15 @@ public bool Equals(MockClass? other) _mockSurfaceHash == other._mockSurfaceHash && ClassFullName == other.ClassFullName); + public IEnumerable AllImplementations() + { + yield return this; + foreach (Class additionalImplementation in AdditionalImplementations) + { + yield return additionalImplementation; + } + } + public override bool Equals(Class? other) => other is MockClass mc && Equals(mc); public override bool Equals(object? obj) => Equals(obj as MockClass); diff --git a/Source/Mockolate.SourceGenerators/Entities/Property.cs b/Source/Mockolate.SourceGenerators/Entities/Property.cs index 9cc775a4..a16d3400 100644 --- a/Source/Mockolate.SourceGenerators/Entities/Property.cs +++ b/Source/Mockolate.SourceGenerators/Entities/Property.cs @@ -1,6 +1,5 @@ using System.Diagnostics; using Microsoft.CodeAnalysis; -using Mockolate.SourceGenerators.Internals; namespace Mockolate.SourceGenerators.Entities; diff --git a/Source/Mockolate.SourceGenerators/Helpers.cs b/Source/Mockolate.SourceGenerators/Helpers.cs index c489870f..cda85ac2 100644 --- a/Source/Mockolate.SourceGenerators/Helpers.cs +++ b/Source/Mockolate.SourceGenerators/Helpers.cs @@ -3,7 +3,6 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Mockolate.SourceGenerators.Entities; -using Mockolate.SourceGenerators.Internals; using Attribute = Mockolate.SourceGenerators.Entities.Attribute; using Type = Mockolate.SourceGenerators.Entities.Type; diff --git a/Source/Mockolate.SourceGenerators/Internals/EntityCache.cs b/Source/Mockolate.SourceGenerators/Internals/EntityCache.cs index 848b4f0f..9ce1424c 100644 --- a/Source/Mockolate.SourceGenerators/Internals/EntityCache.cs +++ b/Source/Mockolate.SourceGenerators/Internals/EntityCache.cs @@ -51,7 +51,7 @@ public MethodParameter GetOrAddParameter(IParameterSymbol symbol, Func Current = previous; - + private readonly EntityCache? _previous; internal Scope(EntityCache? previous) diff --git a/Source/Mockolate.SourceGenerators/MockGeneratorHelpers.cs b/Source/Mockolate.SourceGenerators/MockGeneratorHelpers.cs index a064fa51..454b8b4e 100644 --- a/Source/Mockolate.SourceGenerators/MockGeneratorHelpers.cs +++ b/Source/Mockolate.SourceGenerators/MockGeneratorHelpers.cs @@ -1,4 +1,3 @@ -using System.Diagnostics.CodeAnalysis; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; using Mockolate.SourceGenerators.Entities; diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.MemberIds.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.MemberIds.cs index 43f2e3eb..006fc3df 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.MemberIds.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.MemberIds.cs @@ -1,4 +1,3 @@ -using System; using System.Text; using Mockolate.SourceGenerators.Entities; using Event = Mockolate.SourceGenerators.Entities.Event; @@ -132,8 +131,8 @@ private static void AddMissing(IEnumerable items, Dictionary exist internal sealed class MemberIdTable { private readonly List _declarations = new(); - private readonly Dictionary _usedIdentifiers = new(); private readonly List<(Property Property, string FieldName)> _propertyGetterAccessFields = new(); + private readonly Dictionary _usedIdentifiers = new(); internal Dictionary MethodIds { get; } = new(); internal Dictionary PropertyGetIds { get; } = new(); diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs index ba5977eb..9a865e49 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs @@ -3645,6 +3645,51 @@ private static bool[] ComputeTrailingDefaults(ReadOnlySpan para return result; } + // Priority hierarchy among same-arity overloads emitted for one method: + // all-values : int.MaxValue (so `Method(default, …)` binds here and exposes `.AnyParameters()`) + // IParameters : int.MaxValue - 1 + // pure IParameter? : parameterCount (just below all-values, above any mixed combo) + // mixed : count of non-value (matcher) params, in [1, parameterCount - 1] + // parameterCount == 0 returns int.MaxValue so the lone zero-arg overload keeps its historical priority. + private static string ComputeMethodOverloadPriority(bool useParameters, bool[]? valueFlags, int parameterCount) + { + if (parameterCount == 0) + { + return "int.MaxValue"; + } + + if (useParameters) + { + return "int.MaxValue - 1"; + } + + if (valueFlags is null) + { + return parameterCount.ToString(); + } + + return valueFlags.Count(x => !x).ToString(); + } + + // Object-typed parameters defeat the all-values bump: every reference type — including the + // IParameter? matcher itself — implicitly converts to object, so promoting `Method(object?)` over + // `Method(IParameter?)` would silently capture matcher instances as raw values. Detect that case + // here and skip the priority bump so callers keep using Match.AnyParameters() / It.IsAny(). + private static bool ParametersBlockAllValuesPromotion(EquatableArray parameters, + bool[] valueFlags) + { + ReadOnlySpan span = parameters.AsSpan(); + for (int i = 0; i < span.Length; i++) + { + if (valueFlags[i] && span[i].Type.SpecialType == SpecialType.System_Object) + { + return true; + } + } + + return false; + } + private static void DefineSetupInterface(StringBuilder sb, Class @class, MemberType memberType, bool hasOverloadResolutionPriority) { @@ -3881,6 +3926,14 @@ private static void AppendMethodSetupDefinition(StringBuilder sb, Class @class, { if (valueFlags?.All(x => x) == true) { + if (hasOverloadResolutionPriority && + !ParametersBlockAllValuesPromotion(method.Parameters, valueFlags)) + { + sb.Append( + "\t\t[global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)]") + .AppendLine(); + } + sb.Append("\t\tglobal::Mockolate.Setup.IReturnMethodSetupParameterIgnorer"); } else @@ -3888,7 +3941,8 @@ private static void AppendMethodSetupDefinition(StringBuilder sb, Class @class, if (hasOverloadResolutionPriority) { sb.Append("\t\t[global::System.Runtime.CompilerServices.OverloadResolutionPriority(") - .Append(valueFlags?.Count(x => !x).ToString() ?? "int.MaxValue").Append(")]").AppendLine(); + .Append(ComputeMethodOverloadPriority(useParameters, valueFlags, method.Parameters.Count)) + .Append(")]").AppendLine(); } sb.Append(method.Parameters.Count > 0 @@ -3910,6 +3964,14 @@ private static void AppendMethodSetupDefinition(StringBuilder sb, Class @class, { if (valueFlags?.All(x => x) == true) { + if (hasOverloadResolutionPriority && + !ParametersBlockAllValuesPromotion(method.Parameters, valueFlags)) + { + sb.Append( + "\t\t[global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)]") + .AppendLine(); + } + sb.Append("\t\tglobal::Mockolate.Setup.IVoidMethodSetupParameterIgnorer"); } else @@ -3917,7 +3979,8 @@ private static void AppendMethodSetupDefinition(StringBuilder sb, Class @class, if (hasOverloadResolutionPriority) { sb.Append("\t\t[global::System.Runtime.CompilerServices.OverloadResolutionPriority(") - .Append(valueFlags?.Count(x => !x).ToString() ?? "int.MaxValue").Append(")]").AppendLine(); + .Append(ComputeMethodOverloadPriority(useParameters, valueFlags, method.Parameters.Count)) + .Append(")]").AppendLine(); } sb.Append(method.Parameters.Count > 0 @@ -5532,6 +5595,13 @@ private static void AppendMethodVerifyDefinition(StringBuilder sb, Method method valueFlags, true); if (valueFlags?.All(x => x) == true || (method.Parameters.Count == 0 && !useParameters)) { + if (hasOverloadResolutionPriority && method.Parameters.Count > 0 && valueFlags is not null && + !ParametersBlockAllValuesPromotion(method.Parameters, valueFlags)) + { + sb.Append("\t\t[global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)]") + .AppendLine(); + } + sb.Append("\t\tglobal::Mockolate.Verify.VerificationResult<").Append(verifyName) .Append(">.IgnoreParameters ").Append(methodName).Append("("); } @@ -5540,7 +5610,8 @@ private static void AppendMethodVerifyDefinition(StringBuilder sb, Method method if (hasOverloadResolutionPriority) { sb.Append("\t\t[global::System.Runtime.CompilerServices.OverloadResolutionPriority(") - .Append(valueFlags?.Count(x => !x).ToString() ?? "int.MaxValue").Append(")]").AppendLine(); + .Append(ComputeMethodOverloadPriority(useParameters, valueFlags, method.Parameters.Count)) + .Append(")]").AppendLine(); } sb.Append("\t\tglobal::Mockolate.Verify.VerificationResult<").Append(verifyName).Append("> ") diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.MockCombination.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.MockCombination.cs index 21d657cd..7200a415 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.MockCombination.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.MockCombination.cs @@ -1,6 +1,5 @@ using System.Text; using Mockolate.SourceGenerators.Entities; -using Mockolate.SourceGenerators.Internals; namespace Mockolate.SourceGenerators.Sources; diff --git a/Source/Mockolate/Interactions/FastEventBuffer.cs b/Source/Mockolate/Interactions/FastEventBuffer.cs index 46cc749b..def13db2 100644 --- a/Source/Mockolate/Interactions/FastEventBuffer.cs +++ b/Source/Mockolate/Interactions/FastEventBuffer.cs @@ -136,4 +136,3 @@ internal struct Record public IInteraction? Boxed; } } - diff --git a/Source/Mockolate/Interactions/FastIndexerBuffer.cs b/Source/Mockolate/Interactions/FastIndexerBuffer.cs index 3ba3871b..06f55ce0 100644 --- a/Source/Mockolate/Interactions/FastIndexerBuffer.cs +++ b/Source/Mockolate/Interactions/FastIndexerBuffer.cs @@ -1099,4 +1099,3 @@ internal struct Record public IInteraction? Boxed; } } - diff --git a/Source/Mockolate/Interactions/FastMethodBuffer.cs b/Source/Mockolate/Interactions/FastMethodBuffer.cs index 5e37107b..d503185c 100644 --- a/Source/Mockolate/Interactions/FastMethodBuffer.cs +++ b/Source/Mockolate/Interactions/FastMethodBuffer.cs @@ -637,4 +637,3 @@ internal struct Record public IInteraction? Boxed; } } - diff --git a/Source/Mockolate/Interactions/FastMockInteractions.cs b/Source/Mockolate/Interactions/FastMockInteractions.cs index 522e3a82..f17498aa 100644 --- a/Source/Mockolate/Interactions/FastMockInteractions.cs +++ b/Source/Mockolate/Interactions/FastMockInteractions.cs @@ -30,7 +30,7 @@ public class FastMockInteractions : IMockInteractions /// /// Creates a new sized to . /// Each mockable member's buffer slot starts empty and is materialized lazily on first access via - /// . + /// . /// /// The number of distinct mockable members the buffer array should hold. /// Mirrors . diff --git a/Source/Mockolate/Interactions/FastPropertyBuffer.cs b/Source/Mockolate/Interactions/FastPropertyBuffer.cs index d2920980..00f0cb2f 100644 --- a/Source/Mockolate/Interactions/FastPropertyBuffer.cs +++ b/Source/Mockolate/Interactions/FastPropertyBuffer.cs @@ -245,4 +245,3 @@ internal struct Record public IInteraction? Boxed; } } - diff --git a/Source/Mockolate/It.Is.cs b/Source/Mockolate/It.Is.cs index 1f2ba4a9..c9a8b7e0 100644 --- a/Source/Mockolate/It.Is.cs +++ b/Source/Mockolate/It.Is.cs @@ -47,7 +47,7 @@ public static IIsParameter Is(T value, /// A parameter matcher whose diagnostic string is computed lazily. [EditorBrowsable(EditorBrowsableState.Never)] public static IIsParameter IsValue(T value) - => new ParameterEqualsMatch(value, valueExpression: null); + => new ParameterEqualsMatch(value, null); /// /// An used for equality comparison, with an opt-in custom comparer. @@ -73,9 +73,9 @@ IIsParameter Using(IEqualityComparer comparer, private sealed class ParameterEqualsMatch : TypedMatch, IIsParameter { private readonly T _value; - private string? _valueExpression; private IEqualityComparer? _comparer; private string? _comparerExpression; + private string? _valueExpression; /// /// Constructs an equality matcher for . When diff --git a/Source/Mockolate/Verify/VerificationPropertyResult.cs b/Source/Mockolate/Verify/VerificationPropertyResult.cs index 7a08914a..fff7d0f4 100644 --- a/Source/Mockolate/Verify/VerificationPropertyResult.cs +++ b/Source/Mockolate/Verify/VerificationPropertyResult.cs @@ -1,4 +1,3 @@ -using System.Diagnostics; using System.Runtime.CompilerServices; using Mockolate.Parameters; @@ -8,7 +7,7 @@ namespace Mockolate.Verify; /// Verifications on a property of type . /// #if !DEBUG -[DebuggerNonUserCode] +[System.Diagnostics.DebuggerNonUserCode] #endif public class VerificationPropertyResult { @@ -61,7 +60,8 @@ public VerificationResult Set(IParameter value) /// [OverloadResolutionPriority(1)] public VerificationResult Set(TParameter value, - [CallerArgumentExpression(nameof(value))] string doNotPopulateThisValue = "") + [CallerArgumentExpression(nameof(value))] + string doNotPopulateThisValue = "") => _mockRegistry.VerifyPropertyTyped(_subject, _setMemberId, _propertyName, It.Is(value, doNotPopulateThisValue).AsParameterMatch()); } diff --git a/Source/Mockolate/Verify/VerificationResultExtensions.cs b/Source/Mockolate/Verify/VerificationResultExtensions.cs index 6e594cd9..8d9247ed 100644 --- a/Source/Mockolate/Verify/VerificationResultExtensions.cs +++ b/Source/Mockolate/Verify/VerificationResultExtensions.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using System.Runtime.CompilerServices; using Mockolate.Exceptions; @@ -19,7 +18,7 @@ namespace Mockolate.Verify; /// interactions produced on a background thread. /// #if !DEBUG -[DebuggerNonUserCode] +[System.Diagnostics.DebuggerNonUserCode] #endif public static class VerificationResultExtensions { diff --git a/Tests/Build.Tests/BuildBodyTests.cs b/Tests/Build.Tests/BuildBodyTests.cs index 6549fe22..183abfff 100644 --- a/Tests/Build.Tests/BuildBodyTests.cs +++ b/Tests/Build.Tests/BuildBodyTests.cs @@ -129,7 +129,7 @@ public async Task BuildBody_WhenInvocationCountAndMeanMatch_ShouldInjectBaseline } [Fact] - public async Task BuildBody_WhenTableHasEmptyRowSeparatingParameterGroups_ShouldNotEmitBareSeparator() + public async Task BuildBody_WhenTableHasEmptyRowSeparatingParameterGroups_ShouldEmitEmptyRowMatchingHeaderColumnCount() { string[] report = [ @@ -145,11 +145,16 @@ public async Task BuildBody_WhenTableHasEmptyRowSeparatingParameterGroups_Should string body = BenchmarkReport.BuildBody([file,], _columnsToRemove); - await That(body).DoesNotContain($"{Environment.NewLine}|{Environment.NewLine}"); + string[] lines = body.Split(Environment.NewLine); + int firstGroupLast = Array.IndexOf(lines, "| Moq | 1 | 200 ns | 2 KB |"); + int secondGroupFirst = Array.IndexOf(lines, "| **Mockolate** | **10** | **1000 ns** | **10 KB** |"); + await That(firstGroupLast).IsGreaterThan(-1); + await That(secondGroupFirst).IsGreaterThan(firstGroupLast); + await That(lines[firstGroupLast + 1]).IsEqualTo("| | | | |"); } [Fact] - public async Task BuildBody_WhenTableHasEmptyRowSeparatingParameterGroups_ShouldEmitEmptyRowMatchingHeaderColumnCount() + public async Task BuildBody_WhenTableHasEmptyRowSeparatingParameterGroups_ShouldNotEmitBareSeparator() { string[] report = [ @@ -165,12 +170,7 @@ public async Task BuildBody_WhenTableHasEmptyRowSeparatingParameterGroups_Should string body = BenchmarkReport.BuildBody([file,], _columnsToRemove); - string[] lines = body.Split(Environment.NewLine); - int firstGroupLast = Array.IndexOf(lines, "| Moq | 1 | 200 ns | 2 KB |"); - int secondGroupFirst = Array.IndexOf(lines, "| **Mockolate** | **10** | **1000 ns** | **10 KB** |"); - await That(firstGroupLast).IsGreaterThan(-1); - await That(secondGroupFirst).IsGreaterThan(firstGroupLast); - await That(lines[firstGroupLast + 1]).IsEqualTo("| | | | |"); + await That(body).DoesNotContain($"{Environment.NewLine}|{Environment.NewLine}"); } [Fact] diff --git a/Tests/Mockolate.Analyzers.Tests/AnalyzerHelpersTests.cs b/Tests/Mockolate.Analyzers.Tests/AnalyzerHelpersTests.cs index 48a8ed7d..a0215a91 100644 --- a/Tests/Mockolate.Analyzers.Tests/AnalyzerHelpersTests.cs +++ b/Tests/Mockolate.Analyzers.Tests/AnalyzerHelpersTests.cs @@ -12,32 +12,43 @@ namespace Mockolate.Analyzers.Tests; public class AnalyzerHelpersTests { [Fact] - public async Task WhenInvokedMethodIsNotGeneric_ShouldNotReturnAnyTypeArgument() + public async Task WhenInvocationHasGenericNameSyntax_ShouldReturnTypeArgumentLocation() { const string source = """ - public class C - { - public void Foo() { } - public void Bar() { Foo(); } - } - """; - IMethodSymbol method = GetInvokedMethod(source, "Foo"); + public static class S + { + public static T Make() => default!; + } + + public class C + { + public void Foo() { S.Make(); } + } + """; + SyntaxTree tree = CSharpSyntaxTree.ParseText(source); + CSharpCompilation compilation = CreateCompilation(tree); + SemanticModel model = compilation.GetSemanticModel(tree); + InvocationExpressionSyntax invocation = tree.GetRoot().DescendantNodes() + .OfType() + .Single(i => i.Expression is MemberAccessExpressionSyntax { Name: GenericNameSyntax, }); + IMethodSymbol method = (IMethodSymbol)model.GetSymbolInfo(invocation).Symbol!; + ITypeSymbol typeArgument = method.TypeArguments[0]; - ITypeSymbol? result = AnalyzerHelpers.GetSingleInvocationTypeArgumentOrNull(method); + Location? result = AnalyzerHelpers.GetTypeArgumentLocation(invocation, typeArgument); - await That(result).IsNull(); + await That(result).IsNotNull(); } [Fact] public async Task WhenInvokedMethodIsGeneric_ShouldReturnFirstTypeArgument() { const string source = """ - public class C - { - public T Foo() => default!; - public void Bar() { Foo(); } - } - """; + public class C + { + public T Foo() => default!; + public void Bar() { Foo(); } + } + """; IMethodSymbol method = GetInvokedMethod(source, "Foo"); ITypeSymbol? result = AnalyzerHelpers.GetSingleInvocationTypeArgumentOrNull(method); @@ -47,53 +58,42 @@ public class C } [Fact] - public async Task WhenSyntaxIsNotInvocationExpression_ShouldNotReturnAnyLocation() + public async Task WhenInvokedMethodIsNotGeneric_ShouldNotReturnAnyTypeArgument() { const string source = """ - public class C - { - public int Foo() => 0; - } - """; - SyntaxTree tree = CSharpSyntaxTree.ParseText(source); - CSharpCompilation compilation = CreateCompilation(tree); - SemanticModel model = compilation.GetSemanticModel(tree); - MethodDeclarationSyntax declaration = tree.GetRoot().DescendantNodes() - .OfType() - .Single(); - IMethodSymbol symbol = (IMethodSymbol)model.GetDeclaredSymbol(declaration)!; + public class C + { + public void Foo() { } + public void Bar() { Foo(); } + } + """; + IMethodSymbol method = GetInvokedMethod(source, "Foo"); - Location? result = AnalyzerHelpers.GetTypeArgumentLocation(declaration, symbol.ReturnType); + ITypeSymbol? result = AnalyzerHelpers.GetSingleInvocationTypeArgumentOrNull(method); await That(result).IsNull(); } [Fact] - public async Task WhenInvocationHasGenericNameSyntax_ShouldReturnTypeArgumentLocation() + public async Task WhenSyntaxIsNotInvocationExpression_ShouldNotReturnAnyLocation() { const string source = """ - public static class S - { - public static T Make() => default!; - } - - public class C - { - public void Foo() { S.Make(); } - } - """; + public class C + { + public int Foo() => 0; + } + """; SyntaxTree tree = CSharpSyntaxTree.ParseText(source); CSharpCompilation compilation = CreateCompilation(tree); SemanticModel model = compilation.GetSemanticModel(tree); - InvocationExpressionSyntax invocation = tree.GetRoot().DescendantNodes() - .OfType() - .Single(i => i.Expression is MemberAccessExpressionSyntax { Name: GenericNameSyntax, }); - IMethodSymbol method = (IMethodSymbol)model.GetSymbolInfo(invocation).Symbol!; - ITypeSymbol typeArgument = method.TypeArguments[0]; + MethodDeclarationSyntax declaration = tree.GetRoot().DescendantNodes() + .OfType() + .Single(); + IMethodSymbol symbol = (IMethodSymbol)model.GetDeclaredSymbol(declaration)!; - Location? result = AnalyzerHelpers.GetTypeArgumentLocation(invocation, typeArgument); + Location? result = AnalyzerHelpers.GetTypeArgumentLocation(declaration, symbol.ReturnType); - await That(result).IsNotNull(); + await That(result).IsNull(); } private static IMethodSymbol GetInvokedMethod(string source, string methodName) diff --git a/Tests/Mockolate.SourceGenerators.Tests/Entities/PropertyEqualityComparerTests.cs b/Tests/Mockolate.SourceGenerators.Tests/Entities/PropertyEqualityComparerTests.cs index fee0ec28..17dd2c25 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Entities/PropertyEqualityComparerTests.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Entities/PropertyEqualityComparerTests.cs @@ -79,10 +79,10 @@ public async Task NonIndexersWithDifferentContainingType_ShouldReturnFalse() } private static Property CreateProperty(string source, string propertyName) - => new Property(ParsePropertySymbol(source, propertyName, false), null); + => new(ParsePropertySymbol(source, propertyName, false), null); private static Property CreateIndexer(string source) - => new Property(ParsePropertySymbol(source, null, true), null); + => new(ParsePropertySymbol(source, null, true), null); private static IPropertySymbol ParsePropertySymbol(string source, string? propertyName, bool isIndexer) { diff --git a/Tests/Mockolate.SourceGenerators.Tests/MockGenerator.EqualityTests.cs b/Tests/Mockolate.SourceGenerators.Tests/MockGenerator.EqualityTests.cs index fec624fe..8e00f2e5 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/MockGenerator.EqualityTests.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/MockGenerator.EqualityTests.cs @@ -1,7 +1,6 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Mockolate.SourceGenerators.Entities; -using Mockolate.SourceGenerators.Internals; namespace Mockolate.SourceGenerators.Tests; diff --git a/Tests/Mockolate.SourceGenerators.Tests/MockTests.ClassTests.EventsTests.cs b/Tests/Mockolate.SourceGenerators.Tests/MockTests.ClassTests.EventsTests.cs index eb1dd385..400df654 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/MockTests.ClassTests.EventsTests.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/MockTests.ClassTests.EventsTests.cs @@ -6,6 +6,33 @@ public sealed partial class ClassTests { public sealed class EventsTests { + [Fact] + public async Task EventWithRefOutDelegate_ShouldPreserveModifiersOnRaise() + { + GeneratorResult result = Generator + .Run(""" + using Mockolate; + + namespace MyCode; + public class Program + { + public static void Main(string[] args) + { + _ = IMyService.CreateMock(); + } + } + + public delegate void MyEventDelegate(ref int value, out string message); + + public interface IMyService + { + event MyEventDelegate SomeEvent; + } + """); + + await That(result.Diagnostics).IsEmpty(); + } + [Fact] public async Task MultipleImplementations_ShouldOnlyHaveOneExplicitImplementation() { @@ -450,33 +477,6 @@ await That(result.Sources["Mock.MyService__IMyOtherService.g.cs"]) } """).IgnoringNewlineStyle(); } - - [Fact] - public async Task EventWithRefOutDelegate_ShouldPreserveModifiersOnRaise() - { - GeneratorResult result = Generator - .Run(""" - using Mockolate; - - namespace MyCode; - public class Program - { - public static void Main(string[] args) - { - _ = IMyService.CreateMock(); - } - } - - public delegate void MyEventDelegate(ref int value, out string message); - - public interface IMyService - { - event MyEventDelegate SomeEvent; - } - """); - - await That(result.Diagnostics).IsEmpty(); - } } } } diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/Mock.IComprehensiveInterface.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/Mock.IComprehensiveInterface.g.cs index 7937aae1..2b44a34e 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/Mock.IComprehensiveInterface.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/Mock.IComprehensiveInterface.g.cs @@ -232,28 +232,31 @@ internal class IComprehensiveInterface : internal const int MemberId_WithDefaults = 24; internal const int MemberId_WithCollidingNames = 25; internal const int MemberId_GetMaybeNull = 26; - internal const int MemberId_DoTask = 27; - internal const int MemberId_DoTaskOf = 28; - internal const int MemberId_DoVT = 29; - internal const int MemberId_DoVTOf = 30; - internal const int MemberId_GetTuple = 31; - internal const int MemberId_GetNullable = 32; - internal const int MemberId_GetSpan = 33; - internal const int MemberId_GetROSpan = 34; - internal const int MemberId_GetByRef = 35; - internal const int MemberId_GetByRefReadonly = 36; - internal const int MemberId_G1_T_ = 37; - internal const int MemberId_G2_T_ = 38; - internal const int MemberId_G3_T_ = 39; - internal const int MemberId_G4_T_ = 40; - internal const int MemberId_G5_T_ = 41; - internal const int MemberId_G6_T_ = 42; - internal const int MemberId_G7_T_ = 43; - internal const int MemberId_G8_T_ = 44; - internal const int MemberId_Five = 45; - internal const int MemberId_Seventeen = 46; - internal const int MemberId_SeventeenVoid = 47; - internal const int MemberCount = 48; + internal const int MemberId_TakeObject = 27; + internal const int MemberId_TakeTwoObjects = 28; + internal const int MemberId_TakeIntAndObject = 29; + internal const int MemberId_DoTask = 30; + internal const int MemberId_DoTaskOf = 31; + internal const int MemberId_DoVT = 32; + internal const int MemberId_DoVTOf = 33; + internal const int MemberId_GetTuple = 34; + internal const int MemberId_GetNullable = 35; + internal const int MemberId_GetSpan = 36; + internal const int MemberId_GetROSpan = 37; + internal const int MemberId_GetByRef = 38; + internal const int MemberId_GetByRefReadonly = 39; + internal const int MemberId_G1_T_ = 40; + internal const int MemberId_G2_T_ = 41; + internal const int MemberId_G3_T_ = 42; + internal const int MemberId_G4_T_ = 43; + internal const int MemberId_G5_T_ = 44; + internal const int MemberId_G6_T_ = 45; + internal const int MemberId_G7_T_ = 46; + internal const int MemberId_G8_T_ = 47; + internal const int MemberId_Five = 48; + internal const int MemberId_Seventeen = 49; + internal const int MemberId_SeventeenVoid = 50; + internal const int MemberCount = 51; internal static readonly global::Mockolate.Interactions.PropertyGetterAccess PropertyAccess_GetSet_Get = new global::Mockolate.Interactions.PropertyGetterAccess("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSet"); internal static readonly global::Mockolate.Interactions.PropertyGetterAccess PropertyAccess_GetOnly_Get = new global::Mockolate.Interactions.PropertyGetterAccess("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetOnly"); internal static readonly global::Mockolate.Interactions.PropertyGetterAccess PropertyAccess_SetOnly_Get = new global::Mockolate.Interactions.PropertyGetterAccess("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.SetOnly"); @@ -304,6 +307,15 @@ internal class IComprehensiveInterface : private global::Mockolate.Interactions.FastMethod1Buffer MockolateBuffer_GetMaybeNull => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetMaybeNull, static fast => new global::Mockolate.Interactions.FastMethod1Buffer(fast))); [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod1Buffer MockolateBuffer_TakeObject + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, static fast => new global::Mockolate.Interactions.FastMethod1Buffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod2Buffer MockolateBuffer_TakeTwoObjects + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, static fast => new global::Mockolate.Interactions.FastMethod2Buffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod2Buffer MockolateBuffer_TakeIntAndObject + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, static fast => new global::Mockolate.Interactions.FastMethod2Buffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] private global::Mockolate.Interactions.FastMethod0Buffer MockolateBuffer_DoTask => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_DoTask, static fast => new global::Mockolate.Interactions.FastMethod0Buffer(fast))); [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] @@ -980,6 +992,183 @@ public void WithCollidingNames(int wraps, int result, int outParam1, int methodE return methodSetup?.TryGetReturnValue(s, out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(string?)!, s); } + /// + public bool TakeObject(object? obj) + { + global::Mockolate.Setup.ReturnMethodSetup? methodSetup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject); + if (snapshot_methodSetup is not null) + { + for (int i_methodSetup = snapshot_methodSetup.Length - 1; i_methodSetup >= 0; i_methodSetup--) + { + if (snapshot_methodSetup[i_methodSetup] is global::Mockolate.Setup.ReturnMethodSetup s_methodSetup && s_methodSetup.Matches(obj)) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject")) + { + if (s_methodSetup.Matches(obj)) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + bool wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_TakeObject.Append("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", obj); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.TakeObject(obj); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(obj); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject(object?)' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(obj, out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(bool)!, obj); + } + + /// + public int TakeTwoObjects(object? first, object? second) + { + global::Mockolate.Setup.ReturnMethodSetup? methodSetup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects); + if (snapshot_methodSetup is not null) + { + for (int i_methodSetup = snapshot_methodSetup.Length - 1; i_methodSetup >= 0; i_methodSetup--) + { + if (snapshot_methodSetup[i_methodSetup] is global::Mockolate.Setup.ReturnMethodSetup s_methodSetup && s_methodSetup.Matches(first, second)) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects")) + { + if (s_methodSetup.Matches(first, second)) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + int wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_TakeTwoObjects.Append("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", first, second); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.TakeTwoObjects(first, second); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(first, second); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects(object?, object?)' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(first, second, out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(int)!, first, second); + } + + /// + public int TakeIntAndObject(int n, object? obj) + { + global::Mockolate.Setup.ReturnMethodSetup? methodSetup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject); + if (snapshot_methodSetup is not null) + { + for (int i_methodSetup = snapshot_methodSetup.Length - 1; i_methodSetup >= 0; i_methodSetup--) + { + if (snapshot_methodSetup[i_methodSetup] is global::Mockolate.Setup.ReturnMethodSetup s_methodSetup && s_methodSetup.Matches(n, obj)) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject")) + { + if (s_methodSetup.Matches(n, obj)) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + int wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_TakeIntAndObject.Append("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", n, obj); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.TakeIntAndObject(n, obj); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(n, obj); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject(int, object?)' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(n, obj, out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(int)!, n, obj); + } + /// public global::System.Threading.Tasks.Task DoTask() { @@ -2441,6 +2630,110 @@ public void SeventeenVoid(int a1, int a2, int a3, int a4, int a5, int a6, int a7 return methodSetup; } + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeObject(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", parameters, "obj"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeObject(global::Mockolate.Parameters.IParameter? obj) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", CovariantParameterAdapter.Wrap(obj ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeObject(object? obj) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(obj)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeTwoObjects(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", parameters, "first", "second"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeTwoObjects(global::Mockolate.Parameters.IParameter? first, global::Mockolate.Parameters.IParameter? second) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", CovariantParameterAdapter.Wrap(first ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(second ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeTwoObjects(object? first, global::Mockolate.Parameters.IParameter? second) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(first), CovariantParameterAdapter.Wrap(second ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeTwoObjects(global::Mockolate.Parameters.IParameter? first, object? second) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", CovariantParameterAdapter.Wrap(first ?? global::Mockolate.It.IsNull("null")), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(second)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeTwoObjects(object? first, object? second) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(first), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(second)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeIntAndObject(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", parameters, "n", "obj"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeIntAndObject(global::Mockolate.Parameters.IParameter? n, global::Mockolate.Parameters.IParameter? obj) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", CovariantParameterAdapter.Wrap(n ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(obj ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeIntAndObject(int n, global::Mockolate.Parameters.IParameter? obj) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(n), CovariantParameterAdapter.Wrap(obj ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeIntAndObject(global::Mockolate.Parameters.IParameter? n, object? obj) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", CovariantParameterAdapter.Wrap(n ?? global::Mockolate.It.IsNull("null")), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(obj)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeIntAndObject(int n, object? obj) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(n), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(obj)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, methodSetup); + return methodSetup; + } + /// global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.DoTask() { @@ -2961,6 +3254,73 @@ void IMockRaiseOnIComprehensiveInterface.CustomEvent(global::Mockolate.Parameter => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetMaybeNull, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetMaybeNull", __i => (global::System.Collections.Generic.EqualityComparer.Default.Equals(s, __i.Parameter1)), () => $"GetMaybeNull({s})"); /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.TakeObject(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("obj", __i.Parameter1)]), + _ => true + }, () => $"TakeObject({parameters})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.TakeObject(global::Mockolate.Parameters.IParameter? obj) + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", obj is null ? (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(default!) : CovariantParameterAdapter.Wrap(obj), () => $"TakeObject({obj})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeObject(object? obj) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", __i => + (global::System.Collections.Generic.EqualityComparer.Default.Equals(obj, __i.Parameter1)), () => $"TakeObject({obj})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.TakeTwoObjects(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("first", __i.Parameter1), ("second", __i.Parameter2)]), + _ => true + }, () => $"TakeTwoObjects({parameters})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.TakeTwoObjects(global::Mockolate.Parameters.IParameter? first, global::Mockolate.Parameters.IParameter? second) + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", first is null ? (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(default!) : CovariantParameterAdapter.Wrap(first), second is null ? (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(default!) : CovariantParameterAdapter.Wrap(second), () => $"TakeTwoObjects({first}, {second})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.TakeTwoObjects(object? first, global::Mockolate.Parameters.IParameter? second) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", __i => + (global::System.Collections.Generic.EqualityComparer.Default.Equals(first, __i.Parameter1)) && + (second is not null ? CovariantParameterAdapter.Wrap(second).Matches(__i.Parameter2) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter2, default(object?))), () => $"TakeTwoObjects({first}, {second})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.TakeTwoObjects(global::Mockolate.Parameters.IParameter? first, object? second) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", __i => + (first is not null ? CovariantParameterAdapter.Wrap(first).Matches(__i.Parameter1) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter1, default(object?))) && + (global::System.Collections.Generic.EqualityComparer.Default.Equals(second, __i.Parameter2)), () => $"TakeTwoObjects({first}, {second})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeTwoObjects(object? first, object? second) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", __i => + (global::System.Collections.Generic.EqualityComparer.Default.Equals(first, __i.Parameter1)) && + (global::System.Collections.Generic.EqualityComparer.Default.Equals(second, __i.Parameter2)), () => $"TakeTwoObjects({first}, {second})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.TakeIntAndObject(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("n", __i.Parameter1), ("obj", __i.Parameter2)]), + _ => true + }, () => $"TakeIntAndObject({parameters})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.TakeIntAndObject(global::Mockolate.Parameters.IParameter? n, global::Mockolate.Parameters.IParameter? obj) + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", n is null ? (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(default!) : CovariantParameterAdapter.Wrap(n), obj is null ? (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(default!) : CovariantParameterAdapter.Wrap(obj), () => $"TakeIntAndObject({n}, {obj})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.TakeIntAndObject(int n, global::Mockolate.Parameters.IParameter? obj) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", __i => + (global::System.Collections.Generic.EqualityComparer.Default.Equals(n, __i.Parameter1)) && + (obj is not null ? CovariantParameterAdapter.Wrap(obj).Matches(__i.Parameter2) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter2, default(object?))), () => $"TakeIntAndObject({n}, {obj})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.TakeIntAndObject(global::Mockolate.Parameters.IParameter? n, object? obj) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", __i => + (n is not null ? CovariantParameterAdapter.Wrap(n).Matches(__i.Parameter1) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter1, default(int))) && + (global::System.Collections.Generic.EqualityComparer.Default.Equals(obj, __i.Parameter2)), () => $"TakeIntAndObject({n}, {obj})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeIntAndObject(int n, object? obj) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", __i => + (global::System.Collections.Generic.EqualityComparer.Default.Equals(n, __i.Parameter1)) && + (global::System.Collections.Generic.EqualityComparer.Default.Equals(obj, __i.Parameter2)), () => $"TakeIntAndObject({n}, {obj})"); + /// global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.DoTask() => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_DoTask, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoTask", () => $"DoTask()"); /// @@ -3425,6 +3785,73 @@ private sealed class VerifyMonitorIComprehensiveInterface(global::Mockolate.Mock => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetMaybeNull, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetMaybeNull", __i => (global::System.Collections.Generic.EqualityComparer.Default.Equals(s, __i.Parameter1)), () => $"GetMaybeNull({s})"); /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.TakeObject(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("obj", __i.Parameter1)]), + _ => true + }, () => $"TakeObject({parameters})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.TakeObject(global::Mockolate.Parameters.IParameter? obj) + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", obj is null ? (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(default!) : CovariantParameterAdapter.Wrap(obj), () => $"TakeObject({obj})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeObject(object? obj) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", __i => + (global::System.Collections.Generic.EqualityComparer.Default.Equals(obj, __i.Parameter1)), () => $"TakeObject({obj})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.TakeTwoObjects(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("first", __i.Parameter1), ("second", __i.Parameter2)]), + _ => true + }, () => $"TakeTwoObjects({parameters})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.TakeTwoObjects(global::Mockolate.Parameters.IParameter? first, global::Mockolate.Parameters.IParameter? second) + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", first is null ? (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(default!) : CovariantParameterAdapter.Wrap(first), second is null ? (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(default!) : CovariantParameterAdapter.Wrap(second), () => $"TakeTwoObjects({first}, {second})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.TakeTwoObjects(object? first, global::Mockolate.Parameters.IParameter? second) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", __i => + (global::System.Collections.Generic.EqualityComparer.Default.Equals(first, __i.Parameter1)) && + (second is not null ? CovariantParameterAdapter.Wrap(second).Matches(__i.Parameter2) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter2, default(object?))), () => $"TakeTwoObjects({first}, {second})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.TakeTwoObjects(global::Mockolate.Parameters.IParameter? first, object? second) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", __i => + (first is not null ? CovariantParameterAdapter.Wrap(first).Matches(__i.Parameter1) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter1, default(object?))) && + (global::System.Collections.Generic.EqualityComparer.Default.Equals(second, __i.Parameter2)), () => $"TakeTwoObjects({first}, {second})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeTwoObjects(object? first, object? second) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", __i => + (global::System.Collections.Generic.EqualityComparer.Default.Equals(first, __i.Parameter1)) && + (global::System.Collections.Generic.EqualityComparer.Default.Equals(second, __i.Parameter2)), () => $"TakeTwoObjects({first}, {second})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.TakeIntAndObject(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("n", __i.Parameter1), ("obj", __i.Parameter2)]), + _ => true + }, () => $"TakeIntAndObject({parameters})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.TakeIntAndObject(global::Mockolate.Parameters.IParameter? n, global::Mockolate.Parameters.IParameter? obj) + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", n is null ? (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(default!) : CovariantParameterAdapter.Wrap(n), obj is null ? (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(default!) : CovariantParameterAdapter.Wrap(obj), () => $"TakeIntAndObject({n}, {obj})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.TakeIntAndObject(int n, global::Mockolate.Parameters.IParameter? obj) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", __i => + (global::System.Collections.Generic.EqualityComparer.Default.Equals(n, __i.Parameter1)) && + (obj is not null ? CovariantParameterAdapter.Wrap(obj).Matches(__i.Parameter2) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter2, default(object?))), () => $"TakeIntAndObject({n}, {obj})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.TakeIntAndObject(global::Mockolate.Parameters.IParameter? n, object? obj) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", __i => + (n is not null ? CovariantParameterAdapter.Wrap(n).Matches(__i.Parameter1) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter1, default(int))) && + (global::System.Collections.Generic.EqualityComparer.Default.Equals(obj, __i.Parameter2)), () => $"TakeIntAndObject({n}, {obj})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeIntAndObject(int n, object? obj) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", __i => + (global::System.Collections.Generic.EqualityComparer.Default.Equals(n, __i.Parameter1)) && + (global::System.Collections.Generic.EqualityComparer.Default.Equals(obj, __i.Parameter2)), () => $"TakeIntAndObject({n}, {obj})"); + /// global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.DoTask() => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_DoTask, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoTask", () => $"DoTask()"); /// @@ -3936,25 +4363,129 @@ public MockInScenarioForIComprehensiveInterface(global::Mockolate.MockRegistry m } /// - global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.DoTask() + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeObject(global::Mockolate.Parameters.IParameters parameters) { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoTask"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_DoTask, _scenarioName, methodSetup); + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", parameters, "obj"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, _scenarioName, methodSetup); return methodSetup; } /// - global::Mockolate.Setup.IReturnMethodSetup> global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.DoTaskOf() + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeObject(global::Mockolate.Parameters.IParameter? obj) { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup>.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoTaskOf"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_DoTaskOf, _scenarioName, methodSetup); + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", CovariantParameterAdapter.Wrap(obj ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, _scenarioName, methodSetup); return methodSetup; } /// - global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.DoVT() + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeObject(object? obj) { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoVT"); + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(obj)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeTwoObjects(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", parameters, "first", "second"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeTwoObjects(global::Mockolate.Parameters.IParameter? first, global::Mockolate.Parameters.IParameter? second) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", CovariantParameterAdapter.Wrap(first ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(second ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeTwoObjects(object? first, global::Mockolate.Parameters.IParameter? second) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(first), CovariantParameterAdapter.Wrap(second ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeTwoObjects(global::Mockolate.Parameters.IParameter? first, object? second) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", CovariantParameterAdapter.Wrap(first ?? global::Mockolate.It.IsNull("null")), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(second)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeTwoObjects(object? first, object? second) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(first), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(second)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeIntAndObject(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", parameters, "n", "obj"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeIntAndObject(global::Mockolate.Parameters.IParameter? n, global::Mockolate.Parameters.IParameter? obj) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", CovariantParameterAdapter.Wrap(n ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(obj ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeIntAndObject(int n, global::Mockolate.Parameters.IParameter? obj) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(n), CovariantParameterAdapter.Wrap(obj ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeIntAndObject(global::Mockolate.Parameters.IParameter? n, object? obj) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", CovariantParameterAdapter.Wrap(n ?? global::Mockolate.It.IsNull("null")), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(obj)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeIntAndObject(int n, object? obj) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(n), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(obj)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.DoTask() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoTask"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_DoTask, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup> global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.DoTaskOf() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup>.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoTaskOf"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_DoTaskOf, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.DoVT() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoVT"); this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_DoVT, _scenarioName, methodSetup); return methodSetup; } @@ -4404,7 +4935,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload configures the setup via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Setup.IVoidMethodSetupWithCallback WithModifiers(global::Mockolate.Parameters.IParameters parameters); /// @@ -4413,7 +4944,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(4)] global::Mockolate.Setup.IVoidMethodSetupWithCallback WithModifiers(global::Mockolate.Parameters.IRefParameter a, global::Mockolate.Parameters.IOutParameter b, global::Mockolate.Parameters.IParameter? c, global::Mockolate.Parameters.IParameter? tail); /// @@ -4449,7 +4980,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload configures the setup via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Setup.IVoidMethodSetupWithCallback WithDefaults(global::Mockolate.Parameters.IParameters parameters); /// @@ -4458,7 +4989,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(7)] global::Mockolate.Setup.IVoidMethodSetupWithCallback WithDefaults(global::Mockolate.Parameters.IParameter? i = null, global::Mockolate.Parameters.IParameter? e = null, global::Mockolate.Parameters.IParameter? d = null, global::Mockolate.Parameters.IParameter? f = null, global::Mockolate.Parameters.IParameter? c = null, global::Mockolate.Parameters.IParameter? s = null, global::Mockolate.Parameters.IParameter? st = null); /// @@ -4467,6 +4998,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer WithDefaults(int i, global::Mockolate.Tests.GeneratorCoverage.MyEnum e, decimal d, float f, char c, string? s, global::Mockolate.Tests.GeneratorCoverage.MyStruct st); /// @@ -4475,7 +5007,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload configures the setup via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Setup.IVoidMethodSetupWithCallback WithCollidingNames(global::Mockolate.Parameters.IParameters parameters); /// @@ -4484,7 +5016,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(5)] global::Mockolate.Setup.IVoidMethodSetupWithCallback WithCollidingNames(global::Mockolate.Parameters.IParameter? wraps, global::Mockolate.Parameters.IParameter? result, global::Mockolate.Parameters.IParameter? outParam1, global::Mockolate.Parameters.IParameter? methodExecution, global::Mockolate.Parameters.IParameter? returnValue); /// @@ -4493,6 +5025,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer WithCollidingNames(int wraps, int result, int outParam1, int methodExecution, int returnValue); /// @@ -4501,7 +5034,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload configures the setup via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Setup.IReturnMethodSetupWithCallback GetMaybeNull(global::Mockolate.Parameters.IParameters parameters); /// @@ -4510,7 +5043,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] global::Mockolate.Setup.IReturnMethodSetupWithCallback GetMaybeNull(global::Mockolate.Parameters.IParameter? s); /// @@ -4519,8 +5052,123 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer GetMaybeNull(string? s); + /// + /// Setup for the method TakeObject(object?) with the given . + /// + /// + /// This overload configures the setup via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] + global::Mockolate.Setup.IReturnMethodSetupWithCallback TakeObject(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Setup for the method TakeObject(object?) with the given . + /// + /// + /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IReturnMethodSetupWithCallback TakeObject(global::Mockolate.Parameters.IParameter? obj); + + /// + /// Setup for the method TakeObject(object?) with the given . + /// + /// + /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer TakeObject(object? obj); + + /// + /// Setup for the method TakeTwoObjects(object?, object?) with the given . + /// + /// + /// This overload configures the setup via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] + global::Mockolate.Setup.IReturnMethodSetupWithCallback TakeTwoObjects(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Setup for the method TakeTwoObjects(object?, object?) with the given , . + /// + /// + /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Setup.IReturnMethodSetupWithCallback TakeTwoObjects(global::Mockolate.Parameters.IParameter? first, global::Mockolate.Parameters.IParameter? second); + + /// + /// Setup for the method TakeTwoObjects(object?, object?) with the given , . + /// + /// + /// This overload accepts a direct value for (equivalent to It.Is<T>(value)) and an It matcher for . + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IReturnMethodSetupWithCallback TakeTwoObjects(object? first, global::Mockolate.Parameters.IParameter? second); + + /// + /// Setup for the method TakeTwoObjects(object?, object?) with the given , . + /// + /// + /// This overload accepts a direct value for (equivalent to It.Is<T>(value)) and an It matcher for . + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IReturnMethodSetupWithCallback TakeTwoObjects(global::Mockolate.Parameters.IParameter? first, object? second); + + /// + /// Setup for the method TakeTwoObjects(object?, object?) with the given , . + /// + /// + /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer TakeTwoObjects(object? first, object? second); + + /// + /// Setup for the method TakeIntAndObject(int, object?) with the given . + /// + /// + /// This overload configures the setup via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] + global::Mockolate.Setup.IReturnMethodSetupWithCallback TakeIntAndObject(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Setup for the method TakeIntAndObject(int, object?) with the given , . + /// + /// + /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Setup.IReturnMethodSetupWithCallback TakeIntAndObject(global::Mockolate.Parameters.IParameter? n, global::Mockolate.Parameters.IParameter? obj); + + /// + /// Setup for the method TakeIntAndObject(int, object?) with the given , . + /// + /// + /// This overload accepts a direct value for (equivalent to It.Is<T>(value)) and an It matcher for . + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IReturnMethodSetupWithCallback TakeIntAndObject(int n, global::Mockolate.Parameters.IParameter? obj); + + /// + /// Setup for the method TakeIntAndObject(int, object?) with the given , . + /// + /// + /// This overload accepts a direct value for (equivalent to It.Is<T>(value)) and an It matcher for . + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IReturnMethodSetupWithCallback TakeIntAndObject(global::Mockolate.Parameters.IParameter? n, object? obj); + + /// + /// Setup for the method TakeIntAndObject(int, object?) with the given , . + /// + /// + /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer TakeIntAndObject(int n, object? obj); + /// /// Setup for the method DoTask(). /// @@ -4563,7 +5211,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload configures the setup via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Setup.IReturnMethodSetupWithCallback, int> GetSpan(global::Mockolate.Parameters.IParameters parameters); /// @@ -4572,7 +5220,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] global::Mockolate.Setup.IReturnMethodSetupWithCallback, int> GetSpan(global::Mockolate.Parameters.IParameter? n); /// @@ -4581,6 +5229,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int> GetSpan(int n); /// @@ -4589,7 +5238,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload configures the setup via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Setup.IReturnMethodSetupWithCallback, int> GetROSpan(global::Mockolate.Parameters.IParameters parameters); /// @@ -4598,7 +5247,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] global::Mockolate.Setup.IReturnMethodSetupWithCallback, int> GetROSpan(global::Mockolate.Parameters.IParameter? n); /// @@ -4607,6 +5256,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int> GetROSpan(int n); /// @@ -4676,7 +5326,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload configures the setup via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Setup.IReturnMethodSetupWithCallback Five(global::Mockolate.Parameters.IParameters parameters); /// @@ -4685,7 +5335,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(5)] global::Mockolate.Setup.IReturnMethodSetupWithCallback Five(global::Mockolate.Parameters.IParameter? a, global::Mockolate.Parameters.IParameter? b, global::Mockolate.Parameters.IParameter? c, global::Mockolate.Parameters.IParameter? d, global::Mockolate.Parameters.IParameter? e); /// @@ -4694,6 +5344,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Five(int a, int b, int c, int d, int e); /// @@ -4702,7 +5353,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload configures the setup via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Setup.IReturnMethodSetupWithCallback Seventeen(global::Mockolate.Parameters.IParameters parameters); /// @@ -4711,7 +5362,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(17)] global::Mockolate.Setup.IReturnMethodSetupWithCallback Seventeen(global::Mockolate.Parameters.IParameter? a1, global::Mockolate.Parameters.IParameter? a2, global::Mockolate.Parameters.IParameter? a3, global::Mockolate.Parameters.IParameter? a4, global::Mockolate.Parameters.IParameter? a5, global::Mockolate.Parameters.IParameter? a6, global::Mockolate.Parameters.IParameter? a7, global::Mockolate.Parameters.IParameter? a8, global::Mockolate.Parameters.IParameter? a9, global::Mockolate.Parameters.IParameter? a10, global::Mockolate.Parameters.IParameter? a11, global::Mockolate.Parameters.IParameter? a12, global::Mockolate.Parameters.IParameter? a13, global::Mockolate.Parameters.IParameter? a14, global::Mockolate.Parameters.IParameter? a15, global::Mockolate.Parameters.IParameter? a16, global::Mockolate.Parameters.IParameter? a17); /// @@ -4720,6 +5371,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Seventeen(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10, int a11, int a12, int a13, int a14, int a15, int a16, int a17); /// @@ -4728,7 +5380,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload configures the setup via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Setup.IVoidMethodSetupWithCallback SeventeenVoid(global::Mockolate.Parameters.IParameters parameters); /// @@ -4737,7 +5389,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(17)] global::Mockolate.Setup.IVoidMethodSetupWithCallback SeventeenVoid(global::Mockolate.Parameters.IParameter? a1, global::Mockolate.Parameters.IParameter? a2, global::Mockolate.Parameters.IParameter? a3, global::Mockolate.Parameters.IParameter? a4, global::Mockolate.Parameters.IParameter? a5, global::Mockolate.Parameters.IParameter? a6, global::Mockolate.Parameters.IParameter? a7, global::Mockolate.Parameters.IParameter? a8, global::Mockolate.Parameters.IParameter? a9, global::Mockolate.Parameters.IParameter? a10, global::Mockolate.Parameters.IParameter? a11, global::Mockolate.Parameters.IParameter? a12, global::Mockolate.Parameters.IParameter? a13, global::Mockolate.Parameters.IParameter? a14, global::Mockolate.Parameters.IParameter? a15, global::Mockolate.Parameters.IParameter? a16, global::Mockolate.Parameters.IParameter? a17); /// @@ -4746,6 +5398,7 @@ internal interface IMockSetupForIComprehensiveInterface /// /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer SeventeenVoid(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10, int a11, int a12, int a13, int a14, int a15, int a16, int a17); } @@ -4877,7 +5530,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload matches invocations via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Verify.VerificationResult WithModifiers(global::Mockolate.Parameters.IParameters parameters); /// @@ -4886,7 +5539,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(4)] global::Mockolate.Verify.VerificationResult WithModifiers(global::Mockolate.Parameters.IVerifyRefParameter a, global::Mockolate.Parameters.IVerifyOutParameter b, global::Mockolate.Parameters.IParameter? c, global::Mockolate.Parameters.IParameter? tail); /// @@ -4922,7 +5575,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload matches invocations via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Verify.VerificationResult WithDefaults(global::Mockolate.Parameters.IParameters parameters); /// @@ -4931,7 +5584,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(7)] global::Mockolate.Verify.VerificationResult WithDefaults(global::Mockolate.Parameters.IParameter? i = null, global::Mockolate.Parameters.IParameter? e = null, global::Mockolate.Parameters.IParameter? d = null, global::Mockolate.Parameters.IParameter? f = null, global::Mockolate.Parameters.IParameter? c = null, global::Mockolate.Parameters.IParameter? s = null, global::Mockolate.Parameters.IParameter? st = null); /// @@ -4940,6 +5593,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload accepts direct values for every parameter and returns a VerificationResult<TVerify>.IgnoreParameters whose VerificationResult<TVerify>.AnyParameters() drops per-parameter matching entirely. /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Verify.VerificationResult.IgnoreParameters WithDefaults(int i, global::Mockolate.Tests.GeneratorCoverage.MyEnum e, decimal d, float f, char c, string? s, global::Mockolate.Tests.GeneratorCoverage.MyStruct st); /// @@ -4948,7 +5602,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload matches invocations via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Verify.VerificationResult WithCollidingNames(global::Mockolate.Parameters.IParameters parameters); /// @@ -4957,7 +5611,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(5)] global::Mockolate.Verify.VerificationResult WithCollidingNames(global::Mockolate.Parameters.IParameter? wraps, global::Mockolate.Parameters.IParameter? result, global::Mockolate.Parameters.IParameter? outParam1, global::Mockolate.Parameters.IParameter? methodExecution, global::Mockolate.Parameters.IParameter? returnValue); /// @@ -4966,6 +5620,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload accepts direct values for every parameter and returns a VerificationResult<TVerify>.IgnoreParameters whose VerificationResult<TVerify>.AnyParameters() drops per-parameter matching entirely. /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Verify.VerificationResult.IgnoreParameters WithCollidingNames(int wraps, int result, int outParam1, int methodExecution, int returnValue); /// @@ -4974,7 +5629,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload matches invocations via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Verify.VerificationResult GetMaybeNull(global::Mockolate.Parameters.IParameters parameters); /// @@ -4983,7 +5638,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] global::Mockolate.Verify.VerificationResult GetMaybeNull(global::Mockolate.Parameters.IParameter? s); /// @@ -4992,8 +5647,123 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload accepts direct values for every parameter and returns a VerificationResult<TVerify>.IgnoreParameters whose VerificationResult<TVerify>.AnyParameters() drops per-parameter matching entirely. /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Verify.VerificationResult.IgnoreParameters GetMaybeNull(string? s); + /// + /// Verify invocations for the method TakeObject(object?) with the given . + /// + /// + /// This overload matches invocations via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] + global::Mockolate.Verify.VerificationResult TakeObject(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Verify invocations for the method TakeObject(object?) with the given . + /// + /// + /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationResult TakeObject(global::Mockolate.Parameters.IParameter? obj); + + /// + /// Verify invocations for the method TakeObject(object?) with the given . + /// + /// + /// This overload accepts direct values for every parameter and returns a VerificationResult<TVerify>.IgnoreParameters whose VerificationResult<TVerify>.AnyParameters() drops per-parameter matching entirely. + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters TakeObject(object? obj); + + /// + /// Verify invocations for the method TakeTwoObjects(object?, object?) with the given . + /// + /// + /// This overload matches invocations via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] + global::Mockolate.Verify.VerificationResult TakeTwoObjects(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Verify invocations for the method TakeTwoObjects(object?, object?) with the given , . + /// + /// + /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Verify.VerificationResult TakeTwoObjects(global::Mockolate.Parameters.IParameter? first, global::Mockolate.Parameters.IParameter? second); + + /// + /// Verify invocations for the method TakeTwoObjects(object?, object?) with the given , . + /// + /// + /// This overload accepts a direct value for (equivalent to It.Is<T>(value)) and an It matcher for . + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationResult TakeTwoObjects(object? first, global::Mockolate.Parameters.IParameter? second); + + /// + /// Verify invocations for the method TakeTwoObjects(object?, object?) with the given , . + /// + /// + /// This overload accepts a direct value for (equivalent to It.Is<T>(value)) and an It matcher for . + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationResult TakeTwoObjects(global::Mockolate.Parameters.IParameter? first, object? second); + + /// + /// Verify invocations for the method TakeTwoObjects(object?, object?) with the given , . + /// + /// + /// This overload accepts direct values for every parameter and returns a VerificationResult<TVerify>.IgnoreParameters whose VerificationResult<TVerify>.AnyParameters() drops per-parameter matching entirely. + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters TakeTwoObjects(object? first, object? second); + + /// + /// Verify invocations for the method TakeIntAndObject(int, object?) with the given . + /// + /// + /// This overload matches invocations via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] + global::Mockolate.Verify.VerificationResult TakeIntAndObject(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Verify invocations for the method TakeIntAndObject(int, object?) with the given , . + /// + /// + /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Verify.VerificationResult TakeIntAndObject(global::Mockolate.Parameters.IParameter? n, global::Mockolate.Parameters.IParameter? obj); + + /// + /// Verify invocations for the method TakeIntAndObject(int, object?) with the given , . + /// + /// + /// This overload accepts a direct value for (equivalent to It.Is<T>(value)) and an It matcher for . + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationResult TakeIntAndObject(int n, global::Mockolate.Parameters.IParameter? obj); + + /// + /// Verify invocations for the method TakeIntAndObject(int, object?) with the given , . + /// + /// + /// This overload accepts a direct value for (equivalent to It.Is<T>(value)) and an It matcher for . + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationResult TakeIntAndObject(global::Mockolate.Parameters.IParameter? n, object? obj); + + /// + /// Verify invocations for the method TakeIntAndObject(int, object?) with the given , . + /// + /// + /// This overload accepts direct values for every parameter and returns a VerificationResult<TVerify>.IgnoreParameters whose VerificationResult<TVerify>.AnyParameters() drops per-parameter matching entirely. + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters TakeIntAndObject(int n, object? obj); + /// /// Verify invocations for the method DoTask(). /// @@ -5030,7 +5800,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload matches invocations via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Verify.VerificationResult GetSpan(global::Mockolate.Parameters.IParameters parameters); /// @@ -5039,7 +5809,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] global::Mockolate.Verify.VerificationResult GetSpan(global::Mockolate.Parameters.IParameter? n); /// @@ -5048,6 +5818,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload accepts direct values for every parameter and returns a VerificationResult<TVerify>.IgnoreParameters whose VerificationResult<TVerify>.AnyParameters() drops per-parameter matching entirely. /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Verify.VerificationResult.IgnoreParameters GetSpan(int n); /// @@ -5056,7 +5827,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload matches invocations via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Verify.VerificationResult GetROSpan(global::Mockolate.Parameters.IParameters parameters); /// @@ -5065,7 +5836,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] global::Mockolate.Verify.VerificationResult GetROSpan(global::Mockolate.Parameters.IParameter? n); /// @@ -5074,6 +5845,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload accepts direct values for every parameter and returns a VerificationResult<TVerify>.IgnoreParameters whose VerificationResult<TVerify>.AnyParameters() drops per-parameter matching entirely. /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Verify.VerificationResult.IgnoreParameters GetROSpan(int n); /// @@ -5140,7 +5912,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload matches invocations via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Verify.VerificationResult Five(global::Mockolate.Parameters.IParameters parameters); /// @@ -5149,7 +5921,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(5)] global::Mockolate.Verify.VerificationResult Five(global::Mockolate.Parameters.IParameter? a, global::Mockolate.Parameters.IParameter? b, global::Mockolate.Parameters.IParameter? c, global::Mockolate.Parameters.IParameter? d, global::Mockolate.Parameters.IParameter? e); /// @@ -5158,6 +5930,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload accepts direct values for every parameter and returns a VerificationResult<TVerify>.IgnoreParameters whose VerificationResult<TVerify>.AnyParameters() drops per-parameter matching entirely. /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Verify.VerificationResult.IgnoreParameters Five(int a, int b, int c, int d, int e); /// @@ -5166,7 +5939,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload matches invocations via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Verify.VerificationResult Seventeen(global::Mockolate.Parameters.IParameters parameters); /// @@ -5175,7 +5948,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(17)] global::Mockolate.Verify.VerificationResult Seventeen(global::Mockolate.Parameters.IParameter? a1, global::Mockolate.Parameters.IParameter? a2, global::Mockolate.Parameters.IParameter? a3, global::Mockolate.Parameters.IParameter? a4, global::Mockolate.Parameters.IParameter? a5, global::Mockolate.Parameters.IParameter? a6, global::Mockolate.Parameters.IParameter? a7, global::Mockolate.Parameters.IParameter? a8, global::Mockolate.Parameters.IParameter? a9, global::Mockolate.Parameters.IParameter? a10, global::Mockolate.Parameters.IParameter? a11, global::Mockolate.Parameters.IParameter? a12, global::Mockolate.Parameters.IParameter? a13, global::Mockolate.Parameters.IParameter? a14, global::Mockolate.Parameters.IParameter? a15, global::Mockolate.Parameters.IParameter? a16, global::Mockolate.Parameters.IParameter? a17); /// @@ -5184,6 +5957,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload accepts direct values for every parameter and returns a VerificationResult<TVerify>.IgnoreParameters whose VerificationResult<TVerify>.AnyParameters() drops per-parameter matching entirely. /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Verify.VerificationResult.IgnoreParameters Seventeen(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10, int a11, int a12, int a13, int a14, int a15, int a16, int a17); /// @@ -5192,7 +5966,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload matches invocations via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Verify.VerificationResult SeventeenVoid(global::Mockolate.Parameters.IParameters parameters); /// @@ -5201,7 +5975,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(17)] global::Mockolate.Verify.VerificationResult SeventeenVoid(global::Mockolate.Parameters.IParameter? a1, global::Mockolate.Parameters.IParameter? a2, global::Mockolate.Parameters.IParameter? a3, global::Mockolate.Parameters.IParameter? a4, global::Mockolate.Parameters.IParameter? a5, global::Mockolate.Parameters.IParameter? a6, global::Mockolate.Parameters.IParameter? a7, global::Mockolate.Parameters.IParameter? a8, global::Mockolate.Parameters.IParameter? a9, global::Mockolate.Parameters.IParameter? a10, global::Mockolate.Parameters.IParameter? a11, global::Mockolate.Parameters.IParameter? a12, global::Mockolate.Parameters.IParameter? a13, global::Mockolate.Parameters.IParameter? a14, global::Mockolate.Parameters.IParameter? a15, global::Mockolate.Parameters.IParameter? a16, global::Mockolate.Parameters.IParameter? a17); /// @@ -5210,6 +5984,7 @@ internal interface IMockVerifyForIComprehensiveInterface /// /// This overload accepts direct values for every parameter and returns a VerificationResult<TVerify>.IgnoreParameters whose VerificationResult<TVerify>.AnyParameters() drops per-parameter matching entirely. /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Verify.VerificationResult.IgnoreParameters SeventeenVoid(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10, int a11, int a12, int a13, int a14, int a15, int a16, int a17); /// diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated/Mock.HttpClient.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated/Mock.HttpClient.g.cs index e3384700..12b85acc 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated/Mock.HttpClient.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated/Mock.HttpClient.g.cs @@ -1401,7 +1401,7 @@ internal interface IMockSetupForHttpClient : global::Mockolate.Setup.IMockSetup< /// /// This overload configures the setup via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Setup.IReturnMethodSetupWithCallback Send(global::Mockolate.Parameters.IParameters parameters); /// @@ -1410,7 +1410,7 @@ internal interface IMockSetupForHttpClient : global::Mockolate.Setup.IMockSetup< /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] global::Mockolate.Setup.IReturnMethodSetupWithCallback Send(global::Mockolate.Parameters.IParameter? request, global::Mockolate.Parameters.IParameter? cancellationToken); /// @@ -1437,6 +1437,7 @@ internal interface IMockSetupForHttpClient : global::Mockolate.Setup.IMockSetup< /// /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Send(global::System.Net.Http.HttpRequestMessage request, global::System.Threading.CancellationToken cancellationToken); /// @@ -1445,7 +1446,7 @@ internal interface IMockSetupForHttpClient : global::Mockolate.Setup.IMockSetup< /// /// This overload configures the setup via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Setup.IReturnMethodSetupWithCallback, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::Mockolate.Parameters.IParameters parameters); /// @@ -1454,7 +1455,7 @@ internal interface IMockSetupForHttpClient : global::Mockolate.Setup.IMockSetup< /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] global::Mockolate.Setup.IReturnMethodSetupWithCallback, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::Mockolate.Parameters.IParameter? request, global::Mockolate.Parameters.IParameter? cancellationToken); /// @@ -1481,6 +1482,7 @@ internal interface IMockSetupForHttpClient : global::Mockolate.Setup.IMockSetup< /// /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::System.Net.Http.HttpRequestMessage request, global::System.Threading.CancellationToken cancellationToken); } @@ -1496,7 +1498,7 @@ internal interface IMockProtectedSetupForHttpClient /// /// This overload configures the setup via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Setup.IVoidMethodSetupWithCallback Dispose(global::Mockolate.Parameters.IParameters parameters); /// @@ -1505,7 +1507,7 @@ internal interface IMockProtectedSetupForHttpClient /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] global::Mockolate.Setup.IVoidMethodSetupWithCallback Dispose(global::Mockolate.Parameters.IParameter? disposing); /// @@ -1514,6 +1516,7 @@ internal interface IMockProtectedSetupForHttpClient /// /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer Dispose(bool disposing); } @@ -1529,7 +1532,7 @@ internal interface IMockVerifyForHttpClient : global::Mockolate.Verify.IMockVeri /// /// This overload matches invocations via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Verify.VerificationResult Send(global::Mockolate.Parameters.IParameters parameters); /// @@ -1538,7 +1541,7 @@ internal interface IMockVerifyForHttpClient : global::Mockolate.Verify.IMockVeri /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] global::Mockolate.Verify.VerificationResult Send(global::Mockolate.Parameters.IParameter? request, global::Mockolate.Parameters.IParameter? cancellationToken); /// @@ -1565,6 +1568,7 @@ internal interface IMockVerifyForHttpClient : global::Mockolate.Verify.IMockVeri /// /// This overload accepts direct values for every parameter and returns a VerificationResult<TVerify>.IgnoreParameters whose VerificationResult<TVerify>.AnyParameters() drops per-parameter matching entirely. /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Verify.VerificationResult.IgnoreParameters Send(global::System.Net.Http.HttpRequestMessage request, global::System.Threading.CancellationToken cancellationToken); /// @@ -1573,7 +1577,7 @@ internal interface IMockVerifyForHttpClient : global::Mockolate.Verify.IMockVeri /// /// This overload matches invocations via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Verify.VerificationResult SendAsync(global::Mockolate.Parameters.IParameters parameters); /// @@ -1582,7 +1586,7 @@ internal interface IMockVerifyForHttpClient : global::Mockolate.Verify.IMockVeri /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] global::Mockolate.Verify.VerificationResult SendAsync(global::Mockolate.Parameters.IParameter? request, global::Mockolate.Parameters.IParameter? cancellationToken); /// @@ -1609,6 +1613,7 @@ internal interface IMockVerifyForHttpClient : global::Mockolate.Verify.IMockVeri /// /// This overload accepts direct values for every parameter and returns a VerificationResult<TVerify>.IgnoreParameters whose VerificationResult<TVerify>.AnyParameters() drops per-parameter matching entirely. /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Verify.VerificationResult.IgnoreParameters SendAsync(global::System.Net.Http.HttpRequestMessage request, global::System.Threading.CancellationToken cancellationToken); } @@ -1624,7 +1629,7 @@ internal interface IMockProtectedVerifyForHttpClient /// /// This overload matches invocations via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Verify.VerificationResult Dispose(global::Mockolate.Parameters.IParameters parameters); /// @@ -1633,7 +1638,7 @@ internal interface IMockProtectedVerifyForHttpClient /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] global::Mockolate.Verify.VerificationResult Dispose(global::Mockolate.Parameters.IParameter? disposing); /// @@ -1642,6 +1647,7 @@ internal interface IMockProtectedVerifyForHttpClient /// /// This overload accepts direct values for every parameter and returns a VerificationResult<TVerify>.IgnoreParameters whose VerificationResult<TVerify>.AnyParameters() drops per-parameter matching entirely. /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Verify.VerificationResult.IgnoreParameters Dispose(bool disposing); } diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated/Mock.HttpMessageHandler.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated/Mock.HttpMessageHandler.g.cs index 22c0dc0c..97b30562 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated/Mock.HttpMessageHandler.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated/Mock.HttpMessageHandler.g.cs @@ -1122,7 +1122,7 @@ internal interface IMockProtectedSetupForHttpMessageHandler /// /// This overload configures the setup via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Setup.IReturnMethodSetupWithCallback Send(global::Mockolate.Parameters.IParameters parameters); /// @@ -1131,7 +1131,7 @@ internal interface IMockProtectedSetupForHttpMessageHandler /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] global::Mockolate.Setup.IReturnMethodSetupWithCallback Send(global::Mockolate.Parameters.IParameter? request, global::Mockolate.Parameters.IParameter? cancellationToken); /// @@ -1158,6 +1158,7 @@ internal interface IMockProtectedSetupForHttpMessageHandler /// /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Send(global::System.Net.Http.HttpRequestMessage request, global::System.Threading.CancellationToken cancellationToken); /// @@ -1166,7 +1167,7 @@ internal interface IMockProtectedSetupForHttpMessageHandler /// /// This overload configures the setup via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Setup.IReturnMethodSetupWithCallback, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::Mockolate.Parameters.IParameters parameters); /// @@ -1175,7 +1176,7 @@ internal interface IMockProtectedSetupForHttpMessageHandler /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] global::Mockolate.Setup.IReturnMethodSetupWithCallback, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::Mockolate.Parameters.IParameter? request, global::Mockolate.Parameters.IParameter? cancellationToken); /// @@ -1202,6 +1203,7 @@ internal interface IMockProtectedSetupForHttpMessageHandler /// /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::System.Net.Http.HttpRequestMessage request, global::System.Threading.CancellationToken cancellationToken); /// @@ -1210,7 +1212,7 @@ internal interface IMockProtectedSetupForHttpMessageHandler /// /// This overload configures the setup via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Setup.IVoidMethodSetupWithCallback Dispose(global::Mockolate.Parameters.IParameters parameters); /// @@ -1219,7 +1221,7 @@ internal interface IMockProtectedSetupForHttpMessageHandler /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] global::Mockolate.Setup.IVoidMethodSetupWithCallback Dispose(global::Mockolate.Parameters.IParameter? disposing); /// @@ -1228,6 +1230,7 @@ internal interface IMockProtectedSetupForHttpMessageHandler /// /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer Dispose(bool disposing); } @@ -1250,7 +1253,7 @@ internal interface IMockProtectedVerifyForHttpMessageHandler /// /// This overload matches invocations via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Verify.VerificationResult Send(global::Mockolate.Parameters.IParameters parameters); /// @@ -1259,7 +1262,7 @@ internal interface IMockProtectedVerifyForHttpMessageHandler /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] global::Mockolate.Verify.VerificationResult Send(global::Mockolate.Parameters.IParameter? request, global::Mockolate.Parameters.IParameter? cancellationToken); /// @@ -1286,6 +1289,7 @@ internal interface IMockProtectedVerifyForHttpMessageHandler /// /// This overload accepts direct values for every parameter and returns a VerificationResult<TVerify>.IgnoreParameters whose VerificationResult<TVerify>.AnyParameters() drops per-parameter matching entirely. /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Verify.VerificationResult.IgnoreParameters Send(global::System.Net.Http.HttpRequestMessage request, global::System.Threading.CancellationToken cancellationToken); /// @@ -1294,7 +1298,7 @@ internal interface IMockProtectedVerifyForHttpMessageHandler /// /// This overload matches invocations via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Verify.VerificationResult SendAsync(global::Mockolate.Parameters.IParameters parameters); /// @@ -1303,7 +1307,7 @@ internal interface IMockProtectedVerifyForHttpMessageHandler /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] global::Mockolate.Verify.VerificationResult SendAsync(global::Mockolate.Parameters.IParameter? request, global::Mockolate.Parameters.IParameter? cancellationToken); /// @@ -1330,6 +1334,7 @@ internal interface IMockProtectedVerifyForHttpMessageHandler /// /// This overload accepts direct values for every parameter and returns a VerificationResult<TVerify>.IgnoreParameters whose VerificationResult<TVerify>.AnyParameters() drops per-parameter matching entirely. /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Verify.VerificationResult.IgnoreParameters SendAsync(global::System.Net.Http.HttpRequestMessage request, global::System.Threading.CancellationToken cancellationToken); /// @@ -1338,7 +1343,7 @@ internal interface IMockProtectedVerifyForHttpMessageHandler /// /// This overload matches invocations via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Verify.VerificationResult Dispose(global::Mockolate.Parameters.IParameters parameters); /// @@ -1347,7 +1352,7 @@ internal interface IMockProtectedVerifyForHttpMessageHandler /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] global::Mockolate.Verify.VerificationResult Dispose(global::Mockolate.Parameters.IParameter? disposing); /// @@ -1356,6 +1361,7 @@ internal interface IMockProtectedVerifyForHttpMessageHandler /// /// This overload accepts direct values for every parameter and returns a VerificationResult<TVerify>.IgnoreParameters whose VerificationResult<TVerify>.AnyParameters() drops per-parameter matching entirely. /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Verify.VerificationResult.IgnoreParameters Dispose(bool disposing); } diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated/Mock.IKeywordEdgeCases.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated/Mock.IKeywordEdgeCases.g.cs index 5d66fe61..69267456 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated/Mock.IKeywordEdgeCases.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated/Mock.IKeywordEdgeCases.g.cs @@ -1321,7 +1321,7 @@ internal interface IMockSetupForIKeywordEdgeCases : global::Mockolate.Setup.IMoc /// /// This overload configures the setup via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Setup.IVoidMethodSetupWithCallback @if(global::Mockolate.Parameters.IParameters parameters); /// @@ -1330,7 +1330,7 @@ internal interface IMockSetupForIKeywordEdgeCases : global::Mockolate.Setup.IMoc /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] global::Mockolate.Setup.IVoidMethodSetupWithCallback @if(global::Mockolate.Parameters.IParameter? @params); /// @@ -1339,6 +1339,7 @@ internal interface IMockSetupForIKeywordEdgeCases : global::Mockolate.Setup.IMoc /// /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer @if(int @params); /// @@ -1347,7 +1348,7 @@ internal interface IMockSetupForIKeywordEdgeCases : global::Mockolate.Setup.IMoc /// /// This overload configures the setup via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Setup.IReturnMethodSetupWithCallback @void<@class>(global::Mockolate.Parameters.IParameters parameters); /// @@ -1356,7 +1357,7 @@ internal interface IMockSetupForIKeywordEdgeCases : global::Mockolate.Setup.IMoc /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] global::Mockolate.Setup.IReturnMethodSetupWithCallback @void<@class>(global::Mockolate.Parameters.IParameter? @ref); /// @@ -1365,6 +1366,7 @@ internal interface IMockSetupForIKeywordEdgeCases : global::Mockolate.Setup.IMoc /// /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer @void<@class>(int @ref); } @@ -1443,7 +1445,7 @@ internal interface IMockVerifyForIKeywordEdgeCases : global::Mockolate.Verify.IM /// /// This overload matches invocations via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Verify.VerificationResult @if(global::Mockolate.Parameters.IParameters parameters); /// @@ -1452,7 +1454,7 @@ internal interface IMockVerifyForIKeywordEdgeCases : global::Mockolate.Verify.IM /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] global::Mockolate.Verify.VerificationResult @if(global::Mockolate.Parameters.IParameter? @params); /// @@ -1461,6 +1463,7 @@ internal interface IMockVerifyForIKeywordEdgeCases : global::Mockolate.Verify.IM /// /// This overload accepts direct values for every parameter and returns a VerificationResult<TVerify>.IgnoreParameters whose VerificationResult<TVerify>.AnyParameters() drops per-parameter matching entirely. /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Verify.VerificationResult.IgnoreParameters @if(int @params); /// @@ -1469,7 +1472,7 @@ internal interface IMockVerifyForIKeywordEdgeCases : global::Mockolate.Verify.IM /// /// This overload matches invocations via a custom Match predicate (for example AnyParameters() or Parameters(Func<object?[], bool>, string)) rather than per-parameter matchers. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)] global::Mockolate.Verify.VerificationResult @void<@class>(global::Mockolate.Parameters.IParameters parameters); /// @@ -1478,7 +1481,7 @@ internal interface IMockVerifyForIKeywordEdgeCases : global::Mockolate.Verify.IM /// /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] global::Mockolate.Verify.VerificationResult @void<@class>(global::Mockolate.Parameters.IParameter? @ref); /// @@ -1487,6 +1490,7 @@ internal interface IMockVerifyForIKeywordEdgeCases : global::Mockolate.Verify.IM /// /// This overload accepts direct values for every parameter and returns a VerificationResult<TVerify>.IgnoreParameters whose VerificationResult<TVerify>.AnyParameters() drops per-parameter matching entirely. /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] global::Mockolate.Verify.VerificationResult.IgnoreParameters @void<@class>(int @ref); /// diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotTests.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotTests.cs index 6caf109f..ed3faf85 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotTests.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotTests.cs @@ -19,6 +19,27 @@ namespace Mockolate.SourceGenerators.Tests.Snapshot; /// public sealed partial class MockGenerationSnapshotTests { + [Theory] + [MemberData(nameof(ScenarioNames))] + public async Task GeneratorOutput_MatchesExpectedSnapshot(string scenarioName) + { + SnapshotScenario scenario = Scenarios.Single(s => s.Name == scenarioName); + GeneratorResult result = RunGenerator(scenario); + await That(result.Diagnostics).IsEmpty(); + + IReadOnlyDictionary generated = NormalizeSources(result); + IReadOnlyDictionary expected = SnapshotStorage.GetExpected(scenarioName); + + await That(generated.Keys).IsEqualTo(expected.Keys).InAnyOrder(); + + foreach (string fileName in expected.Keys) + { + await That(StripConfigSpecificLines(generated[fileName])) + .IsEqualTo(StripConfigSpecificLines(expected[fileName])) + .IgnoringNewlineStyle(); + } + } + internal static readonly IReadOnlyList Scenarios = [ new( @@ -95,27 +116,6 @@ public static TheoryData ScenarioNames } } - [Theory] - [MemberData(nameof(ScenarioNames))] - public async Task GeneratorOutput_MatchesExpectedSnapshot(string scenarioName) - { - SnapshotScenario scenario = Scenarios.Single(s => s.Name == scenarioName); - GeneratorResult result = RunGenerator(scenario); - await That(result.Diagnostics).IsEmpty(); - - IReadOnlyDictionary generated = NormalizeSources(result); - IReadOnlyDictionary expected = SnapshotStorage.GetExpected(scenarioName); - - await That(generated.Keys).IsEqualTo(expected.Keys).InAnyOrder(); - - foreach (string fileName in expected.Keys) - { - await That(StripConfigSpecificLines(generated[fileName])) - .IsEqualTo(StripConfigSpecificLines(expected[fileName])) - .IgnoringNewlineStyle(); - } - } - internal static GeneratorResult RunGenerator(SnapshotScenario scenario) { List sources = new(); diff --git a/Tests/Mockolate.Tests/GeneratorCoverage/IComprehensiveInterface.cs b/Tests/Mockolate.Tests/GeneratorCoverage/IComprehensiveInterface.cs index 4f9f7618..9e2dfc36 100644 --- a/Tests/Mockolate.Tests/GeneratorCoverage/IComprehensiveInterface.cs +++ b/Tests/Mockolate.Tests/GeneratorCoverage/IComprehensiveInterface.cs @@ -57,6 +57,10 @@ void WithCollidingNames(int wraps, int result, int outParam1, string? GetMaybeNull(string? s); + bool TakeObject(object? obj); + int TakeTwoObjects(object? first, object? second); + int TakeIntAndObject(int n, object? obj); + Task DoTask(); Task DoTaskOf(); ValueTask DoVT(); diff --git a/Tests/Mockolate.Tests/MockBehaviorTests.InitializeTests.cs b/Tests/Mockolate.Tests/MockBehaviorTests.InitializeTests.cs index 2a11a1de..b7a36d82 100644 --- a/Tests/Mockolate.Tests/MockBehaviorTests.InitializeTests.cs +++ b/Tests/Mockolate.Tests/MockBehaviorTests.InitializeTests.cs @@ -9,9 +9,8 @@ public sealed class InitializeTests [Fact] public async Task Initialize_DirectSetupsTakePrecedence() { - MockBehavior behavior = MockBehavior.Default.Initialize( - (Mock.IMockSetupForIChocolateDispenser setup) - => setup[It.Satisfies((string s) => s.StartsWith("da"))].InitializeWith(5)); + MockBehavior behavior = MockBehavior.Default.Initialize(setup + => setup[It.Satisfies((string s) => s.StartsWith("da"))].InitializeWith(5)); IChocolateDispenser sut = IChocolateDispenser.CreateMock(behavior, setup => setup[It.Satisfies(s => s.EndsWith("rk"))].InitializeWith(16)); @@ -31,9 +30,8 @@ public async Task Initialize_DirectSetupsTakePrecedence() public async Task Initialize_OtherType_ShouldIgnoreInitializations() { MockBehavior behavior = - MockBehavior.Default.Initialize( - (Mock.IMockSetupForIChocolateDispenser setup) - => setup[It.Is("Dark")].InitializeWith(15)); + MockBehavior.Default.Initialize(setup + => setup[It.Is("Dark")].InitializeWith(15)); void Act() { @@ -47,9 +45,8 @@ void Act() public async Task Initialize_ShouldApplySetupToCreatedMock() { MockBehavior behavior = - MockBehavior.Default.Initialize( - (Mock.IMockSetupForIChocolateDispenser setup) - => setup[It.Is("Dark")].InitializeWith(15)); + MockBehavior.Default.Initialize(setup + => setup[It.Is("Dark")].InitializeWith(15)); IChocolateDispenser sut = IChocolateDispenser.CreateMock(behavior); diff --git a/Tests/Mockolate.Tests/MockBehaviorTests.SkipInteractionRecordingTests.cs b/Tests/Mockolate.Tests/MockBehaviorTests.SkipInteractionRecordingTests.cs index 60c94307..8f69124e 100644 --- a/Tests/Mockolate.Tests/MockBehaviorTests.SkipInteractionRecordingTests.cs +++ b/Tests/Mockolate.Tests/MockBehaviorTests.SkipInteractionRecordingTests.cs @@ -1,5 +1,4 @@ using Mockolate.Exceptions; -using Mockolate.Interactions; using Mockolate.Tests.TestHelpers; namespace Mockolate.Tests; diff --git a/Tests/Mockolate.Tests/MockEvents/InteractionsTests.cs b/Tests/Mockolate.Tests/MockEvents/InteractionsTests.cs index 943394cd..624fb5ad 100644 --- a/Tests/Mockolate.Tests/MockEvents/InteractionsTests.cs +++ b/Tests/Mockolate.Tests/MockEvents/InteractionsTests.cs @@ -1,5 +1,4 @@ -using Mockolate.Interactions; -using Mockolate.Tests.TestHelpers; +using Mockolate.Tests.TestHelpers; namespace Mockolate.Tests.MockEvents; diff --git a/Tests/Mockolate.Tests/MockIndexers/InteractionsTests.cs b/Tests/Mockolate.Tests/MockIndexers/InteractionsTests.cs index adac3125..9aecc96a 100644 --- a/Tests/Mockolate.Tests/MockIndexers/InteractionsTests.cs +++ b/Tests/Mockolate.Tests/MockIndexers/InteractionsTests.cs @@ -1,5 +1,4 @@ using aweXpect.Chronology; -using Mockolate.Interactions; namespace Mockolate.Tests.MockIndexers; diff --git a/Tests/Mockolate.Tests/MockIndexers/SetupIndexerTests.cs b/Tests/Mockolate.Tests/MockIndexers/SetupIndexerTests.cs index 3abee714..9844db17 100644 --- a/Tests/Mockolate.Tests/MockIndexers/SetupIndexerTests.cs +++ b/Tests/Mockolate.Tests/MockIndexers/SetupIndexerTests.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using Mockolate.Exceptions; -using Mockolate.Interactions; using Mockolate.Setup; namespace Mockolate.Tests.MockIndexers; @@ -518,7 +517,6 @@ void Act() await That(Act).Throws() .WithParamName("signatureIndex"); } - } diff --git a/Tests/Mockolate.Tests/MockMethods/InteractionsTests.CancellationTokenTests.cs b/Tests/Mockolate.Tests/MockMethods/InteractionsTests.CancellationTokenTests.cs index fa3d3007..c619ec20 100644 --- a/Tests/Mockolate.Tests/MockMethods/InteractionsTests.CancellationTokenTests.cs +++ b/Tests/Mockolate.Tests/MockMethods/InteractionsTests.CancellationTokenTests.cs @@ -76,43 +76,43 @@ public async Task WithTaskOfString_ShouldReturnCanceledTask() await That(result.IsCanceled).IsTrue(); } -#if NET8_0_OR_GREATER [Fact] - public async Task WithValueTask_ShouldReturnCanceledTask() + public async Task WithTupleContainingTask_ShouldCancelTaskElement() { IMockWithCancellationToken sut = IMockWithCancellationToken.CreateMock(); CancellationToken canceledToken = new(true); - ValueTask result = sut.ValueTaskMethod(canceledToken); + (Task task, string text) result = sut.TupleWithTaskMethod(canceledToken); - await That(result.IsCanceled).IsTrue(); + await That(result.task.IsCanceled).IsTrue(); + await That(result.text).IsEqualTo(string.Empty); } -#endif #if NET8_0_OR_GREATER [Fact] - public async Task WithValueTaskOfInt_ShouldReturnCanceledTask() + public async Task WithValueTask_ShouldReturnCanceledTask() { IMockWithCancellationToken sut = IMockWithCancellationToken.CreateMock(); CancellationToken canceledToken = new(true); - ValueTask result = sut.ValueTaskOfIntMethod(canceledToken); + ValueTask result = sut.ValueTaskMethod(canceledToken); await That(result.IsCanceled).IsTrue(); } #endif +#if NET8_0_OR_GREATER [Fact] - public async Task WithTupleContainingTask_ShouldCancelTaskElement() + public async Task WithValueTaskOfInt_ShouldReturnCanceledTask() { IMockWithCancellationToken sut = IMockWithCancellationToken.CreateMock(); CancellationToken canceledToken = new(true); - (Task task, string text) result = sut.TupleWithTaskMethod(canceledToken); + ValueTask result = sut.ValueTaskOfIntMethod(canceledToken); - await That(result.task.IsCanceled).IsTrue(); - await That(result.text).IsEqualTo(string.Empty); + await That(result.IsCanceled).IsTrue(); } +#endif } public interface IMockWithCancellationToken diff --git a/Tests/Mockolate.Tests/MockMethods/InteractionsTests.cs b/Tests/Mockolate.Tests/MockMethods/InteractionsTests.cs index bd43dcbf..d3b1ec43 100644 --- a/Tests/Mockolate.Tests/MockMethods/InteractionsTests.cs +++ b/Tests/Mockolate.Tests/MockMethods/InteractionsTests.cs @@ -1,5 +1,4 @@ using aweXpect.Chronology; -using Mockolate.Interactions; namespace Mockolate.Tests.MockMethods; diff --git a/Tests/Mockolate.Tests/MockMethods/SetupMethodTests.cs b/Tests/Mockolate.Tests/MockMethods/SetupMethodTests.cs index 11a95f50..551db3de 100644 --- a/Tests/Mockolate.Tests/MockMethods/SetupMethodTests.cs +++ b/Tests/Mockolate.Tests/MockMethods/SetupMethodTests.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Threading; using Mockolate.Exceptions; -using Mockolate.Interactions; using Mockolate.Parameters; using Mockolate.Setup; using Mockolate.Tests.TestHelpers; @@ -150,12 +149,12 @@ public async Task ParameterExplicitMixWithNull_ShouldWork() { IMethodService sut = IMethodService.CreateMock(); MyMethodServiceType value = new(5); - sut.Mock.Setup.Combine(value, null).Returns(4); + sut.Mock.Setup.Combine(value, null!).Returns(4); int result = sut.Combine(value, null!); await That(result).IsEqualTo(4); - await That(sut.Mock.Verify.Combine(value, null)).Once(); + await That(sut.Mock.Verify.Combine(value, null!)).Once(); } [Fact] @@ -570,6 +569,18 @@ public async Task WhenSetupWithNull_ShouldReturnDefaultValue() public class ReturnMethodWith1Parameters { + [Fact] + public async Task AnyParameters_OnUntypedDefaultArgument_ShouldBindToValuesOverload() + { + IReturnMethodSetupTest sut = IReturnMethodSetupTest.CreateMock(); + + sut.Mock.Setup.Method1(default).AnyParameters() + .Returns("foo"); + + await That(sut.Method1(0)).IsEqualTo("foo"); + await That(sut.Method1(42)).IsEqualTo("foo"); + } + [Fact] public async Task AnyParameters_ShouldIgnoreExplicitParameters() { @@ -665,6 +676,18 @@ public async Task WithExplicitParameter_ShouldWork() public class ReturnMethodWith2Parameters { + [Fact] + public async Task AnyParameters_OnUntypedDefaultArguments_ShouldBindToValuesOverload() + { + IReturnMethodSetupTest sut = IReturnMethodSetupTest.CreateMock(); + + sut.Mock.Setup.Method2(default, default).AnyParameters() + .Returns("foo"); + + await That(sut.Method2(0, 0)).IsEqualTo("foo"); + await That(sut.Method2(7, 9)).IsEqualTo("foo"); + } + [Fact] public async Task AnyParameters_ShouldIgnoreExplicitParameters() { diff --git a/Tests/Mockolate.Tests/MockProperties/InteractionsTests.cs b/Tests/Mockolate.Tests/MockProperties/InteractionsTests.cs index 5b9158a0..872faf00 100644 --- a/Tests/Mockolate.Tests/MockProperties/InteractionsTests.cs +++ b/Tests/Mockolate.Tests/MockProperties/InteractionsTests.cs @@ -1,5 +1,3 @@ -using Mockolate.Interactions; - namespace Mockolate.Tests.MockProperties; public sealed partial class InteractionsTests diff --git a/Tests/Mockolate.Tests/MockSetupsTests.cs b/Tests/Mockolate.Tests/MockSetupsTests.cs index 0411495f..0b1d4160 100644 --- a/Tests/Mockolate.Tests/MockSetupsTests.cs +++ b/Tests/Mockolate.Tests/MockSetupsTests.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using Mockolate.Interactions; using Mockolate.Tests.TestHelpers; namespace Mockolate.Tests; diff --git a/Tests/Mockolate.Tests/MockTests.CreateTests.cs b/Tests/Mockolate.Tests/MockTests.CreateTests.cs index e521b474..93b6d30d 100644 --- a/Tests/Mockolate.Tests/MockTests.CreateTests.cs +++ b/Tests/Mockolate.Tests/MockTests.CreateTests.cs @@ -176,9 +176,8 @@ await That(sut2.Mock.As().Verify .DoSomething(It.IsAny())).Exactly(3); } } - - #if NET10_0_OR_GREATER +#if NET10_0_OR_GREATER /// /// Compile-and-create coverage for every special case in /// Source/Mockolate.SourceGenerators. The example types in this folder diff --git a/Tests/Mockolate.Tests/Mockolate.Tests.csproj b/Tests/Mockolate.Tests/Mockolate.Tests.csproj index 664f2b15..ef12abef 100644 --- a/Tests/Mockolate.Tests/Mockolate.Tests.csproj +++ b/Tests/Mockolate.Tests/Mockolate.Tests.csproj @@ -6,7 +6,7 @@ - + all diff --git a/Tests/Mockolate.Tests/Verify/VerificationResultExtensionsTests.cs b/Tests/Mockolate.Tests/Verify/VerificationResultExtensionsTests.cs index 77a299f4..8bacd773 100644 --- a/Tests/Mockolate.Tests/Verify/VerificationResultExtensionsTests.cs +++ b/Tests/Mockolate.Tests/Verify/VerificationResultExtensionsTests.cs @@ -412,6 +412,18 @@ await That(Act).Throws() "Expected that mock invoked method Dispense(It.IsAny(), It.IsAny()) exactly once, but it timed out after 00:00:00.0200000."); } + [Fact] + public void Then_RepeatedPropertyGetter_ShouldNotCollapseIntoOnePosition() + { + IChocolateDispenser sut = IChocolateDispenser.CreateMock(); + _ = sut.TotalDispensed; + sut.Dispense("Dark", 1); + _ = sut.TotalDispensed; + + sut.Mock.Verify.TotalDispensed.Got() + .Then(m => m.TotalDispensed.Got()); + } + [Fact] public async Task Then_ShouldVerifyInOrder() { @@ -437,18 +449,6 @@ await That(Act).Throws() .Then(m => m.Dispense(It.IsAny(), It.Is(2))); } - [Fact] - public void Then_RepeatedPropertyGetter_ShouldNotCollapseIntoOnePosition() - { - IChocolateDispenser sut = IChocolateDispenser.CreateMock(); - _ = sut.TotalDispensed; - sut.Dispense("Dark", 1); - _ = sut.TotalDispensed; - - sut.Mock.Verify.TotalDispensed.Got() - .Then(m => m.TotalDispensed.Got()); - } - [Theory] [InlineData(false, 1, 2, 3, 4)] [InlineData(true, 1, 2, 2, 4)] diff --git a/Tests/Mockolate.Tests/Verify/VerificationResultTests.cs b/Tests/Mockolate.Tests/Verify/VerificationResultTests.cs index b98095f5..e58d8f15 100644 --- a/Tests/Mockolate.Tests/Verify/VerificationResultTests.cs +++ b/Tests/Mockolate.Tests/Verify/VerificationResultTests.cs @@ -1,4 +1,3 @@ -using Mockolate.Interactions; using Mockolate.Tests.TestHelpers; using Mockolate.Verify; @@ -32,6 +31,20 @@ public async Task AnyParameters_OnOverloadedMethod_FastPath_ShouldOnlyCountTheTa await That(sut.Mock.Verify.DoSomething(0, false).AnyParameters()).Once(); } + [Fact] + public async Task AnyParameters_OnUntypedDefaultArguments_ShouldBindToValuesOverload() + { + IOverloadedMethodService sut = IOverloadedMethodService.CreateMock(); + + sut.DoSomething(1); + sut.DoSomething(2); + sut.DoSomething(3, true); + + await That(sut.Mock.Verify.DoSomething(default).AnyParameters()).Exactly(2); + await That(sut.Mock.Verify.DoSomething(default, default).AnyParameters()).Once(); + await That(sut.Mock.Verify.DoSomething(default!, default!).AnyParameters()).Once(); + } + [Fact] public async Task CustomVerificationResult_ShouldKeepExpectation() {