From 65600e38d155fef0c2cf3e8c5ec686b9fecc5f10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Fri, 4 Sep 2026 19:04:18 +0200 Subject: [PATCH 01/14] chore: build on the .NET 11 preview SDK and add net11.0 targets Moves global.json to 11.0.100-preview.7 and adds net11.0 to the runtime and to the three multi-target test projects; the generator and analyzer test projects, which pin a single target, move from net10.0 to net11.0. On net11.0 only, the test projects compile with the preview language version and set MockolateUnionParameters, so that the upcoming union-typed setup surface is exercised there while every other target keeps today's behaviour. Consumers are unaffected: the shipped assembly still compiles as C# 14 and the README keeps recommending the .NET 10 SDK. - Pipeline: new unlisted UnionTests target running the test projects on net11.0. - CI: every setup-dotnet step that runs the Nuke build (build.yml, ci.yml, ci-analysis.yml) pins the SDK via global.json; the package push step keeps the runner SDK since it only runs dotnet nuget push. Dedicated union-tests job in build.yml and ci.yml, awaited by publish-test-results. - API snapshot for net11.0 (identical to net10.0 apart from the header). - HttpClient generator snapshot: .NET 11 marks Send(HttpRequestMessage, CancellationToken) as unsupported on android/ios/tvos, which the generated mock now mirrors. - Benchmarks project moves to net11.0; target lists in README, docs index, CLAUDE.md and copilot-instructions mention .NET 11. --- .github/copilot-instructions.md | 2 +- .github/workflows/build.yml | 36 +- .github/workflows/ci-analysis.yml | 2 + .github/workflows/ci.yml | 34 +- .../Mockolate.Benchmarks.csproj | 2 +- CLAUDE.md | 4 +- Docs/pages/00-index.md | 2 +- Pipeline/Build.UnitTest.cs | 32 + README.md | 2 +- Source/Directory.Build.props | 2 +- Tests/Directory.Build.props | 8 +- .../Mockolate.Analyzers.Tests.csproj | 2 +- .../Expected/Mockolate_net11.0.txt | 3527 +++++++++++++++++ .../Mockolate.SourceGenerators.Tests.csproj | 2 +- .../Mock.HttpClient.g.cs | 3 + global.json | 2 +- 16 files changed, 3649 insertions(+), 13 deletions(-) create mode 100644 Tests/Mockolate.Api.Tests/Expected/Mockolate_net11.0.txt diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index d982e769..7adad51e 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -8,7 +8,7 @@ Mockolate is a modern, strongly-typed mocking library for .NET, powered by sourc - Source generator-based (no runtime proxy generation) - Strongly-typed with compile-time safety - AOT compatible (NativeAOT and trimming) -- Supports .NET Standard 2.0, .NET 8, .NET 10, and .NET Framework 4.8 +- Supports .NET Standard 2.0, .NET 8, .NET 10, .NET 11, and .NET Framework 4.8 ## Architecture diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e544adff..b2069178 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,6 +24,7 @@ jobs: dotnet-version: | 8.0.x 10.0.x + global-json-file: global.json - name: Run unit tests (windows) if: matrix.os == 'windows-latest' run: ./build.ps1 CodeCoverage @@ -54,6 +55,7 @@ jobs: dotnet-version: | 8.0.x 10.0.x + global-json-file: global.json - name: API checks run: ./build.sh ApiChecks - name: Upload artifacts @@ -65,6 +67,33 @@ jobs: ./Artifacts/* ./TestResults/*.trx + union-tests: + name: "Union tests (net11.0, C# preview)" + runs-on: ubuntu-latest + env: + DOTNET_NOLOGO: true + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + - name: Setup .NET SDKs + uses: actions/setup-dotnet@v6 + with: + dotnet-version: | + 8.0.x + 10.0.x + global-json-file: global.json + - name: Union tests + run: ./build.sh UnionTests + - name: Upload artifacts + if: always() + uses: actions/upload-artifact@v7 + with: + name: Union-tests + path: | + ./Artifacts/* + ./TestResults/*.trx + benchmarks: name: "Benchmarks (${{ matrix.benchmark }})" strategy: @@ -92,6 +121,7 @@ jobs: dotnet-version: | 8.0.x 10.0.x + global-json-file: global.json - name: Run benchmarks run: ./build.sh Benchmarks --benchmark-filter "*${{ matrix.benchmark }}*" - name: Upload artifacts @@ -122,6 +152,7 @@ jobs: with: dotnet-version: | 10.0.x + global-json-file: global.json - name: Publish benchmark report run: ./build.sh PublishBenchmarkReport env: @@ -144,6 +175,7 @@ jobs: dotnet-version: | 8.0.x 10.0.x + global-json-file: global.json - name: Run mutation tests run: ./build.sh MutationTests MutationTestDashboard @@ -164,12 +196,13 @@ jobs: dotnet-version: | 8.0.x 10.0.x + global-json-file: global.json - name: Run sonarcloud analysis run: ./build.sh CodeAnalysis publish-test-results: name: "Publish Tests Results" - needs: [ api-tests, unit-tests ] + needs: [ api-tests, unit-tests, union-tests ] runs-on: ubuntu-latest permissions: checks: write @@ -201,6 +234,7 @@ jobs: dotnet-version: | 8.0.x 10.0.x + global-json-file: global.json - name: Pack nuget packages run: ./build.sh Pack - name: Upload packages diff --git a/.github/workflows/ci-analysis.yml b/.github/workflows/ci-analysis.yml index d1483f63..8356a755 100644 --- a/.github/workflows/ci-analysis.yml +++ b/.github/workflows/ci-analysis.yml @@ -22,6 +22,7 @@ jobs: with: dotnet-version: | 10.0.x + global-json-file: global.json - name: Create mutation test comment run: ./build.sh MutationTestComment env: @@ -43,6 +44,7 @@ jobs: with: dotnet-version: | 10.0.x + global-json-file: global.json - name: Create benchmark comment run: ./build.sh BenchmarkComment env: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3611296c..a78d2c4f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,7 @@ jobs: dotnet-version: | 8.0.x 10.0.x + global-json-file: global.json - name: Run unit tests (windows) if: matrix.os == 'windows-latest' run: ./build.ps1 CodeCoverage @@ -53,6 +54,7 @@ jobs: dotnet-version: | 8.0.x 10.0.x + global-json-file: global.json - name: API checks run: ./build.sh ApiChecks - name: Upload artifacts @@ -79,6 +81,7 @@ jobs: dotnet-version: | 8.0.x 10.0.x + global-json-file: global.json - name: Run mutation tests run: ./build.sh MutationTests - name: Upload artifacts @@ -89,6 +92,33 @@ jobs: path: | ./Artifacts/* + union-tests: + name: "Union tests (net11.0, C# preview)" + runs-on: ubuntu-latest + env: + DOTNET_NOLOGO: true + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + - name: Setup .NET SDKs + uses: actions/setup-dotnet@v6 + with: + dotnet-version: | + 8.0.x + 10.0.x + global-json-file: global.json + - name: Union tests + run: ./build.sh UnionTests + - name: Upload artifacts + if: always() + uses: actions/upload-artifact@v7 + with: + name: Union-tests + path: | + ./Artifacts/* + ./TestResults/*.trx + benchmarks: name: "Benchmarks (${{ matrix.benchmark }})" strategy: @@ -114,6 +144,7 @@ jobs: dotnet-version: | 8.0.x 10.0.x + global-json-file: global.json - name: Run benchmarks run: ./build.sh Benchmarks --benchmark-filter "*${{ matrix.benchmark }}*" - name: Upload artifacts @@ -143,12 +174,13 @@ jobs: dotnet-version: | 8.0.x 10.0.x + global-json-file: global.json - name: Run sonarcloud analysis run: ./build.sh CodeAnalysis publish-test-results: name: "Publish Tests Results" - needs: [ api-tests, unit-tests ] + needs: [ api-tests, unit-tests, union-tests ] runs-on: ubuntu-latest permissions: checks: write diff --git a/Benchmarks/Mockolate.Benchmarks/Mockolate.Benchmarks.csproj b/Benchmarks/Mockolate.Benchmarks/Mockolate.Benchmarks.csproj index b7d5f92e..6b2d721e 100644 --- a/Benchmarks/Mockolate.Benchmarks/Mockolate.Benchmarks.csproj +++ b/Benchmarks/Mockolate.Benchmarks/Mockolate.Benchmarks.csproj @@ -2,7 +2,7 @@ Exe - net10.0 + net11.0 enable enable false diff --git a/CLAUDE.md b/CLAUDE.md index 503c7d88..614b754a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -6,7 +6,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co Mockolate is a strongly-typed .NET mocking library powered by **Roslyn source generators**. Unlike reflection-based mocking libraries, it generates mock implementations at compile time, providing full IntelliSense support and AOT compatibility. -**Supported targets**: .NET Standard 2.0, .NET 8, .NET 10, .NET Framework 4.8 +**Supported targets**: .NET Standard 2.0, .NET 8, .NET 10, .NET 11, .NET Framework 4.8 ## Build and Test Commands @@ -33,7 +33,7 @@ dotnet test Tests/Mockolate.Tests/Mockolate.Tests.csproj --filter "FullyQualifie ./build.sh Pack # Create NuGet packages ``` -**Requires**: .NET 10 SDK (see `global.json`). For source generator changes, run `dotnet clean && dotnet build` to force regeneration. +**Requires**: .NET 11 SDK (currently a preview, see `global.json`). For source generator changes, run `dotnet clean && dotnet build` to force regeneration. ## Architecture diff --git a/Docs/pages/00-index.md b/Docs/pages/00-index.md index 0d4bd158..73d7e51a 100644 --- a/Docs/pages/00-index.md +++ b/Docs/pages/00-index.md @@ -5,7 +5,7 @@ [![Nuget](https://img.shields.io/nuget/v/Mockolate)](https://www.nuget.org/packages/Mockolate) [**Mockolate**](https://github.com/Testably/Mockolate) is a modern, strongly-typed, AOT-compatible mocking library for .NET, powered by source generators. -It enables fast, compile-time validated mocking with .NET Standard 2.0, .NET 8, .NET 10 and .NET Framework 4.8. +It enables fast, compile-time validated mocking with .NET Standard 2.0, .NET 8, .NET 10, .NET 11 and .NET Framework 4.8. - **Source generator-based**: No runtime proxy generation. - **Fast**: Direct dispatch with no reflection or dynamic proxies. diff --git a/Pipeline/Build.UnitTest.cs b/Pipeline/Build.UnitTest.cs index 78f32d74..6049e68d 100644 --- a/Pipeline/Build.UnitTest.cs +++ b/Pipeline/Build.UnitTest.cs @@ -51,4 +51,36 @@ partial class Build ), completeOnFailure: true ); }); + + Project[] UnionTestProjects => + [ + Solution.Tests.Mockolate_Tests, + Solution.Tests.Mockolate_Internal_Tests, + Solution.Tests.Mockolate_SourceGenerators_Tests, + Solution.Tests.Mockolate_ExampleTests, + ]; + + /// + /// Runs the test projects on net11.0 only, where Tests/Directory.Build.props enables the C# preview + /// language version and the union-typed setup surface (MockolateUnionParameters). + /// + Target UnionTests => _ => _ + .Unlisted() + .DependsOn(Compile) + .Executes(() => + { + DotNetTest(s => s + .SetConfiguration(Configuration) + .SetProcessEnvironmentVariable("DOTNET_CLI_UI_LANGUAGE", "en-US") + .EnableNoBuild() + .SetFramework("net11.0") + .SetResultsDirectory(TestResultsDirectory) + .CombineWith( + UnionTestProjects, + (settings, project) => settings + .SetProjectFile(project) + .AddLoggers($"trx;LogFileName={project.Name}_net11.0_unions.trx") + ), completeOnFailure: true + ); + }); } diff --git a/README.md b/README.md index 3f4dfeea..984af0f3 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ [![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FTestably%2FMockolate%2Fmain)](https://dashboard.stryker-mutator.io/reports/github.com/Testably/Mockolate/main) **Mockolate** is a modern, strongly-typed, AOT-compatible mocking library for .NET, powered by source generators. -It enables fast, compile-time validated mocking with .NET Standard 2.0, .NET 8, .NET 10 and .NET Framework 4.8. +It enables fast, compile-time validated mocking with .NET Standard 2.0, .NET 8, .NET 10, .NET 11 and .NET Framework 4.8. - **Source generator-based**: No runtime proxy generation. - **Fast**: Direct dispatch with no reflection or dynamic proxies. diff --git a/Source/Directory.Build.props b/Source/Directory.Build.props index fa71b8e7..988b1095 100644 --- a/Source/Directory.Build.props +++ b/Source/Directory.Build.props @@ -16,7 +16,7 @@ - netstandard2.0;net8.0;net10.0 + netstandard2.0;net8.0;net10.0;net11.0 diff --git a/Tests/Directory.Build.props b/Tests/Directory.Build.props index 9867a05b..9695088f 100644 --- a/Tests/Directory.Build.props +++ b/Tests/Directory.Build.props @@ -4,7 +4,7 @@ Condition="Exists('$(MSBuildThisFileDirectory)/../Directory.Build.props')"/> - net10.0;net8.0;net48 + net11.0;net10.0;net8.0;net48 @@ -16,6 +16,12 @@ 701;1702;CA1845 + + + preview + true + + exe diff --git a/Tests/Mockolate.Analyzers.Tests/Mockolate.Analyzers.Tests.csproj b/Tests/Mockolate.Analyzers.Tests/Mockolate.Analyzers.Tests.csproj index c11c6f4d..0e06e04c 100644 --- a/Tests/Mockolate.Analyzers.Tests/Mockolate.Analyzers.Tests.csproj +++ b/Tests/Mockolate.Analyzers.Tests/Mockolate.Analyzers.Tests.csproj @@ -1,7 +1,7 @@  false - net10.0 + net11.0 diff --git a/Tests/Mockolate.Api.Tests/Expected/Mockolate_net11.0.txt b/Tests/Mockolate.Api.Tests/Expected/Mockolate_net11.0.txt new file mode 100644 index 00000000..44002742 --- /dev/null +++ b/Tests/Mockolate.Api.Tests/Expected/Mockolate_net11.0.txt @@ -0,0 +1,3527 @@ +[assembly: System.Reflection.AssemblyMetadata("IsAotCompatible", "True")] +[assembly: System.Reflection.AssemblyMetadata("IsTrimmable", "True")] +[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/Testably/Mockolate.git")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"Mockolate.Internal.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100917b2e28a0dcd1de99a208f70383c300caa03729b1f9cdad97cb11a127f822aa36aad08225cc24312de1fadf3aeafc7ab6c2c4b588d5e88c2b61f0a56e02df1b6aa11d0c3e4ee6675f24b20dbd75ee4fc229f82b0eeeafe1a5bc376d5e5f9a5c4320267921d9a962cc5f58ccc94e7127db3119bafedfb76fd3a7b1f2d22155ac")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v11.0", FrameworkDisplayName=".NET 11.0")] +namespace Mockolate.Behavior +{ + public interface IMockBehaviorInitializer { } +} +namespace Mockolate +{ + public class DefaultValueFactory + { + protected DefaultValueFactory() { } + public DefaultValueFactory(System.Func predicate, System.Func generator) { } + public virtual bool CanGenerateValue(System.Type type) { } + public virtual object? GenerateValue(System.Type type, params object?[] parameters) { } + } + public static class HttpClientExtensions + { + extension(Mockolate.Setup.IMockSetup setup) + { + public Mockolate.Setup.IReturnMethodSetup, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> SendAsync(Mockolate.Parameters.IParameter request) { } + public Mockolate.Setup.IReturnMethodSetup, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> DeleteAsync(Mockolate.Parameters.IParameter requestUri) { } + public Mockolate.Setup.IReturnMethodSetup, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> DeleteAsync(Mockolate.Parameters.IParameter requestUri) { } + public Mockolate.Setup.IReturnMethodSetup, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> DeleteAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter cancellationToken) { } + public Mockolate.Setup.IReturnMethodSetup, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> DeleteAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter cancellationToken) { } + public Mockolate.Setup.IReturnMethodSetup, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> GetAsync(Mockolate.Parameters.IParameter requestUri) { } + public Mockolate.Setup.IReturnMethodSetup, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> GetAsync(Mockolate.Parameters.IParameter requestUri) { } + public Mockolate.Setup.IReturnMethodSetup, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> GetAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter cancellationToken) { } + public Mockolate.Setup.IReturnMethodSetup, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> GetAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter cancellationToken) { } + public Mockolate.Setup.IReturnMethodSetup, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> PatchAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter? content = null) { } + public Mockolate.Setup.IReturnMethodSetup, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> PatchAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter? content = null) { } + public Mockolate.Setup.IReturnMethodSetup, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> PatchAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter content, Mockolate.Parameters.IParameter cancellationToken) { } + public Mockolate.Setup.IReturnMethodSetup, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> PatchAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter content, Mockolate.Parameters.IParameter cancellationToken) { } + public Mockolate.Setup.IReturnMethodSetup, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> PostAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter? content = null) { } + public Mockolate.Setup.IReturnMethodSetup, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> PostAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter? content = null) { } + public Mockolate.Setup.IReturnMethodSetup, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> PostAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter content, Mockolate.Parameters.IParameter cancellationToken) { } + public Mockolate.Setup.IReturnMethodSetup, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> PostAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter content, Mockolate.Parameters.IParameter cancellationToken) { } + public Mockolate.Setup.IReturnMethodSetup, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> PutAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter? content = null) { } + public Mockolate.Setup.IReturnMethodSetup, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> PutAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter? content = null) { } + public Mockolate.Setup.IReturnMethodSetup, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> PutAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter content, Mockolate.Parameters.IParameter cancellationToken) { } + public Mockolate.Setup.IReturnMethodSetup, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> PutAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter content, Mockolate.Parameters.IParameter cancellationToken) { } + } + extension(Mockolate.Setup.IReturnMethodSetup, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> setup) + { + public Mockolate.Setup.IReturnMethodSetupReturnBuilder, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> ReturnsAsync(System.Net.HttpStatusCode statusCode) { } + public Mockolate.Setup.IReturnMethodSetupReturnBuilder, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> ReturnsAsync(System.Net.HttpStatusCode statusCode, string content) { } + public Mockolate.Setup.IReturnMethodSetupReturnBuilder, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> ReturnsAsync(System.Net.HttpStatusCode statusCode, string content, string mediaType) { } + public Mockolate.Setup.IReturnMethodSetupReturnBuilder, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> ReturnsAsync(System.Net.HttpStatusCode statusCode, byte[] bytes) { } + public Mockolate.Setup.IReturnMethodSetupReturnBuilder, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> ReturnsAsync(System.Net.HttpStatusCode statusCode, byte[] bytes, string mediaType) { } + public Mockolate.Setup.IReturnMethodSetupReturnBuilder, System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken> ReturnsAsync(System.Net.HttpStatusCode statusCode, System.Net.Http.HttpContent content) { } + } + extension(Mockolate.Verify.IMockVerify verify) + { + public Mockolate.Verify.VerificationResult DeleteAsync(Mockolate.Parameters.IParameter requestUri) { } + public Mockolate.Verify.VerificationResult DeleteAsync(Mockolate.Parameters.IParameter requestUri) { } + public Mockolate.Verify.VerificationResult DeleteAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter cancellationToken) { } + public Mockolate.Verify.VerificationResult DeleteAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter cancellationToken) { } + public Mockolate.Verify.VerificationResult GetAsync(Mockolate.Parameters.IParameter requestUri) { } + public Mockolate.Verify.VerificationResult GetAsync(Mockolate.Parameters.IParameter requestUri) { } + public Mockolate.Verify.VerificationResult GetAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter cancellationToken) { } + public Mockolate.Verify.VerificationResult GetAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter cancellationToken) { } + public Mockolate.Verify.VerificationResult PatchAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter? content = null) { } + public Mockolate.Verify.VerificationResult PatchAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter? content = null) { } + public Mockolate.Verify.VerificationResult PatchAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter content, Mockolate.Parameters.IParameter cancellationToken) { } + public Mockolate.Verify.VerificationResult PatchAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter content, Mockolate.Parameters.IParameter cancellationToken) { } + public Mockolate.Verify.VerificationResult PostAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter? content = null) { } + public Mockolate.Verify.VerificationResult PostAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter? content = null) { } + public Mockolate.Verify.VerificationResult PostAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter content, Mockolate.Parameters.IParameter cancellationToken) { } + public Mockolate.Verify.VerificationResult PostAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter content, Mockolate.Parameters.IParameter cancellationToken) { } + public Mockolate.Verify.VerificationResult PutAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter? content = null) { } + public Mockolate.Verify.VerificationResult PutAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter? content = null) { } + public Mockolate.Verify.VerificationResult PutAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter content, Mockolate.Parameters.IParameter cancellationToken) { } + public Mockolate.Verify.VerificationResult PutAsync(Mockolate.Parameters.IParameter requestUri, Mockolate.Parameters.IParameter content, Mockolate.Parameters.IParameter cancellationToken) { } + } + } + public interface IDefaultValueGenerator + { + object? GenerateValue(System.Type type, params object?[] parameters); + } + public interface IInteractiveMock { } + public interface IMock + { + Mockolate.MockRegistry MockRegistry { get; } + string ToString(); + } + public interface IMockBehaviorAccess + { + Mockolate.MockBehavior Set(T value); + bool TryGet([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out T value); + bool TryGetConstructorParameters([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out object?[]? parameters); + } + public class It + { + public static Mockolate.It.IContainsParameter Contains(T item, [System.Runtime.CompilerServices.CallerArgumentExpression("item")] string doNotPopulateThisValue = "") { } + public static Mockolate.It.IIsParameter Is(T value, [System.Runtime.CompilerServices.CallerArgumentExpression("value")] string doNotPopulateThisValue = "") { } + public static Mockolate.Parameters.IParameterWithCallback IsAny() { } + public static Mockolate.Parameters.IOutParameter IsAnyOut() { } + public static Mockolate.Parameters.IOutParameter> IsAnyOutReadOnlySpan() { } + public static Mockolate.Parameters.IOutRefStructParameter IsAnyOutRefStruct() { } + public static Mockolate.Parameters.IOutParameter> IsAnyOutSpan() { } + public static Mockolate.Parameters.IVerifyReadOnlySpanParameter IsAnyReadOnlySpan() { } + public static Mockolate.Parameters.IRefParameter IsAnyRef() { } + public static Mockolate.Parameters.IRefParameter> IsAnyRefReadOnlySpan() { } + public static Mockolate.Parameters.IRefRefStructParameter IsAnyRefRefStruct() { } + public static Mockolate.Parameters.IRefParameter> IsAnyRefSpan() { } + public static Mockolate.Parameters.IParameter IsAnyRefStruct() { } + public static Mockolate.Parameters.IVerifySpanParameter IsAnySpan() { } + public static Mockolate.Parameters.IParameterWithCallback IsFalse() { } + public static Mockolate.It.IInRangeParameter IsInRange(T minimum, T maximum, [System.Runtime.CompilerServices.CallerArgumentExpression("minimum")] string doNotPopulateThisValue1 = "", [System.Runtime.CompilerServices.CallerArgumentExpression("maximum")] string doNotPopulateThisValue2 = "") + where T : System.IComparable { } + public static Mockolate.It.IIsNotParameter IsNot(T value, [System.Runtime.CompilerServices.CallerArgumentExpression("value")] string doNotPopulateThisValue = "") { } + public static Mockolate.Parameters.IParameterWithCallback IsNotNull(string? toString = null) { } + public static Mockolate.It.IIsNotOneOfParameter IsNotOneOf(System.Collections.Generic.IEnumerable values) { } + public static Mockolate.Parameters.IParameterWithCallback IsNull(string? toString = null) { } + public static Mockolate.It.IIsOneOfParameter IsOneOf(System.Collections.Generic.IEnumerable values) { } + public static Mockolate.Parameters.IVerifyOutParameter IsOut() { } + public static Mockolate.Parameters.IOutRefStructParameter IsOut(Mockolate.RefStructFactory setter, [System.Runtime.CompilerServices.CallerArgumentExpression("setter")] string doNotPopulateThisValue = "") { } + public static Mockolate.Parameters.IOutParameter IsOut(System.Func setter, [System.Runtime.CompilerServices.CallerArgumentExpression("setter")] string doNotPopulateThisValue = "") { } + public static Mockolate.Parameters.IOutParameter> IsOutReadOnlySpan(System.Func> setter, [System.Runtime.CompilerServices.CallerArgumentExpression("setter")] string doNotPopulateThisValue = "") { } + public static Mockolate.Parameters.IOutParameter> IsOutSpan(System.Func> setter, [System.Runtime.CompilerServices.CallerArgumentExpression("setter")] string doNotPopulateThisValue = "") { } + public static Mockolate.Parameters.IVerifyReadOnlySpanParameter IsReadOnlySpan(System.Func predicate, [System.Runtime.CompilerServices.CallerArgumentExpression("predicate")] string doNotPopulateThisValue = "") { } + public static Mockolate.Parameters.IVerifyRefParameter IsRef() { } + public static Mockolate.Parameters.IRefRefStructParameter IsRef(Mockolate.RefStructPredicate predicate, [System.Runtime.CompilerServices.CallerArgumentExpression("predicate")] string doNotPopulateThisValue = "") { } + public static Mockolate.Parameters.IRefRefStructParameter IsRef(Mockolate.RefStructTransform setter, [System.Runtime.CompilerServices.CallerArgumentExpression("setter")] string doNotPopulateThisValue = "") { } + public static Mockolate.Parameters.IRefParameter IsRef(System.Func setter, [System.Runtime.CompilerServices.CallerArgumentExpression("setter")] string doNotPopulateThisValue = "") { } + public static Mockolate.Parameters.IRefParameter IsRef(System.Func predicate, [System.Runtime.CompilerServices.CallerArgumentExpression("predicate")] string doNotPopulateThisValue = "") { } + public static Mockolate.Parameters.IRefRefStructParameter IsRef(Mockolate.RefStructPredicate predicate, Mockolate.RefStructTransform setter, [System.Runtime.CompilerServices.CallerArgumentExpression("predicate")] string doNotPopulateThisValue1 = "", [System.Runtime.CompilerServices.CallerArgumentExpression("setter")] string doNotPopulateThisValue2 = "") { } + public static Mockolate.Parameters.IRefParameter IsRef(System.Func predicate, System.Func setter, [System.Runtime.CompilerServices.CallerArgumentExpression("predicate")] string doNotPopulateThisValue1 = "", [System.Runtime.CompilerServices.CallerArgumentExpression("setter")] string doNotPopulateThisValue2 = "") { } + public static Mockolate.Parameters.IRefParameter> IsRefReadOnlySpan(System.Func, Mockolate.Setup.ReadOnlySpanWrapper> setter, [System.Runtime.CompilerServices.CallerArgumentExpression("setter")] string doNotPopulateThisValue = "") { } + public static Mockolate.Parameters.IRefParameter> IsRefReadOnlySpan(System.Func, bool> predicate, [System.Runtime.CompilerServices.CallerArgumentExpression("predicate")] string doNotPopulateThisValue = "") { } + public static Mockolate.Parameters.IRefParameter> IsRefReadOnlySpan(System.Func, bool> predicate, System.Func, Mockolate.Setup.ReadOnlySpanWrapper> setter, [System.Runtime.CompilerServices.CallerArgumentExpression("predicate")] string doNotPopulateThisValue1 = "", [System.Runtime.CompilerServices.CallerArgumentExpression("setter")] string doNotPopulateThisValue2 = "") { } + public static Mockolate.Parameters.IRefParameter> IsRefSpan(System.Func, Mockolate.Setup.SpanWrapper> setter, [System.Runtime.CompilerServices.CallerArgumentExpression("setter")] string doNotPopulateThisValue = "") { } + public static Mockolate.Parameters.IRefParameter> IsRefSpan(System.Func, bool> predicate, [System.Runtime.CompilerServices.CallerArgumentExpression("predicate")] string doNotPopulateThisValue = "") { } + public static Mockolate.Parameters.IRefParameter> IsRefSpan(System.Func, bool> predicate, System.Func, Mockolate.Setup.SpanWrapper> setter, [System.Runtime.CompilerServices.CallerArgumentExpression("predicate")] string doNotPopulateThisValue1 = "", [System.Runtime.CompilerServices.CallerArgumentExpression("setter")] string doNotPopulateThisValue2 = "") { } + public static Mockolate.Parameters.IParameter IsRefStruct(Mockolate.RefStructPredicate predicate) { } + public static Mockolate.Parameters.IParameter IsRefStructBy(Mockolate.RefStructProjection projection) + where TProjected : notnull { } + public static Mockolate.Parameters.IParameter IsRefStructBy(Mockolate.RefStructProjection projection, System.Func projectedPredicate) + where TProjected : notnull { } + public static Mockolate.Parameters.IVerifySpanParameter IsSpan(System.Func predicate, [System.Runtime.CompilerServices.CallerArgumentExpression("predicate")] string doNotPopulateThisValue = "") { } + public static Mockolate.Parameters.IParameterWithCallback IsTrue() { } + public static Mockolate.It.IIsParameter IsValue(T value) { } + public static Mockolate.It.IParameterMatches Matches(string pattern) { } + public static Mockolate.Parameters.IParameterWithCallback Satisfies(System.Func predicate, [System.Runtime.CompilerServices.CallerArgumentExpression("predicate")] string doNotPopulateThisValue = "") { } + public static Mockolate.It.ISequenceEqualsParameter SequenceEquals(System.Collections.Generic.IEnumerable values) { } + public interface IContainsParameter : Mockolate.Parameters.IParameter, Mockolate.Parameters.IParameter>, Mockolate.Parameters.IParameter>, Mockolate.Parameters.IParameter>, Mockolate.Parameters.IParameter>, Mockolate.Parameters.IParameter>, Mockolate.Parameters.IParameter>, Mockolate.Parameters.IParameter>, Mockolate.Parameters.IParameter>, Mockolate.Parameters.IParameter>, Mockolate.Parameters.IParameter>, Mockolate.Parameters.IParameter + { + Mockolate.It.IContainsParameter Using(System.Collections.Generic.IEqualityComparer comparer, [System.Runtime.CompilerServices.CallerArgumentExpression("comparer")] string doNotPopulateThisValue = ""); + } + public interface IInRangeParameter : Mockolate.Parameters.IParameter, Mockolate.Parameters.IParameterWithCallback, Mockolate.Parameters.IParameter + { + Mockolate.Parameters.IParameterWithCallback Exclusive(); + Mockolate.Parameters.IParameterWithCallback Inclusive(); + } + public interface IIsNotOneOfParameter : Mockolate.Parameters.IParameter, Mockolate.Parameters.IParameterWithCallback, Mockolate.Parameters.IParameter + { + Mockolate.It.IIsNotOneOfParameter Using(System.Collections.Generic.IEqualityComparer comparer, [System.Runtime.CompilerServices.CallerArgumentExpression("comparer")] string doNotPopulateThisValue = ""); + } + public interface IIsNotParameter : Mockolate.Parameters.IParameter, Mockolate.Parameters.IParameterWithCallback, Mockolate.Parameters.IParameter + { + Mockolate.It.IIsNotParameter Using(System.Collections.Generic.IEqualityComparer comparer, [System.Runtime.CompilerServices.CallerArgumentExpression("comparer")] string doNotPopulateThisValue = ""); + } + public interface IIsOneOfParameter : Mockolate.Parameters.IParameter, Mockolate.Parameters.IParameterWithCallback, Mockolate.Parameters.IParameter + { + Mockolate.It.IIsOneOfParameter Using(System.Collections.Generic.IEqualityComparer comparer, [System.Runtime.CompilerServices.CallerArgumentExpression("comparer")] string doNotPopulateThisValue = ""); + } + public interface IIsParameter : Mockolate.Parameters.IParameter, Mockolate.Parameters.IParameterWithCallback, Mockolate.Parameters.IParameter + { + Mockolate.It.IIsParameter Using(System.Collections.Generic.IEqualityComparer comparer, [System.Runtime.CompilerServices.CallerArgumentExpression("comparer")] string doNotPopulateThisValue = ""); + } + public interface IParameterMatches : Mockolate.Parameters.IParameter, Mockolate.Parameters.IParameterWithCallback, Mockolate.Parameters.IParameter + { + Mockolate.It.IParameterMatches AsRegex(System.Text.RegularExpressions.RegexOptions options = 0, System.TimeSpan? timeout = default, [System.Runtime.CompilerServices.CallerArgumentExpression("options")] string doNotPopulateThisValue1 = "", [System.Runtime.CompilerServices.CallerArgumentExpression("timeout")] string doNotPopulateThisValue2 = ""); + Mockolate.It.IParameterMatches CaseSensitive(bool caseSensitive = true); + } + public interface ISequenceEqualsParameter : Mockolate.Parameters.IParameter, Mockolate.Parameters.IParameter>, Mockolate.Parameters.IParameter>, Mockolate.Parameters.IParameter>, Mockolate.Parameters.IParameter>, Mockolate.Parameters.IParameter>, Mockolate.Parameters.IParameter>, Mockolate.Parameters.IParameter>, Mockolate.Parameters.IParameter>, Mockolate.Parameters.IParameter + { + Mockolate.It.ISequenceEqualsParameter Using(System.Collections.Generic.IEqualityComparer comparer, [System.Runtime.CompilerServices.CallerArgumentExpression("comparer")] string doNotPopulateThisValue = ""); + } + } + public class Match + { + public static Mockolate.Parameters.IParameters AnyParameters() { } + public static Mockolate.Parameters.IParameters Parameters(System.Func predicate, [System.Runtime.CompilerServices.CallerArgumentExpression("predicate")] string doNotPopulateThisValue = "") { } + public static Mockolate.Parameters.IDefaultEventParameters WithDefaultParameters() { } + } + public class MockBehavior : Mockolate.IMockBehaviorAccess, System.IEquatable + { + public MockBehavior(Mockolate.IDefaultValueGenerator defaultValue) { } + public Mockolate.IDefaultValueGenerator DefaultValue { get; init; } + public bool SkipBaseClass { get; init; } + public bool SkipInteractionRecording { get; init; } + public bool ThrowWhenNotSetup { get; init; } + public override string ToString() { } + public Mockolate.MockBehavior UseConstructorParametersFor(System.Func parameters) { } + public Mockolate.MockBehavior UseConstructorParametersFor(params object?[] parameters) { } + public Mockolate.MockBehavior WithDefaultValueFor(params Mockolate.DefaultValueFactory[] defaultValueFactories) { } + } + public static class MockBehaviorExtensions + { + extension(Mockolate.MockBehavior mockBehavior) + { + public Mockolate.MockBehavior SkippingBaseClass(bool skipBaseClass = true) { } + public Mockolate.MockBehavior ThrowingWhenNotSetup(bool throwWhenNotSetup = true) { } + public Mockolate.MockBehavior SkippingInteractionRecording(bool skipInteractionRecording = true) { } + public Mockolate.MockBehavior WithDefaultValueFor(System.Func factory) { } + } + } + [System.Diagnostics.DebuggerDisplay("{Interactions} | {Setup}")] + public class MockRegistry + { + public MockRegistry(Mockolate.MockRegistry registry, Mockolate.Interactions.IMockInteractions interactions) { } + public MockRegistry(Mockolate.MockRegistry registry, object wraps) { } + public MockRegistry(Mockolate.MockRegistry registry, object?[] constructorParameters) { } + public MockRegistry(Mockolate.MockBehavior behavior, Mockolate.Interactions.IMockInteractions interactions, object?[]? constructorParameters = null) { } + public MockRegistry(Mockolate.MockBehavior behavior, int memberCount, object?[]? constructorParameters = null) { } + public Mockolate.MockBehavior Behavior { get; } + public object?[]? ConstructorParameters { get; } + public Mockolate.Interactions.IMockInteractions Interactions { get; } + public string Scenario { get; } + public object? Wraps { get; } + public void AddEvent(string name, object? target, System.Reflection.MethodInfo? method) { } + public void AddEvent(int memberId, string name, object? target, System.Reflection.MethodInfo? method) { } + public TResult ApplyIndexerGetter(Mockolate.Interactions.IndexerAccess access, Mockolate.Setup.IndexerSetup? setup, System.Func defaultValueGenerator, int signatureIndex) { } + public TResult ApplyIndexerGetter(Mockolate.Interactions.IndexerAccess access, Mockolate.Setup.IndexerSetup? setup, TResult baseValue, int signatureIndex) { } + public bool ApplyIndexerSetter(Mockolate.Interactions.IndexerAccess access, Mockolate.Setup.IndexerSetup? setup, TResult value, int signatureIndex) { } + public TResult ApplyIndexerSetup(Mockolate.Interactions.IndexerAccess access, Mockolate.Setup.IndexerSetup setup, int signatureIndex) { } + public void ClearAllInteractions() { } + public Mockolate.Setup.EventSetup[]? GetEventSetupSnapshot(int memberId) { } + public TResult GetIndexerFallback(Mockolate.Interactions.IndexerAccess access, int signatureIndex) { } + public T? GetIndexerSetup(Mockolate.Interactions.IndexerAccess access) + where T : Mockolate.Setup.IndexerSetup { } + public T? GetIndexerSetup(System.Func predicate) + where T : Mockolate.Setup.IndexerSetup { } + public Mockolate.Setup.IndexerSetup[]? GetIndexerSetupSnapshot(int memberId) { } + public Mockolate.Setup.MethodSetup[]? GetMethodSetupSnapshot(int memberId) { } + public System.Collections.Generic.IEnumerable GetMethodSetups(string methodName) + where T : Mockolate.Setup.MethodSetup { } + public TResult GetProperty(Mockolate.Interactions.PropertyGetterAccess access, System.Func defaultValueGenerator, System.Func? baseValueAccessor) { } + public TResult GetProperty(string propertyName, System.Func defaultValueGenerator, System.Func? baseValueAccessor) { } + public TResult GetPropertyFast(int memberId, Mockolate.Interactions.PropertyGetterAccess access, System.Func defaultValueGenerator, System.Func? baseValueAccessor = null) { } + public System.Collections.Generic.IReadOnlyCollection GetUnusedSetups(Mockolate.Interactions.IMockInteractions interactions) { } + public Mockolate.Verify.VerificationResult IndexerGot(T subject, int memberId, System.Func gotPredicate, System.Func parametersDescription) { } + public Mockolate.Verify.VerificationResult IndexerGotTyped(T subject, int memberId, Mockolate.Parameters.IParameterMatch match1, System.Func parametersDescription) { } + public Mockolate.Verify.VerificationResult IndexerGotTyped(T subject, int memberId, Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, System.Func parametersDescription) { } + public Mockolate.Verify.VerificationResult IndexerGotTyped(T subject, int memberId, Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, Mockolate.Parameters.IParameterMatch match3, System.Func parametersDescription) { } + public Mockolate.Verify.VerificationResult IndexerGotTyped(T subject, int memberId, Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, Mockolate.Parameters.IParameterMatch match3, Mockolate.Parameters.IParameterMatch match4, System.Func parametersDescription) { } + public Mockolate.Verify.VerificationResult IndexerSet(T subject, int memberId, System.Func, bool> setPredicate, Mockolate.Parameters.IParameterMatch value, System.Func parametersDescription) { } + public Mockolate.Verify.VerificationResult IndexerSetTyped(T subject, int memberId, Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch value, System.Func parametersDescription) { } + public Mockolate.Verify.VerificationResult IndexerSetTyped(T subject, int memberId, Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, Mockolate.Parameters.IParameterMatch value, System.Func parametersDescription) { } + public Mockolate.Verify.VerificationResult IndexerSetTyped(T subject, int memberId, Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, Mockolate.Parameters.IParameterMatch match3, Mockolate.Parameters.IParameterMatch value, System.Func parametersDescription) { } + public Mockolate.Verify.VerificationResult IndexerSetTyped(T subject, int memberId, Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, Mockolate.Parameters.IParameterMatch match3, Mockolate.Parameters.IParameterMatch match4, Mockolate.Parameters.IParameterMatch value, System.Func parametersDescription) { } + public Mockolate.Verify.VerificationResult Method(T subject, Mockolate.Setup.IMethodSetup methodSetup) { } + public void RegisterInteraction(Mockolate.Interactions.IInteraction interaction) { } + public void RemoveEvent(string name, object? target, System.Reflection.MethodInfo? method) { } + public void RemoveEvent(int memberId, string name, object? target, System.Reflection.MethodInfo? method) { } + public bool SetProperty(string propertyName, T value) { } + public bool SetProperty(int memberId, string propertyName, T value) { } + public bool SetPropertyFast(int memberId, int setterMemberId, string propertyName, T value) { } + public void SetupEvent(Mockolate.Setup.EventSetup eventSetup) { } + public void SetupEvent(int memberId, Mockolate.Setup.EventSetup eventSetup) { } + public void SetupEvent(string scenario, Mockolate.Setup.EventSetup eventSetup) { } + public void SetupEvent(int memberId, string scenario, Mockolate.Setup.EventSetup eventSetup) { } + public void SetupIndexer(Mockolate.Setup.IndexerSetup indexerSetup) { } + public void SetupIndexer(int memberId, Mockolate.Setup.IndexerSetup indexerSetup) { } + public void SetupIndexer(string scenario, Mockolate.Setup.IndexerSetup indexerSetup) { } + public void SetupIndexer(int memberId, string scenario, Mockolate.Setup.IndexerSetup indexerSetup) { } + public void SetupMethod(Mockolate.Setup.MethodSetup methodSetup) { } + public void SetupMethod(int memberId, Mockolate.Setup.MethodSetup methodSetup) { } + public void SetupMethod(string scenario, Mockolate.Setup.MethodSetup methodSetup) { } + public void SetupMethod(int memberId, string scenario, Mockolate.Setup.MethodSetup methodSetup) { } + public void SetupProperty(Mockolate.Setup.PropertySetup propertySetup) { } + public void SetupProperty(int memberId, Mockolate.Setup.PropertySetup propertySetup) { } + public void SetupProperty(string scenario, Mockolate.Setup.PropertySetup propertySetup) { } + public void SetupProperty(int memberId, string scenario, Mockolate.Setup.PropertySetup propertySetup) { } + public Mockolate.Verify.VerificationResult SubscribedTo(T subject, int memberId, string eventName) { } + public Mockolate.Verify.VerificationResult SubscribedToTyped(T subject, int memberId, string eventName) { } + public void TransitionTo(string scenario) { } + public Mockolate.Verify.VerificationResult UnsubscribedFrom(T subject, int memberId, string eventName) { } + public Mockolate.Verify.VerificationResult UnsubscribedFromTyped(T subject, int memberId, string eventName) { } + public Mockolate.Verify.VerificationResult.IgnoreParameters VerifyMethod(T subject, int memberId, string methodName, System.Func expectation) { } + public Mockolate.Verify.VerificationResult.IgnoreParameters VerifyMethod(T subject, string methodName, System.Func predicate, System.Func expectation) + where TMethod : Mockolate.Interactions.IMethodInteraction { } + public Mockolate.Verify.VerificationResult.IgnoreParameters VerifyMethod(T subject, int memberId, string methodName, Mockolate.Parameters.IParameterMatch match1, System.Func expectation) { } + public Mockolate.Verify.VerificationResult.IgnoreParameters VerifyMethod(T subject, int memberId, string methodName, System.Func predicate, System.Func expectation) + where TMethod : Mockolate.Interactions.IMethodInteraction { } + public Mockolate.Verify.VerificationResult.IgnoreParameters VerifyMethod(T subject, int memberId, string methodName, T1 literalValue1, System.Func expectation) { } + public Mockolate.Verify.VerificationResult.IgnoreParameters VerifyMethod(T subject, int memberId, string methodName, Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, System.Func expectation) { } + public Mockolate.Verify.VerificationResult.IgnoreParameters VerifyMethod(T subject, int memberId, string methodName, T1 literalValue1, T2 literalValue2, System.Func expectation) { } + public Mockolate.Verify.VerificationResult.IgnoreParameters VerifyMethod(T subject, int memberId, string methodName, Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, Mockolate.Parameters.IParameterMatch match3, System.Func expectation) { } + public Mockolate.Verify.VerificationResult.IgnoreParameters VerifyMethod(T subject, int memberId, string methodName, T1 literalValue1, T2 literalValue2, T3 literalValue3, System.Func expectation) { } + public Mockolate.Verify.VerificationResult.IgnoreParameters VerifyMethod(T subject, int memberId, string methodName, Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, Mockolate.Parameters.IParameterMatch match3, Mockolate.Parameters.IParameterMatch match4, System.Func expectation) { } + public Mockolate.Verify.VerificationResult.IgnoreParameters VerifyMethod(T subject, int memberId, string methodName, T1 literalValue1, T2 literalValue2, T3 literalValue3, T4 literalValue4, System.Func expectation) { } + public Mockolate.Verify.VerificationResult VerifyProperty(T subject, int memberId, string propertyName) { } + public Mockolate.Verify.VerificationResult VerifyProperty(TSubject subject, int memberId, string propertyName, Mockolate.Parameters.IParameterMatch value) { } + public Mockolate.Verify.VerificationResult VerifyPropertyTyped(T subject, int memberId, string propertyName) { } + public Mockolate.Verify.VerificationResult VerifyPropertyTyped(TSubject subject, int memberId, string propertyName, Mockolate.Parameters.IParameterMatch value) { } + } + public static class ParameterExtensions + { + public static Mockolate.Parameters.IOutParameter Monitor(this Mockolate.Parameters.IOutParameter parameter, out Mockolate.Parameters.IParameterMonitor monitor) { } + public static Mockolate.Parameters.IParameterWithCallback Monitor(this Mockolate.Parameters.IParameterWithCallback parameter, out Mockolate.Parameters.IParameterMonitor monitor) { } + public static Mockolate.Parameters.IRefParameter Monitor(this Mockolate.Parameters.IRefParameter parameter, out Mockolate.Parameters.IParameterMonitor monitor) { } + } + public delegate T RefStructFactory(); + public delegate bool RefStructPredicate(T value); + public delegate TProjected RefStructProjection(T value); + public delegate T RefStructTransform(T value); + public static class ReturnsThrowsAsyncExtensions + { + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetup> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetup> setup, TReturn returnValue) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetup> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetup> setup, TReturn returnValue) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetupWithCallback, T1> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetupWithCallback, T1> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetup, T1> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetup, T1> setup, TReturn returnValue) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetup, T1> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetup, T1> setup, TReturn returnValue) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2> setup, TReturn returnValue) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2> setup, TReturn returnValue) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2, T3> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2, T3> setup, TReturn returnValue) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2, T3> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2, T3> setup, TReturn returnValue) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4> setup, TReturn returnValue) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4> ReturnsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4> setup, TReturn returnValue) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetup> setup, System.Exception exception) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetup> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetup> setup, System.Exception exception) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetup> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetupWithCallback, T1> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetupWithCallback, T1> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetup, T1> setup, System.Exception exception) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetup, T1> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetup, T1> setup, System.Exception exception) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetup, T1> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2> setup, System.Exception exception) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2> setup, System.Exception exception) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2, T3> setup, System.Exception exception) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2, T3> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2, T3> setup, System.Exception exception) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2, T3> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4> setup, System.Exception exception) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4> setup, System.Func callback) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4> setup, System.Exception exception) { } + public static Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4> ThrowsAsync(this Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4> setup, System.Func callback) { } + } + public static class SetupExtensions + { + extension(Mockolate.Setup.IPropertySetupReturnWhenBuilder? setup) + { + public void Forever() { } + public Mockolate.Setup.IPropertySetup OnlyOnce() { } + } + extension(Mockolate.Setup.IPropertyGetterSetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IPropertySetup OnlyOnce() { } + } + extension(Mockolate.Setup.IPropertySetterSetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IPropertySetup OnlyOnce() { } + } + extension(Mockolate.Setup.IPropertyGetterOnlySetupReturnWhenBuilder? setup) + { + public void Forever() { } + public Mockolate.Setup.IPropertyGetterOnlySetup OnlyOnce() { } + } + extension(Mockolate.Setup.IPropertyGetterOnlySetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IPropertyGetterOnlySetup OnlyOnce() { } + } + extension(Mockolate.Setup.IPropertySetterOnlySetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IPropertySetterOnlySetup OnlyOnce() { } + } + extension(Mockolate.Setup.IEventSubscriptionSetupCallbackWhenBuilder? setup) + { + public void Forever() { } + public Mockolate.Setup.IEventSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IEventUnsubscriptionSetupCallbackWhenBuilder? setup) + { + public void Forever() { } + public Mockolate.Setup.IEventSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerSetupReturnWhenBuilder? setup) + { + public void Forever() { } + public Mockolate.Setup.IIndexerSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IIndexerSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IIndexerSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerSetupReturnWhenBuilder? setup) + { + public void Forever() { } + public Mockolate.Setup.IIndexerSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IIndexerSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IIndexerSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerSetupReturnWhenBuilder? setup) + { + public void Forever() { } + public Mockolate.Setup.IIndexerSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IIndexerSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IIndexerSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerSetupReturnWhenBuilder? setup) + { + public void Forever() { } + public Mockolate.Setup.IIndexerSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IIndexerSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IIndexerSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerGetterOnlySetupReturnWhenBuilder? setup) + { + public void Forever() { } + public Mockolate.Setup.IIndexerGetterOnlySetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IIndexerGetterOnlySetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IIndexerSetterOnlySetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerGetterOnlySetupReturnWhenBuilder? setup) + { + public void Forever() { } + public Mockolate.Setup.IIndexerGetterOnlySetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IIndexerGetterOnlySetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IIndexerSetterOnlySetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerGetterOnlySetupReturnWhenBuilder? setup) + { + public void Forever() { } + public Mockolate.Setup.IIndexerGetterOnlySetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IIndexerGetterOnlySetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IIndexerSetterOnlySetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerGetterOnlySetupReturnWhenBuilder? setup) + { + public void Forever() { } + public Mockolate.Setup.IIndexerGetterOnlySetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IIndexerGetterOnlySetup OnlyOnce() { } + } + extension(Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IIndexerSetterOnlySetup OnlyOnce() { } + } + extension(Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder? setup) + { + public void Forever() { } + public Mockolate.Setup.IReturnMethodSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IReturnMethodSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder? setup) + { + public void Forever() { } + public Mockolate.Setup.IReturnMethodSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IReturnMethodSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder? setup) + { + public void Forever() { } + public Mockolate.Setup.IReturnMethodSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IReturnMethodSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder? setup) + { + public void Forever() { } + public Mockolate.Setup.IReturnMethodSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IReturnMethodSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder? setup) + { + public void Forever() { } + public Mockolate.Setup.IReturnMethodSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IReturnMethodSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder? setup) + { + public void Forever() { } + public Mockolate.Setup.IVoidMethodSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IVoidMethodSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder? setup) + { + public void Forever() { } + public Mockolate.Setup.IVoidMethodSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IVoidMethodSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder? setup) + { + public void Forever() { } + public Mockolate.Setup.IVoidMethodSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IVoidMethodSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder? setup) + { + public void Forever() { } + public Mockolate.Setup.IVoidMethodSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IVoidMethodSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder? setup) + { + public void Forever() { } + public Mockolate.Setup.IVoidMethodSetup OnlyOnce() { } + } + extension(Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder? setup) + { + public Mockolate.Setup.IVoidMethodSetup OnlyOnce() { } + } + } +} +namespace Mockolate.Exceptions +{ + public class MockException : System.Exception + { + public MockException(string message) { } + public MockException(string message, System.Exception innerException) { } + } + public class MockNotSetupException : Mockolate.Exceptions.MockException + { + public MockNotSetupException(string message) { } + public MockNotSetupException(string message, System.Exception innerException) { } + } + public class MockVerificationException : Mockolate.Exceptions.MockException + { + public MockVerificationException(string message) { } + public MockVerificationException(string message, System.Exception innerException) { } + } + public class MockVerificationTimeoutException : Mockolate.Exceptions.MockVerificationException + { + public MockVerificationTimeoutException(System.TimeSpan? timeout, System.Exception innerException) { } + public System.TimeSpan? Timeout { get; } + } +} +namespace Mockolate.Interactions +{ + [System.Diagnostics.DebuggerDisplay("{ToString()}")] + public class EventSubscription : Mockolate.Interactions.IInteraction + { + public EventSubscription(string name, object? target, System.Reflection.MethodInfo method) { } + public System.Reflection.MethodInfo Method { get; } + public string Name { get; } + public object? Target { get; } + public override string ToString() { } + } + [System.Diagnostics.DebuggerDisplay("{ToString()}")] + public class EventUnsubscription : Mockolate.Interactions.IInteraction + { + public EventUnsubscription(string name, object? target, System.Reflection.MethodInfo method) { } + public System.Reflection.MethodInfo Method { get; } + public string Name { get; } + public object? Target { get; } + public override string ToString() { } + } + [System.Diagnostics.DebuggerDisplay("{Count} event {_kind}s")] + public sealed class FastEventBuffer : Mockolate.Interactions.IFastMemberBuffer + { + public FastEventBuffer(Mockolate.Interactions.FastMockInteractions owner, Mockolate.Interactions.FastEventBufferKind kind) { } + public int Count { get; } + public void Append(string name, object? target, System.Reflection.MethodInfo method) { } + public void Clear() { } + public int ConsumeMatching() { } + } + public enum FastEventBufferKind + { + Subscribe = 0, + Unsubscribe = 1, + } + [System.Diagnostics.DebuggerDisplay("{Count} indexer gets")] + public sealed class FastIndexerGetterBuffer : Mockolate.Interactions.IFastMemberBuffer + { + public FastIndexerGetterBuffer(Mockolate.Interactions.FastMockInteractions owner) { } + public int Count { get; } + public void Append(Mockolate.Interactions.IndexerGetterAccess access) { } + public void Append(T1 parameter1) { } + public void Clear() { } + public int ConsumeMatching(Mockolate.Parameters.IParameterMatch match1) { } + } + [System.Diagnostics.DebuggerDisplay("{Count} indexer gets")] + public sealed class FastIndexerGetterBuffer : Mockolate.Interactions.IFastMemberBuffer + { + public FastIndexerGetterBuffer(Mockolate.Interactions.FastMockInteractions owner) { } + public int Count { get; } + public void Append(Mockolate.Interactions.IndexerGetterAccess access) { } + public void Append(T1 parameter1, T2 parameter2) { } + public void Clear() { } + public int ConsumeMatching(Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2) { } + } + [System.Diagnostics.DebuggerDisplay("{Count} indexer gets")] + public sealed class FastIndexerGetterBuffer : Mockolate.Interactions.IFastMemberBuffer + { + public FastIndexerGetterBuffer(Mockolate.Interactions.FastMockInteractions owner) { } + public int Count { get; } + public void Append(Mockolate.Interactions.IndexerGetterAccess access) { } + public void Append(T1 parameter1, T2 parameter2, T3 parameter3) { } + public void Clear() { } + public int ConsumeMatching(Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, Mockolate.Parameters.IParameterMatch match3) { } + } + [System.Diagnostics.DebuggerDisplay("{Count} indexer gets")] + public sealed class FastIndexerGetterBuffer : Mockolate.Interactions.IFastMemberBuffer + { + public FastIndexerGetterBuffer(Mockolate.Interactions.FastMockInteractions owner) { } + public int Count { get; } + public void Append(Mockolate.Interactions.IndexerGetterAccess access) { } + public void Append(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4) { } + public void Clear() { } + public int ConsumeMatching(Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, Mockolate.Parameters.IParameterMatch match3, Mockolate.Parameters.IParameterMatch match4) { } + } + [System.Diagnostics.DebuggerDisplay("{Count} indexer sets")] + public sealed class FastIndexerSetterBuffer : Mockolate.Interactions.IFastMemberBuffer + { + public FastIndexerSetterBuffer(Mockolate.Interactions.FastMockInteractions owner) { } + public int Count { get; } + public void Append(Mockolate.Interactions.IndexerSetterAccess access) { } + public void Append(T1 parameter1, TValue value) { } + public void Clear() { } + public int ConsumeMatching(Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch matchValue) { } + } + [System.Diagnostics.DebuggerDisplay("{Count} indexer sets")] + public sealed class FastIndexerSetterBuffer : Mockolate.Interactions.IFastMemberBuffer + { + public FastIndexerSetterBuffer(Mockolate.Interactions.FastMockInteractions owner) { } + public int Count { get; } + public void Append(Mockolate.Interactions.IndexerSetterAccess access) { } + public void Append(T1 parameter1, T2 parameter2, TValue value) { } + public void Clear() { } + public int ConsumeMatching(Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, Mockolate.Parameters.IParameterMatch matchValue) { } + } + [System.Diagnostics.DebuggerDisplay("{Count} indexer sets")] + public sealed class FastIndexerSetterBuffer : Mockolate.Interactions.IFastMemberBuffer + { + public FastIndexerSetterBuffer(Mockolate.Interactions.FastMockInteractions owner) { } + public int Count { get; } + public void Append(Mockolate.Interactions.IndexerSetterAccess access) { } + public void Append(T1 parameter1, T2 parameter2, T3 parameter3, TValue value) { } + public void Clear() { } + public int ConsumeMatching(Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, Mockolate.Parameters.IParameterMatch match3, Mockolate.Parameters.IParameterMatch matchValue) { } + } + [System.Diagnostics.DebuggerDisplay("{Count} indexer sets")] + public sealed class FastIndexerSetterBuffer : Mockolate.Interactions.IFastMemberBuffer + { + public FastIndexerSetterBuffer(Mockolate.Interactions.FastMockInteractions owner) { } + public int Count { get; } + public void Append(Mockolate.Interactions.IndexerSetterAccess access) { } + public void Append(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, TValue value) { } + public void Clear() { } + public int ConsumeMatching(Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, Mockolate.Parameters.IParameterMatch match3, Mockolate.Parameters.IParameterMatch match4, Mockolate.Parameters.IParameterMatch matchValue) { } + } + [System.Diagnostics.DebuggerDisplay("{Count} method calls")] + public sealed class FastMethod0Buffer : Mockolate.Interactions.IFastMemberBuffer + { + public FastMethod0Buffer(Mockolate.Interactions.FastMockInteractions owner) { } + public int Count { get; } + public void Append(string name) { } + public void Clear() { } + public int ConsumeMatching() { } + } + [System.Diagnostics.DebuggerDisplay("{Count} method calls")] + public sealed class FastMethod1Buffer : Mockolate.Interactions.IFastMemberBuffer + { + public FastMethod1Buffer(Mockolate.Interactions.FastMockInteractions owner) { } + public int Count { get; } + public void Append(string name, T1 parameter1) { } + public void Clear() { } + public int ConsumeMatching(Mockolate.Parameters.IParameterMatch match1) { } + public int ConsumeMatchingLiteral(T1 value1) { } + } + [System.Diagnostics.DebuggerDisplay("{Count} method calls")] + public sealed class FastMethod2Buffer : Mockolate.Interactions.IFastMemberBuffer + { + public FastMethod2Buffer(Mockolate.Interactions.FastMockInteractions owner) { } + public int Count { get; } + public void Append(string name, T1 parameter1, T2 parameter2) { } + public void Clear() { } + public int ConsumeMatching(Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2) { } + public int ConsumeMatchingLiteral(T1 value1, T2 value2) { } + } + [System.Diagnostics.DebuggerDisplay("{Count} method calls")] + public sealed class FastMethod3Buffer : Mockolate.Interactions.IFastMemberBuffer + { + public FastMethod3Buffer(Mockolate.Interactions.FastMockInteractions owner) { } + public int Count { get; } + public void Append(string name, T1 parameter1, T2 parameter2, T3 parameter3) { } + public void Clear() { } + public int ConsumeMatching(Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, Mockolate.Parameters.IParameterMatch match3) { } + public int ConsumeMatchingLiteral(T1 value1, T2 value2, T3 value3) { } + } + [System.Diagnostics.DebuggerDisplay("{Count} method calls")] + public sealed class FastMethod4Buffer : Mockolate.Interactions.IFastMemberBuffer + { + public FastMethod4Buffer(Mockolate.Interactions.FastMockInteractions owner) { } + public int Count { get; } + public void Append(string name, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4) { } + public void Clear() { } + public int ConsumeMatching(Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, Mockolate.Parameters.IParameterMatch match3, Mockolate.Parameters.IParameterMatch match4) { } + public int ConsumeMatchingLiteral(T1 value1, T2 value2, T3 value3, T4 value4) { } + } + [System.Diagnostics.DebuggerDisplay("{Count} interactions")] + public class FastMockInteractions : Mockolate.Interactions.IMockInteractions, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.IEnumerable + { + public FastMockInteractions(int memberCount, bool skipInteractionRecording = false) { } + public Mockolate.Interactions.IFastMemberBuffer?[] Buffers { get; } + public int Count { get; } + public bool HasInteractionAddedSubscribers { get; } + public bool SkipInteractionRecording { get; } + public event System.EventHandler? InteractionAdded; + public event System.EventHandler? OnClearing; + public void Clear() { } + public System.Collections.Generic.IEnumerator GetEnumerator() { } + public TBuffer GetOrCreateBuffer(int memberId, System.Func factory) + where TBuffer : class, Mockolate.Interactions.IFastMemberBuffer { } + public TBuffer GetOrCreateBuffer(int memberId, System.Func factory, TState state) + where TBuffer : class, Mockolate.Interactions.IFastMemberBuffer { } + public System.Collections.Generic.IReadOnlyCollection GetUnverifiedInteractions() { } + public long NextSequence() { } + public void RaiseAdded() { } + } + [System.Diagnostics.DebuggerDisplay("{Count} property gets")] + public sealed class FastPropertyGetterBuffer : Mockolate.Interactions.IFastMemberBuffer + { + public FastPropertyGetterBuffer(Mockolate.Interactions.FastMockInteractions owner, Mockolate.Interactions.PropertyGetterAccess access) { } + public int Count { get; } + public void Append() { } + public void Clear() { } + public int ConsumeMatching() { } + } + [System.Diagnostics.DebuggerDisplay("{Count} property sets")] + public sealed class FastPropertySetterBuffer : Mockolate.Interactions.IFastMemberBuffer + { + public FastPropertySetterBuffer(Mockolate.Interactions.FastMockInteractions owner) { } + public int Count { get; } + public void Append(string name, T value) { } + public void Clear() { } + public int ConsumeMatching(Mockolate.Parameters.IParameterMatch match) { } + } + public interface IFastMemberBuffer + { + int Count { get; } + void AppendBoxed([System.Runtime.CompilerServices.TupleElementNames(new string[] { + "Seq", + "Interaction"})] System.Collections.Generic.List> dest); + void AppendBoxedUnverified([System.Runtime.CompilerServices.TupleElementNames(new string[] { + "Seq", + "Interaction"})] System.Collections.Generic.List> dest); + void Clear(); + } + public interface IInteraction { } + public interface IMethodInteraction : Mockolate.Interactions.IInteraction + { + string Name { get; } + } + public interface IMockInteractions : System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.IEnumerable + { + bool SkipInteractionRecording { get; } + event System.EventHandler? InteractionAdded; + event System.EventHandler? OnClearing; + void Clear(); + System.Collections.Generic.IReadOnlyCollection GetUnverifiedInteractions(); + TInteraction RegisterInteraction(TInteraction interaction) + where TInteraction : Mockolate.Interactions.IInteraction; + } + public abstract class IndexerAccess : Mockolate.Interactions.IInteraction + { + protected IndexerAccess() { } + public abstract int ParameterCount { get; } + public abstract object? GetParameterValueAt(int index); + public void StoreValue(T value) { } + protected abstract Mockolate.Setup.IndexerValueStorage? TraverseStorage(Mockolate.Setup.IndexerValueStorage? storage, bool createMissing); + public bool TryFindStoredValue(out T value) { } + } + [System.Diagnostics.DebuggerDisplay("{ToString()}")] + public class IndexerGetterAccess : Mockolate.Interactions.IndexerAccess + { + public IndexerGetterAccess(T1 parameter1) { } + public T1 Parameter1 { get; } + public override int ParameterCount { get; } + public override object? GetParameterValueAt(int index) { } + public override string ToString() { } + protected override Mockolate.Setup.IndexerValueStorage? TraverseStorage(Mockolate.Setup.IndexerValueStorage? storage, bool createMissing) { } + } + [System.Diagnostics.DebuggerDisplay("{ToString()}")] + public class IndexerGetterAccess : Mockolate.Interactions.IndexerAccess + { + public IndexerGetterAccess(T1 parameter1, T2 parameter2) { } + public T1 Parameter1 { get; } + public T2 Parameter2 { get; } + public override int ParameterCount { get; } + public override object? GetParameterValueAt(int index) { } + public override string ToString() { } + protected override Mockolate.Setup.IndexerValueStorage? TraverseStorage(Mockolate.Setup.IndexerValueStorage? storage, bool createMissing) { } + } + [System.Diagnostics.DebuggerDisplay("{ToString()}")] + public class IndexerGetterAccess : Mockolate.Interactions.IndexerAccess + { + public IndexerGetterAccess(T1 parameter1, T2 parameter2, T3 parameter3) { } + public T1 Parameter1 { get; } + public T2 Parameter2 { get; } + public T3 Parameter3 { get; } + public override int ParameterCount { get; } + public override object? GetParameterValueAt(int index) { } + public override string ToString() { } + protected override Mockolate.Setup.IndexerValueStorage? TraverseStorage(Mockolate.Setup.IndexerValueStorage? storage, bool createMissing) { } + } + [System.Diagnostics.DebuggerDisplay("{ToString()}")] + public class IndexerGetterAccess : Mockolate.Interactions.IndexerAccess + { + public IndexerGetterAccess(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4) { } + public T1 Parameter1 { get; } + public T2 Parameter2 { get; } + public T3 Parameter3 { get; } + public T4 Parameter4 { get; } + public override int ParameterCount { get; } + public override object? GetParameterValueAt(int index) { } + public override string ToString() { } + protected override Mockolate.Setup.IndexerValueStorage? TraverseStorage(Mockolate.Setup.IndexerValueStorage? storage, bool createMissing) { } + } + [System.Diagnostics.DebuggerDisplay("{ToString()}")] + public class IndexerSetterAccess : Mockolate.Interactions.IndexerAccess + { + public IndexerSetterAccess(T1 parameter1, TValue value) { } + public T1 Parameter1 { get; } + public override int ParameterCount { get; } + public TValue TypedValue { get; } + public override object? GetParameterValueAt(int index) { } + public override string ToString() { } + protected override Mockolate.Setup.IndexerValueStorage? TraverseStorage(Mockolate.Setup.IndexerValueStorage? storage, bool createMissing) { } + } + [System.Diagnostics.DebuggerDisplay("{ToString()}")] + public class IndexerSetterAccess : Mockolate.Interactions.IndexerAccess + { + public IndexerSetterAccess(T1 parameter1, T2 parameter2, TValue value) { } + public T1 Parameter1 { get; } + public T2 Parameter2 { get; } + public override int ParameterCount { get; } + public TValue TypedValue { get; } + public override object? GetParameterValueAt(int index) { } + public override string ToString() { } + protected override Mockolate.Setup.IndexerValueStorage? TraverseStorage(Mockolate.Setup.IndexerValueStorage? storage, bool createMissing) { } + } + [System.Diagnostics.DebuggerDisplay("{ToString()}")] + public class IndexerSetterAccess : Mockolate.Interactions.IndexerAccess + { + public IndexerSetterAccess(T1 parameter1, T2 parameter2, T3 parameter3, TValue value) { } + public T1 Parameter1 { get; } + public T2 Parameter2 { get; } + public T3 Parameter3 { get; } + public override int ParameterCount { get; } + public TValue TypedValue { get; } + public override object? GetParameterValueAt(int index) { } + public override string ToString() { } + protected override Mockolate.Setup.IndexerValueStorage? TraverseStorage(Mockolate.Setup.IndexerValueStorage? storage, bool createMissing) { } + } + [System.Diagnostics.DebuggerDisplay("{ToString()}")] + public class IndexerSetterAccess : Mockolate.Interactions.IndexerAccess + { + public IndexerSetterAccess(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, TValue value) { } + public T1 Parameter1 { get; } + public T2 Parameter2 { get; } + public T3 Parameter3 { get; } + public T4 Parameter4 { get; } + public override int ParameterCount { get; } + public TValue TypedValue { get; } + public override object? GetParameterValueAt(int index) { } + public override string ToString() { } + protected override Mockolate.Setup.IndexerValueStorage? TraverseStorage(Mockolate.Setup.IndexerValueStorage? storage, bool createMissing) { } + } + [System.Diagnostics.DebuggerDisplay("{ToString()}")] + public class MethodInvocation : Mockolate.Interactions.IInteraction, Mockolate.Interactions.IMethodInteraction + { + public MethodInvocation(string name) { } + public string Name { get; } + public override string ToString() { } + } + [System.Diagnostics.DebuggerDisplay("{ToString()}")] + public class MethodInvocation : Mockolate.Interactions.IInteraction, Mockolate.Interactions.IMethodInteraction + { + public MethodInvocation(string name, T1 parameter1) { } + public string Name { get; } + public T1 Parameter1 { get; } + public override string ToString() { } + } + [System.Diagnostics.DebuggerDisplay("{ToString()}")] + public class MethodInvocation : Mockolate.Interactions.IInteraction, Mockolate.Interactions.IMethodInteraction + { + public MethodInvocation(string name, T1 parameter1, T2 parameter2) { } + public string Name { get; } + public T1 Parameter1 { get; } + public T2 Parameter2 { get; } + public override string ToString() { } + } + [System.Diagnostics.DebuggerDisplay("{ToString()}")] + public class MethodInvocation : Mockolate.Interactions.IInteraction, Mockolate.Interactions.IMethodInteraction + { + public MethodInvocation(string name, T1 parameter1, T2 parameter2, T3 parameter3) { } + public string Name { get; } + public T1 Parameter1 { get; } + public T2 Parameter2 { get; } + public T3 Parameter3 { get; } + public override string ToString() { } + } + [System.Diagnostics.DebuggerDisplay("{ToString()}")] + public class MethodInvocation : Mockolate.Interactions.IInteraction, Mockolate.Interactions.IMethodInteraction + { + public MethodInvocation(string name, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4) { } + public string Name { get; } + public T1 Parameter1 { get; } + public T2 Parameter2 { get; } + public T3 Parameter3 { get; } + public T4 Parameter4 { get; } + public override string ToString() { } + } + [System.Diagnostics.DebuggerDisplay("{ToString()}")] + public abstract class PropertyAccess : Mockolate.Interactions.IInteraction + { + protected PropertyAccess(string propertyName) { } + public string Name { get; } + } + [System.Diagnostics.DebuggerDisplay("{ToString()}")] + public class PropertyGetterAccess : Mockolate.Interactions.PropertyAccess + { + public PropertyGetterAccess(string propertyName) { } + public override string ToString() { } + } + [System.Diagnostics.DebuggerDisplay("{ToString()}")] + public class PropertySetterAccess : Mockolate.Interactions.PropertyAccess + { + public PropertySetterAccess(string propertyName, T value) { } + public T Value { get; } + public override string ToString() { } + } + [System.Diagnostics.DebuggerDisplay("{ToString()}")] + public sealed class RefStructMethodInvocation : Mockolate.Interactions.IInteraction, Mockolate.Interactions.IMethodInteraction + { + public RefStructMethodInvocation(string name, params string[] parameterNames) { } + public string Name { get; } + public System.Collections.Generic.IReadOnlyList ParameterNames { get; } + public override string ToString() { } + } +} +namespace Mockolate.Monitor +{ + public abstract class MockMonitor + { + protected MockMonitor(Mockolate.Interactions.IMockInteractions mockInteractions) { } + protected Mockolate.Interactions.IMockInteractions Interactions { get; } + public System.IDisposable Run() { } + protected void UpdateInteractions() { } + } + public sealed class MockMonitor : Mockolate.Monitor.MockMonitor + { + public MockMonitor(Mockolate.Interactions.IMockInteractions interactions, System.Func verify) { } + public T Verify { get; } + } +} +namespace Mockolate.Parameters +{ + public interface IDefaultEventParameters { } + public interface INamedParametersMatch + { + bool Matches(System.ReadOnlySpan> values); + } + public interface IOutParameter + { + Mockolate.Parameters.IOutParameter Do(System.Action callback); + bool TryGetValue(out T value); + } + public interface IOutRefStructParameter + { + bool TryGetValue(out T value); + } + public interface IParameter + { + void InvokeCallbacks(object? value); + bool Matches(object? value); + } + public interface IParameterMatch + { + void InvokeCallbacks(T value); + bool Matches(T value); + } + public interface IParameterMonitor + { + System.Collections.Generic.IReadOnlyList Values { get; } + } + public interface IParameterWithCallback : Mockolate.Parameters.IParameter, Mockolate.Parameters.IParameter + { + Mockolate.Parameters.IParameterWithCallback Do(System.Action callback); + } + public interface IParameter : Mockolate.Parameters.IParameter { } + public interface IParameters { } + public interface IParametersMatch + { + bool Matches(System.ReadOnlySpan values); + } + public interface IReadOnlySpanParameter : Mockolate.Parameters.IParameter, Mockolate.Parameters.IParameterWithCallback>, Mockolate.Parameters.IParameter> { } + public interface IRefParameter + { + Mockolate.Parameters.IRefParameter Do(System.Action callback); + T GetValue(T value); + } + public interface IRefRefStructParameter + { + T GetValue(T value); + } + public interface IRefStructProjectionMatch : Mockolate.Parameters.IParameterMatch + { + object Project(T value); + } + public interface IRefStructProjectionMatch : Mockolate.Parameters.IParameterMatch, Mockolate.Parameters.IRefStructProjectionMatch + where TProjected : notnull + { + TProjected Project(T value); + } + public interface ISpanParameter : Mockolate.Parameters.IParameter, Mockolate.Parameters.IParameterWithCallback>, Mockolate.Parameters.IParameter> { } + public interface IVerifyOutParameter { } + public interface IVerifyReadOnlySpanParameter : Mockolate.Parameters.IParameter, Mockolate.Parameters.IParameterWithCallback>, Mockolate.Parameters.IParameter>, Mockolate.Parameters.IReadOnlySpanParameter { } + public interface IVerifyRefParameter { } + public interface IVerifySpanParameter : Mockolate.Parameters.IParameter, Mockolate.Parameters.IParameterWithCallback>, Mockolate.Parameters.IParameter>, Mockolate.Parameters.ISpanParameter { } + public sealed class ParamsArrayParameterMatch : Mockolate.Parameters.IParameterMatch + { + public ParamsArrayParameterMatch(params Mockolate.Parameters.IParameter[] matchers) { } + public void InvokeCallbacks(TElement[] value) { } + public bool Matches(TElement[] value) { } + public override string ToString() { } + } +} +namespace Mockolate.Setup +{ + public class Callback + { + public Callback() { } + protected bool HasForSpecified { get; } + protected bool RunInParallel { get; } + protected bool CheckInvocations(int invocationCount) { } + protected bool CheckMatching(int matchingCount) { } + public void For(int times) { } + public void InParallel() { } + protected bool IsActive(int matchingCount) { } + public void Only(int times) { } + public void When(System.Func predicate) { } + } + public class Callback : Mockolate.Setup.Callback + where TDelegate : System.Delegate + { + public Callback(TDelegate @delegate) { } + public bool Invoke(ref int index, TState state, System.Action callback) { } + public bool Invoke(bool wasInvoked, ref int index, TState state, System.Action callback) { } + public bool Invoke(ref int index, TState state, System.Func callback, [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out TReturn? returnValue) { } + } + public static class CallbacksExtensions + { + public static Mockolate.Setup.Callbacks Register(this Mockolate.Setup.Callbacks? callbacks, Mockolate.Setup.Callback callback) + where T : System.Delegate { } + } + public class Callbacks : System.Collections.Generic.List> + where T : System.Delegate + { + public int CurrentIndex; + public Callbacks() { } + public Mockolate.Setup.Callback? Active { get; } + } + [System.Diagnostics.DebuggerDisplay("{ToString()}")] + public class EventSetup : Mockolate.Setup.IEventSetup, Mockolate.Setup.IEventSubscriptionSetup, Mockolate.Setup.IEventSubscriptionSetupCallbackBuilder, Mockolate.Setup.IEventSubscriptionSetupCallbackWhenBuilder, Mockolate.Setup.IEventSubscriptionSetupParallelCallbackBuilder, Mockolate.Setup.IEventUnsubscriptionSetup, Mockolate.Setup.IEventUnsubscriptionSetupCallbackBuilder, Mockolate.Setup.IEventUnsubscriptionSetupCallbackWhenBuilder, Mockolate.Setup.IEventUnsubscriptionSetupParallelCallbackBuilder + { + public EventSetup(Mockolate.MockRegistry mockRegistry, string name) { } + public string Name { get; } + public Mockolate.Setup.IEventSubscriptionSetup OnSubscribed { get; } + public Mockolate.Setup.IEventUnsubscriptionSetup OnUnsubscribed { get; } + public override string ToString() { } + } + public interface IEventSetup + { + Mockolate.Setup.IEventSubscriptionSetup OnSubscribed { get; } + Mockolate.Setup.IEventUnsubscriptionSetup OnUnsubscribed { get; } + } + public interface IEventSubscriptionSetup + { + Mockolate.Setup.IEventSubscriptionSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IEventSubscriptionSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IEventSubscriptionSetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IEventSubscriptionSetupCallbackBuilder : Mockolate.Setup.IEventSetup, Mockolate.Setup.IEventSubscriptionSetupCallbackWhenBuilder, Mockolate.Setup.IEventSubscriptionSetupParallelCallbackBuilder + { + Mockolate.Setup.IEventSubscriptionSetupParallelCallbackBuilder InParallel(); + } + public interface IEventSubscriptionSetupCallbackWhenBuilder : Mockolate.Setup.IEventSetup + { + Mockolate.Setup.IEventSubscriptionSetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IEventSetup Only(int times); + } + public interface IEventSubscriptionSetupParallelCallbackBuilder : Mockolate.Setup.IEventSetup, Mockolate.Setup.IEventSubscriptionSetupCallbackWhenBuilder + { + Mockolate.Setup.IEventSubscriptionSetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IEventUnsubscriptionSetup + { + Mockolate.Setup.IEventUnsubscriptionSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IEventUnsubscriptionSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IEventUnsubscriptionSetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IEventUnsubscriptionSetupCallbackBuilder : Mockolate.Setup.IEventSetup, Mockolate.Setup.IEventUnsubscriptionSetupCallbackWhenBuilder, Mockolate.Setup.IEventUnsubscriptionSetupParallelCallbackBuilder + { + Mockolate.Setup.IEventUnsubscriptionSetupParallelCallbackBuilder InParallel(); + } + public interface IEventUnsubscriptionSetupCallbackWhenBuilder : Mockolate.Setup.IEventSetup + { + Mockolate.Setup.IEventUnsubscriptionSetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IEventSetup Only(int times); + } + public interface IEventUnsubscriptionSetupParallelCallbackBuilder : Mockolate.Setup.IEventSetup, Mockolate.Setup.IEventUnsubscriptionSetupCallbackWhenBuilder + { + Mockolate.Setup.IEventUnsubscriptionSetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IIndexerGetterOnlyGetterSetup + { + Mockolate.Setup.IIndexerGetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterOnlySetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IIndexerGetterOnlyGetterSetup + { + Mockolate.Setup.IIndexerGetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterOnlySetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IIndexerGetterOnlyGetterSetup + { + Mockolate.Setup.IIndexerGetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterOnlySetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IIndexerGetterOnlyGetterSetup + { + Mockolate.Setup.IIndexerGetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterOnlySetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IIndexerGetterOnlySetupCallbackBuilder : Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerGetterOnlySetupParallelCallbackBuilder, Mockolate.Setup.IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlySetupParallelCallbackBuilder InParallel(); + } + public interface IIndexerGetterOnlySetupCallbackBuilder : Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerGetterOnlySetupParallelCallbackBuilder, Mockolate.Setup.IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlySetupParallelCallbackBuilder InParallel(); + } + public interface IIndexerGetterOnlySetupCallbackBuilder : Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerGetterOnlySetupParallelCallbackBuilder, Mockolate.Setup.IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlySetupParallelCallbackBuilder InParallel(); + } + public interface IIndexerGetterOnlySetupCallbackBuilder : Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerGetterOnlySetupParallelCallbackBuilder, Mockolate.Setup.IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlySetupParallelCallbackBuilder InParallel(); + } + public interface IIndexerGetterOnlySetupCallbackWhenBuilder : Mockolate.Setup.IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IIndexerGetterOnlySetup Only(int times); + } + public interface IIndexerGetterOnlySetupCallbackWhenBuilder : Mockolate.Setup.IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IIndexerGetterOnlySetup Only(int times); + } + public interface IIndexerGetterOnlySetupCallbackWhenBuilder : Mockolate.Setup.IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IIndexerGetterOnlySetup Only(int times); + } + public interface IIndexerGetterOnlySetupCallbackWhenBuilder : Mockolate.Setup.IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IIndexerGetterOnlySetup Only(int times); + } + public interface IIndexerGetterOnlySetupParallelCallbackBuilder : Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IIndexerGetterOnlySetupParallelCallbackBuilder : Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IIndexerGetterOnlySetupParallelCallbackBuilder : Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IIndexerGetterOnlySetupParallelCallbackBuilder : Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IIndexerGetterOnlySetupReturnBuilder : Mockolate.Setup.IIndexerGetterOnlySetupReturnWhenBuilder, Mockolate.Setup.IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlySetupReturnWhenBuilder When(System.Func predicate); + } + public interface IIndexerGetterOnlySetupReturnBuilder : Mockolate.Setup.IIndexerGetterOnlySetupReturnWhenBuilder, Mockolate.Setup.IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlySetupReturnWhenBuilder When(System.Func predicate); + } + public interface IIndexerGetterOnlySetupReturnBuilder : Mockolate.Setup.IIndexerGetterOnlySetupReturnWhenBuilder, Mockolate.Setup.IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlySetupReturnWhenBuilder When(System.Func predicate); + } + public interface IIndexerGetterOnlySetupReturnBuilder : Mockolate.Setup.IIndexerGetterOnlySetupReturnWhenBuilder, Mockolate.Setup.IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlySetupReturnWhenBuilder When(System.Func predicate); + } + public interface IIndexerGetterOnlySetupReturnWhenBuilder : Mockolate.Setup.IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlySetupReturnWhenBuilder For(int times); + Mockolate.Setup.IIndexerGetterOnlySetup Only(int times); + } + public interface IIndexerGetterOnlySetupReturnWhenBuilder : Mockolate.Setup.IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlySetupReturnWhenBuilder For(int times); + Mockolate.Setup.IIndexerGetterOnlySetup Only(int times); + } + public interface IIndexerGetterOnlySetupReturnWhenBuilder : Mockolate.Setup.IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlySetupReturnWhenBuilder For(int times); + Mockolate.Setup.IIndexerGetterOnlySetup Only(int times); + } + public interface IIndexerGetterOnlySetupReturnWhenBuilder : Mockolate.Setup.IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlySetupReturnWhenBuilder For(int times); + Mockolate.Setup.IIndexerGetterOnlySetup Only(int times); + } + public interface IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlyGetterSetup OnGet { get; } + Mockolate.Setup.IIndexerGetterOnlySetup InitializeWith(System.Func valueGenerator); + Mockolate.Setup.IIndexerGetterOnlySetup InitializeWith(TValue value); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Returns(TValue returnValue); + Mockolate.Setup.IIndexerGetterOnlySetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Throws(System.Exception exception); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Throws() + where TException : System.Exception, new (); + } + public interface IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlyGetterSetup OnGet { get; } + Mockolate.Setup.IIndexerGetterOnlySetup InitializeWith(System.Func valueGenerator); + Mockolate.Setup.IIndexerGetterOnlySetup InitializeWith(TValue value); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Returns(TValue returnValue); + Mockolate.Setup.IIndexerGetterOnlySetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Throws(System.Exception exception); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Throws() + where TException : System.Exception, new (); + } + public interface IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlyGetterSetup OnGet { get; } + Mockolate.Setup.IIndexerGetterOnlySetup InitializeWith(System.Func valueGenerator); + Mockolate.Setup.IIndexerGetterOnlySetup InitializeWith(TValue value); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Returns(TValue returnValue); + Mockolate.Setup.IIndexerGetterOnlySetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Throws(System.Exception exception); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Throws() + where TException : System.Exception, new (); + } + public interface IIndexerGetterOnlySetup + { + Mockolate.Setup.IIndexerGetterOnlyGetterSetup OnGet { get; } + Mockolate.Setup.IIndexerGetterOnlySetup InitializeWith(System.Func valueGenerator); + Mockolate.Setup.IIndexerGetterOnlySetup InitializeWith(TValue value); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Returns(TValue returnValue); + Mockolate.Setup.IIndexerGetterOnlySetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Throws(System.Exception exception); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder Throws() + where TException : System.Exception, new (); + } + public interface IIndexerGetterSetupCallbackBuilder : Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerGetterSetupParallelCallbackBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerGetterSetupParallelCallbackBuilder InParallel(); + } + public interface IIndexerGetterSetupCallbackBuilder : Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerGetterSetupParallelCallbackBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerGetterSetupParallelCallbackBuilder InParallel(); + } + public interface IIndexerGetterSetupCallbackBuilder : Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerGetterSetupParallelCallbackBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerGetterSetupParallelCallbackBuilder InParallel(); + } + public interface IIndexerGetterSetupCallbackBuilder : Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerGetterSetupParallelCallbackBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerGetterSetupParallelCallbackBuilder InParallel(); + } + public interface IIndexerGetterSetupCallbackWhenBuilder : Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IIndexerSetup Only(int times); + } + public interface IIndexerGetterSetupCallbackWhenBuilder : Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IIndexerSetup Only(int times); + } + public interface IIndexerGetterSetupCallbackWhenBuilder : Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IIndexerSetup Only(int times); + } + public interface IIndexerGetterSetupCallbackWhenBuilder : Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IIndexerSetup Only(int times); + } + public interface IIndexerGetterSetupParallelCallbackBuilder : Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IIndexerGetterSetupParallelCallbackBuilder : Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IIndexerGetterSetupParallelCallbackBuilder : Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IIndexerGetterSetupParallelCallbackBuilder : Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IIndexerGetterSetupWithCallback : Mockolate.Setup.IIndexerGetterSetup + { + Mockolate.Setup.IIndexerGetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterSetupCallbackBuilder Do(System.Action callback); + } + public interface IIndexerGetterSetupWithCallback : Mockolate.Setup.IIndexerGetterSetup + { + Mockolate.Setup.IIndexerGetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterSetupCallbackBuilder Do(System.Action callback); + } + public interface IIndexerGetterSetupWithCallback : Mockolate.Setup.IIndexerGetterSetup + { + Mockolate.Setup.IIndexerGetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterSetupCallbackBuilder Do(System.Action callback); + } + public interface IIndexerGetterSetupWithCallback : Mockolate.Setup.IIndexerGetterSetup + { + Mockolate.Setup.IIndexerGetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterSetupCallbackBuilder Do(System.Action callback); + } + public interface IIndexerGetterSetup + { + Mockolate.Setup.IIndexerGetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterSetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IIndexerGetterSetup + { + Mockolate.Setup.IIndexerGetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterSetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IIndexerGetterSetup + { + Mockolate.Setup.IIndexerGetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterSetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IIndexerGetterSetup + { + Mockolate.Setup.IIndexerGetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerGetterSetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IIndexerSetterOnlySetterSetup + { + Mockolate.Setup.IIndexerSetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterOnlySetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IIndexerSetterOnlySetterSetup + { + Mockolate.Setup.IIndexerSetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterOnlySetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IIndexerSetterOnlySetterSetup + { + Mockolate.Setup.IIndexerSetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterOnlySetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IIndexerSetterOnlySetterSetup + { + Mockolate.Setup.IIndexerSetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterOnlySetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IIndexerSetterOnlySetupCallbackBuilder : Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetterOnlySetupParallelCallbackBuilder, Mockolate.Setup.IIndexerSetterOnlySetup + { + Mockolate.Setup.IIndexerSetterOnlySetupParallelCallbackBuilder InParallel(); + } + public interface IIndexerSetterOnlySetupCallbackBuilder : Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetterOnlySetupParallelCallbackBuilder, Mockolate.Setup.IIndexerSetterOnlySetup + { + Mockolate.Setup.IIndexerSetterOnlySetupParallelCallbackBuilder InParallel(); + } + public interface IIndexerSetterOnlySetupCallbackBuilder : Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetterOnlySetupParallelCallbackBuilder, Mockolate.Setup.IIndexerSetterOnlySetup + { + Mockolate.Setup.IIndexerSetterOnlySetupParallelCallbackBuilder InParallel(); + } + public interface IIndexerSetterOnlySetupCallbackBuilder : Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetterOnlySetupParallelCallbackBuilder, Mockolate.Setup.IIndexerSetterOnlySetup + { + Mockolate.Setup.IIndexerSetterOnlySetupParallelCallbackBuilder InParallel(); + } + public interface IIndexerSetterOnlySetupCallbackWhenBuilder : Mockolate.Setup.IIndexerSetterOnlySetup + { + Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IIndexerSetterOnlySetup Only(int times); + } + public interface IIndexerSetterOnlySetupCallbackWhenBuilder : Mockolate.Setup.IIndexerSetterOnlySetup + { + Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IIndexerSetterOnlySetup Only(int times); + } + public interface IIndexerSetterOnlySetupCallbackWhenBuilder : Mockolate.Setup.IIndexerSetterOnlySetup + { + Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IIndexerSetterOnlySetup Only(int times); + } + public interface IIndexerSetterOnlySetupCallbackWhenBuilder : Mockolate.Setup.IIndexerSetterOnlySetup + { + Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IIndexerSetterOnlySetup Only(int times); + } + public interface IIndexerSetterOnlySetupParallelCallbackBuilder : Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetterOnlySetup + { + Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IIndexerSetterOnlySetupParallelCallbackBuilder : Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetterOnlySetup + { + Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IIndexerSetterOnlySetupParallelCallbackBuilder : Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetterOnlySetup + { + Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IIndexerSetterOnlySetupParallelCallbackBuilder : Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetterOnlySetup + { + Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IIndexerSetterOnlySetup + { + Mockolate.Setup.IIndexerSetterOnlySetterSetup OnSet { get; } + Mockolate.Setup.IIndexerSetterOnlySetup SkippingBaseClass(bool skipBaseClass = true); + } + public interface IIndexerSetterOnlySetup + { + Mockolate.Setup.IIndexerSetterOnlySetterSetup OnSet { get; } + Mockolate.Setup.IIndexerSetterOnlySetup SkippingBaseClass(bool skipBaseClass = true); + } + public interface IIndexerSetterOnlySetup + { + Mockolate.Setup.IIndexerSetterOnlySetterSetup OnSet { get; } + Mockolate.Setup.IIndexerSetterOnlySetup SkippingBaseClass(bool skipBaseClass = true); + } + public interface IIndexerSetterOnlySetup + { + Mockolate.Setup.IIndexerSetterOnlySetterSetup OnSet { get; } + Mockolate.Setup.IIndexerSetterOnlySetup SkippingBaseClass(bool skipBaseClass = true); + } + public interface IIndexerSetterSetupCallbackBuilder : Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetterSetupParallelCallbackBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetterSetupParallelCallbackBuilder InParallel(); + } + public interface IIndexerSetterSetupCallbackBuilder : Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetterSetupParallelCallbackBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetterSetupParallelCallbackBuilder InParallel(); + } + public interface IIndexerSetterSetupCallbackBuilder : Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetterSetupParallelCallbackBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetterSetupParallelCallbackBuilder InParallel(); + } + public interface IIndexerSetterSetupCallbackBuilder : Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetterSetupParallelCallbackBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetterSetupParallelCallbackBuilder InParallel(); + } + public interface IIndexerSetterSetupCallbackWhenBuilder : Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IIndexerSetup Only(int times); + } + public interface IIndexerSetterSetupCallbackWhenBuilder : Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IIndexerSetup Only(int times); + } + public interface IIndexerSetterSetupCallbackWhenBuilder : Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IIndexerSetup Only(int times); + } + public interface IIndexerSetterSetupCallbackWhenBuilder : Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IIndexerSetup Only(int times); + } + public interface IIndexerSetterSetupParallelCallbackBuilder : Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IIndexerSetterSetupParallelCallbackBuilder : Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IIndexerSetterSetupParallelCallbackBuilder : Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IIndexerSetterSetupParallelCallbackBuilder : Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IIndexerSetterSetupWithCallback : Mockolate.Setup.IIndexerSetterSetup + { + Mockolate.Setup.IIndexerSetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterSetupCallbackBuilder Do(System.Action callback); + } + public interface IIndexerSetterSetupWithCallback : Mockolate.Setup.IIndexerSetterSetup + { + Mockolate.Setup.IIndexerSetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterSetupCallbackBuilder Do(System.Action callback); + } + public interface IIndexerSetterSetupWithCallback : Mockolate.Setup.IIndexerSetterSetup + { + Mockolate.Setup.IIndexerSetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterSetupCallbackBuilder Do(System.Action callback); + } + public interface IIndexerSetterSetupWithCallback : Mockolate.Setup.IIndexerSetterSetup + { + Mockolate.Setup.IIndexerSetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterSetupCallbackBuilder Do(System.Action callback); + } + public interface IIndexerSetterSetup + { + Mockolate.Setup.IIndexerSetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterSetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IIndexerSetterSetup + { + Mockolate.Setup.IIndexerSetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterSetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IIndexerSetterSetup + { + Mockolate.Setup.IIndexerSetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterSetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IIndexerSetterSetup + { + Mockolate.Setup.IIndexerSetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IIndexerSetterSetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IIndexerSetupReturnBuilder : Mockolate.Setup.IIndexerSetupReturnWhenBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetupReturnWhenBuilder When(System.Func predicate); + } + public interface IIndexerSetupReturnBuilder : Mockolate.Setup.IIndexerSetupReturnWhenBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetupReturnWhenBuilder When(System.Func predicate); + } + public interface IIndexerSetupReturnBuilder : Mockolate.Setup.IIndexerSetupReturnWhenBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetupReturnWhenBuilder When(System.Func predicate); + } + public interface IIndexerSetupReturnBuilder : Mockolate.Setup.IIndexerSetupReturnWhenBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetupReturnWhenBuilder When(System.Func predicate); + } + public interface IIndexerSetupReturnWhenBuilder : Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetupReturnWhenBuilder For(int times); + Mockolate.Setup.IIndexerSetup Only(int times); + } + public interface IIndexerSetupReturnWhenBuilder : Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetupReturnWhenBuilder For(int times); + Mockolate.Setup.IIndexerSetup Only(int times); + } + public interface IIndexerSetupReturnWhenBuilder : Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetupReturnWhenBuilder For(int times); + Mockolate.Setup.IIndexerSetup Only(int times); + } + public interface IIndexerSetupReturnWhenBuilder : Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetupReturnWhenBuilder For(int times); + Mockolate.Setup.IIndexerSetup Only(int times); + } + public interface IIndexerSetupWithCallback : Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetup InitializeWith(System.Func valueGenerator); + Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback); + } + public interface IIndexerSetupWithCallback : Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetup InitializeWith(System.Func valueGenerator); + Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback); + } + public interface IIndexerSetupWithCallback : Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetup InitializeWith(System.Func valueGenerator); + Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback); + } + public interface IIndexerSetupWithCallback : Mockolate.Setup.IIndexerSetup + { + Mockolate.Setup.IIndexerSetup InitializeWith(System.Func valueGenerator); + Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback); + } + public interface IIndexerSetup + { + Mockolate.Setup.IIndexerGetterSetupWithCallback OnGet { get; } + Mockolate.Setup.IIndexerSetterSetupWithCallback OnSet { get; } + Mockolate.Setup.IIndexerSetup InitializeWith(TValue value); + Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerSetupReturnBuilder Returns(TValue returnValue); + Mockolate.Setup.IIndexerSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Exception exception); + Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IIndexerSetupReturnBuilder Throws() + where TException : System.Exception, new (); + } + public interface IIndexerSetup + { + Mockolate.Setup.IIndexerGetterSetupWithCallback OnGet { get; } + Mockolate.Setup.IIndexerSetterSetupWithCallback OnSet { get; } + Mockolate.Setup.IIndexerSetup InitializeWith(TValue value); + Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerSetupReturnBuilder Returns(TValue returnValue); + Mockolate.Setup.IIndexerSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Exception exception); + Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IIndexerSetupReturnBuilder Throws() + where TException : System.Exception, new (); + } + public interface IIndexerSetup + { + Mockolate.Setup.IIndexerGetterSetupWithCallback OnGet { get; } + Mockolate.Setup.IIndexerSetterSetupWithCallback OnSet { get; } + Mockolate.Setup.IIndexerSetup InitializeWith(TValue value); + Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerSetupReturnBuilder Returns(TValue returnValue); + Mockolate.Setup.IIndexerSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Exception exception); + Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IIndexerSetupReturnBuilder Throws() + where TException : System.Exception, new (); + } + public interface IIndexerSetup + { + Mockolate.Setup.IIndexerGetterSetupWithCallback OnGet { get; } + Mockolate.Setup.IIndexerSetterSetupWithCallback OnSet { get; } + Mockolate.Setup.IIndexerSetup InitializeWith(TValue value); + Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IIndexerSetupReturnBuilder Returns(TValue returnValue); + Mockolate.Setup.IIndexerSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Exception exception); + Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IIndexerSetupReturnBuilder Throws() + where TException : System.Exception, new (); + } + public interface IInteractiveIndexerSetup : Mockolate.Setup.ISetup + { + bool Matches(Mockolate.Interactions.IndexerAccess indexerAccess); + bool? SkipBaseClass(); + } + public interface IInteractivePropertySetup : Mockolate.Setup.ISetup + { + void InitializeWith(object? value); + TResult InvokeGetter(Mockolate.Interactions.IInteraction? invocation, Mockolate.MockBehavior behavior, System.Func defaultValueGenerator); + void InvokeSetter(Mockolate.Interactions.IInteraction? invocation, T value, Mockolate.MockBehavior behavior); + bool Matches(Mockolate.Interactions.PropertyAccess propertyAccess); + bool? SkipBaseClass(); + } + public interface IMethodMatch + { + bool Matches(Mockolate.Interactions.MethodInvocation methodInvocation); + } + public interface IMethodSetup : Mockolate.Setup.ISetup + { + string Name { get; } + } + public interface IMockSetup : Mockolate.IInteractiveMock { } + public interface IPropertyGetterOnlyGetterSetup + { + Mockolate.Setup.IPropertyGetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IPropertyGetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IPropertyGetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IPropertyGetterOnlySetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IPropertyGetterOnlySetupCallbackBuilder : Mockolate.Setup.IPropertyGetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IPropertyGetterOnlySetupParallelCallbackBuilder, Mockolate.Setup.IPropertyGetterOnlySetup + { + Mockolate.Setup.IPropertyGetterOnlySetupParallelCallbackBuilder InParallel(); + } + public interface IPropertyGetterOnlySetupCallbackWhenBuilder : Mockolate.Setup.IPropertyGetterOnlySetup + { + Mockolate.Setup.IPropertyGetterOnlySetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IPropertyGetterOnlySetup Only(int times); + } + public interface IPropertyGetterOnlySetupParallelCallbackBuilder : Mockolate.Setup.IPropertyGetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IPropertyGetterOnlySetup + { + Mockolate.Setup.IPropertyGetterOnlySetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IPropertyGetterOnlySetupReturnBuilder : Mockolate.Setup.IPropertyGetterOnlySetupReturnWhenBuilder, Mockolate.Setup.IPropertyGetterOnlySetup + { + Mockolate.Setup.IPropertyGetterOnlySetupReturnWhenBuilder When(System.Func predicate); + } + public interface IPropertyGetterOnlySetupReturnWhenBuilder : Mockolate.Setup.IPropertyGetterOnlySetup + { + Mockolate.Setup.IPropertyGetterOnlySetupReturnWhenBuilder For(int times); + Mockolate.Setup.IPropertyGetterOnlySetup Only(int times); + } + public interface IPropertyGetterOnlySetup + { + Mockolate.Setup.IPropertyGetterOnlyGetterSetup OnGet { get; } + Mockolate.Setup.IPropertyGetterOnlySetup InitializeWith(T value); + Mockolate.Setup.IPropertyGetterOnlySetup Register(); + Mockolate.Setup.IPropertyGetterOnlySetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IPropertyGetterOnlySetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IPropertyGetterOnlySetupReturnBuilder Returns(T returnValue); + Mockolate.Setup.IPropertyGetterOnlySetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IPropertyGetterOnlySetupReturnBuilder Throws(System.Exception exception); + Mockolate.Setup.IPropertyGetterOnlySetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IPropertyGetterOnlySetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IPropertyGetterOnlySetupReturnBuilder Throws() + where TException : System.Exception, new (); + } + public interface IPropertyGetterSetupCallbackBuilder : Mockolate.Setup.IPropertyGetterSetupCallbackWhenBuilder, Mockolate.Setup.IPropertyGetterSetupParallelCallbackBuilder, Mockolate.Setup.IPropertySetup + { + Mockolate.Setup.IPropertyGetterSetupParallelCallbackBuilder InParallel(); + } + public interface IPropertyGetterSetupCallbackWhenBuilder : Mockolate.Setup.IPropertySetup + { + Mockolate.Setup.IPropertyGetterSetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IPropertySetup Only(int times); + } + public interface IPropertyGetterSetupParallelCallbackBuilder : Mockolate.Setup.IPropertyGetterSetupCallbackWhenBuilder, Mockolate.Setup.IPropertySetup + { + Mockolate.Setup.IPropertyGetterSetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IPropertyGetterSetup + { + Mockolate.Setup.IPropertyGetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IPropertyGetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IPropertyGetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IPropertyGetterSetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IPropertySetterOnlySetterSetup + { + Mockolate.Setup.IPropertySetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IPropertySetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IPropertySetterOnlySetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IPropertySetterOnlySetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IPropertySetterOnlySetupCallbackBuilder : Mockolate.Setup.IPropertySetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IPropertySetterOnlySetupParallelCallbackBuilder, Mockolate.Setup.IPropertySetterOnlySetup + { + Mockolate.Setup.IPropertySetterOnlySetupParallelCallbackBuilder InParallel(); + } + public interface IPropertySetterOnlySetupCallbackWhenBuilder : Mockolate.Setup.IPropertySetterOnlySetup + { + Mockolate.Setup.IPropertySetterOnlySetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IPropertySetterOnlySetup Only(int times); + } + public interface IPropertySetterOnlySetupParallelCallbackBuilder : Mockolate.Setup.IPropertySetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IPropertySetterOnlySetup + { + Mockolate.Setup.IPropertySetterOnlySetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IPropertySetterOnlySetup + { + Mockolate.Setup.IPropertySetterOnlySetterSetup OnSet { get; } + Mockolate.Setup.IPropertySetterOnlySetup Register(); + Mockolate.Setup.IPropertySetterOnlySetup SkippingBaseClass(bool skipBaseClass = true); + } + public interface IPropertySetterSetupCallbackBuilder : Mockolate.Setup.IPropertySetterSetupCallbackWhenBuilder, Mockolate.Setup.IPropertySetterSetupParallelCallbackBuilder, Mockolate.Setup.IPropertySetup + { + Mockolate.Setup.IPropertySetterSetupParallelCallbackBuilder InParallel(); + } + public interface IPropertySetterSetupCallbackWhenBuilder : Mockolate.Setup.IPropertySetup + { + Mockolate.Setup.IPropertySetterSetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IPropertySetup Only(int times); + } + public interface IPropertySetterSetupParallelCallbackBuilder : Mockolate.Setup.IPropertySetterSetupCallbackWhenBuilder, Mockolate.Setup.IPropertySetup + { + Mockolate.Setup.IPropertySetterSetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IPropertySetterSetup + { + Mockolate.Setup.IPropertySetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IPropertySetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IPropertySetterSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IPropertySetterSetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IPropertySetupReturnBuilder : Mockolate.Setup.IPropertySetupReturnWhenBuilder, Mockolate.Setup.IPropertySetup + { + Mockolate.Setup.IPropertySetupReturnWhenBuilder When(System.Func predicate); + } + public interface IPropertySetupReturnWhenBuilder : Mockolate.Setup.IPropertySetup + { + Mockolate.Setup.IPropertySetupReturnWhenBuilder For(int times); + Mockolate.Setup.IPropertySetup Only(int times); + } + public interface IPropertySetup + { + Mockolate.Setup.IPropertyGetterSetup OnGet { get; } + Mockolate.Setup.IPropertySetterSetup OnSet { get; } + Mockolate.Setup.IPropertySetup InitializeWith(T value); + Mockolate.Setup.IPropertySetup Register(); + Mockolate.Setup.IPropertySetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IPropertySetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IPropertySetupReturnBuilder Returns(T returnValue); + Mockolate.Setup.IPropertySetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IPropertySetupReturnBuilder Throws(System.Exception exception); + Mockolate.Setup.IPropertySetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IPropertySetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IPropertySetupReturnBuilder Throws() + where TException : System.Exception, new (); + } + public interface IRefStructIndexerGetterSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IRefStructIndexerGetterSetup Returns(System.Func returnFactory); + Mockolate.Setup.IRefStructIndexerGetterSetup Returns(TValue returnValue); + Mockolate.Setup.IRefStructIndexerGetterSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IRefStructIndexerGetterSetup Throws(System.Exception exception); + Mockolate.Setup.IRefStructIndexerGetterSetup Throws(System.Func exceptionFactory); + Mockolate.Setup.IRefStructIndexerGetterSetup Throws() + where TException : System.Exception, new (); + } + public interface IRefStructIndexerGetterSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IRefStructIndexerGetterSetup Returns(System.Func returnFactory); + Mockolate.Setup.IRefStructIndexerGetterSetup Returns(TValue returnValue); + Mockolate.Setup.IRefStructIndexerGetterSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IRefStructIndexerGetterSetup Throws(System.Exception exception); + Mockolate.Setup.IRefStructIndexerGetterSetup Throws(System.Func exceptionFactory); + Mockolate.Setup.IRefStructIndexerGetterSetup Throws() + where TException : System.Exception, new (); + } + public interface IRefStructIndexerGetterSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IRefStructIndexerGetterSetup Returns(System.Func returnFactory); + Mockolate.Setup.IRefStructIndexerGetterSetup Returns(TValue returnValue); + Mockolate.Setup.IRefStructIndexerGetterSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IRefStructIndexerGetterSetup Throws(System.Exception exception); + Mockolate.Setup.IRefStructIndexerGetterSetup Throws(System.Func exceptionFactory); + Mockolate.Setup.IRefStructIndexerGetterSetup Throws() + where TException : System.Exception, new (); + } + public interface IRefStructIndexerGetterSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IRefStructIndexerGetterSetup Returns(System.Func returnFactory); + Mockolate.Setup.IRefStructIndexerGetterSetup Returns(TValue returnValue); + Mockolate.Setup.IRefStructIndexerGetterSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IRefStructIndexerGetterSetup Throws(System.Exception exception); + Mockolate.Setup.IRefStructIndexerGetterSetup Throws(System.Func exceptionFactory); + Mockolate.Setup.IRefStructIndexerGetterSetup Throws() + where TException : System.Exception, new (); + } + public interface IRefStructIndexerSetterSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IRefStructIndexerSetterSetup OnSet(System.Action callback); + Mockolate.Setup.IRefStructIndexerSetterSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IRefStructIndexerSetterSetup Throws(System.Exception exception); + Mockolate.Setup.IRefStructIndexerSetterSetup Throws(System.Func exceptionFactory); + Mockolate.Setup.IRefStructIndexerSetterSetup Throws() + where TException : System.Exception, new (); + } + public interface IRefStructIndexerSetterSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IRefStructIndexerSetterSetup OnSet(System.Action callback); + Mockolate.Setup.IRefStructIndexerSetterSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IRefStructIndexerSetterSetup Throws(System.Exception exception); + Mockolate.Setup.IRefStructIndexerSetterSetup Throws(System.Func exceptionFactory); + Mockolate.Setup.IRefStructIndexerSetterSetup Throws() + where TException : System.Exception, new (); + } + public interface IRefStructIndexerSetterSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IRefStructIndexerSetterSetup OnSet(System.Action callback); + Mockolate.Setup.IRefStructIndexerSetterSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IRefStructIndexerSetterSetup Throws(System.Exception exception); + Mockolate.Setup.IRefStructIndexerSetterSetup Throws(System.Func exceptionFactory); + Mockolate.Setup.IRefStructIndexerSetterSetup Throws() + where TException : System.Exception, new (); + } + public interface IRefStructIndexerSetterSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IRefStructIndexerSetterSetup OnSet(System.Action callback); + Mockolate.Setup.IRefStructIndexerSetterSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IRefStructIndexerSetterSetup Throws(System.Exception exception); + Mockolate.Setup.IRefStructIndexerSetterSetup Throws(System.Func exceptionFactory); + Mockolate.Setup.IRefStructIndexerSetterSetup Throws() + where TException : System.Exception, new (); + } + public interface IRefStructIndexerSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IRefStructIndexerSetup OnSet(System.Action callback); + Mockolate.Setup.IRefStructIndexerSetup Returns(System.Func returnFactory); + Mockolate.Setup.IRefStructIndexerSetup Returns(TValue returnValue); + Mockolate.Setup.IRefStructIndexerSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IRefStructIndexerSetup Throws(System.Exception exception); + Mockolate.Setup.IRefStructIndexerSetup Throws(System.Func exceptionFactory); + Mockolate.Setup.IRefStructIndexerSetup Throws() + where TException : System.Exception, new (); + } + public interface IRefStructIndexerSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IRefStructIndexerSetup OnSet(System.Action callback); + Mockolate.Setup.IRefStructIndexerSetup Returns(System.Func returnFactory); + Mockolate.Setup.IRefStructIndexerSetup Returns(TValue returnValue); + Mockolate.Setup.IRefStructIndexerSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IRefStructIndexerSetup Throws(System.Exception exception); + Mockolate.Setup.IRefStructIndexerSetup Throws(System.Func exceptionFactory); + Mockolate.Setup.IRefStructIndexerSetup Throws() + where TException : System.Exception, new (); + } + public interface IRefStructIndexerSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IRefStructIndexerSetup OnSet(System.Action callback); + Mockolate.Setup.IRefStructIndexerSetup Returns(System.Func returnFactory); + Mockolate.Setup.IRefStructIndexerSetup Returns(TValue returnValue); + Mockolate.Setup.IRefStructIndexerSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IRefStructIndexerSetup Throws(System.Exception exception); + Mockolate.Setup.IRefStructIndexerSetup Throws(System.Func exceptionFactory); + Mockolate.Setup.IRefStructIndexerSetup Throws() + where TException : System.Exception, new (); + } + public interface IRefStructIndexerSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IRefStructIndexerSetup OnSet(System.Action callback); + Mockolate.Setup.IRefStructIndexerSetup Returns(System.Func returnFactory); + Mockolate.Setup.IRefStructIndexerSetup Returns(TValue returnValue); + Mockolate.Setup.IRefStructIndexerSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IRefStructIndexerSetup Throws(System.Exception exception); + Mockolate.Setup.IRefStructIndexerSetup Throws(System.Func exceptionFactory); + Mockolate.Setup.IRefStructIndexerSetup Throws() + where TException : System.Exception, new (); + } + public interface IRefStructReturnMethodSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IRefStructReturnMethodSetup Returns(System.Func returnFactory); + Mockolate.Setup.IRefStructReturnMethodSetup Returns(TReturn returnValue); + Mockolate.Setup.IRefStructReturnMethodSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IRefStructReturnMethodSetup Throws(System.Exception exception); + Mockolate.Setup.IRefStructReturnMethodSetup Throws(System.Func exceptionFactory); + Mockolate.Setup.IRefStructReturnMethodSetup Throws() + where TException : System.Exception, new (); + } + public interface IRefStructReturnMethodSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IRefStructReturnMethodSetup Returns(System.Func returnFactory); + Mockolate.Setup.IRefStructReturnMethodSetup Returns(TReturn returnValue); + Mockolate.Setup.IRefStructReturnMethodSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IRefStructReturnMethodSetup Throws(System.Exception exception); + Mockolate.Setup.IRefStructReturnMethodSetup Throws(System.Func exceptionFactory); + Mockolate.Setup.IRefStructReturnMethodSetup Throws() + where TException : System.Exception, new (); + } + public interface IRefStructReturnMethodSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IRefStructReturnMethodSetup Returns(System.Func returnFactory); + Mockolate.Setup.IRefStructReturnMethodSetup Returns(TReturn returnValue); + Mockolate.Setup.IRefStructReturnMethodSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IRefStructReturnMethodSetup Throws(System.Exception exception); + Mockolate.Setup.IRefStructReturnMethodSetup Throws(System.Func exceptionFactory); + Mockolate.Setup.IRefStructReturnMethodSetup Throws() + where TException : System.Exception, new (); + } + public interface IRefStructReturnMethodSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IRefStructReturnMethodSetup Returns(System.Func returnFactory); + Mockolate.Setup.IRefStructReturnMethodSetup Returns(TReturn returnValue); + Mockolate.Setup.IRefStructReturnMethodSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IRefStructReturnMethodSetup Throws(System.Exception exception); + Mockolate.Setup.IRefStructReturnMethodSetup Throws(System.Func exceptionFactory); + Mockolate.Setup.IRefStructReturnMethodSetup Throws() + where TException : System.Exception, new (); + } + public interface IRefStructVoidMethodSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IRefStructVoidMethodSetup DoesNotThrow(); + Mockolate.Setup.IRefStructVoidMethodSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IRefStructVoidMethodSetup Throws(System.Exception exception); + Mockolate.Setup.IRefStructVoidMethodSetup Throws(System.Func exceptionFactory); + Mockolate.Setup.IRefStructVoidMethodSetup Throws() + where TException : System.Exception, new (); + } + public interface IRefStructVoidMethodSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IRefStructVoidMethodSetup DoesNotThrow(); + Mockolate.Setup.IRefStructVoidMethodSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IRefStructVoidMethodSetup Throws(System.Exception exception); + Mockolate.Setup.IRefStructVoidMethodSetup Throws(System.Func exceptionFactory); + Mockolate.Setup.IRefStructVoidMethodSetup Throws() + where TException : System.Exception, new (); + } + public interface IRefStructVoidMethodSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IRefStructVoidMethodSetup DoesNotThrow(); + Mockolate.Setup.IRefStructVoidMethodSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IRefStructVoidMethodSetup Throws(System.Exception exception); + Mockolate.Setup.IRefStructVoidMethodSetup Throws(System.Func exceptionFactory); + Mockolate.Setup.IRefStructVoidMethodSetup Throws() + where TException : System.Exception, new (); + } + public interface IRefStructVoidMethodSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IRefStructVoidMethodSetup DoesNotThrow(); + Mockolate.Setup.IRefStructVoidMethodSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IRefStructVoidMethodSetup Throws(System.Exception exception); + Mockolate.Setup.IRefStructVoidMethodSetup Throws(System.Func exceptionFactory); + Mockolate.Setup.IRefStructVoidMethodSetup Throws() + where TException : System.Exception, new (); + } + public interface IReturnMethodSetupCallbackBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder, Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder InParallel(); + } + public interface IReturnMethodSetupCallbackBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder, Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder InParallel(); + } + public interface IReturnMethodSetupCallbackBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder, Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder InParallel(); + } + public interface IReturnMethodSetupCallbackBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder, Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder InParallel(); + } + public interface IReturnMethodSetupCallbackBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder, Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder InParallel(); + } + public interface IReturnMethodSetupCallbackWhenBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IReturnMethodSetup Only(int times); + } + public interface IReturnMethodSetupCallbackWhenBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IReturnMethodSetup Only(int times); + } + public interface IReturnMethodSetupCallbackWhenBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IReturnMethodSetup Only(int times); + } + public interface IReturnMethodSetupCallbackWhenBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IReturnMethodSetup Only(int times); + } + public interface IReturnMethodSetupCallbackWhenBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IReturnMethodSetup Only(int times); + } + public interface IReturnMethodSetupParallelCallbackBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IReturnMethodSetupParallelCallbackBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IReturnMethodSetupParallelCallbackBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IReturnMethodSetupParallelCallbackBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IReturnMethodSetupParallelCallbackBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IReturnMethodSetupParameterIgnorer : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetup AnyParameters(); + } + public interface IReturnMethodSetupParameterIgnorer : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetup AnyParameters(); + } + public interface IReturnMethodSetupParameterIgnorer : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetup AnyParameters(); + } + public interface IReturnMethodSetupParameterIgnorer : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetup AnyParameters(); + } + public interface IReturnMethodSetupReturnBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder When(System.Func predicate); + } + public interface IReturnMethodSetupReturnBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder When(System.Func predicate); + } + public interface IReturnMethodSetupReturnBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder When(System.Func predicate); + } + public interface IReturnMethodSetupReturnBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder When(System.Func predicate); + } + public interface IReturnMethodSetupReturnBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder When(System.Func predicate); + } + public interface IReturnMethodSetupReturnWhenBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder For(int times); + Mockolate.Setup.IReturnMethodSetup Only(int times); + } + public interface IReturnMethodSetupReturnWhenBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder For(int times); + Mockolate.Setup.IReturnMethodSetup Only(int times); + } + public interface IReturnMethodSetupReturnWhenBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder For(int times); + Mockolate.Setup.IReturnMethodSetup Only(int times); + } + public interface IReturnMethodSetupReturnWhenBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder For(int times); + Mockolate.Setup.IReturnMethodSetup Only(int times); + } + public interface IReturnMethodSetupReturnWhenBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder For(int times); + Mockolate.Setup.IReturnMethodSetup Only(int times); + } + public interface IReturnMethodSetupWithCallback : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(System.Func callback); + } + public interface IReturnMethodSetupWithCallback : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(System.Func callback); + } + public interface IReturnMethodSetupWithCallback : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(System.Func callback); + } + public interface IReturnMethodSetupWithCallback : Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(System.Func callback); + } + public interface IReturnMethodSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(TReturn returnValue); + Mockolate.Setup.IReturnMethodSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(System.Exception exception); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws() + where TException : System.Exception, new (); + Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IReturnMethodSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(TReturn returnValue); + Mockolate.Setup.IReturnMethodSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(System.Exception exception); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws() + where TException : System.Exception, new (); + Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IReturnMethodSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(TReturn returnValue); + Mockolate.Setup.IReturnMethodSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(System.Exception exception); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws() + where TException : System.Exception, new (); + Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IReturnMethodSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(TReturn returnValue); + Mockolate.Setup.IReturnMethodSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(System.Exception exception); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws() + where TException : System.Exception, new (); + Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IReturnMethodSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(System.Func callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(TReturn returnValue); + Mockolate.Setup.IReturnMethodSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(System.Exception exception); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws() + where TException : System.Exception, new (); + Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface ISetup { } + public interface IVerifiableMethodSetup + { + bool Matches(Mockolate.Interactions.IMethodInteraction interaction); + } + public interface IVoidMethodSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IVoidMethodSetup DoesNotThrow(); + Mockolate.Setup.IVoidMethodSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(System.Exception exception); + Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws() + where TException : System.Exception, new (); + Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IVoidMethodSetupCallbackBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetup, Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder, Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder + { + Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder InParallel(); + } + public interface IVoidMethodSetupCallbackBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder, Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder InParallel(); + } + public interface IVoidMethodSetupCallbackBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder, Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder InParallel(); + } + public interface IVoidMethodSetupCallbackBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder, Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder InParallel(); + } + public interface IVoidMethodSetupCallbackBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder, Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder InParallel(); + } + public interface IVoidMethodSetupCallbackWhenBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IVoidMethodSetup Only(int times); + } + public interface IVoidMethodSetupCallbackWhenBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IVoidMethodSetup Only(int times); + } + public interface IVoidMethodSetupCallbackWhenBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IVoidMethodSetup Only(int times); + } + public interface IVoidMethodSetupCallbackWhenBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IVoidMethodSetup Only(int times); + } + public interface IVoidMethodSetupCallbackWhenBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder For(int times); + Mockolate.Setup.IVoidMethodSetup Only(int times); + } + public interface IVoidMethodSetupParallelCallbackBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetup, Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder + { + Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IVoidMethodSetupParallelCallbackBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IVoidMethodSetupParallelCallbackBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IVoidMethodSetupParallelCallbackBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IVoidMethodSetupParallelCallbackBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder When(System.Func predicate); + } + public interface IVoidMethodSetupParameterIgnorer : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetup AnyParameters(); + } + public interface IVoidMethodSetupParameterIgnorer : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetup AnyParameters(); + } + public interface IVoidMethodSetupParameterIgnorer : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetup AnyParameters(); + } + public interface IVoidMethodSetupParameterIgnorer : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetup AnyParameters(); + } + public interface IVoidMethodSetupReturnBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetup, Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder + { + Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder When(System.Func predicate); + } + public interface IVoidMethodSetupReturnBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder When(System.Func predicate); + } + public interface IVoidMethodSetupReturnBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder When(System.Func predicate); + } + public interface IVoidMethodSetupReturnBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder When(System.Func predicate); + } + public interface IVoidMethodSetupReturnBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder When(System.Func predicate); + } + public interface IVoidMethodSetupReturnWhenBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder For(int times); + Mockolate.Setup.IVoidMethodSetup Only(int times); + } + public interface IVoidMethodSetupReturnWhenBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder For(int times); + Mockolate.Setup.IVoidMethodSetup Only(int times); + } + public interface IVoidMethodSetupReturnWhenBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder For(int times); + Mockolate.Setup.IVoidMethodSetup Only(int times); + } + public interface IVoidMethodSetupReturnWhenBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder For(int times); + Mockolate.Setup.IVoidMethodSetup Only(int times); + } + public interface IVoidMethodSetupReturnWhenBuilder : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder For(int times); + Mockolate.Setup.IVoidMethodSetup Only(int times); + } + public interface IVoidMethodSetupWithCallback : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(System.Func callback); + } + public interface IVoidMethodSetupWithCallback : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(System.Func callback); + } + public interface IVoidMethodSetupWithCallback : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(System.Func callback); + } + public interface IVoidMethodSetupWithCallback : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetup + { + Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(System.Func callback); + } + public interface IVoidMethodSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IVoidMethodSetup DoesNotThrow(); + Mockolate.Setup.IVoidMethodSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(System.Exception exception); + Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws() + where TException : System.Exception, new (); + Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IVoidMethodSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IVoidMethodSetup DoesNotThrow(); + Mockolate.Setup.IVoidMethodSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(System.Exception exception); + Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws() + where TException : System.Exception, new (); + Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IVoidMethodSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IVoidMethodSetup DoesNotThrow(); + Mockolate.Setup.IVoidMethodSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(System.Exception exception); + Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws() + where TException : System.Exception, new (); + Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder TransitionTo(string scenario); + } + public interface IVoidMethodSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup + { + Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(System.Action callback); + Mockolate.Setup.IVoidMethodSetup DoesNotThrow(); + Mockolate.Setup.IVoidMethodSetup SkippingBaseClass(bool skipBaseClass = true); + Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(System.Exception exception); + Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(System.Func callback); + Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws() + where TException : System.Exception, new (); + Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder TransitionTo(string scenario); + } + public abstract class IndexerSetup : Mockolate.Setup.IInteractiveIndexerSetup, Mockolate.Setup.ISetup + { + protected IndexerSetup(Mockolate.MockRegistry mockRegistry) { } + public abstract TResult GetResult(Mockolate.Interactions.IndexerAccess access, Mockolate.MockBehavior behavior); + public abstract TResult GetResult(Mockolate.Interactions.IndexerAccess access, Mockolate.MockBehavior behavior, System.Func defaultValueGenerator); + public abstract TResult GetResult(Mockolate.Interactions.IndexerAccess access, Mockolate.MockBehavior behavior, TResult baseValue); + protected abstract bool MatchesAccess(Mockolate.Interactions.IndexerAccess access); + public abstract void SetResult(Mockolate.Interactions.IndexerAccess access, Mockolate.MockBehavior behavior, TResult value); + public abstract bool? SkipBaseClass(); + protected void TransitionScenario(string scenario) { } + protected static string FormatType(System.Type type) { } + protected static bool TryCast([System.Diagnostics.CodeAnalysis.NotNullWhen(false)] object? value, out T result, Mockolate.MockBehavior behavior) { } + } + public class IndexerSetup : Mockolate.Setup.IndexerSetup, Mockolate.Setup.IIndexerGetterOnlyGetterSetup, Mockolate.Setup.IIndexerGetterOnlySetupCallbackBuilder, Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerGetterOnlySetupParallelCallbackBuilder, Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder, Mockolate.Setup.IIndexerGetterOnlySetupReturnWhenBuilder, Mockolate.Setup.IIndexerGetterOnlySetup, Mockolate.Setup.IIndexerGetterSetupCallbackBuilder, Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerGetterSetupParallelCallbackBuilder, Mockolate.Setup.IIndexerGetterSetupWithCallback, Mockolate.Setup.IIndexerGetterSetup, Mockolate.Setup.IIndexerSetterOnlySetterSetup, Mockolate.Setup.IIndexerSetterOnlySetupCallbackBuilder, Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetterOnlySetupParallelCallbackBuilder, Mockolate.Setup.IIndexerSetterOnlySetup, Mockolate.Setup.IIndexerSetterSetupCallbackBuilder, Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetterSetupParallelCallbackBuilder, Mockolate.Setup.IIndexerSetterSetupWithCallback, Mockolate.Setup.IIndexerSetterSetup, Mockolate.Setup.IIndexerSetupReturnBuilder, Mockolate.Setup.IIndexerSetupReturnWhenBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + public IndexerSetup(Mockolate.MockRegistry mockRegistry, Mockolate.Parameters.IParameterMatch parameter1) { } + public Mockolate.Setup.IIndexerGetterSetupWithCallback OnGet { get; } + public Mockolate.Setup.IIndexerSetterSetupWithCallback OnSet { get; } + public override TResult GetResult(Mockolate.Interactions.IndexerAccess access, Mockolate.MockBehavior behavior) { } + public override TResult GetResult(Mockolate.Interactions.IndexerAccess access, Mockolate.MockBehavior behavior, System.Func defaultValueGenerator) { } + public override TResult GetResult(Mockolate.Interactions.IndexerAccess access, Mockolate.MockBehavior behavior, TResult baseValue) { } + public Mockolate.Setup.IIndexerSetup InitializeWith(System.Func valueGenerator) { } + public Mockolate.Setup.IIndexerSetupWithCallback InitializeWith(TValue value) { } + public virtual bool Matches(T1 p1) { } + public virtual bool Matches(T1 p1, TValue value) { } + protected override bool MatchesAccess(Mockolate.Interactions.IndexerAccess access) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Returns(TValue returnValue) { } + public override void SetResult(Mockolate.Interactions.IndexerAccess access, Mockolate.MockBehavior behavior, TResult value) { } + public override bool? SkipBaseClass() { } + public Mockolate.Setup.IIndexerSetup SkippingBaseClass(bool skipBaseClass = true) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Exception exception) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Throws() + where TException : System.Exception, new () { } + public override string ToString() { } + } + public class IndexerSetup : Mockolate.Setup.IndexerSetup, Mockolate.Setup.IIndexerGetterOnlyGetterSetup, Mockolate.Setup.IIndexerGetterOnlySetupCallbackBuilder, Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerGetterOnlySetupParallelCallbackBuilder, Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder, Mockolate.Setup.IIndexerGetterOnlySetupReturnWhenBuilder, Mockolate.Setup.IIndexerGetterOnlySetup, Mockolate.Setup.IIndexerGetterSetupCallbackBuilder, Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerGetterSetupParallelCallbackBuilder, Mockolate.Setup.IIndexerGetterSetupWithCallback, Mockolate.Setup.IIndexerGetterSetup, Mockolate.Setup.IIndexerSetterOnlySetterSetup, Mockolate.Setup.IIndexerSetterOnlySetupCallbackBuilder, Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetterOnlySetupParallelCallbackBuilder, Mockolate.Setup.IIndexerSetterOnlySetup, Mockolate.Setup.IIndexerSetterSetupCallbackBuilder, Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetterSetupParallelCallbackBuilder, Mockolate.Setup.IIndexerSetterSetupWithCallback, Mockolate.Setup.IIndexerSetterSetup, Mockolate.Setup.IIndexerSetupReturnBuilder, Mockolate.Setup.IIndexerSetupReturnWhenBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + public IndexerSetup(Mockolate.MockRegistry mockRegistry, Mockolate.Parameters.IParameterMatch parameter1, Mockolate.Parameters.IParameterMatch parameter2) { } + public Mockolate.Setup.IIndexerGetterSetupWithCallback OnGet { get; } + public Mockolate.Setup.IIndexerSetterSetupWithCallback OnSet { get; } + public override TResult GetResult(Mockolate.Interactions.IndexerAccess access, Mockolate.MockBehavior behavior) { } + public override TResult GetResult(Mockolate.Interactions.IndexerAccess access, Mockolate.MockBehavior behavior, System.Func defaultValueGenerator) { } + public override TResult GetResult(Mockolate.Interactions.IndexerAccess access, Mockolate.MockBehavior behavior, TResult baseValue) { } + public Mockolate.Setup.IIndexerSetup InitializeWith(System.Func valueGenerator) { } + public Mockolate.Setup.IIndexerSetupWithCallback InitializeWith(TValue value) { } + public virtual bool Matches(T1 p1, T2 p2) { } + public virtual bool Matches(T1 p1, T2 p2, TValue value) { } + protected override bool MatchesAccess(Mockolate.Interactions.IndexerAccess access) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Returns(TValue returnValue) { } + public override void SetResult(Mockolate.Interactions.IndexerAccess access, Mockolate.MockBehavior behavior, TResult value) { } + public override bool? SkipBaseClass() { } + public Mockolate.Setup.IIndexerSetup SkippingBaseClass(bool skipBaseClass = true) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Exception exception) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Throws() + where TException : System.Exception, new () { } + public override string ToString() { } + } + public class IndexerSetup : Mockolate.Setup.IndexerSetup, Mockolate.Setup.IIndexerGetterOnlyGetterSetup, Mockolate.Setup.IIndexerGetterOnlySetupCallbackBuilder, Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerGetterOnlySetupParallelCallbackBuilder, Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder, Mockolate.Setup.IIndexerGetterOnlySetupReturnWhenBuilder, Mockolate.Setup.IIndexerGetterOnlySetup, Mockolate.Setup.IIndexerGetterSetupCallbackBuilder, Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerGetterSetupParallelCallbackBuilder, Mockolate.Setup.IIndexerGetterSetupWithCallback, Mockolate.Setup.IIndexerGetterSetup, Mockolate.Setup.IIndexerSetterOnlySetterSetup, Mockolate.Setup.IIndexerSetterOnlySetupCallbackBuilder, Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetterOnlySetupParallelCallbackBuilder, Mockolate.Setup.IIndexerSetterOnlySetup, Mockolate.Setup.IIndexerSetterSetupCallbackBuilder, Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetterSetupParallelCallbackBuilder, Mockolate.Setup.IIndexerSetterSetupWithCallback, Mockolate.Setup.IIndexerSetterSetup, Mockolate.Setup.IIndexerSetupReturnBuilder, Mockolate.Setup.IIndexerSetupReturnWhenBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + public IndexerSetup(Mockolate.MockRegistry mockRegistry, Mockolate.Parameters.IParameterMatch parameter1, Mockolate.Parameters.IParameterMatch parameter2, Mockolate.Parameters.IParameterMatch parameter3) { } + public Mockolate.Setup.IIndexerGetterSetupWithCallback OnGet { get; } + public Mockolate.Setup.IIndexerSetterSetupWithCallback OnSet { get; } + public override TResult GetResult(Mockolate.Interactions.IndexerAccess access, Mockolate.MockBehavior behavior) { } + public override TResult GetResult(Mockolate.Interactions.IndexerAccess access, Mockolate.MockBehavior behavior, System.Func defaultValueGenerator) { } + public override TResult GetResult(Mockolate.Interactions.IndexerAccess access, Mockolate.MockBehavior behavior, TResult baseValue) { } + public Mockolate.Setup.IIndexerSetup InitializeWith(System.Func valueGenerator) { } + public Mockolate.Setup.IIndexerSetupWithCallback InitializeWith(TValue value) { } + public virtual bool Matches(T1 p1, T2 p2, T3 p3) { } + public virtual bool Matches(T1 p1, T2 p2, T3 p3, TValue value) { } + protected override bool MatchesAccess(Mockolate.Interactions.IndexerAccess access) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Returns(TValue returnValue) { } + public override void SetResult(Mockolate.Interactions.IndexerAccess access, Mockolate.MockBehavior behavior, TResult value) { } + public override bool? SkipBaseClass() { } + public Mockolate.Setup.IIndexerSetup SkippingBaseClass(bool skipBaseClass = true) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Exception exception) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Throws() + where TException : System.Exception, new () { } + public override string ToString() { } + } + public class IndexerSetup : Mockolate.Setup.IndexerSetup, Mockolate.Setup.IIndexerGetterOnlyGetterSetup, Mockolate.Setup.IIndexerGetterOnlySetupCallbackBuilder, Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerGetterOnlySetupParallelCallbackBuilder, Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder, Mockolate.Setup.IIndexerGetterOnlySetupReturnWhenBuilder, Mockolate.Setup.IIndexerGetterOnlySetup, Mockolate.Setup.IIndexerGetterSetupCallbackBuilder, Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerGetterSetupParallelCallbackBuilder, Mockolate.Setup.IIndexerGetterSetupWithCallback, Mockolate.Setup.IIndexerGetterSetup, Mockolate.Setup.IIndexerSetterOnlySetterSetup, Mockolate.Setup.IIndexerSetterOnlySetupCallbackBuilder, Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetterOnlySetupParallelCallbackBuilder, Mockolate.Setup.IIndexerSetterOnlySetup, Mockolate.Setup.IIndexerSetterSetupCallbackBuilder, Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder, Mockolate.Setup.IIndexerSetterSetupParallelCallbackBuilder, Mockolate.Setup.IIndexerSetterSetupWithCallback, Mockolate.Setup.IIndexerSetterSetup, Mockolate.Setup.IIndexerSetupReturnBuilder, Mockolate.Setup.IIndexerSetupReturnWhenBuilder, Mockolate.Setup.IIndexerSetupWithCallback, Mockolate.Setup.IIndexerSetup + { + public IndexerSetup(Mockolate.MockRegistry mockRegistry, Mockolate.Parameters.IParameterMatch parameter1, Mockolate.Parameters.IParameterMatch parameter2, Mockolate.Parameters.IParameterMatch parameter3, Mockolate.Parameters.IParameterMatch parameter4) { } + public Mockolate.Setup.IIndexerGetterSetupWithCallback OnGet { get; } + public Mockolate.Setup.IIndexerSetterSetupWithCallback OnSet { get; } + public override TResult GetResult(Mockolate.Interactions.IndexerAccess access, Mockolate.MockBehavior behavior) { } + public override TResult GetResult(Mockolate.Interactions.IndexerAccess access, Mockolate.MockBehavior behavior, System.Func defaultValueGenerator) { } + public override TResult GetResult(Mockolate.Interactions.IndexerAccess access, Mockolate.MockBehavior behavior, TResult baseValue) { } + public Mockolate.Setup.IIndexerSetup InitializeWith(System.Func valueGenerator) { } + public Mockolate.Setup.IIndexerSetupWithCallback InitializeWith(TValue value) { } + public virtual bool Matches(T1 p1, T2 p2, T3 p3, T4 p4) { } + public virtual bool Matches(T1 p1, T2 p2, T3 p3, T4 p4, TValue value) { } + protected override bool MatchesAccess(Mockolate.Interactions.IndexerAccess access) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Returns(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Returns(TValue returnValue) { } + public override void SetResult(Mockolate.Interactions.IndexerAccess access, Mockolate.MockBehavior behavior, TResult value) { } + public override bool? SkipBaseClass() { } + public Mockolate.Setup.IIndexerSetup SkippingBaseClass(bool skipBaseClass = true) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Exception exception) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Throws(System.Func callback) { } + public Mockolate.Setup.IIndexerSetupReturnBuilder Throws() + where TException : System.Exception, new () { } + public override string ToString() { } + } + public abstract class IndexerValueStorage + { + protected IndexerValueStorage() { } + public abstract Mockolate.Setup.IndexerValueStorage? GetChildDispatch(TKey key); + public abstract Mockolate.Setup.IndexerValueStorage GetOrAddChildDispatch(TKey key); + } + public abstract class MethodSetup : Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVerifiableMethodSetup + { + protected MethodSetup(string name) { } + public string Name { get; } + protected abstract bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction); + protected static string FormatLiteralValue(T value) { } + protected static string FormatType(System.Type type) { } + } + public abstract class PropertySetup : Mockolate.Setup.IInteractivePropertySetup, Mockolate.Setup.ISetup + { + protected PropertySetup() { } + public abstract string Name { get; } + protected abstract bool? GetSkipBaseClass(); + protected abstract void InitializeValue(object? value); + protected abstract TResult InvokeGetter(Mockolate.MockBehavior behavior, System.Func defaultValueGenerator); + protected abstract void InvokeSetter(TValue value, Mockolate.MockBehavior behavior); + protected abstract bool Matches(Mockolate.Interactions.PropertyAccess propertyAccess); + } + public class PropertySetup : Mockolate.Setup.PropertySetup, Mockolate.Setup.IPropertyGetterOnlyGetterSetup, Mockolate.Setup.IPropertyGetterOnlySetupCallbackBuilder, Mockolate.Setup.IPropertyGetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IPropertyGetterOnlySetupParallelCallbackBuilder, Mockolate.Setup.IPropertyGetterOnlySetupReturnBuilder, Mockolate.Setup.IPropertyGetterOnlySetupReturnWhenBuilder, Mockolate.Setup.IPropertyGetterOnlySetup, Mockolate.Setup.IPropertyGetterSetupCallbackBuilder, Mockolate.Setup.IPropertyGetterSetupCallbackWhenBuilder, Mockolate.Setup.IPropertyGetterSetupParallelCallbackBuilder, Mockolate.Setup.IPropertyGetterSetup, Mockolate.Setup.IPropertySetterOnlySetterSetup, Mockolate.Setup.IPropertySetterOnlySetupCallbackBuilder, Mockolate.Setup.IPropertySetterOnlySetupCallbackWhenBuilder, Mockolate.Setup.IPropertySetterOnlySetupParallelCallbackBuilder, Mockolate.Setup.IPropertySetterOnlySetup, Mockolate.Setup.IPropertySetterSetupCallbackBuilder, Mockolate.Setup.IPropertySetterSetupCallbackWhenBuilder, Mockolate.Setup.IPropertySetterSetupParallelCallbackBuilder, Mockolate.Setup.IPropertySetterSetup, Mockolate.Setup.IPropertySetupReturnBuilder, Mockolate.Setup.IPropertySetupReturnWhenBuilder, Mockolate.Setup.IPropertySetup + { + public PropertySetup(Mockolate.MockRegistry mockRegistry, string name) { } + public override string Name { get; } + public Mockolate.Setup.IPropertyGetterSetup OnGet { get; } + public Mockolate.Setup.IPropertySetterSetup OnSet { get; } + protected override bool? GetSkipBaseClass() { } + protected override void InitializeValue(object? value) { } + public Mockolate.Setup.IPropertySetup InitializeWith(T value) { } + protected override TResult InvokeGetter(Mockolate.MockBehavior behavior, System.Func defaultValueGenerator) { } + protected override void InvokeSetter(TValue value, Mockolate.MockBehavior behavior) { } + protected override bool Matches(Mockolate.Interactions.PropertyAccess propertyAccess) { } + public Mockolate.Setup.IPropertySetup Register() { } + public Mockolate.Setup.IPropertySetupReturnBuilder Returns(System.Func callback) { } + public Mockolate.Setup.IPropertySetupReturnBuilder Returns(System.Func callback) { } + public Mockolate.Setup.IPropertySetupReturnBuilder Returns(T returnValue) { } + public Mockolate.Setup.IPropertySetup SkippingBaseClass(bool skipBaseClass = true) { } + public Mockolate.Setup.IPropertySetupReturnBuilder Throws(System.Exception exception) { } + public Mockolate.Setup.IPropertySetupReturnBuilder Throws(System.Func callback) { } + public Mockolate.Setup.IPropertySetupReturnBuilder Throws(System.Func callback) { } + public Mockolate.Setup.IPropertySetupReturnBuilder Throws() + where TException : System.Exception, new () { } + public override string ToString() { } + } + public class ReadOnlySpanWrapper + { + public ReadOnlySpanWrapper(System.ReadOnlySpan span) { } + public T[] ReadOnlySpanValues { get; } + public static System.ReadOnlySpan op_Implicit(Mockolate.Setup.ReadOnlySpanWrapper? wrapper) { } + public static Mockolate.Setup.ReadOnlySpanWrapper op_Implicit(System.ReadOnlySpan span) { } + } + public sealed class RefStructIndexerGetterSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IRefStructIndexerGetterSetup, Mockolate.Setup.ISetup + { + public RefStructIndexerGetterSetup(string name, Mockolate.Parameters.IParameterMatch? matcher = null) { } + public bool HasReturnValue { get; } + public TValue Invoke(T value, System.Func? defaultFactory = null) { } + public bool Matches(T value) { } + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public override string ToString() { } + } + public sealed class RefStructIndexerGetterSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IRefStructIndexerGetterSetup, Mockolate.Setup.ISetup + { + public RefStructIndexerGetterSetup(string name, Mockolate.Parameters.IParameterMatch? matcher1 = null, Mockolate.Parameters.IParameterMatch? matcher2 = null) { } + public bool HasReturnValue { get; } + public TValue Invoke(T1 value1, T2 value2, object? rawKey1 = null, object? rawKey2 = null, System.Func? defaultFactory = null) { } + public bool Matches(T1 value1, T2 value2) { } + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public override string ToString() { } + } + public sealed class RefStructIndexerGetterSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IRefStructIndexerGetterSetup, Mockolate.Setup.ISetup + { + public RefStructIndexerGetterSetup(string name, Mockolate.Parameters.IParameterMatch? matcher1 = null, Mockolate.Parameters.IParameterMatch? matcher2 = null, Mockolate.Parameters.IParameterMatch? matcher3 = null) { } + public bool HasReturnValue { get; } + public TValue Invoke(T1 value1, T2 value2, T3 value3, object? rawKey1 = null, object? rawKey2 = null, object? rawKey3 = null, System.Func? defaultFactory = null) { } + public bool Matches(T1 value1, T2 value2, T3 value3) { } + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public override string ToString() { } + } + public sealed class RefStructIndexerGetterSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IRefStructIndexerGetterSetup, Mockolate.Setup.ISetup + { + public RefStructIndexerGetterSetup(string name, Mockolate.Parameters.IParameterMatch? matcher1 = null, Mockolate.Parameters.IParameterMatch? matcher2 = null, Mockolate.Parameters.IParameterMatch? matcher3 = null, Mockolate.Parameters.IParameterMatch? matcher4 = null) { } + public bool HasReturnValue { get; } + public TValue Invoke(T1 value1, T2 value2, T3 value3, T4 value4, object? rawKey1 = null, object? rawKey2 = null, object? rawKey3 = null, object? rawKey4 = null, System.Func? defaultFactory = null) { } + public bool Matches(T1 value1, T2 value2, T3 value3, T4 value4) { } + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public override string ToString() { } + } + public sealed class RefStructIndexerSetterSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IRefStructIndexerSetterSetup, Mockolate.Setup.ISetup + { + public RefStructIndexerSetterSetup(string name, Mockolate.Parameters.IParameterMatch? matcher = null) { } + public void Invoke(T key, TValue value) { } + public bool Matches(T value) { } + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public override string ToString() { } + } + public sealed class RefStructIndexerSetterSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IRefStructIndexerSetterSetup, Mockolate.Setup.ISetup + { + public RefStructIndexerSetterSetup(string name, Mockolate.Parameters.IParameterMatch? matcher1 = null, Mockolate.Parameters.IParameterMatch? matcher2 = null) { } + public void Invoke(T1 k1, T2 k2, TValue value, object? rawKey1 = null, object? rawKey2 = null) { } + public bool Matches(T1 value1, T2 value2) { } + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public override string ToString() { } + } + public sealed class RefStructIndexerSetterSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IRefStructIndexerSetterSetup, Mockolate.Setup.ISetup + { + public RefStructIndexerSetterSetup(string name, Mockolate.Parameters.IParameterMatch? matcher1 = null, Mockolate.Parameters.IParameterMatch? matcher2 = null, Mockolate.Parameters.IParameterMatch? matcher3 = null) { } + public void Invoke(T1 k1, T2 k2, T3 k3, TValue value, object? rawKey1 = null, object? rawKey2 = null, object? rawKey3 = null) { } + public bool Matches(T1 value1, T2 value2, T3 value3) { } + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public override string ToString() { } + } + public sealed class RefStructIndexerSetterSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IRefStructIndexerSetterSetup, Mockolate.Setup.ISetup + { + public RefStructIndexerSetterSetup(string name, Mockolate.Parameters.IParameterMatch? matcher1 = null, Mockolate.Parameters.IParameterMatch? matcher2 = null, Mockolate.Parameters.IParameterMatch? matcher3 = null, Mockolate.Parameters.IParameterMatch? matcher4 = null) { } + public void Invoke(T1 k1, T2 k2, T3 k3, T4 k4, TValue value, object? rawKey1 = null, object? rawKey2 = null, object? rawKey3 = null, object? rawKey4 = null) { } + public bool Matches(T1 value1, T2 value2, T3 value3, T4 value4) { } + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public override string ToString() { } + } + public sealed class RefStructIndexerSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IRefStructIndexerSetup, Mockolate.Setup.ISetup + { + public RefStructIndexerSetup(string getterName, string setterName, Mockolate.Parameters.IParameterMatch? matcher = null) { } + public Mockolate.Setup.RefStructIndexerGetterSetup Getter { get; } + public Mockolate.Setup.RefStructIndexerSetterSetup Setter { get; } + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + } + public sealed class RefStructIndexerSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IRefStructIndexerSetup, Mockolate.Setup.ISetup + { + public RefStructIndexerSetup(string getterName, string setterName, Mockolate.Parameters.IParameterMatch? matcher1 = null, Mockolate.Parameters.IParameterMatch? matcher2 = null) { } + public Mockolate.Setup.RefStructIndexerGetterSetup Getter { get; } + public Mockolate.Setup.RefStructIndexerSetterSetup Setter { get; } + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + } + public sealed class RefStructIndexerSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IRefStructIndexerSetup, Mockolate.Setup.ISetup + { + public RefStructIndexerSetup(string getterName, string setterName, Mockolate.Parameters.IParameterMatch? matcher1 = null, Mockolate.Parameters.IParameterMatch? matcher2 = null, Mockolate.Parameters.IParameterMatch? matcher3 = null) { } + public Mockolate.Setup.RefStructIndexerGetterSetup Getter { get; } + public Mockolate.Setup.RefStructIndexerSetterSetup Setter { get; } + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + } + public sealed class RefStructIndexerSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IRefStructIndexerSetup, Mockolate.Setup.ISetup + { + public RefStructIndexerSetup(string getterName, string setterName, Mockolate.Parameters.IParameterMatch? matcher1 = null, Mockolate.Parameters.IParameterMatch? matcher2 = null, Mockolate.Parameters.IParameterMatch? matcher3 = null, Mockolate.Parameters.IParameterMatch? matcher4 = null) { } + public Mockolate.Setup.RefStructIndexerGetterSetup Getter { get; } + public Mockolate.Setup.RefStructIndexerSetterSetup Setter { get; } + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + } + public sealed class RefStructReturnMethodSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IRefStructReturnMethodSetup, Mockolate.Setup.ISetup + { + public RefStructReturnMethodSetup(string name, Mockolate.Parameters.IParameterMatch? matcher = null) { } + public bool HasReturnValue { get; } + public Mockolate.Parameters.IParameterMatch? GetMatcher1() { } + public TReturn Invoke(T value, System.Func? defaultFactory = null) { } + public bool Matches(T value) { } + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public override string ToString() { } + } + public sealed class RefStructReturnMethodSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IRefStructReturnMethodSetup, Mockolate.Setup.ISetup + { + public RefStructReturnMethodSetup(string name, Mockolate.Parameters.IParameterMatch? matcher1 = null, Mockolate.Parameters.IParameterMatch? matcher2 = null) { } + public bool HasReturnValue { get; } + public Mockolate.Parameters.IParameterMatch? GetMatcher1() { } + public Mockolate.Parameters.IParameterMatch? GetMatcher2() { } + public TReturn Invoke(T1 value1, T2 value2, System.Func? defaultFactory = null) { } + public bool Matches(T1 value1, T2 value2) { } + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public override string ToString() { } + } + public sealed class RefStructReturnMethodSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IRefStructReturnMethodSetup, Mockolate.Setup.ISetup + { + public RefStructReturnMethodSetup(string name, Mockolate.Parameters.IParameterMatch? matcher1 = null, Mockolate.Parameters.IParameterMatch? matcher2 = null, Mockolate.Parameters.IParameterMatch? matcher3 = null) { } + public bool HasReturnValue { get; } + public Mockolate.Parameters.IParameterMatch? GetMatcher1() { } + public Mockolate.Parameters.IParameterMatch? GetMatcher2() { } + public Mockolate.Parameters.IParameterMatch? GetMatcher3() { } + public TReturn Invoke(T1 value1, T2 value2, T3 value3, System.Func? defaultFactory = null) { } + public bool Matches(T1 value1, T2 value2, T3 value3) { } + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public override string ToString() { } + } + public sealed class RefStructReturnMethodSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IRefStructReturnMethodSetup, Mockolate.Setup.ISetup + { + public RefStructReturnMethodSetup(string name, Mockolate.Parameters.IParameterMatch? matcher1 = null, Mockolate.Parameters.IParameterMatch? matcher2 = null, Mockolate.Parameters.IParameterMatch? matcher3 = null, Mockolate.Parameters.IParameterMatch? matcher4 = null) { } + public bool HasReturnValue { get; } + public Mockolate.Parameters.IParameterMatch? GetMatcher1() { } + public Mockolate.Parameters.IParameterMatch? GetMatcher2() { } + public Mockolate.Parameters.IParameterMatch? GetMatcher3() { } + public Mockolate.Parameters.IParameterMatch? GetMatcher4() { } + public TReturn Invoke(T1 value1, T2 value2, T3 value3, T4 value4, System.Func? defaultFactory = null) { } + public bool Matches(T1 value1, T2 value2, T3 value3, T4 value4) { } + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public override string ToString() { } + } + public static class RefStructStorageHelper + { + public static Mockolate.Setup.IndexerValueStorage CreateStorage() { } + public static bool IsSlotStorageReady(Mockolate.Parameters.IRefStructProjectionMatch? projection) { } + public static void SetLeafValue(Mockolate.Setup.IndexerValueStorage leaf, TValue value) { } + public static bool TryGetLeafValue(Mockolate.Setup.IndexerValueStorage? leaf, out TValue value) { } + public static bool TryResolveKey(Mockolate.Parameters.IRefStructProjectionMatch? projection, T value, object? rawKey, out object key) { } + } + public sealed class RefStructVoidMethodSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IRefStructVoidMethodSetup, Mockolate.Setup.ISetup + { + public RefStructVoidMethodSetup(string name, Mockolate.Parameters.IParameterMatch? matcher = null) { } + public Mockolate.Parameters.IParameterMatch? GetMatcher1() { } + public void Invoke(T value) { } + public bool Matches(T value) { } + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public override string ToString() { } + } + public sealed class RefStructVoidMethodSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IRefStructVoidMethodSetup, Mockolate.Setup.ISetup + { + public RefStructVoidMethodSetup(string name, Mockolate.Parameters.IParameterMatch? matcher1 = null, Mockolate.Parameters.IParameterMatch? matcher2 = null) { } + public Mockolate.Parameters.IParameterMatch? GetMatcher1() { } + public Mockolate.Parameters.IParameterMatch? GetMatcher2() { } + public void Invoke(T1 value1, T2 value2) { } + public bool Matches(T1 value1, T2 value2) { } + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public override string ToString() { } + } + public sealed class RefStructVoidMethodSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IRefStructVoidMethodSetup, Mockolate.Setup.ISetup + { + public RefStructVoidMethodSetup(string name, Mockolate.Parameters.IParameterMatch? matcher1 = null, Mockolate.Parameters.IParameterMatch? matcher2 = null, Mockolate.Parameters.IParameterMatch? matcher3 = null) { } + public Mockolate.Parameters.IParameterMatch? GetMatcher1() { } + public Mockolate.Parameters.IParameterMatch? GetMatcher2() { } + public Mockolate.Parameters.IParameterMatch? GetMatcher3() { } + public void Invoke(T1 value1, T2 value2, T3 value3) { } + public bool Matches(T1 value1, T2 value2, T3 value3) { } + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public override string ToString() { } + } + public sealed class RefStructVoidMethodSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IRefStructVoidMethodSetup, Mockolate.Setup.ISetup + { + public RefStructVoidMethodSetup(string name, Mockolate.Parameters.IParameterMatch? matcher1 = null, Mockolate.Parameters.IParameterMatch? matcher2 = null, Mockolate.Parameters.IParameterMatch? matcher3 = null, Mockolate.Parameters.IParameterMatch? matcher4 = null) { } + public Mockolate.Parameters.IParameterMatch? GetMatcher1() { } + public Mockolate.Parameters.IParameterMatch? GetMatcher2() { } + public Mockolate.Parameters.IParameterMatch? GetMatcher3() { } + public Mockolate.Parameters.IParameterMatch? GetMatcher4() { } + public void Invoke(T1 value1, T2 value2, T3 value3, T4 value4) { } + public bool Matches(T1 value1, T2 value2, T3 value3, T4 value4) { } + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public override string ToString() { } + } + public abstract class ReturnMethodSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupCallbackBuilder, Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder, Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder, Mockolate.Setup.IReturnMethodSetupReturnBuilder, Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + protected ReturnMethodSetup(Mockolate.MockRegistry mockRegistry, string name) { } + public bool HasReturnCallbacks { get; } + public abstract bool Matches(); + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public virtual void TriggerCallbacks() { } + public bool TryGetReturnValue(out TReturn returnValue) { } + public class WithParameterCollection : Mockolate.Setup.ReturnMethodSetup + { + public WithParameterCollection(Mockolate.MockRegistry mockRegistry, string name) { } + public override bool Matches() { } + public override string ToString() { } + } + } + public abstract class ReturnMethodSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupCallbackBuilder, Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder, Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder, Mockolate.Setup.IReturnMethodSetupReturnBuilder, Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + protected ReturnMethodSetup(Mockolate.MockRegistry mockRegistry, string name) { } + public bool HasReturnCallbacks { get; } + public abstract bool Matches(T1 p1Value); + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public virtual void TriggerCallbacks(T1 parameter1) { } + public bool TryGetReturnValue(T1 p1, out TReturn returnValue) { } + public class WithLiteralValues : Mockolate.Setup.ReturnMethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupParameterIgnorer, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + public WithLiteralValues(Mockolate.MockRegistry mockRegistry, string name, T1 value1) { } + public override bool Matches(T1 p1Value) { } + public override string ToString() { } + } + public class WithParameterCollection : Mockolate.Setup.ReturnMethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupParameterIgnorer, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + public WithParameterCollection(Mockolate.MockRegistry mockRegistry, string name, Mockolate.Parameters.IParameterMatch parameter1) { } + public Mockolate.Parameters.IParameterMatch Parameter1 { get; } + public override bool Matches(T1 p1Value) { } + public override string ToString() { } + public override void TriggerCallbacks(T1 parameter1) { } + } + public class WithParameters : Mockolate.Setup.ReturnMethodSetup + { + public WithParameters(Mockolate.MockRegistry mockRegistry, string name, Mockolate.Parameters.IParameters parameters, string parameterName1) { } + public override bool Matches(T1 p1Value) { } + public override string ToString() { } + } + } + public abstract class ReturnMethodSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupCallbackBuilder, Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder, Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder, Mockolate.Setup.IReturnMethodSetupReturnBuilder, Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + protected ReturnMethodSetup(Mockolate.MockRegistry mockRegistry, string name) { } + public bool HasReturnCallbacks { get; } + public abstract bool Matches(T1 p1Value, T2 p2Value); + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public virtual void TriggerCallbacks(T1 parameter1, T2 parameter2) { } + public bool TryGetReturnValue(T1 p1, T2 p2, out TReturn returnValue) { } + public class WithLiteralValues : Mockolate.Setup.ReturnMethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupParameterIgnorer, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + public WithLiteralValues(Mockolate.MockRegistry mockRegistry, string name, T1 value1, T2 value2) { } + public override bool Matches(T1 p1Value, T2 p2Value) { } + public override string ToString() { } + } + public class WithParameterCollection : Mockolate.Setup.ReturnMethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupParameterIgnorer, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + public WithParameterCollection(Mockolate.MockRegistry mockRegistry, string name, Mockolate.Parameters.IParameterMatch parameter1, Mockolate.Parameters.IParameterMatch parameter2) { } + public Mockolate.Parameters.IParameterMatch Parameter1 { get; } + public Mockolate.Parameters.IParameterMatch Parameter2 { get; } + public override bool Matches(T1 p1Value, T2 p2Value) { } + public override string ToString() { } + public override void TriggerCallbacks(T1 parameter1, T2 parameter2) { } + } + public class WithParameters : Mockolate.Setup.ReturnMethodSetup + { + public WithParameters(Mockolate.MockRegistry mockRegistry, string name, Mockolate.Parameters.IParameters parameters, string parameterName1, string parameterName2) { } + public override bool Matches(T1 p1Value, T2 p2Value) { } + public override string ToString() { } + } + } + public abstract class ReturnMethodSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupCallbackBuilder, Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder, Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder, Mockolate.Setup.IReturnMethodSetupReturnBuilder, Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + protected ReturnMethodSetup(Mockolate.MockRegistry mockRegistry, string name) { } + public bool HasReturnCallbacks { get; } + public abstract bool Matches(T1 p1Value, T2 p2Value, T3 p3Value); + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public virtual void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3) { } + public bool TryGetReturnValue(T1 p1, T2 p2, T3 p3, out TReturn returnValue) { } + public class WithLiteralValues : Mockolate.Setup.ReturnMethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupParameterIgnorer, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + public WithLiteralValues(Mockolate.MockRegistry mockRegistry, string name, T1 value1, T2 value2, T3 value3) { } + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value) { } + public override string ToString() { } + } + public class WithParameterCollection : Mockolate.Setup.ReturnMethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupParameterIgnorer, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + public WithParameterCollection(Mockolate.MockRegistry mockRegistry, string name, Mockolate.Parameters.IParameterMatch parameter1, Mockolate.Parameters.IParameterMatch parameter2, Mockolate.Parameters.IParameterMatch parameter3) { } + public Mockolate.Parameters.IParameterMatch Parameter1 { get; } + public Mockolate.Parameters.IParameterMatch Parameter2 { get; } + public Mockolate.Parameters.IParameterMatch Parameter3 { get; } + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value) { } + public override string ToString() { } + public override void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3) { } + } + public class WithParameters : Mockolate.Setup.ReturnMethodSetup + { + public WithParameters(Mockolate.MockRegistry mockRegistry, string name, Mockolate.Parameters.IParameters parameters, string parameterName1, string parameterName2, string parameterName3) { } + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value) { } + public override string ToString() { } + } + } + public abstract class ReturnMethodSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupCallbackBuilder, Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder, Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder, Mockolate.Setup.IReturnMethodSetupReturnBuilder, Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + protected ReturnMethodSetup(Mockolate.MockRegistry mockRegistry, string name) { } + public bool HasReturnCallbacks { get; } + public abstract bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value); + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public virtual void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4) { } + public bool TryGetReturnValue(T1 p1, T2 p2, T3 p3, T4 p4, out TReturn returnValue) { } + public class WithLiteralValues : Mockolate.Setup.ReturnMethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupParameterIgnorer, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + public WithLiteralValues(Mockolate.MockRegistry mockRegistry, string name, T1 value1, T2 value2, T3 value3, T4 value4) { } + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value) { } + public override string ToString() { } + } + public class WithParameterCollection : Mockolate.Setup.ReturnMethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.IReturnMethodSetupParameterIgnorer, Mockolate.Setup.IReturnMethodSetupWithCallback, Mockolate.Setup.IReturnMethodSetup, Mockolate.Setup.ISetup + { + public WithParameterCollection(Mockolate.MockRegistry mockRegistry, string name, Mockolate.Parameters.IParameterMatch parameter1, Mockolate.Parameters.IParameterMatch parameter2, Mockolate.Parameters.IParameterMatch parameter3, Mockolate.Parameters.IParameterMatch parameter4) { } + public Mockolate.Parameters.IParameterMatch Parameter1 { get; } + public Mockolate.Parameters.IParameterMatch Parameter2 { get; } + public Mockolate.Parameters.IParameterMatch Parameter3 { get; } + public Mockolate.Parameters.IParameterMatch Parameter4 { get; } + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value) { } + public override string ToString() { } + public override void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4) { } + } + public class WithParameters : Mockolate.Setup.ReturnMethodSetup + { + public WithParameters(Mockolate.MockRegistry mockRegistry, string name, Mockolate.Parameters.IParameters parameters, string parameterName1, string parameterName2, string parameterName3, string parameterName4) { } + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value) { } + public override string ToString() { } + } + } + public class SpanWrapper + { + public SpanWrapper(System.Span span) { } + public T[] SpanValues { get; } + public static System.Span op_Implicit(Mockolate.Setup.SpanWrapper? wrapper) { } + public static Mockolate.Setup.SpanWrapper op_Implicit(System.Span span) { } + } + public abstract class VoidMethodSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetup, Mockolate.Setup.IVoidMethodSetupCallbackBuilder, Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder, Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder, Mockolate.Setup.IVoidMethodSetupReturnBuilder, Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder + { + protected VoidMethodSetup(Mockolate.MockRegistry mockRegistry, string name) { } + public abstract bool Matches(); + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public void TriggerCallbacks() { } + public class WithParameterCollection : Mockolate.Setup.VoidMethodSetup + { + public WithParameterCollection(Mockolate.MockRegistry mockRegistry, string name) { } + public override bool Matches() { } + public override string ToString() { } + } + } + public abstract class VoidMethodSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupCallbackBuilder, Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder, Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder, Mockolate.Setup.IVoidMethodSetupReturnBuilder, Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + public VoidMethodSetup(Mockolate.MockRegistry mockRegistry, string name) { } + public abstract bool Matches(T1 p1Value); + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public virtual void TriggerCallbacks(T1 parameter1) { } + public class WithLiteralValues : Mockolate.Setup.VoidMethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupParameterIgnorer, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + public WithLiteralValues(Mockolate.MockRegistry mockRegistry, string name, T1 value1) { } + public override bool Matches(T1 p1Value) { } + public override string ToString() { } + } + public class WithParameterCollection : Mockolate.Setup.VoidMethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupParameterIgnorer, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + public WithParameterCollection(Mockolate.MockRegistry mockRegistry, string name, Mockolate.Parameters.IParameterMatch parameter1) { } + public Mockolate.Parameters.IParameterMatch Parameter1 { get; } + public override bool Matches(T1 p1Value) { } + public override string ToString() { } + public override void TriggerCallbacks(T1 parameter1) { } + } + public class WithParameters : Mockolate.Setup.VoidMethodSetup + { + public WithParameters(Mockolate.MockRegistry mockRegistry, string name, Mockolate.Parameters.IParameters parameters, string parameterName1) { } + public override bool Matches(T1 p1Value) { } + public override string ToString() { } + } + } + public abstract class VoidMethodSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupCallbackBuilder, Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder, Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder, Mockolate.Setup.IVoidMethodSetupReturnBuilder, Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + public VoidMethodSetup(Mockolate.MockRegistry mockRegistry, string name) { } + public abstract bool Matches(T1 p1Value, T2 p2Value); + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public virtual void TriggerCallbacks(T1 parameter1, T2 parameter2) { } + public class WithLiteralValues : Mockolate.Setup.VoidMethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupParameterIgnorer, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + public WithLiteralValues(Mockolate.MockRegistry mockRegistry, string name, T1 value1, T2 value2) { } + public override bool Matches(T1 p1Value, T2 p2Value) { } + public override string ToString() { } + } + public class WithParameterCollection : Mockolate.Setup.VoidMethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupParameterIgnorer, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + public WithParameterCollection(Mockolate.MockRegistry mockRegistry, string name, Mockolate.Parameters.IParameterMatch parameter1, Mockolate.Parameters.IParameterMatch parameter2) { } + public Mockolate.Parameters.IParameterMatch Parameter1 { get; } + public Mockolate.Parameters.IParameterMatch Parameter2 { get; } + public override bool Matches(T1 p1Value, T2 p2Value) { } + public override string ToString() { } + public override void TriggerCallbacks(T1 parameter1, T2 parameter2) { } + } + public class WithParameters : Mockolate.Setup.VoidMethodSetup + { + public WithParameters(Mockolate.MockRegistry mockRegistry, string name, Mockolate.Parameters.IParameters parameters, string parameterName1, string parameterName2) { } + public override bool Matches(T1 p1Value, T2 p2Value) { } + public override string ToString() { } + } + } + public abstract class VoidMethodSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupCallbackBuilder, Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder, Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder, Mockolate.Setup.IVoidMethodSetupReturnBuilder, Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + public VoidMethodSetup(Mockolate.MockRegistry mockRegistry, string name) { } + public abstract bool Matches(T1 p1Value, T2 p2Value, T3 p3Value); + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public virtual void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3) { } + public class WithLiteralValues : Mockolate.Setup.VoidMethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupParameterIgnorer, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + public WithLiteralValues(Mockolate.MockRegistry mockRegistry, string name, T1 value1, T2 value2, T3 value3) { } + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value) { } + public override string ToString() { } + } + public class WithParameterCollection : Mockolate.Setup.VoidMethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupParameterIgnorer, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + public WithParameterCollection(Mockolate.MockRegistry mockRegistry, string name, Mockolate.Parameters.IParameterMatch parameter1, Mockolate.Parameters.IParameterMatch parameter2, Mockolate.Parameters.IParameterMatch parameter3) { } + public Mockolate.Parameters.IParameterMatch Parameter1 { get; } + public Mockolate.Parameters.IParameterMatch Parameter2 { get; } + public Mockolate.Parameters.IParameterMatch Parameter3 { get; } + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value) { } + public override string ToString() { } + public override void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3) { } + } + public class WithParameters : Mockolate.Setup.VoidMethodSetup + { + public WithParameters(Mockolate.MockRegistry mockRegistry, string name, Mockolate.Parameters.IParameters parameters, string parameterName1, string parameterName2, string parameterName3) { } + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value) { } + public override string ToString() { } + } + } + public abstract class VoidMethodSetup : Mockolate.Setup.MethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupCallbackBuilder, Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder, Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder, Mockolate.Setup.IVoidMethodSetupReturnBuilder, Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + public VoidMethodSetup(Mockolate.MockRegistry mockRegistry, string name) { } + public abstract bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value); + protected override bool MatchesInteraction(Mockolate.Interactions.IMethodInteraction interaction) { } + public bool SkipBaseClass(Mockolate.MockBehavior behavior) { } + public virtual void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4) { } + public class WithLiteralValues : Mockolate.Setup.VoidMethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupParameterIgnorer, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + public WithLiteralValues(Mockolate.MockRegistry mockRegistry, string name, T1 value1, T2 value2, T3 value3, T4 value4) { } + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value) { } + public override string ToString() { } + } + public class WithParameterCollection : Mockolate.Setup.VoidMethodSetup, Mockolate.Setup.IMethodSetup, Mockolate.Setup.ISetup, Mockolate.Setup.IVoidMethodSetupParameterIgnorer, Mockolate.Setup.IVoidMethodSetupWithCallback, Mockolate.Setup.IVoidMethodSetup + { + public WithParameterCollection(Mockolate.MockRegistry mockRegistry, string name, Mockolate.Parameters.IParameterMatch parameter1, Mockolate.Parameters.IParameterMatch parameter2, Mockolate.Parameters.IParameterMatch parameter3, Mockolate.Parameters.IParameterMatch parameter4) { } + public Mockolate.Parameters.IParameterMatch Parameter1 { get; } + public Mockolate.Parameters.IParameterMatch Parameter2 { get; } + public Mockolate.Parameters.IParameterMatch Parameter3 { get; } + public Mockolate.Parameters.IParameterMatch Parameter4 { get; } + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value) { } + public override string ToString() { } + public override void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4) { } + } + public class WithParameters : Mockolate.Setup.VoidMethodSetup + { + public WithParameters(Mockolate.MockRegistry mockRegistry, string name, Mockolate.Parameters.IParameters parameters, string parameterName1, string parameterName2, string parameterName3, string parameterName4) { } + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value) { } + public override string ToString() { } + } + } +} +namespace Mockolate.Verify +{ + public interface IAsyncVerificationResult : Mockolate.Verify.IVerificationResult + { + System.Threading.Tasks.Task VerifyAsync(System.Func predicate); + } + public interface IMockVerify : Mockolate.IInteractiveMock { } + public interface IVerificationResult + { + string Expectation { get; } + Mockolate.Interactions.IMockInteractions Interactions { get; } + bool Verify(System.Func predicate); + } + public interface IVerificationResult + { + TVerify Object { get; } + } + public class VerificationEventResult + { + public VerificationEventResult(TSubject subject, Mockolate.MockRegistry mockRegistry, string name) { } + public VerificationEventResult(TSubject subject, Mockolate.MockRegistry mockRegistry, int subscribeMemberId, int unsubscribeMemberId, string name) { } + public Mockolate.Verify.VerificationResult Subscribed() { } + public Mockolate.Verify.VerificationResult Unsubscribed() { } + } + public class VerificationIndexerGetterResult + { + public VerificationIndexerGetterResult(TSubject subject, Mockolate.MockRegistry mockRegistry, int getMemberId, Mockolate.Parameters.IParameterMatch match1, System.Func parametersDescription) { } + public Mockolate.Verify.VerificationResult Got() { } + } + public class VerificationIndexerGetterResult + { + public VerificationIndexerGetterResult(TSubject subject, Mockolate.MockRegistry mockRegistry, int getMemberId, Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, System.Func parametersDescription) { } + public Mockolate.Verify.VerificationResult Got() { } + } + public class VerificationIndexerGetterResult + { + public VerificationIndexerGetterResult(TSubject subject, Mockolate.MockRegistry mockRegistry, int getMemberId, Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, Mockolate.Parameters.IParameterMatch match3, System.Func parametersDescription) { } + public Mockolate.Verify.VerificationResult Got() { } + } + public class VerificationIndexerGetterResult + { + public VerificationIndexerGetterResult(TSubject subject, Mockolate.MockRegistry mockRegistry, int getMemberId, Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, Mockolate.Parameters.IParameterMatch match3, Mockolate.Parameters.IParameterMatch match4, System.Func parametersDescription) { } + public Mockolate.Verify.VerificationResult Got() { } + } + public class VerificationIndexerResult + { + public VerificationIndexerResult(TSubject subject, Mockolate.MockRegistry mockRegistry, System.Func gotPredicate, System.Func, bool> setPredicate, System.Func parametersDescription) { } + public VerificationIndexerResult(TSubject subject, Mockolate.MockRegistry mockRegistry, int getMemberId, int setMemberId, System.Func gotPredicate, System.Func, bool> setPredicate, System.Func parametersDescription) { } + public virtual Mockolate.Verify.VerificationResult Got() { } + public virtual Mockolate.Verify.VerificationResult Set(Mockolate.Parameters.IParameter value) { } + public virtual Mockolate.Verify.VerificationResult Set(TParameter value, [System.Runtime.CompilerServices.CallerArgumentExpression("value")] string doNotPopulateThisValue = "") { } + } + public sealed class VerificationIndexerResult : Mockolate.Verify.VerificationIndexerResult + { + public VerificationIndexerResult(TSubject subject, Mockolate.MockRegistry mockRegistry, int getMemberId, int setMemberId, Mockolate.Parameters.IParameterMatch match1, System.Func parametersDescription) { } + public override Mockolate.Verify.VerificationResult Got() { } + public override Mockolate.Verify.VerificationResult Set(Mockolate.Parameters.IParameter value) { } + public override Mockolate.Verify.VerificationResult Set(TParameter value, [System.Runtime.CompilerServices.CallerArgumentExpression("value")] string doNotPopulateThisValue = "") { } + } + public sealed class VerificationIndexerResult : Mockolate.Verify.VerificationIndexerResult + { + public VerificationIndexerResult(TSubject subject, Mockolate.MockRegistry mockRegistry, int getMemberId, int setMemberId, Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, System.Func parametersDescription) { } + public override Mockolate.Verify.VerificationResult Got() { } + public override Mockolate.Verify.VerificationResult Set(Mockolate.Parameters.IParameter value) { } + public override Mockolate.Verify.VerificationResult Set(TParameter value, [System.Runtime.CompilerServices.CallerArgumentExpression("value")] string doNotPopulateThisValue = "") { } + } + public sealed class VerificationIndexerResult : Mockolate.Verify.VerificationIndexerResult + { + public VerificationIndexerResult(TSubject subject, Mockolate.MockRegistry mockRegistry, int getMemberId, int setMemberId, Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, Mockolate.Parameters.IParameterMatch match3, System.Func parametersDescription) { } + public override Mockolate.Verify.VerificationResult Got() { } + public override Mockolate.Verify.VerificationResult Set(Mockolate.Parameters.IParameter value) { } + public override Mockolate.Verify.VerificationResult Set(TParameter value, [System.Runtime.CompilerServices.CallerArgumentExpression("value")] string doNotPopulateThisValue = "") { } + } + public sealed class VerificationIndexerResult : Mockolate.Verify.VerificationIndexerResult + { + public VerificationIndexerResult(TSubject subject, Mockolate.MockRegistry mockRegistry, int getMemberId, int setMemberId, Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, Mockolate.Parameters.IParameterMatch match3, Mockolate.Parameters.IParameterMatch match4, System.Func parametersDescription) { } + public override Mockolate.Verify.VerificationResult Got() { } + public override Mockolate.Verify.VerificationResult Set(Mockolate.Parameters.IParameter value) { } + public override Mockolate.Verify.VerificationResult Set(TParameter value, [System.Runtime.CompilerServices.CallerArgumentExpression("value")] string doNotPopulateThisValue = "") { } + } + public class VerificationIndexerSetterResult + { + public VerificationIndexerSetterResult(TSubject subject, Mockolate.MockRegistry mockRegistry, int setMemberId, Mockolate.Parameters.IParameterMatch match1, System.Func parametersDescription) { } + public Mockolate.Verify.VerificationResult Set(Mockolate.Parameters.IParameter value) { } + public Mockolate.Verify.VerificationResult Set(TParameter value, [System.Runtime.CompilerServices.CallerArgumentExpression("value")] string doNotPopulateThisValue = "") { } + } + public class VerificationIndexerSetterResult + { + public VerificationIndexerSetterResult(TSubject subject, Mockolate.MockRegistry mockRegistry, int setMemberId, Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, System.Func parametersDescription) { } + public Mockolate.Verify.VerificationResult Set(Mockolate.Parameters.IParameter value) { } + public Mockolate.Verify.VerificationResult Set(TParameter value, [System.Runtime.CompilerServices.CallerArgumentExpression("value")] string doNotPopulateThisValue = "") { } + } + public class VerificationIndexerSetterResult + { + public VerificationIndexerSetterResult(TSubject subject, Mockolate.MockRegistry mockRegistry, int setMemberId, Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, Mockolate.Parameters.IParameterMatch match3, System.Func parametersDescription) { } + public Mockolate.Verify.VerificationResult Set(Mockolate.Parameters.IParameter value) { } + public Mockolate.Verify.VerificationResult Set(TParameter value, [System.Runtime.CompilerServices.CallerArgumentExpression("value")] string doNotPopulateThisValue = "") { } + } + public class VerificationIndexerSetterResult + { + public VerificationIndexerSetterResult(TSubject subject, Mockolate.MockRegistry mockRegistry, int setMemberId, Mockolate.Parameters.IParameterMatch match1, Mockolate.Parameters.IParameterMatch match2, Mockolate.Parameters.IParameterMatch match3, Mockolate.Parameters.IParameterMatch match4, System.Func parametersDescription) { } + public Mockolate.Verify.VerificationResult Set(Mockolate.Parameters.IParameter value) { } + public Mockolate.Verify.VerificationResult Set(TParameter value, [System.Runtime.CompilerServices.CallerArgumentExpression("value")] string doNotPopulateThisValue = "") { } + } + public class VerificationPropertyGetterResult + { + public VerificationPropertyGetterResult(TSubject subject, Mockolate.MockRegistry mockRegistry, int getMemberId, string propertyName) { } + public Mockolate.Verify.VerificationResult Got() { } + } + public class VerificationPropertyResult + { + public VerificationPropertyResult(TSubject subject, Mockolate.MockRegistry mockRegistry, string propertyName) { } + public VerificationPropertyResult(TSubject subject, Mockolate.MockRegistry mockRegistry, int getMemberId, int setMemberId, string propertyName) { } + public Mockolate.Verify.VerificationResult Got() { } + public Mockolate.Verify.VerificationResult Set(Mockolate.Parameters.IParameter value) { } + public Mockolate.Verify.VerificationResult Set(TParameter value, [System.Runtime.CompilerServices.CallerArgumentExpression("value")] string doNotPopulateThisValue = "") { } + } + public class VerificationPropertySetterResult + { + public VerificationPropertySetterResult(TSubject subject, Mockolate.MockRegistry mockRegistry, int setMemberId, string propertyName) { } + public Mockolate.Verify.VerificationResult Set(Mockolate.Parameters.IParameter value) { } + public Mockolate.Verify.VerificationResult Set(TParameter value, [System.Runtime.CompilerServices.CallerArgumentExpression("value")] string doNotPopulateThisValue = "") { } + } + public static class VerificationResultExtensions + { + extension(Mockolate.Verify.VerificationResult? verificationResult) + { + public void AtLeast(int times) { } + public void AtLeastOnce() { } + public void AtLeastTwice() { } + public void AtMost(int times) { } + public void Between(int minimum, int maximum) { } + public void AtMostOnce() { } + public void AtMostTwice() { } + public void Exactly(int times) { } + public void Never() { } + public void Once() { } + public void Twice() { } + public void Times(System.Func predicate, [System.Runtime.CompilerServices.CallerArgumentExpression("predicate")] string doNotPopulateThisValue = "") { } + public void Then(params System.Func>[] orderedChecks) { } + } + } + public class VerificationResult : Mockolate.Verify.IVerificationResult, Mockolate.Verify.IVerificationResult + { + public VerificationResult(TVerify verify, Mockolate.Interactions.IMockInteractions interactions, System.Func predicate, System.Func expectation) { } + public VerificationResult(TVerify verify, Mockolate.Interactions.IMockInteractions interactions, System.Func predicate, string expectation) { } + public virtual Mockolate.Verify.VerificationResult WithCancellation(System.Threading.CancellationToken cancellationToken) { } + public virtual Mockolate.Verify.VerificationResult Within(System.TimeSpan timeout) { } + public class IgnoreParameters : Mockolate.Verify.VerificationResult + { + public Mockolate.Verify.VerificationResult AnyParameters() { } + } + } +} +namespace Mockolate.Web +{ + public class HttpFormDataValue + { + public HttpFormDataValue(string value) { } + public virtual bool Matches(string parameterValue) { } + public override string ToString() { } + public static Mockolate.Web.HttpFormDataValue op_Implicit(string value) { } + } + public class HttpHeaderValue + { + public HttpHeaderValue(string value) { } + public virtual bool Matches(string headerValue) { } + public override string ToString() { } + public static Mockolate.Web.HttpHeaderValue op_Implicit(string value) { } + } + public class HttpQueryParameterValue + { + public HttpQueryParameterValue(string value) { } + public virtual bool Matches(string parameterValue) { } + public override string ToString() { } + public static Mockolate.Web.HttpQueryParameterValue op_Implicit(string value) { } + } + public static class ItExtensions + { + public abstract class HttpContentParameterWrapper : Mockolate.Parameters.IParameter, Mockolate.Parameters.IParameterMatch, Mockolate.Parameters.IParameterWithCallback, Mockolate.Parameters.IParameter, Mockolate.Web.ItExtensions.IHttpContentParameter, Mockolate.Web.ItExtensions.IHttpHeaderParameter + { + protected HttpContentParameterWrapper(Mockolate.Web.ItExtensions.IHttpContentParameter parameter, System.Func parameterString) { } + public Mockolate.Parameters.IParameterWithCallback Do(System.Action callback) { } + public void InvokeCallbacks(System.Net.Http.HttpContent? value) { } + public bool Matches(System.Net.Http.HttpContent? value) { } + public override string ToString() { } + public Mockolate.Web.ItExtensions.IHttpContentParameter WithBytes(System.Func predicate, [System.Runtime.CompilerServices.CallerArgumentExpression("predicate")] string doNotPopulateThisValue = "") { } + public Mockolate.Web.ItExtensions.IHttpContentHeaderParameter WithHeaders([System.Runtime.CompilerServices.TupleElementNames(new string[] { + "Name", + "Value"})] System.Collections.Generic.IEnumerable> headers) { } + public Mockolate.Web.ItExtensions.IHttpContentParameter WithMediaType(string? mediaType) { } + public Mockolate.Web.ItExtensions.IHttpContentParameter WithString(System.Func predicate, [System.Runtime.CompilerServices.CallerArgumentExpression("predicate")] string doNotPopulateThisValue = "") { } + } + public interface IFormDataContentParameter : Mockolate.Parameters.IParameter, Mockolate.Parameters.IParameterWithCallback, Mockolate.Parameters.IParameter, Mockolate.Web.ItExtensions.IHttpContentParameter, Mockolate.Web.ItExtensions.IHttpHeaderParameter + { + Mockolate.Web.ItExtensions.IFormDataContentParameter Exactly(); + } + public interface IHttpContentHeaderParameter : Mockolate.Parameters.IParameter, Mockolate.Parameters.IParameterWithCallback, Mockolate.Parameters.IParameter, Mockolate.Web.ItExtensions.IHttpContentParameter, Mockolate.Web.ItExtensions.IHttpHeaderParameter + { + Mockolate.Web.ItExtensions.IHttpContentParameter IncludingRequestHeaders(); + } + public interface IHttpContentParameter : Mockolate.Parameters.IParameter, Mockolate.Parameters.IParameterWithCallback, Mockolate.Parameters.IParameter, Mockolate.Web.ItExtensions.IHttpHeaderParameter + { + Mockolate.Web.ItExtensions.IHttpContentParameter WithBytes(System.Func predicate, [System.Runtime.CompilerServices.CallerArgumentExpression("predicate")] string doNotPopulateThisValue = ""); + Mockolate.Web.ItExtensions.IHttpContentParameter WithMediaType(string? mediaType); + Mockolate.Web.ItExtensions.IHttpContentParameter WithString(System.Func predicate, [System.Runtime.CompilerServices.CallerArgumentExpression("predicate")] string doNotPopulateThisValue = ""); + } + public interface IHttpHeaderParameter + { + TParameter WithHeaders([System.Runtime.CompilerServices.TupleElementNames(new string[] { + "Name", + "Value"})] System.Collections.Generic.IEnumerable> headers); + } + public interface IHttpRequestMessageParameter : Mockolate.Parameters.IParameter, Mockolate.Parameters.IParameterWithCallback, Mockolate.Parameters.IParameter, Mockolate.Web.ItExtensions.IHttpHeaderParameter, Mockolate.Web.ItExtensions.IHttpRequestMessageParameter { } + public interface IHttpRequestMessageParameter : Mockolate.Parameters.IParameter, Mockolate.Parameters.IParameterWithCallback, Mockolate.Parameters.IParameter, Mockolate.Web.ItExtensions.IHttpHeaderParameter + { + TParameter WhoseContentIs(System.Action configureContent); + TParameter WhoseContentIs(string mediaType, System.Action? configureContent = null); + TParameter WhoseUriIs(System.Action configureUri); + TParameter WhoseUriIs(string uri, System.Action? configureUri = null); + } + public interface IStringContentBodyMatchingParameter : Mockolate.Parameters.IParameter, Mockolate.Parameters.IParameterWithCallback, Mockolate.Parameters.IParameter, Mockolate.Web.ItExtensions.IHttpContentParameter, Mockolate.Web.ItExtensions.IHttpHeaderParameter, Mockolate.Web.ItExtensions.IStringContentBodyParameter + { + Mockolate.Web.ItExtensions.IStringContentBodyParameter AsRegex(System.Text.RegularExpressions.RegexOptions options = 0, System.TimeSpan? timeout = default); + } + public interface IStringContentBodyParameter : Mockolate.Parameters.IParameter, Mockolate.Parameters.IParameterWithCallback, Mockolate.Parameters.IParameter, Mockolate.Web.ItExtensions.IHttpContentParameter, Mockolate.Web.ItExtensions.IHttpHeaderParameter + { + Mockolate.Web.ItExtensions.IStringContentBodyParameter Exactly(); + Mockolate.Web.ItExtensions.IStringContentBodyParameter IgnoringCase(); + } + public interface IUriParameter : Mockolate.Parameters.IParameter, Mockolate.Parameters.IParameterWithCallback, Mockolate.Parameters.IParameter + { + Mockolate.Web.ItExtensions.IUriParameter ForHttp(); + Mockolate.Web.ItExtensions.IUriParameter ForHttps(); + Mockolate.Web.ItExtensions.IUriParameter WithHost(string hostPattern); + Mockolate.Web.ItExtensions.IUriParameter WithPath(string pathPattern); + Mockolate.Web.ItExtensions.IUriParameter WithPort(int port); + Mockolate.Web.ItExtensions.IUriParameter WithQuery([System.Runtime.CompilerServices.TupleElementNames(new string[] { + "Key", + "Value"})] System.Collections.Generic.IEnumerable> parameters); + Mockolate.Web.ItExtensions.IUriParameter WithQuery(string queryString); + Mockolate.Web.ItExtensions.IUriParameter WithQuery(string key, Mockolate.Web.HttpQueryParameterValue value); + } + extension(Mockolate.It _) + { + Mockolate.Web.ItExtensions.IHttpContentParameter IsHttpContent(); + Mockolate.Web.ItExtensions.IHttpContentParameter IsHttpContent(string mediaType); + Mockolate.Web.ItExtensions.IHttpRequestMessageParameter IsHttpRequestMessage(System.Net.Http.HttpMethod? method = null); + Mockolate.Web.ItExtensions.IUriParameter IsUri(string? pattern = null); + } + extension(Mockolate.Web.ItExtensions.IHttpContentParameter parameter) + { + Mockolate.Web.ItExtensions.IHttpContentParameter WithBytes(byte[] bytes); + Mockolate.Web.ItExtensions.IFormDataContentParameter WithFormData(string key, Mockolate.Web.HttpFormDataValue value); + Mockolate.Web.ItExtensions.IFormDataContentParameter WithFormData([System.Runtime.CompilerServices.TupleElementNames(new string[] { + "Key", + "Value"})] System.Collections.Generic.IEnumerable> values); + Mockolate.Web.ItExtensions.IFormDataContentParameter WithFormData(string values); + Mockolate.Web.ItExtensions.IStringContentBodyParameter WithString(string expected); + Mockolate.Web.ItExtensions.IStringContentBodyMatchingParameter WithStringMatching(string pattern); + } + extension(Mockolate.Web.ItExtensions.IHttpHeaderParameter parameter) + where TParameter : notnull + { + TParameter WithHeaders(string name, Mockolate.Web.HttpHeaderValue value); + TParameter WithHeaders(string headers); + } + } +} \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Mockolate.SourceGenerators.Tests.csproj b/Tests/Mockolate.SourceGenerators.Tests/Mockolate.SourceGenerators.Tests.csproj index beca3921..d377d436 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Mockolate.SourceGenerators.Tests.csproj +++ b/Tests/Mockolate.SourceGenerators.Tests/Mockolate.SourceGenerators.Tests.csproj @@ -1,7 +1,7 @@  - net10.0 + net11.0 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 2f55e729..8ad9deb2 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 @@ -163,7 +163,10 @@ public HttpClient(global::Mockolate.MockBehavior behavior, global::System.Net.Ht #region System.Net.Http.HttpClient /// + [global::System.Runtime.Versioning.UnsupportedOSPlatform("android")] [global::System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [global::System.Runtime.Versioning.UnsupportedOSPlatform("ios")] + [global::System.Runtime.Versioning.UnsupportedOSPlatform("tvos")] public override global::System.Net.Http.HttpResponseMessage Send(global::System.Net.Http.HttpRequestMessage request, global::System.Threading.CancellationToken cancellationToken) { global::Mockolate.Setup.ReturnMethodSetup? methodSetup = null; diff --git a/global.json b/global.json index 9cfde950..802f0beb 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "10.0.300", + "version": "11.0.100-preview.7.26381.103", "rollForward": "latestMinor" } } From 02b3762917adb2698d455343cb9904cf3ccc617c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Fri, 4 Sep 2026 19:32:05 +0200 Subject: [PATCH 02/14] feat: detect C# union support and emit the ParameterArg union type Adds the opt-in switch and the building block for union-typed setup and verify parameters, without changing any generated mock yet. - The generator reads the effective language version and the MockolateUnionParameters build property. The property wins when set ("true" opts in on a preview compiler, anything else is the kill switch); otherwise unions are used once the host Roslyn ships C# 15 and the compilation targets it. Below that, nothing is emitted. - When enabled, a ParameterArg.g.cs is generated into the consuming assembly: a [Union] struct with the case types IParameter and T?, stored in typed slots (no boxing), with TryGetValue accessors and a ToParameterMatch() bridge to IParameterMatch. UnionAttribute is declared in that file only when neither the framework (it ships with .NET 11) nor the consuming assembly already declares it, so net48, netstandard2.0 and net8.0 consumers and PolySharp-style polyfills work. - build/Mockolate.props (packed as build and buildTransitive) makes the property visible to the generator; Tests/Directory.Build.props imports it so project references behave like the package. - Generator tests cover the detection matrix, the polyfill decision and the emitted text. The generator test project pins the minimum Roslyn, which predates unions, so the union conversions themselves are tested in Mockolate.Tests on net11.0 with the SDK compiler. --- .../MockGenerator.cs | 43 +++++ .../Sources/Sources.ParameterArg.cs | 169 ++++++++++++++++++ Source/Mockolate/Mockolate.csproj | 1 + Source/Mockolate/build/Mockolate.props | 10 ++ Tests/Directory.Build.props | 3 + .../TestHelpers/Generator.cs | 12 +- .../TestAnalyzerConfigOptionsProvider.cs | 24 +++ .../UnionParameterArgTests.cs | 104 +++++++++++ Tests/Mockolate.Tests/ParameterArgTests.cs | 155 ++++++++++++++++ 9 files changed, 518 insertions(+), 3 deletions(-) create mode 100644 Source/Mockolate.SourceGenerators/Sources/Sources.ParameterArg.cs create mode 100644 Source/Mockolate/build/Mockolate.props create mode 100644 Tests/Mockolate.SourceGenerators.Tests/TestHelpers/TestAnalyzerConfigOptionsProvider.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/UnionParameterArgTests.cs create mode 100644 Tests/Mockolate.Tests/ParameterArgTests.cs diff --git a/Source/Mockolate.SourceGenerators/MockGenerator.cs b/Source/Mockolate.SourceGenerators/MockGenerator.cs index 9a22ffe8..bcffcba8 100644 --- a/Source/Mockolate.SourceGenerators/MockGenerator.cs +++ b/Source/Mockolate.SourceGenerators/MockGenerator.cs @@ -1,6 +1,8 @@ using System.Collections.Immutable; using System.Text; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Text; using Mockolate.SourceGenerators.Entities; using Mockolate.SourceGenerators.Internals; @@ -51,6 +53,27 @@ void IIncrementalGenerator.Initialize(IncrementalGeneratorInitializationContext .Select(static (compilation, _) => HasAttribute(compilation, "System.Runtime.CompilerServices.OverloadResolutionPriorityAttribute")); + // Union-typed setup/verify arguments need C# 15 union conversions in the consuming compilation. + // Reduced to a bool so the union-dependent outputs only re-run when the answer flips. + IncrementalValueProvider hasUnionSupport = context.ParseOptionsProvider + .Combine(context.AnalyzerConfigOptionsProvider) + .Select(static (source, _) => HasUnionSupport(source.Left, source.Right)); + + // The attribute ships with .NET 11; older targets (or consumers polyfilling it themselves) decide + // whether the generated union type has to declare it. + IncrementalValueProvider hasUnionAttribute = context.CompilationProvider + .Select(static (compilation, _) => HasAttribute(compilation, + "System.Runtime.CompilerServices.UnionAttribute")); + + context.RegisterSourceOutput(hasUnionSupport.Combine(hasUnionAttribute), static (spc, source) => + { + if (source.Left) + { + spc.AddSource("ParameterArg.g.cs", + ToSource(Sources.Sources.ParameterArg(emitUnionAttributePolyfill: !source.Right))); + } + }); + // Naming step: cross-mock disambiguation. Cached as a unit; one NamedMock per emission. IncrementalValueProvider> namedMocksAggregate = collectedMocks .Select(static (arr, _) => CreateNamedMocks(arr)); @@ -163,6 +186,26 @@ static bool HasAttribute(Compilation c, string attributeName) (attributeSymbol.DeclaredAccessibility == Accessibility.Internal && SymbolEqualityComparer.Default.Equals(attributeSymbol.ContainingAssembly, c.Assembly))); } + + // The MockolateUnionParameters build property (made compiler-visible by build/Mockolate.props) wins when + // set: "true" opts in on a preview compiler, any other value is the kill switch. Otherwise unions are used once the + // host compiler has shipped C# 15 (the generator is compiled against an older Roslyn and cannot name + // LanguageVersion.CSharp15, hence the numeric check) and the compilation's effective language version + // includes it. LanguageVersion.Preview passes the numeric test, but only counts once the compiler is capable. + static bool HasUnionSupport(ParseOptions parseOptions, AnalyzerConfigOptionsProvider analyzerConfigOptions) + { + if (analyzerConfigOptions.GlobalOptions.TryGetValue("build_property.MockolateUnionParameters", + out string? configured) && + !string.IsNullOrWhiteSpace(configured)) + { + return string.Equals(configured.Trim(), "true", StringComparison.OrdinalIgnoreCase); + } + + const int csharp15 = 1500; + return parseOptions is CSharpParseOptions csharpParseOptions && + Enum.IsDefined(typeof(LanguageVersion), csharp15) && + (int)csharpParseOptions.LanguageVersion >= csharp15; + } } private static SourceText ToSource(string source) diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.ParameterArg.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.ParameterArg.cs new file mode 100644 index 00000000..dbdf5d2a --- /dev/null +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.ParameterArg.cs @@ -0,0 +1,169 @@ +using System.Text; + +namespace Mockolate.SourceGenerators.Sources; + +internal static partial class Sources +{ + /// + /// The union-typed setup/verify argument: a hand-written [Union] struct with the case types + /// IParameter<T> and T?, so that a setup overload can take a matcher or a literal value + /// through a single parameter. Stored in typed slots rather than a boxed object, so that a value type + /// T does not allocate. Only emitted when the compilation supports C# unions. + /// + /// + /// when neither the referenced framework nor the consuming assembly declares + /// System.Runtime.CompilerServices.UnionAttribute (it ships with .NET 11), so the file has to + /// declare it. + /// + public static string ParameterArg(bool emitUnionAttributePolyfill) + { + StringBuilder sb = InitializeBuilder(); + + sb.AppendLine("#nullable enable"); + sb.AppendLine(); + if (emitUnionAttributePolyfill) + { + sb.Append(""" + namespace System.Runtime.CompilerServices + { + /// + /// Polyfill for the attribute that marks a union type; the runtime ships it starting with .NET 11. + /// + [global::System.AttributeUsage(global::System.AttributeTargets.Class | global::System.AttributeTargets.Struct, AllowMultiple = false)] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal sealed class UnionAttribute : global::System.Attribute + { + } + } + + """); + } + + sb.Append(""" + namespace Mockolate + { + /// + /// A setup or verify argument that is either an It matcher + /// () or a literal value of type . + /// + /// + /// Both case types convert implicitly, so Setup.Method(42) and Setup.Method(It.IsAny<int>()) + /// bind to the same overload. A instance stands for the literal default(T). + /// + [global::System.Runtime.CompilerServices.Union] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal readonly struct ParameterArg + { + private const byte MatcherTag = 1; + private const byte LiteralTag = 2; + + private readonly global::Mockolate.Parameters.IParameter? _matcher; + private readonly T? _literal; + private readonly byte _tag; + + /// + /// Creates the matcher case. + /// + public ParameterArg(global::Mockolate.Parameters.IParameter matcher) + { + _matcher = matcher; + _literal = default; + _tag = MatcherTag; + } + + /// + /// Creates the literal value case. + /// + public ParameterArg(T? literal) + { + _matcher = null; + _literal = literal; + _tag = LiteralTag; + } + + /// + /// The contained matcher or literal value, boxed. Part of the union pattern; the generated mocks use the + /// typed accessors instead. + /// + public object? Value => _tag switch + { + MatcherTag => _matcher, + LiteralTag => _literal, + _ => null, + }; + + /// + /// unless this is the instance. + /// + public bool HasValue => _tag != 0; + + /// + /// when the argument is a literal value (including the instance). + /// + public bool IsLiteral => _tag != MatcherTag; + + /// + /// The literal value; default(T) for the matcher case and the instance. + /// + public T? Literal => _literal; + + /// + /// Gets the matcher, when this is the matcher case. + /// + public bool TryGetValue(out global::Mockolate.Parameters.IParameter? matcher) + { + matcher = _matcher; + return _tag == MatcherTag; + } + + /// + /// Gets the literal value, when this is the literal case. + /// + public bool TryGetValue(out T? literal) + { + literal = _literal; + return _tag == LiteralTag; + } + + /// + /// The for this argument: the matcher itself, + /// or an equality match for the literal value. + /// + public global::Mockolate.Parameters.IParameterMatch ToParameterMatch() + { + if (_tag != MatcherTag) + { + return (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(_literal!); + } + + if (_matcher is null) + { + return (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsNull("null"); + } + + return _matcher is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantAdapter(_matcher); + } + + /// + public override string ToString() => _tag switch + { + MatcherTag => _matcher?.ToString() ?? "null", + _ => _literal?.ToString() ?? "null", + }; + + private sealed class CovariantAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch + { + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + } + } + } + #nullable disable + """); + + return sb.ToString(); + } +} diff --git a/Source/Mockolate/Mockolate.csproj b/Source/Mockolate/Mockolate.csproj index 6a37bd4e..4c030af1 100644 --- a/Source/Mockolate/Mockolate.csproj +++ b/Source/Mockolate/Mockolate.csproj @@ -6,6 +6,7 @@ + diff --git a/Source/Mockolate/build/Mockolate.props b/Source/Mockolate/build/Mockolate.props new file mode 100644 index 00000000..6f2b5d36 --- /dev/null +++ b/Source/Mockolate/build/Mockolate.props @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/Tests/Directory.Build.props b/Tests/Directory.Build.props index 9695088f..74fede68 100644 --- a/Tests/Directory.Build.props +++ b/Tests/Directory.Build.props @@ -16,6 +16,9 @@ 701;1702;CA1845 + + + preview diff --git a/Tests/Mockolate.SourceGenerators.Tests/TestHelpers/Generator.cs b/Tests/Mockolate.SourceGenerators.Tests/TestHelpers/Generator.cs index 0e363def..b4fa523c 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/TestHelpers/Generator.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/TestHelpers/Generator.cs @@ -60,11 +60,17 @@ public static GeneratorResult RunWithReferences([StringSyntax("c#-test")] string MetadataReference[] externalReferences, params Type[] assemblyTypes) => RunCore([source,], DocumentationMode.Parse, [], externalReferences, assemblyTypes); + public static GeneratorResult Run([StringSyntax("c#-test")] string source, LanguageVersion languageVersion, + IReadOnlyDictionary? globalOptions) + => RunCore([source,], DocumentationMode.Parse, [], [], [], languageVersion, globalOptions); + private static GeneratorResult RunCore(string[] sources, DocumentationMode documentationMode, - string[] preprocessorSymbols, MetadataReference[] externalReferences, Type[] assemblyTypes) + string[] preprocessorSymbols, MetadataReference[] externalReferences, Type[] assemblyTypes, + LanguageVersion languageVersion = LanguageVersion.Latest, + IReadOnlyDictionary? globalOptions = null) { MockGenerator generator = new(); - CSharpParseOptions parseOptions = new CSharpParseOptions(LanguageVersion.Latest, documentationMode) + CSharpParseOptions parseOptions = new CSharpParseOptions(languageVersion, documentationMode) .WithPreprocessorSymbols(preprocessorSymbols); SyntaxTree[] syntaxTrees = sources .Select(s => CSharpSyntaxTree.ParseText(s, parseOptions)) @@ -80,7 +86,7 @@ private static GeneratorResult RunCore(string[] sources, DocumentationMode docum [generator.AsSourceGenerator(),], [], parseOptions, - null); + globalOptions is null ? null : new TestAnalyzerConfigOptionsProvider(globalOptions)); driver = driver.RunGeneratorsAndUpdateCompilation(compilation, out Compilation outputCompilation, out ImmutableArray diagnostics); diff --git a/Tests/Mockolate.SourceGenerators.Tests/TestHelpers/TestAnalyzerConfigOptionsProvider.cs b/Tests/Mockolate.SourceGenerators.Tests/TestHelpers/TestAnalyzerConfigOptionsProvider.cs new file mode 100644 index 00000000..3668012e --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/TestHelpers/TestAnalyzerConfigOptionsProvider.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; + +namespace Mockolate.SourceGenerators.Tests.TestHelpers; + +internal sealed class TestAnalyzerConfigOptionsProvider(IReadOnlyDictionary globalOptions) + : AnalyzerConfigOptionsProvider +{ + public override AnalyzerConfigOptions GlobalOptions { get; } = new Options(globalOptions); + + public override AnalyzerConfigOptions GetOptions(SyntaxTree tree) => Options.Empty; + + public override AnalyzerConfigOptions GetOptions(AdditionalText textFile) => Options.Empty; + + private sealed class Options(IReadOnlyDictionary values) : AnalyzerConfigOptions + { + public static readonly Options Empty = new(new Dictionary()); + + public override bool TryGetValue(string key, [NotNullWhen(true)] out string? value) + => values.TryGetValue(key, out value); + } +} diff --git a/Tests/Mockolate.SourceGenerators.Tests/UnionParameterArgTests.cs b/Tests/Mockolate.SourceGenerators.Tests/UnionParameterArgTests.cs new file mode 100644 index 00000000..0b5cdb92 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/UnionParameterArgTests.cs @@ -0,0 +1,104 @@ +using System.Collections.Generic; +using Microsoft.CodeAnalysis.CSharp; + +namespace Mockolate.SourceGenerators.Tests; + +// These tests compile against the pinned minimum Roslyn (MinimumRoslynVersion), which predates unions, so they +// can only check the emission and the plain C# validity of the generated struct. The union conversions themselves +// are covered by Mockolate.Tests on net11.0 with the SDK compiler. +public sealed class UnionParameterArgTests +{ + private const string UnionParametersProperty = "build_property.MockolateUnionParameters"; + private const string ParameterArgFile = "ParameterArg.g.cs"; + private const string PolyfillDeclaration = "internal sealed class UnionAttribute : global::System.Attribute"; + + private const string Source = """ + using System; + using Mockolate; + + namespace MyCode + { + public class Program + { + public static void Main(string[] args) + { + _ = IMyInterface.CreateMock(); + } + } + + public interface IMyInterface + { + bool MyFunc(int value); + } + } + """; + + [Fact] + public async Task WithoutUnionSupport_ShouldNotEmitParameterArg() + { + GeneratorResult result = Generator.Run(Source, LanguageVersion.CSharp14, null); + + await That(result.Sources.Keys).DoesNotContain(ParameterArgFile); + await That(result.Sources.Values).None().Satisfy(x => x!.Contains("ParameterArg")); + } + + [Fact] + public async Task WithPreviewLanguageVersion_WithoutProperty_ShouldFollowCompilerCapability() + { + bool compilerShipsCSharp15 = Enum.IsDefined(typeof(LanguageVersion), 1500); + + GeneratorResult result = Generator.Run(Source, LanguageVersion.Preview, null); + + await That(result.Sources.ContainsKey(ParameterArgFile)).IsEqualTo(compilerShipsCSharp15); + } + + [Theory] + [InlineData("false")] + [InlineData("False")] + [InlineData("no")] + public async Task WithPropertyNotTrue_ShouldNotEmitParameterArg(string value) + { + GeneratorResult result = Generator.Run(Source, LanguageVersion.Preview, + new Dictionary { [UnionParametersProperty] = value, }); + + await That(result.Sources.Keys).DoesNotContain(ParameterArgFile); + } + + [Theory] + [InlineData("true")] + [InlineData("TRUE")] + [InlineData(" true ")] + public async Task WithPropertyTrue_ShouldEmitParameterArg_EvenBelowCSharp15(string value) + { + GeneratorResult result = Generator.Run(Source, LanguageVersion.CSharp14, + new Dictionary { [UnionParametersProperty] = value, }); + + await That(result.Sources.Keys).Contains(ParameterArgFile); + await That(result.Sources[ParameterArgFile]) + .Contains("[global::System.Runtime.CompilerServices.Union]").And + .Contains("internal readonly struct ParameterArg"); + await That(result.Diagnostics).IsEmpty(); + } + + [Fact] + public async Task WhenTheFrameworkDeclaresUnionAttribute_ShouldNotEmitThePolyfill() + { + // The test compilation references the current runtime, which ships the attribute. + GeneratorResult result = Generator.Run(Source, LanguageVersion.Preview, + new Dictionary { [UnionParametersProperty] = "true", }); + + await That(result.Sources[ParameterArgFile]).DoesNotContain(PolyfillDeclaration); + await That(result.Diagnostics).IsEmpty(); + } + + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task ParameterArgSource_ShouldContainThePolyfillOnlyWhenRequested(bool emitPolyfill) + { + string source = Sources.Sources.ParameterArg(emitPolyfill); + + await That(source.Contains(PolyfillDeclaration)).IsEqualTo(emitPolyfill); + await That(source).Contains("internal readonly struct ParameterArg"); + } +} diff --git a/Tests/Mockolate.Tests/ParameterArgTests.cs b/Tests/Mockolate.Tests/ParameterArgTests.cs new file mode 100644 index 00000000..701de692 --- /dev/null +++ b/Tests/Mockolate.Tests/ParameterArgTests.cs @@ -0,0 +1,155 @@ +#if NET11_0_OR_GREATER +using Mockolate.Parameters; + +namespace Mockolate.Tests; + +// The generated ParameterArg union is only emitted for this target (C# preview with MockolateUnionParameters +// enabled), so these tests exercise the real union conversions. +public sealed class ParameterArgTests +{ + [Fact] + public async Task LiteralValue_ShouldConvertImplicitly() + { + ParameterArg sut = 42; + + await That(sut.IsLiteral).IsTrue(); + await That(sut.HasValue).IsTrue(); + await That(sut.Literal).IsEqualTo(42); + await That(sut.TryGetValue(out int literal)).IsTrue(); + await That(literal).IsEqualTo(42); + await That(sut.TryGetValue(out IParameter? _)).IsFalse(); + await That(sut.Value).IsEqualTo(42); + } + + [Fact] + public async Task TypedNullLiteral_ShouldBeTheLiteralCase() + { + string? value = null; + + ParameterArg sut = value; + + await That(sut.IsLiteral).IsTrue(); + await That(sut.HasValue).IsTrue(); + await That(sut.Literal).IsNull(); + await That(sut.ToParameterMatch().Matches(null!)).IsTrue(); + await That(sut.ToParameterMatch().Matches("foo")).IsFalse(); + } + + [Fact] + public async Task NullableValueTypeLiteral_ShouldBeTheLiteralCase() + { + ParameterArg sut = (int?)null; + + await That(sut.IsLiteral).IsTrue(); + await That(sut.HasValue).IsTrue(); + await That(sut.Literal).IsNull(); + await That(sut.ToParameterMatch().Matches(null)).IsTrue(); + await That(sut.ToParameterMatch().Matches(1)).IsFalse(); + } + + [Fact] + public async Task Matcher_ShouldConvertImplicitly() + { + IParameter matcher = It.IsInRange(1, 3); + + ParameterArg sut = matcher; + + await That(sut.IsLiteral).IsFalse(); + await That(sut.HasValue).IsTrue(); + await That(sut.TryGetValue(out IParameter? result)).IsTrue(); + await That(result).IsSameAs(matcher); + await That(sut.TryGetValue(out int _)).IsFalse(); + } + + [Fact] + public async Task CovariantMatcher_ShouldConvertToTheMatcherCase() + { + ParameterArg sut = It.IsAny(); + + await That(sut.IsLiteral).IsFalse(); + await That(sut.ToParameterMatch().Matches("foo")).IsTrue(); + await That(sut.ToParameterMatch().Matches(42)).IsFalse(); + } + + [Fact] + public async Task Default_ForReferenceType_ShouldBeTheLiteralNull() + { + ParameterArg sut = default; + + await That(sut.HasValue).IsFalse(); + await That(sut.IsLiteral).IsTrue(); + await That(sut.Literal).IsNull(); + await That(sut.Value).IsNull(); + await That(sut.ToParameterMatch().Matches(null!)).IsTrue(); + await That(sut.ToParameterMatch().Matches("foo")).IsFalse(); + } + + [Fact] + public async Task Default_ForValueType_ShouldBeTheLiteralDefaultValue() + { + ParameterArg sut = default; + + await That(sut.HasValue).IsFalse(); + await That(sut.IsLiteral).IsTrue(); + await That(sut.Literal).IsEqualTo(0); + await That(sut.ToParameterMatch().Matches(0)).IsTrue(); + await That(sut.ToParameterMatch().Matches(1)).IsFalse(); + } + + [Fact] + public async Task NullableParameter_ShouldAcceptNullAndBothCases() + { + static string Describe(ParameterArg? arg) + => arg is null ? "none" : arg.Value.IsLiteral ? $"literal:{arg.Value.Literal}" : "matcher"; + + await That(Describe(null)).IsEqualTo("none"); + await That(Describe("foo")).IsEqualTo("literal:foo"); + await That(Describe(It.IsAny())).IsEqualTo("matcher"); + } + + [Fact] + public async Task ToParameterMatch_ForLiteral_ShouldMatchOnEquality() + { + ParameterArg sut = 5; + + IParameterMatch result = sut.ToParameterMatch(); + + await That(result.Matches(5)).IsTrue(); + await That(result.Matches(6)).IsFalse(); + } + + [Fact] + public async Task ToParameterMatch_ForDirectMatcher_ShouldReturnTheSameInstance() + { + IParameter matcher = It.IsAny(); + ParameterArg sut = matcher; + + IParameterMatch result = sut.ToParameterMatch(); + + await That(result).IsSameAs(matcher); + } + + [Fact] + public async Task ToParameterMatch_ForNullMatcher_ShouldMatchNull() + { + ParameterArg sut = new((IParameter)null!); + + IParameterMatch result = sut.ToParameterMatch(); + + await That(result.Matches(null!)).IsTrue(); + await That(result.Matches("foo")).IsFalse(); + } + + [Fact] + public async Task ToString_ShouldDescribeTheContent() + { + ParameterArg literal = 42; + ParameterArg matcher = It.IsAny(); + ParameterArg none = default; + + await That(literal.ToString()).IsEqualTo("42"); + await That(matcher.ToString()).IsEqualTo(It.IsAny().ToString()); + await That(none.ToString()).IsEqualTo("null"); + } +} +#endif From 7d3e0ba636dce56e973ca82b9a10d16945e97ffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Fri, 4 Sep 2026 20:28:59 +0200 Subject: [PATCH 03/14] feat: union-typed setup and verify overloads for methods When union support is detected, every method whose name is unique on the mocked type and that has value-capable parameters gets one Setup and one Verify overload per assignment of its parameters to either ParameterArg? (an It matcher or a literal value; null and default stand for the literal default) or Func (a predicate forwarded to It.Satisfies together with the caller's argument text). The count stays at 2^n for n eligible parameters, the same as today's matcher/value set, so predicates come for free. Without union support the generator output is unchanged. Rules that keep the surface sound: - Overloaded method groups (including a generic sibling) keep the classic set: a union conversion loses to the identity and numeric conversions of a sibling, so Setup.M(5) on M(int)/M(long) would be ambiguous. - Delegate-typed parameters offer the raw delegate instead of a predicate, because a lambda never converts to a union type. - ref/out/in and Span parameters keep their matcher slot. - Generic methods, params methods and ref-struct pipelines keep the classic overloads: a union slot hides the type argument from type inference, and a params slot cannot survive inside a union type. - Above four parameters only the all-union overload is emitted. - Priorities mirror the classic set (all-union int.MaxValue, object-typed slots below IParameters, predicate combinations by union count), so null and default arguments still bind to the union overload. - All-literal calls keep the WithLiteralValues / literal VerifyMethod fast paths at runtime; everything else uses ToParameterMatch(). ParameterArg.g.cs now also polyfills OverloadResolutionPriorityAttribute and CallerArgumentExpressionAttribute where the framework lacks them, and in union mode every overload set of the compilation carries priorities, so union mode works the same on net48, netstandard2.0 and net8.0. Generators cannot see each other's output, so a project that gets those two attributes from PolySharp sets MockolateUnionAttributePolyfills=false (or lists the attribute names it provides itself); UnionAttribute keeps following the compilation. Tests: union-mode snapshot scenarios (classic scenarios pinned to C# 14 so they never flip), generator tests for the overload shapes and the classic fallbacks, and Mockolate.Tests on net11.0, where the whole existing suite now runs against the union overloads plus dedicated tests for predicates, null, default, delegate-typed, optional, object and out parameters, overloaded groups, scenarios, verify AnyParameters and a delegate mock. --- .../Entities/Type.cs | 4 + .../MockGenerator.cs | 92 +- .../Sources/Sources.MockClass.Unions.cs | 632 ++ .../Sources/Sources.MockClass.cs | 79 +- .../Sources/Sources.MockCombination.cs | 23 +- .../Sources/Sources.MockDelegate.cs | 190 +- .../Sources/Sources.ParameterArg.cs | 79 +- Source/Mockolate/build/Mockolate.props | 5 + .../MethodSetups.g.cs | 771 ++ .../Mock.ComprehensiveDelegate.g.cs | 491 ++ .../Mock.g.cs | 133 + .../MockBehaviorExtensions.g.cs | 285 + .../ParameterArg.g.cs | 133 + .../ReturnsThrowsAsyncExtensions.g.cs | 156 + .../ActionFunc.g.cs | 34 + .../IndexerSetups.g.cs | 1618 ++++ .../MethodSetups.g.cs | 3557 +++++++++ .../Mock.IComprehensiveInterface.g.cs | 7030 +++++++++++++++++ .../Mock.g.cs | 133 + .../MockBehaviorExtensions.g.cs | 285 + .../ParameterArg.g.cs | 133 + .../ReturnsThrowsAsyncExtensions.g.cs | 288 + .../Mock.HttpClient.g.cs | 1823 +++++ .../Mock.HttpMessageHandler.g.cs | 1506 ++++ .../HttpClient_CanBeCreated_Unions/Mock.g.cs | 133 + .../MockBehaviorExtensions.g.cs | 301 + .../ParameterArg.g.cs | 133 + .../Mock.IKeywordEdgeCases.g.cs | 1541 ++++ .../Mock.g.cs | 133 + .../MockBehaviorExtensions.g.cs | 285 + .../ParameterArg.g.cs | 133 + .../Snapshot/MockGenerationSnapshotTests.cs | 52 +- .../Snapshot/SnapshotScenario.cs | 3 +- .../TestHelpers/Generator.cs | 5 + .../UnionOverloadTests.cs | 210 + .../UnionParameterArgTests.cs | 2 +- Tests/Mockolate.Tests/UnionSetupTests.cs | 268 + 37 files changed, 22543 insertions(+), 136 deletions(-) create mode 100644 Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.Unions.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/MethodSetups.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/Mock.ComprehensiveDelegate.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/Mock.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/MockBehaviorExtensions.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/ParameterArg.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/ReturnsThrowsAsyncExtensions.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ActionFunc.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/IndexerSetups.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/MethodSetups.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/Mock.IComprehensiveInterface.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/Mock.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/MockBehaviorExtensions.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ParameterArg.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ReturnsThrowsAsyncExtensions.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpClient.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpMessageHandler.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/MockBehaviorExtensions.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/ParameterArg.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.IKeywordEdgeCases.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/MockBehaviorExtensions.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/ParameterArg.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/UnionOverloadTests.cs create mode 100644 Tests/Mockolate.Tests/UnionSetupTests.cs diff --git a/Source/Mockolate.SourceGenerators/Entities/Type.cs b/Source/Mockolate.SourceGenerators/Entities/Type.cs index e32f5a7d..613467db 100644 --- a/Source/Mockolate.SourceGenerators/Entities/Type.cs +++ b/Source/Mockolate.SourceGenerators/Entities/Type.cs @@ -49,11 +49,15 @@ typeSymbol is INamedTypeSymbol // setup pipeline for parameters that cannot flow through the regular IParameter path // on TFMs predating C# 13's `allows ref struct` anti-constraint. IsRefStruct = typeSymbol.IsRefLikeType; + // A lambda never converts to a union type, so union-mode setups keep the raw delegate type as the + // value alternative of a delegate-typed parameter instead of offering a predicate overload. + IsDelegate = typeSymbol.TypeKind == TypeKind.Delegate; } public bool IsFormattable { get; } public bool CanBeNullable { get; } public bool IsRefStruct { get; } + public bool IsDelegate { get; } public SpecialType SpecialType { get; } public SpecialGenericType SpecialGenericType { get; } public EquatableArray? TupleTypes { get; } diff --git a/Source/Mockolate.SourceGenerators/MockGenerator.cs b/Source/Mockolate.SourceGenerators/MockGenerator.cs index bcffcba8..756097ee 100644 --- a/Source/Mockolate.SourceGenerators/MockGenerator.cs +++ b/Source/Mockolate.SourceGenerators/MockGenerator.cs @@ -59,21 +59,45 @@ void IIncrementalGenerator.Initialize(IncrementalGeneratorInitializationContext .Combine(context.AnalyzerConfigOptionsProvider) .Select(static (source, _) => HasUnionSupport(source.Left, source.Right)); - // The attribute ships with .NET 11; older targets (or consumers polyfilling it themselves) decide - // whether the generated union type has to declare it. - IncrementalValueProvider hasUnionAttribute = context.CompilationProvider - .Select(static (compilation, _) => HasAttribute(compilation, - "System.Runtime.CompilerServices.UnionAttribute")); - - context.RegisterSourceOutput(hasUnionSupport.Combine(hasUnionAttribute), static (spc, source) => + // The union-mode surface needs three compiler-recognised attributes that older frameworks lack + // (UnionAttribute: .NET 11, OverloadResolutionPriorityAttribute: .NET 9, CallerArgumentExpressionAttribute: + // .NET 6). Whatever the referenced framework or the consuming assembly does not declare is polyfilled next + // to the generated union type, so that union mode works on every target a C# 15 compiler can build. The + // compilation cannot show the output of other generators (PolySharp), so MockolateUnionAttributePolyfills + // names the attributes the project already gets elsewhere: "false" stands for the two that PolySharp ships. + IncrementalValueProvider<(bool Union, bool Priority, bool CallerArgumentExpression)> hasUnionAttributes = + context.CompilationProvider + .Combine(context.AnalyzerConfigOptionsProvider) + .Select(static (source, _) => + { + HashSet provided = ProvidedUnionAttributes(source.Right); + return ( + provided.Contains("UnionAttribute") || + HasAttribute(source.Left, "System.Runtime.CompilerServices.UnionAttribute"), + provided.Contains("OverloadResolutionPriorityAttribute") || + HasAttribute(source.Left, "System.Runtime.CompilerServices.OverloadResolutionPriorityAttribute"), + provided.Contains("CallerArgumentExpressionAttribute") || + HasAttribute(source.Left, "System.Runtime.CompilerServices.CallerArgumentExpressionAttribute")); + }); + + context.RegisterSourceOutput(hasUnionSupport.Combine(hasUnionAttributes), static (spc, source) => { if (source.Left) { spc.AddSource("ParameterArg.g.cs", - ToSource(Sources.Sources.ParameterArg(emitUnionAttributePolyfill: !source.Right))); + ToSource(Sources.Sources.ParameterArg( + emitUnionAttributePolyfill: !source.Right.Union, + emitOverloadResolutionPriorityPolyfill: !source.Right.Priority, + emitCallerArgumentExpressionPolyfill: !source.Right.CallerArgumentExpression))); } }); + // In union mode ParameterArg.g.cs guarantees OverloadResolutionPriorityAttribute, so every overload set of + // the compilation (union-typed or classic) can carry priorities; without union mode nothing changes. + IncrementalValueProvider canUseOverloadResolutionPriority = hasOverloadResolutionPriority + .Combine(hasUnionSupport) + .Select(static (source, _) => source.Left || source.Right); + // Naming step: cross-mock disambiguation. Cached as a unit; one NamedMock per emission. IncrementalValueProvider> namedMocksAggregate = collectedMocks .Select(static (arr, _) => CreateNamedMocks(arr)); @@ -83,8 +107,8 @@ void IIncrementalGenerator.Initialize(IncrementalGeneratorInitializationContext // Per-mock source output: cache hit when the NamedMock is identity-equal to last run. context.RegisterSourceOutput( - perMock.Combine(hasOverloadResolutionPriority), - static (spc, source) => EmitMockFile(spc, source.Left, source.Right)); + perMock.Combine(canUseOverloadResolutionPriority).Combine(hasUnionSupport), + static (spc, source) => EmitMockFile(spc, source.Left.Left, source.Left.Right, source.Right)); // As bridge extensions across (a, b) pairs. Cross-mock dedup; one file. IncrementalValueProvider> asPairs = namedMocksAggregate @@ -104,7 +128,7 @@ void IIncrementalGenerator.Initialize(IncrementalGeneratorInitializationContext .Select(static (arr, _) => CollectIndexerSetupKeys(arr)); context.RegisterSourceOutput( - indexerSetupKeys.Combine(hasOverloadResolutionPriority), + indexerSetupKeys.Combine(canUseOverloadResolutionPriority), static (spc, source) => { if (source.Left.Count == 0) @@ -187,6 +211,39 @@ static bool HasAttribute(Compilation c, string attributeName) SymbolEqualityComparer.Default.Equals(attributeSymbol.ContainingAssembly, c.Assembly))); } + // MockolateUnionAttributePolyfills: "false" means the project gets OverloadResolutionPriorityAttribute and + // CallerArgumentExpressionAttribute from another generator (PolySharp); any other value is a ';'-separated + // list of attribute names (with or without namespace) that must not be polyfilled. + static HashSet ProvidedUnionAttributes(AnalyzerConfigOptionsProvider analyzerConfigOptions) + { + HashSet provided = new(StringComparer.OrdinalIgnoreCase); + if (!analyzerConfigOptions.GlobalOptions.TryGetValue("build_property.MockolateUnionAttributePolyfills", + out string? configured) || + string.IsNullOrWhiteSpace(configured)) + { + return provided; + } + + if (string.Equals(configured.Trim(), "false", StringComparison.OrdinalIgnoreCase)) + { + provided.Add("OverloadResolutionPriorityAttribute"); + provided.Add("CallerArgumentExpressionAttribute"); + return provided; + } + + foreach (string name in configured.Split(';')) + { + string trimmed = name.Trim(); + int lastDot = trimmed.LastIndexOf('.'); + if (trimmed.Length > 0 && !string.Equals(trimmed, "true", StringComparison.OrdinalIgnoreCase)) + { + provided.Add(lastDot < 0 ? trimmed : trimmed.Substring(lastDot + 1)); + } + } + + return provided; + } + // The MockolateUnionParameters build property (made compiler-visible by build/Mockolate.props) wins when // set: "true" opts in on a preview compiler, any other value is the kill switch. Otherwise unions are used once the // host compiler has shipped C# 15 (the generator is compiled against an older Roslyn and cannot name @@ -535,15 +592,18 @@ static void AddIfNew(HashSet set, List } } - private static void EmitMockFile(SourceProductionContext context, NamedMock named, bool hasOverloadResolutionPriority) + private static void EmitMockFile(SourceProductionContext context, NamedMock named, bool hasOverloadResolutionPriority, + bool hasUnionSupport) { string fileName = named.FileName; Class @class = named.Mock; + // hasOverloadResolutionPriority already accounts for the polyfill that ParameterArg.g.cs emits in union mode. + bool useUnionOverloads = hasUnionSupport; if (@class is MockClass { Delegate: not null, } mockClass) { context.AddSource($"Mock.{fileName}.g.cs", - ToSource(Sources.Sources.MockDelegate(named.ParentName, mockClass, mockClass.Delegate))); + ToSource(Sources.Sources.MockDelegate(named.ParentName, mockClass, mockClass.Delegate, useUnionOverloads))); return; } @@ -561,7 +621,8 @@ private static void EmitMockFile(SourceProductionContext context, NamedMock name } context.AddSource($"Mock.{fileName}.g.cs", - ToSource(Sources.Sources.MockClass(named.ParentName, @class, hasOverloadResolutionPriority, hiddenBaseArr))); + ToSource(Sources.Sources.MockClass(named.ParentName, @class, hasOverloadResolutionPriority, hiddenBaseArr, + useUnionOverloads))); return; } @@ -573,7 +634,8 @@ private static void EmitMockFile(SourceProductionContext context, NamedMock name } context.AddSource($"Mock.{fileName}.g.cs", - ToSource(Sources.Sources.MockCombinationClass(fileName, named.ParentName, @class, additionalArr))); + ToSource(Sources.Sources.MockCombinationClass(fileName, named.ParentName, @class, additionalArr, + useUnionOverloads))); } private static bool IsValidMockDeclaration(MockClass mockClass) diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.Unions.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.Unions.cs new file mode 100644 index 00000000..8ca2c4e2 --- /dev/null +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.Unions.cs @@ -0,0 +1,632 @@ +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.CodeAnalysis; +using Mockolate.SourceGenerators.Entities; +using Type = Mockolate.SourceGenerators.Entities.Type; + +namespace Mockolate.SourceGenerators.Sources; + +/// +/// Union mode for the per-method setup and verify overloads. When the consuming compilation supports C# unions, +/// the classic matcher/value overload set (one overload per matcher-or-value assignment of the parameters) is +/// replaced by one overload per union-or-predicate assignment: a ParameterArg<T>? slot accepts an +/// It matcher or a literal value, a Func<T, bool> slot accepts a predicate. The overload count +/// stays at 2^n for n eligible parameters, but predicates become available at every call site. +/// +internal static partial class Sources +{ + /// + /// How one parameter slot is rendered in a union-mode overload. + /// + private enum UnionSlot : byte + { + /// + /// The parameter cannot carry a literal value (ref/out, Span): rendered exactly like the classic + /// matcher slot. + /// + Fixed, + + /// + /// ParameterArg<T>?: an It matcher or a literal value; and + /// stand for the literal default value. + /// + Union, + + /// + /// Func<T, bool>, forwarded to It.Satisfies together with the caller's argument expression. + /// + Predicate, + + /// + /// The raw delegate type of a delegate-typed parameter: lambdas never convert to a union, so this keeps + /// Setup.Register(x => x > 0) binding as a literal value instead of being mistaken for a predicate. + /// + RawDelegate, + } + + /// + /// Whether gets the union-mode overload set instead of the classic one. + /// Only methods whose name is unique on the mocked type qualify (, see + /// ): a union conversion loses to the identity and numeric conversions of a + /// sibling overload, so Setup.M(5) on M(int)/M(long) would be ambiguous or bind to the + /// wrong method. Generic methods keep the classic set because a union slot hides the type argument from type + /// inference (Setup.Method(1, "x") would need explicit type arguments); params methods keep it + /// because a params T[] value slot cannot survive inside a union type; ref-struct pipelines have no + /// value overloads at all. + /// + private static bool UseUnionOverloads(Method method, bool hasUniqueName, bool useUnionOverloads) + => useUnionOverloads && + hasUniqueName && + !method.HasUnsupportedAllowsRefStructTypeParameter && + (method.GenericParameters is null || method.GenericParameters.Value.Count == 0) && + method.Parameters.Count > 0 && + !method.Parameters.Any(p => p.NeedsRefStructPipeline() || p.IsParams) && + method.Parameters.Any(p => p.CanUseNullableParameterOverload()); + + /// + /// Whether no other mockable method of shares the C# name of . + /// carries the type parameter list of generic methods (Foo<T>), so the + /// comparison strips it: a generic sibling is an overload for the compiler as well. + /// + private static bool HasUniqueMethodName(Class @class, Method method) + { + string bareName = BareName(method); + return @class.AllMethods().Count(m => m.ExplicitImplementation is null && BareName(m) == bareName) == 1; + + static string BareName(Method m) + { + int typeParameterList = m.Name.IndexOf('<'); + return typeParameterList < 0 ? m.Name : m.Name.Substring(0, typeParameterList); + } + } + + /// + /// Enumerates the slot assignments of the union-mode overload set, all-union first. Above + /// only the all-union overload is emitted (it already covers matchers and + /// values); predicates are not offered there. + /// + private static IEnumerable GenerateUnionSlotCombinations(EquatableArray parameters) + { + MethodParameter[] all = parameters.AsArray(); + int[] valueableIndices = all + .Select((p, i) => (p, i)) + .Where(x => x.p.CanUseNullableParameterOverload()) + .Select(x => x.i) + .ToArray(); + int totalCombos = all.Length <= MaxExplicitParameters ? 1 << valueableIndices.Length : 1; + for (int combo = 0; combo < totalCombos; combo++) + { + UnionSlot[] slots = new UnionSlot[all.Length]; + for (int bit = 0; bit < valueableIndices.Length; bit++) + { + int index = valueableIndices[bit]; + slots[index] = (combo & (1 << bit)) == 0 + ? UnionSlot.Union + : all[index].Type.IsDelegate + ? UnionSlot.RawDelegate + : UnionSlot.Predicate; + } + + yield return slots; + } + } + + // Priority hierarchy of the union-mode overloads, mirroring the classic set: + // all-union : int.MaxValue (takes the classic all-values role: binds `Method(null, …)` / `Method(default, …)`) + // IParameters : int.MaxValue - 1 (unchanged) + // all-union, object slot: parameterCount (an IParameters argument converts to object, so it must not outrank IParameters) + // with predicates : count of union/fixed slots, so a null argument binds to the union-heavier overload + private static string UnionOverloadPriority(EquatableArray parameters, UnionSlot[] slots) + { + int unionCount = slots.Count(s => s is UnionSlot.Union or UnionSlot.Fixed); + if (unionCount < slots.Length) + { + return unionCount.ToString(); + } + + bool[] unionFlags = slots.Select(s => s == UnionSlot.Union).ToArray(); + return ParametersBlockAllValuesPromotion(parameters, unionFlags) ? unionCount.ToString() : "int.MaxValue"; + } + + private static string UnionArgumentLocalName(Method method, MethodParameter parameter) + => CreateUniqueParameterName(method.Parameters, $"{parameter.Name}Arg"); + + private static string UnionExpressionParameterName(Method method, MethodParameter parameter) + => CreateUniqueParameterName(method.Parameters, $"{parameter.Name}Expression"); + + private static void AppendUnionSummary(StringBuilder sb, Class @class, Method method, string? methodNameOverride, + bool isVerify) + { + string action = isVerify ? "Verify invocations for" : "Setup for"; + sb.Append("\t\t/// ").AppendLine(); + if (methodNameOverride is null) + { + sb.Append("\t\t/// ").Append(action).Append(" the method p.RefKind.GetString() + p.Type.Fullname.EscapeForXmlDoc()))) + .Append(")\"/>"); + } + else + { + sb.Append("\t\t/// ").Append(action).Append(" the delegate "); + } + + sb.Append(" with the given ") + .Append(string.Join(", ", method.Parameters.Select(p => $""))) + .Append(".").AppendLine(); + sb.Append("\t\t/// ").AppendLine(); + } + + private static void AppendUnionOverloadRemark(StringBuilder sb, Method method, UnionSlot[] slots) + { + MethodParameter[] parameters = method.Parameters.AsArray(); + List parts = []; + AddPart(UnionSlot.Union, "an matcher or a direct value for {0}"); + AddPart(UnionSlot.Predicate, "a predicate for {0}"); + AddPart(UnionSlot.RawDelegate, "a delegate value for {0}"); + AddPart(UnionSlot.Fixed, "an matcher for {0}"); + string scope = slots.All(s => s == UnionSlot.Union) ? "every parameter" : string.Join(" and ", parts); + sb.AppendXmlRemarks( + $"This overload accepts {(slots.All(s => s == UnionSlot.Union) ? "an matcher or a direct value for " : "")}{scope}. A or argument stands for the literal default value."); + + void AddPart(UnionSlot slot, string format) + { + string[] names = parameters + .Where((_, i) => slots[i] == slot) + .Select(p => $"") + .ToArray(); + if (names.Length > 0) + { + parts.Add(string.Format(format, string.Join(", ", names))); + } + } + } + + private static void AppendUnionPriority(StringBuilder sb, Method method, UnionSlot[] slots) + => sb.Append("\t\t[global::System.Runtime.CompilerServices.OverloadResolutionPriority(") + .Append(UnionOverloadPriority(method.Parameters, slots)) + .Append(")]").AppendLine(); + + /// + /// <TReturn, T1, …> for returning methods, <T1, …> for void methods. + /// + private static void AppendSetupTypeArguments(StringBuilder sb, Method method) + { + sb.Append('<'); + bool first = true; + if (method.ReturnType != Type.Void) + { + AppendSetupReturnType(sb, method); + first = false; + } + + foreach (MethodParameter parameter in method.Parameters) + { + if (!first) + { + sb.Append(", "); + } + + sb.AppendTypeOrWrapper(parameter.Type); + first = false; + } + + sb.Append('>'); + } + + private static void AppendUnionParameters(StringBuilder sb, Method method, UnionSlot[] slots, bool isDefinition, + bool isVerify) + { + MethodParameter[] parameters = method.Parameters.AsArray(); + // Predicate and raw delegate slots have no default, so they end the optional suffix like value slots do. + bool[] breaksDefaults = slots.Select(s => s is UnionSlot.Predicate or UnionSlot.RawDelegate).ToArray(); + bool[] hasTrailingDefault = isDefinition + ? ComputeTrailingDefaults(method.Parameters.AsSpan(), breaksDefaults) + : new bool[parameters.Length]; + for (int i = 0; i < parameters.Length; i++) + { + if (i > 0) + { + sb.Append(", "); + } + + MethodParameter parameter = parameters[i]; + switch (slots[i]) + { + case UnionSlot.Union: + sb.Append("global::Mockolate.ParameterArg<").Append(parameter.ToNullableType()).Append(">? ") + .Append(parameter.Name); + break; + case UnionSlot.Predicate: + sb.Append("global::System.Func<").Append(parameter.ToNullableType()).Append(", bool> ") + .Append(parameter.Name); + break; + case UnionSlot.RawDelegate: + sb.Append(parameter.ToNullableType()).Append(' ').Append(parameter.Name); + break; + default: + if (isVerify) + { + sb.AppendVerifyParameter(parameter); + } + else + { + sb.Append(parameter.ToParameter()); + } + + sb.Append(' ').Append(parameter.Name); + break; + } + + if (hasTrailingDefault[i]) + { + sb.Append(" = null"); + } + } + + for (int i = 0; i < parameters.Length; i++) + { + if (slots[i] != UnionSlot.Predicate) + { + continue; + } + + sb.Append(", "); + if (isDefinition) + { + // Parameter names are stored escaped (`@params`); the attribute needs the bare identifier. + sb.Append("[global::System.Runtime.CompilerServices.CallerArgumentExpression(\"") + .Append(parameters[i].Name.TrimStart('@')).Append("\")] "); + } + + sb.Append("string ").Append(UnionExpressionParameterName(method, parameters[i])); + if (isDefinition) + { + sb.Append(" = \"\""); + } + } + } + + /// + /// ParameterArg<T> xArg = x ?? …; per union slot: an omitted or argument falls + /// back to the parameter's declared default value when it has one, otherwise to the literal default(T). + /// + private static void AppendUnionArgumentLocals(StringBuilder sb, Method method, UnionSlot[] slots) + { + MethodParameter[] parameters = method.Parameters.AsArray(); + for (int i = 0; i < parameters.Length; i++) + { + if (slots[i] != UnionSlot.Union) + { + continue; + } + + MethodParameter parameter = parameters[i]; + string type = parameter.ToNullableType(); + sb.Append("\t\t\tglobal::Mockolate.ParameterArg<").Append(type).Append("> ") + .Append(UnionArgumentLocalName(method, parameter)).Append(" = ").Append(parameter.Name).Append(" ?? "); + if (parameter.HasExplicitDefaultValue) + { + sb.Append("new global::Mockolate.ParameterArg<").Append(type).Append(">((").Append(type).Append(")(") + .Append(parameter.ExplicitDefaultValue).Append("))"); + } + else + { + sb.Append("default"); + } + + sb.Append(';').AppendLine(); + } + } + + private static string UnionLiteralExpression(Method method, MethodParameter parameter, UnionSlot slot) + => slot == UnionSlot.Union ? $"{UnionArgumentLocalName(method, parameter)}.Literal!" : parameter.Name; + + private static void AppendUnionMatchExpression(StringBuilder sb, Method method, MethodParameter parameter, + UnionSlot slot) + { + switch (slot) + { + case UnionSlot.Union: + sb.Append(UnionArgumentLocalName(method, parameter)).Append(".ToParameterMatch()"); + break; + case UnionSlot.Predicate: + sb.Append("(global::Mockolate.Parameters.IParameterMatch<").Append(parameter.ToTypeOrWrapper()) + .Append(">)global::Mockolate.It.Satisfies<").Append(parameter.ToNullableType()).Append(">(") + .Append(parameter.Name).Append(", ").Append(UnionExpressionParameterName(method, parameter)).Append(')'); + break; + case UnionSlot.RawDelegate: + AppendNamedValueParameter(sb, parameter); + break; + default: + AppendNamedParameter(sb, parameter); + break; + } + } + + private static string UnionExpectationLambda(Method method, UnionSlot[] slots) + { + MethodParameter[] parameters = method.Parameters.AsArray(); + IEnumerable placeholders = parameters.Select((p, i) => slots[i] switch + { + UnionSlot.Union => $"{{{UnionArgumentLocalName(method, p)}}}", + UnionSlot.Predicate => $"{{{UnionExpressionParameterName(method, p)}}}", + _ => $"{{{p.Name}}}", + }); + return $"() => $\"{method.Name}({string.Join(", ", placeholders)})\""; + } + + private static string UnionLiteralCondition(Method method, UnionSlot[] slots) + { + MethodParameter[] parameters = method.Parameters.AsArray(); + return string.Join(" && ", parameters + .Where((_, i) => slots[i] == UnionSlot.Union) + .Select(p => $"{UnionArgumentLocalName(method, p)}.IsLiteral")); + } + + private static void AppendUnionMethodSetupDefinition(StringBuilder sb, Class @class, Method method, + UnionSlot[] slots, string? methodNameOverride = null) + { + AppendUnionSummary(sb, @class, method, methodNameOverride, isVerify: false); + AppendUnionOverloadRemark(sb, method, slots); + AppendUnionPriority(sb, method, slots); + sb.Append(method.ReturnType != Type.Void + ? "\t\tglobal::Mockolate.Setup.IReturnMethodSetupParameterIgnorer" + : "\t\tglobal::Mockolate.Setup.IVoidMethodSetupParameterIgnorer"); + AppendSetupTypeArguments(sb, method); + sb.Append(' ').Append(methodNameOverride ?? method.Name).Append('('); + AppendUnionParameters(sb, method, slots, isDefinition: true, isVerify: false); + sb.Append(");").AppendLine(); + sb.AppendLine(); + } + +#pragma warning disable S107 // Methods should not have too many parameters + private static void AppendUnionMethodSetupImplementation(StringBuilder sb, Method method, string mockRegistryName, + string setupName, MemberIdTable memberIds, string memberIdPrefix, UnionSlot[] slots, + string? methodNameOverride = null, string? scopeExpression = null) +#pragma warning restore S107 + { + MethodParameter[] parameters = method.Parameters.AsArray(); + bool isVoid = method.ReturnType == Type.Void; + string scopePrefix = scopeExpression is null ? "" : scopeExpression + ", "; + string ignorerType = isVoid + ? "global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer" + : "global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer"; + StringBuilder typeArguments = new(); + AppendSetupTypeArguments(typeArguments, method); + string setupType = (isVoid ? "global::Mockolate.Setup.VoidMethodSetup" : "global::Mockolate.Setup.ReturnMethodSetup") + + typeArguments; + + sb.Append("\t\t/// ").AppendLine(); + sb.Append("\t\t").Append(ignorerType).Append(typeArguments).Append(" global::Mockolate.Mock.").Append(setupName) + .Append('.').Append(methodNameOverride ?? method.Name).Append('('); + AppendUnionParameters(sb, method, slots, isDefinition: false, isVerify: false); + sb.Append(')').AppendLine(); + sb.AppendLine("\t\t{"); + AppendUnionArgumentLocals(sb, method, slots); + + string methodSetupVar = Helpers.GetUniqueLocalVariableName("methodSetup", method.Parameters); + string memberIdRef = memberIdPrefix + memberIds.GetMethodIdentifier(method); + // Same fast path as the classic all-values overload: when every argument turns out to be a literal value the + // setup stores the values directly (WithLiteralValues, arity 1..4) instead of allocating one matcher per slot. + bool literalEligible = parameters.Length <= MaxExplicitParameters && + slots.All(s => s is UnionSlot.Union or UnionSlot.RawDelegate); + string literalCondition = literalEligible ? UnionLiteralCondition(method, slots) : ""; + if (literalEligible && literalCondition.Length > 0) + { + sb.Append("\t\t\t").Append(setupType).Append(' ').Append(methodSetupVar).Append(';').AppendLine(); + sb.Append("\t\t\tif (").Append(literalCondition).Append(')').AppendLine(); + sb.AppendLine("\t\t\t{"); + sb.Append("\t\t\t\t").Append(methodSetupVar).Append(" = new ").Append(setupType); + AppendLiteralSetup(sb); + sb.AppendLine("\t\t\t}"); + sb.AppendLine("\t\t\telse"); + sb.AppendLine("\t\t\t{"); + sb.Append("\t\t\t\t").Append(methodSetupVar).Append(" = new ").Append(setupType); + AppendCollectionSetup(sb); + sb.AppendLine("\t\t\t}"); + } + else + { + sb.Append("\t\t\tvar ").Append(methodSetupVar).Append(" = new ").Append(setupType); + if (literalEligible) + { + AppendLiteralSetup(sb); + } + else + { + AppendCollectionSetup(sb); + } + } + + sb.Append("\t\t\tthis.").Append(mockRegistryName).Append(".SetupMethod(").Append(memberIdRef).Append(", ") + .Append(scopePrefix).Append(methodSetupVar).Append(");").AppendLine(); + sb.Append("\t\t\treturn (").Append(ignorerType).Append(typeArguments).Append(')').Append(methodSetupVar) + .Append(';').AppendLine(); + sb.AppendLine("\t\t}"); + sb.AppendLine(); + + void AppendLiteralSetup(StringBuilder target) + { + target.Append(".WithLiteralValues(").Append(mockRegistryName).Append(", ") + .Append(method.GetUniqueNameString()); + for (int i = 0; i < parameters.Length; i++) + { + target.Append(", ").Append(UnionLiteralExpression(method, parameters[i], slots[i])); + } + + target.Append(");").AppendLine(); + } + + void AppendCollectionSetup(StringBuilder target) + { + target.Append(".WithParameterCollection(").Append(mockRegistryName).Append(", ") + .Append(method.GetUniqueNameString()); + for (int i = 0; i < parameters.Length; i++) + { + target.Append(", "); + AppendUnionMatchExpression(target, method, parameters[i], slots[i]); + } + + target.Append(");").AppendLine(); + } + } + + private static void AppendUnionMethodVerifyDefinition(StringBuilder sb, Class @class, Method method, + string verifyName, UnionSlot[] slots, string? methodNameOverride = null) + { + AppendUnionSummary(sb, @class, method, methodNameOverride, isVerify: true); + AppendUnionOverloadRemark(sb, method, slots); + AppendUnionPriority(sb, method, slots); + sb.Append("\t\tglobal::Mockolate.Verify.VerificationResult<").Append(verifyName) + .Append(">.IgnoreParameters ").Append(methodNameOverride ?? method.Name).Append('('); + AppendUnionParameters(sb, method, slots, isDefinition: true, isVerify: true); + sb.Append(");").AppendLine(); + sb.AppendLine(); + } + +#pragma warning disable S107 // Methods should not have too many parameters + private static void AppendUnionMethodVerifyImplementation(StringBuilder sb, Method method, + string mockRegistryName, string verifyName, MemberIdTable memberIds, string memberIdPrefix, + bool useFastBuffers, UnionSlot[] slots, string? methodNameOverride = null) +#pragma warning restore S107 + { + MethodParameter[] parameters = method.Parameters.AsArray(); + bool useFastForMethod = useFastBuffers && IsFastBufferEligibleMethod(method); + string methodMemberId = useFastForMethod + ? memberIdPrefix + memberIds.GetMethodIdentifier(method) + : "-1"; + string typeArguments = string.Join(", ", parameters.Select(p => p.ToTypeOrWrapper())); + string expectation = UnionExpectationLambda(method, slots); + + sb.Append("\t\t/// ").AppendLine(); + sb.Append("\t\tglobal::Mockolate.Verify.VerificationResult<").Append(verifyName).Append(">.IgnoreParameters ") + .Append(verifyName).Append('.').Append(methodNameOverride ?? method.Name).Append('('); + AppendUnionParameters(sb, method, slots, isDefinition: false, isVerify: true); + sb.Append(')').AppendLine(); + sb.AppendLine("\t\t{"); + AppendUnionArgumentLocals(sb, method, slots); + + // Mirrors the classic verify paths: literal values go through the allocation-free VerifyMethod overload, + // matchers through the typed overload when the member has a fast buffer, everything else through the + // MethodInvocation predicate. + bool noFixedSlots = slots.All(s => s != UnionSlot.Fixed); + bool literalEligible = parameters.Length <= 4 && noFixedSlots && + slots.All(s => s is UnionSlot.Union or UnionSlot.RawDelegate); + bool typedEligible = useFastForMethod && parameters.Length <= 4 && noFixedSlots; + if (literalEligible) + { + string literalCondition = UnionLiteralCondition(method, slots); + string indent = "\t\t\t"; + if (literalCondition.Length > 0) + { + sb.Append("\t\t\tif (").Append(literalCondition).Append(')').AppendLine(); + sb.AppendLine("\t\t\t{"); + indent = "\t\t\t\t"; + } + + sb.Append(indent).Append("return this.").Append(mockRegistryName).Append(".VerifyMethod<").Append(verifyName) + .Append(", ").Append(typeArguments).Append(">(this, ").Append(methodMemberId).Append(", ") + .Append(method.GetUniqueNameString()); + for (int i = 0; i < parameters.Length; i++) + { + sb.Append(", ").Append(UnionLiteralExpression(method, parameters[i], slots[i])); + } + + sb.Append(", ").Append(expectation).Append(");").AppendLine(); + if (literalCondition.Length == 0) + { + sb.AppendLine("\t\t}"); + sb.AppendLine(); + return; + } + + sb.AppendLine("\t\t\t}"); + } + + if (typedEligible) + { + sb.Append("\t\t\treturn this.").Append(mockRegistryName).Append(".VerifyMethod<").Append(verifyName) + .Append(", ").Append(typeArguments).Append(">(this, ").Append(methodMemberId).Append(", ") + .Append(method.GetUniqueNameString()); + for (int i = 0; i < parameters.Length; i++) + { + sb.Append(", "); + AppendUnionMatchExpression(sb, method, parameters[i], slots[i]); + } + + sb.Append(", ").Append(expectation).Append(");").AppendLine(); + } + else + { + for (int i = 0; i < parameters.Length; i++) + { + if (slots[i] is not (UnionSlot.Union or UnionSlot.Predicate)) + { + continue; + } + + sb.Append("\t\t\tglobal::Mockolate.Parameters.IParameterMatch<").Append(parameters[i].ToTypeOrWrapper()) + .Append("> ").Append(UnionMatchLocalName(method, parameters[i])).Append(" = "); + AppendUnionMatchExpression(sb, method, parameters[i], slots[i]); + sb.Append(';').AppendLine(); + } + + sb.Append("\t\t\treturn this.").Append(mockRegistryName).Append(".VerifyMethod<").Append(verifyName) + .Append(", global::Mockolate.Interactions.MethodInvocation<").Append(typeArguments).Append(">>(this, ") + .Append(methodMemberId).Append(", ").Append(method.GetUniqueNameString()).Append(", __i => "); + for (int i = 0; i < parameters.Length; i++) + { + if (i > 0) + { + sb.Append(" && "); + } + + sb.AppendLine().Append("\t\t\t\t"); + MethodParameter parameter = parameters[i]; + string type = parameter.ToTypeOrWrapper(); + string invocationValue = $"__i.Parameter{i + 1}"; + switch (slots[i]) + { + case UnionSlot.Union: + case UnionSlot.Predicate: + sb.Append('(').Append(UnionMatchLocalName(method, parameter)).Append(".Matches(") + .Append(invocationValue).Append("))"); + break; + case UnionSlot.RawDelegate: + sb.Append("(global::System.Collections.Generic.EqualityComparer<").Append(type) + .Append(">.Default.Equals(").Append(parameter.Name).Append(", ").Append(invocationValue).Append("))"); + break; + default: + if (parameter.RefKind is RefKind.Out or RefKind.Ref or RefKind.RefReadOnlyParameter) + { + // out/ref verify parameters use IVerifyOutParameter / IVerifyRefParameter, which don't inherit + // from IParameter; keep the direct IParameterMatch check like the classic overloads. + sb.Append( + $"({parameter.Name} is global::Mockolate.Parameters.IParameterMatch<{type}> {parameter.Name}Match ? {parameter.Name}Match.Matches({invocationValue}) : global::System.Collections.Generic.EqualityComparer<{type}>.Default.Equals({invocationValue}, default({type})))"); + } + else + { + sb.Append( + $"({parameter.Name} is not null ? CovariantParameterAdapter<{type}>.Wrap({parameter.Name}).Matches({invocationValue}) : global::System.Collections.Generic.EqualityComparer<{type}>.Default.Equals({invocationValue}, default({type})))"); + } + + break; + } + } + + sb.Append(", ").Append(expectation).Append(");").AppendLine(); + } + + sb.AppendLine("\t\t}"); + sb.AppendLine(); + } + + private static string UnionMatchLocalName(Method method, MethodParameter parameter) + => CreateUniqueParameterName(method.Parameters, $"{parameter.Name}Match"); +} diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs index 77ba3ff8..cc7bcb08 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs @@ -14,7 +14,8 @@ public static string MockClass( string name, Class @class, bool hasOverloadResolutionPriority = false, - (string Name, Class Class)[]? hiddenBaseInterfaces = null) + (string Name, Class Class)[]? hiddenBaseInterfaces = null, + bool useUnionOverloads = false) { hiddenBaseInterfaces ??= []; EquatableArray? constructors = (@class as MockClass)?.Constructors; @@ -221,7 +222,7 @@ public static string MockClass( sb.Append("\t\t#region IMockSetupFor").Append(name).AppendLine(); sb.AppendLine(); - ImplementSetupInterface(sb, @class, mockRegistryName, $"IMockSetupFor{name}", MemberType.Public, memberIds, memberIdPrefix); + ImplementSetupInterface(sb, @class, mockRegistryName, $"IMockSetupFor{name}", MemberType.Public, memberIds, memberIdPrefix, useUnionOverloads: useUnionOverloads); sb.Append("\t\t#endregion IMockSetupFor").Append(name).AppendLine(); if (hasProtectedMembers) @@ -229,7 +230,7 @@ public static string MockClass( sb.AppendLine(); sb.Append("\t\t#region IMockProtectedSetupFor").Append(name).AppendLine(); sb.AppendLine(); - ImplementSetupInterface(sb, @class, mockRegistryName, $"IMockProtectedSetupFor{name}", MemberType.Protected, memberIds, memberIdPrefix); + ImplementSetupInterface(sb, @class, mockRegistryName, $"IMockProtectedSetupFor{name}", MemberType.Protected, memberIds, memberIdPrefix, useUnionOverloads: useUnionOverloads); sb.Append("\t\t#endregion IMockProtectedSetupFor").Append(name).AppendLine(); } @@ -238,7 +239,7 @@ public static string MockClass( sb.AppendLine(); sb.Append("\t\t#region IMockStaticSetupFor").Append(name).AppendLine(); sb.AppendLine(); - ImplementSetupInterface(sb, @class, mockRegistryName, $"IMockStaticSetupFor{name}", MemberType.Static, memberIds, memberIdPrefix); + ImplementSetupInterface(sb, @class, mockRegistryName, $"IMockStaticSetupFor{name}", MemberType.Static, memberIds, memberIdPrefix, useUnionOverloads: useUnionOverloads); sb.Append("\t\t#endregion IMockStaticSetupFor").Append(name).AppendLine(); } @@ -247,7 +248,7 @@ public static string MockClass( sb.AppendLine(); sb.Append("\t\t#region IMockSetupFor").Append(hiddenBase.Name).AppendLine(); sb.AppendLine(); - ImplementSetupInterface(sb, hiddenBase.Class, mockRegistryName, $"IMockSetupFor{hiddenBase.Name}", MemberType.Public, memberIds, memberIdPrefix); + ImplementSetupInterface(sb, hiddenBase.Class, mockRegistryName, $"IMockSetupFor{hiddenBase.Name}", MemberType.Public, memberIds, memberIdPrefix, useUnionOverloads: useUnionOverloads); sb.Append("\t\t#endregion IMockSetupFor").Append(hiddenBase.Name).AppendLine(); } @@ -302,7 +303,7 @@ public static string MockClass( sb.AppendLine(); sb.Append("\t\t#region IMockVerifyFor").Append(name).AppendLine(); sb.AppendLine(); - ImplementVerifyInterface(sb, @class, mockRegistryName, $"IMockVerifyFor{name}", MemberType.Public, memberIds, memberIdPrefix); + ImplementVerifyInterface(sb, @class, mockRegistryName, $"IMockVerifyFor{name}", MemberType.Public, memberIds, memberIdPrefix, useUnionOverloads: useUnionOverloads); sb.Append("\t\t#endregion IMockVerifyFor").Append(name).AppendLine(); if (hasProtectedMembers || hasProtectedEvents) @@ -310,7 +311,7 @@ public static string MockClass( sb.AppendLine(); sb.Append("\t\t#region IMockProtectedVerifyFor").Append(name).AppendLine(); sb.AppendLine(); - ImplementVerifyInterface(sb, @class, mockRegistryName, $"IMockProtectedVerifyFor{name}", MemberType.Protected, memberIds, memberIdPrefix); + ImplementVerifyInterface(sb, @class, mockRegistryName, $"IMockProtectedVerifyFor{name}", MemberType.Protected, memberIds, memberIdPrefix, useUnionOverloads: useUnionOverloads); sb.Append("\t\t#endregion IMockProtectedVerifyFor").Append(name).AppendLine(); } @@ -319,7 +320,7 @@ public static string MockClass( sb.AppendLine(); sb.Append("\t\t#region IMockStaticVerifyFor").Append(name).AppendLine(); sb.AppendLine(); - ImplementVerifyInterface(sb, @class, mockRegistryName, $"IMockStaticVerifyFor{name}", MemberType.Static, memberIds, memberIdPrefix); + ImplementVerifyInterface(sb, @class, mockRegistryName, $"IMockStaticVerifyFor{name}", MemberType.Static, memberIds, memberIdPrefix, useUnionOverloads: useUnionOverloads); sb.Append("\t\t#endregion IMockStaticVerifyFor").Append(name).AppendLine(); } @@ -328,7 +329,7 @@ public static string MockClass( sb.AppendLine(); sb.Append("\t\t#region IMockVerifyFor").Append(hiddenBase.Name).AppendLine(); sb.AppendLine(); - ImplementVerifyInterface(sb, hiddenBase.Class, mockRegistryName, $"IMockVerifyFor{hiddenBase.Name}", MemberType.Public, memberIds, memberIdPrefix, false); + ImplementVerifyInterface(sb, hiddenBase.Class, mockRegistryName, $"IMockVerifyFor{hiddenBase.Name}", MemberType.Public, memberIds, memberIdPrefix, false, useUnionOverloads); sb.Append("\t\t#endregion IMockVerifyFor").Append(hiddenBase.Name).AppendLine(); } @@ -352,7 +353,7 @@ public static string MockClass( sb.Append("\t\t#region IMockVerifyFor").Append(name).AppendLine(); sb.AppendLine(); - ImplementVerifyInterface(sb, @class, mockRegistryName, $"IMockVerifyFor{name}", MemberType.Public, memberIds, memberIdPrefix); + ImplementVerifyInterface(sb, @class, mockRegistryName, $"IMockVerifyFor{name}", MemberType.Public, memberIds, memberIdPrefix, useUnionOverloads: useUnionOverloads); sb.Append("\t\t#endregion IMockVerifyFor").Append(name).AppendLine(); sb.Append("\t}").AppendLine(); @@ -398,7 +399,7 @@ public static string MockClass( sb.Append("\t\t#region IMockSetupFor").Append(name).AppendLine(); sb.AppendLine(); - ImplementSetupInterface(sb, @class, mockRegistryName, $"IMockSetupFor{name}", MemberType.Public, memberIds, memberIdPrefix, "_scenarioName"); + ImplementSetupInterface(sb, @class, mockRegistryName, $"IMockSetupFor{name}", MemberType.Public, memberIds, memberIdPrefix, "_scenarioName", useUnionOverloads); sb.Append("\t\t#endregion IMockSetupFor").Append(name).AppendLine(); if (hasProtectedMembers) @@ -407,7 +408,7 @@ public static string MockClass( sb.Append("\t\t#region IMockProtectedSetupFor").Append(name).AppendLine(); sb.AppendLine(); - ImplementSetupInterface(sb, @class, mockRegistryName, $"IMockProtectedSetupFor{name}", MemberType.Protected, memberIds, memberIdPrefix, "_scenarioName"); + ImplementSetupInterface(sb, @class, mockRegistryName, $"IMockProtectedSetupFor{name}", MemberType.Protected, memberIds, memberIdPrefix, "_scenarioName", useUnionOverloads); sb.Append("\t\t#endregion IMockProtectedSetupFor").Append(name).AppendLine(); } @@ -587,7 +588,7 @@ public static string MockClass( sb.Append("\t{").AppendLine(); - DefineSetupInterface(sb, @class, MemberType.Public, hasOverloadResolutionPriority); + DefineSetupInterface(sb, @class, MemberType.Public, hasOverloadResolutionPriority, useUnionOverloads); sb.Append("\t}").AppendLine(); sb.AppendLine(); @@ -602,7 +603,7 @@ public static string MockClass( sb.Append("\tinternal interface IMockProtectedSetupFor").Append(name).AppendLine(); sb.Append("\t{").AppendLine(); - DefineSetupInterface(sb, @class, MemberType.Protected, hasOverloadResolutionPriority); + DefineSetupInterface(sb, @class, MemberType.Protected, hasOverloadResolutionPriority, useUnionOverloads); sb.Append("\t}").AppendLine(); sb.AppendLine(); @@ -618,7 +619,7 @@ public static string MockClass( sb.Append("\tinternal interface IMockStaticSetupFor").Append(name).AppendLine(); sb.Append("\t{").AppendLine(); - DefineSetupInterface(sb, @class, MemberType.Static, hasOverloadResolutionPriority); + DefineSetupInterface(sb, @class, MemberType.Static, hasOverloadResolutionPriority, useUnionOverloads); sb.Append("\t}").AppendLine(); sb.AppendLine(); @@ -689,7 +690,7 @@ public static string MockClass( sb.Append("\t{").AppendLine(); - DefineVerifyInterface(sb, @class, $"IMockVerifyFor{name}", MemberType.Public, hasOverloadResolutionPriority); + DefineVerifyInterface(sb, @class, $"IMockVerifyFor{name}", MemberType.Public, hasOverloadResolutionPriority, useUnionOverloads); sb.Append("\t}").AppendLine(); @@ -705,7 +706,7 @@ public static string MockClass( sb.Append("\tinternal interface IMockProtectedVerifyFor").Append(name).AppendLine(); sb.Append("\t{").AppendLine(); DefineVerifyInterface(sb, @class, $"IMockProtectedVerifyFor{name}", MemberType.Protected, - hasOverloadResolutionPriority); + hasOverloadResolutionPriority, useUnionOverloads); sb.Append("\t}").AppendLine(); } @@ -721,7 +722,7 @@ public static string MockClass( sb.Append("\tinternal interface IMockStaticVerifyFor").Append(name).AppendLine(); sb.Append("\t{").AppendLine(); DefineVerifyInterface(sb, @class, $"IMockStaticVerifyFor{name}", MemberType.Static, - hasOverloadResolutionPriority); + hasOverloadResolutionPriority, useUnionOverloads); sb.Append("\t}").AppendLine(); } @@ -1161,7 +1162,7 @@ static bool TryCastWithDefaultValue(object?[] values, int index, TValue sb.Append("\t\t#region IMockSetupFor").Append(name).AppendLine(); sb.AppendLine(); - ImplementSetupInterface(sb, @class, mockRegistryName, $"IMockSetupFor{name}", MemberType.Public, memberIds, memberIdPrefix); + ImplementSetupInterface(sb, @class, mockRegistryName, $"IMockSetupFor{name}", MemberType.Public, memberIds, memberIdPrefix, useUnionOverloads: useUnionOverloads); sb.Append("\t\t#endregion IMockSetupFor").Append(name).AppendLine(); if (hasProtectedMembers) @@ -1170,7 +1171,7 @@ static bool TryCastWithDefaultValue(object?[] values, int index, TValue sb.Append("\t\t#region IMockProtectedSetupFor").Append(name).AppendLine(); sb.AppendLine(); - ImplementSetupInterface(sb, @class, mockRegistryName, $"IMockProtectedSetupFor{name}", MemberType.Protected, memberIds, memberIdPrefix); + ImplementSetupInterface(sb, @class, mockRegistryName, $"IMockProtectedSetupFor{name}", MemberType.Protected, memberIds, memberIdPrefix, useUnionOverloads: useUnionOverloads); sb.Append("\t\t#endregion IMockProtectedSetupFor").Append(name).AppendLine(); } @@ -3260,7 +3261,7 @@ private static void AppendIndexerVerifyType(StringBuilder sb, Property indexer, } private static void DefineSetupInterface(StringBuilder sb, Class @class, MemberType memberType, - bool hasOverloadResolutionPriority) + bool hasOverloadResolutionPriority, bool useUnionOverloads = false) { #region Properties @@ -3348,6 +3349,13 @@ bool MethodPredicate(Method method) AppendMethodSetupDefinition(sb, @class, method, false, hasOverloadResolutionPriority: hasOverloadResolutionPriority); } + else if (UseUnionOverloads(method, HasUniqueMethodName(@class, method), useUnionOverloads)) + { + foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(method.Parameters)) + { + AppendUnionMethodSetupDefinition(sb, @class, method, slots); + } + } else { AppendMethodSetupDefinition(sb, @class, method, false, @@ -3692,7 +3700,7 @@ private static void AppendMethodSetupDefinition(StringBuilder sb, Class @class, #pragma warning disable S107 // Methods should not have too many parameters private static void ImplementSetupInterface(StringBuilder sb, Class @class, string mockRegistryName, string setupName, MemberType memberType, MemberIdTable memberIds, string memberIdPrefix, - string? scopeExpression = null) + string? scopeExpression = null, bool useUnionOverloads = false) #pragma warning restore S107 { string scopePrefix = scopeExpression is null ? "" : scopeExpression + ", "; @@ -3815,6 +3823,14 @@ bool MethodPredicate(Method method) AppendMethodSetupImplementation(sb, method, mockRegistryName, setupName, false, memberIds, memberIdPrefix, scopeExpression: scopeExpression); } + else if (UseUnionOverloads(method, HasUniqueMethodName(@class, method), useUnionOverloads)) + { + foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(method.Parameters)) + { + AppendUnionMethodSetupImplementation(sb, method, mockRegistryName, setupName, memberIds, + memberIdPrefix, slots, scopeExpression: scopeExpression); + } + } else { AppendMethodSetupImplementation(sb, method, mockRegistryName, setupName, false, @@ -5175,7 +5191,7 @@ private static void ImplementRaiseInterface(StringBuilder sb, Class @class, stri #region Verify Helpers private static void DefineVerifyInterface(StringBuilder sb, Class @class, string verifyName, MemberType memberType, - bool hasOverloadResolutionPriority) + bool hasOverloadResolutionPriority, bool useUnionOverloads = false) { #region Properties @@ -5251,6 +5267,13 @@ bool MethodPredicate(Method method) AppendMethodVerifyDefinition(sb, method, verifyName, false, hasOverloadResolutionPriority: hasOverloadResolutionPriority); } + else if (UseUnionOverloads(method, HasUniqueMethodName(@class, method), useUnionOverloads)) + { + foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(method.Parameters)) + { + AppendUnionMethodVerifyDefinition(sb, @class, method, verifyName, slots); + } + } else { AppendMethodVerifyDefinition(sb, method, verifyName, false, @@ -5439,7 +5462,7 @@ private static void AppendMethodVerifyDefinition(StringBuilder sb, Method method #pragma warning disable S107 // Methods should not have too many parameters private static void ImplementVerifyInterface(StringBuilder sb, Class @class, string mockRegistryName, string verifyName, MemberType memberType, MemberIdTable memberIds, string memberIdPrefix, - bool useFastBuffers = true) + bool useFastBuffers = true, bool useUnionOverloads = false) #pragma warning restore S107 { #region Properties @@ -5542,6 +5565,14 @@ bool MethodPredicate(Method method) AppendMethodVerifyImplementation(sb, method, mockRegistryName, verifyName, false, memberIds, memberIdPrefix, useFastBuffers); } + else if (UseUnionOverloads(method, HasUniqueMethodName(@class, method), useUnionOverloads)) + { + foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(method.Parameters)) + { + AppendUnionMethodVerifyImplementation(sb, method, mockRegistryName, verifyName, memberIds, + memberIdPrefix, useFastBuffers, slots); + } + } else { AppendMethodVerifyImplementation(sb, method, mockRegistryName, verifyName, false, diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.MockCombination.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.MockCombination.cs index 9fb131f8..e9351b76 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.MockCombination.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.MockCombination.cs @@ -9,7 +9,8 @@ public static string MockCombinationClass( string fileName, string name, Class @class, - (string Name, Class Class)[] additionalInterfaces) + (string Name, Class Class)[] additionalInterfaces, + bool useUnionOverloads = false) { EquatableArray? constructors = (@class as MockClass)?.Constructors; MemberAliases aliases = new(); @@ -214,7 +215,7 @@ public static string MockCombinationClass( sb.Append("\t\t#region IMockSetupFor").Append(name).AppendLine(); sb.AppendLine(); - ImplementSetupInterface(sb, @class, mockRegistryName, $"IMockSetupFor{name}", MemberType.Public, memberIds, memberIdPrefix); + ImplementSetupInterface(sb, @class, mockRegistryName, $"IMockSetupFor{name}", MemberType.Public, memberIds, memberIdPrefix, useUnionOverloads: useUnionOverloads); sb.Append("\t\t#endregion IMockSetupFor").Append(name).AppendLine(); if (hasProtectedMembers) @@ -223,7 +224,7 @@ public static string MockCombinationClass( sb.Append("\t\t#region IMockProtectedSetupFor").Append(name).AppendLine(); sb.AppendLine(); - ImplementSetupInterface(sb, @class, mockRegistryName, $"IMockProtectedSetupFor{name}", MemberType.Protected, memberIds, memberIdPrefix); + ImplementSetupInterface(sb, @class, mockRegistryName, $"IMockProtectedSetupFor{name}", MemberType.Protected, memberIds, memberIdPrefix, useUnionOverloads: useUnionOverloads); sb.Append("\t\t#endregion IMockProtectedSetupFor").Append(name).AppendLine(); } @@ -234,7 +235,7 @@ public static string MockCombinationClass( sb.Append("\t\t#region IMockStaticSetupFor").Append(name).AppendLine(); sb.AppendLine(); - ImplementSetupInterface(sb, @class, mockRegistryName, $"IMockStaticSetupFor{name}", MemberType.Static, memberIds, memberIdPrefix); + ImplementSetupInterface(sb, @class, mockRegistryName, $"IMockStaticSetupFor{name}", MemberType.Static, memberIds, memberIdPrefix, useUnionOverloads: useUnionOverloads); sb.Append("\t\t#endregion IMockStaticSetupFor").Append(name).AppendLine(); } @@ -245,7 +246,7 @@ public static string MockCombinationClass( sb.Append("\t\t#region IMockSetupFor").Append(item.Name).AppendLine(); sb.AppendLine(); - ImplementSetupInterface(sb, item.Class, mockRegistryName, $"IMockSetupFor{item.Name}", MemberType.Public, memberIds, memberIdPrefix); + ImplementSetupInterface(sb, item.Class, mockRegistryName, $"IMockSetupFor{item.Name}", MemberType.Public, memberIds, memberIdPrefix, useUnionOverloads: useUnionOverloads); sb.Append("\t\t#endregion IMockSetupFor").Append(item.Name).AppendLine(); @@ -255,7 +256,7 @@ public static string MockCombinationClass( sb.Append("\t\t#region IMockStaticSetupFor").Append(item.Name).AppendLine(); sb.AppendLine(); - ImplementSetupInterface(sb, item.Class, mockRegistryName, $"IMockStaticSetupFor{item.Name}", MemberType.Static, memberIds, memberIdPrefix); + ImplementSetupInterface(sb, item.Class, mockRegistryName, $"IMockStaticSetupFor{item.Name}", MemberType.Static, memberIds, memberIdPrefix, useUnionOverloads: useUnionOverloads); sb.Append("\t\t#endregion IMockStaticSetupFor").Append(item.Name).AppendLine(); } @@ -335,7 +336,7 @@ public static string MockCombinationClass( // memberIds enumerate a different (typically larger) set, so they cannot be used to fetch the // base buffers — emit the slow Verify path here instead. Recordings flow through the // FastMockInteractions fallback buffer (see AppendMockSubject_ImplementClass useFastBuffers: false). - ImplementVerifyInterface(sb, @class, mockRegistryName, $"IMockVerifyFor{name}", MemberType.Public, memberIds, memberIdPrefix, false); + ImplementVerifyInterface(sb, @class, mockRegistryName, $"IMockVerifyFor{name}", MemberType.Public, memberIds, memberIdPrefix, false, useUnionOverloads); sb.Append("\t\t#endregion IMockVerifyFor").Append(name).AppendLine(); if (hasProtectedMembers || hasProtectedEvents) { @@ -343,7 +344,7 @@ public static string MockCombinationClass( sb.Append("\t\t#region IMockProtectedVerifyFor").Append(name).AppendLine(); sb.AppendLine(); - ImplementVerifyInterface(sb, @class, mockRegistryName, $"IMockProtectedVerifyFor{name}", MemberType.Protected, memberIds, memberIdPrefix, false); + ImplementVerifyInterface(sb, @class, mockRegistryName, $"IMockProtectedVerifyFor{name}", MemberType.Protected, memberIds, memberIdPrefix, false, useUnionOverloads); sb.Append("\t\t#endregion IMockProtectedVerifyFor").Append(name).AppendLine(); } @@ -354,7 +355,7 @@ public static string MockCombinationClass( sb.Append("\t\t#region IMockStaticVerifyFor").Append(name).AppendLine(); sb.AppendLine(); - ImplementVerifyInterface(sb, @class, mockRegistryName, $"IMockStaticVerifyFor{name}", MemberType.Static, memberIds, memberIdPrefix, false); + ImplementVerifyInterface(sb, @class, mockRegistryName, $"IMockStaticVerifyFor{name}", MemberType.Static, memberIds, memberIdPrefix, false, useUnionOverloads); sb.Append("\t\t#endregion IMockStaticVerifyFor").Append(name).AppendLine(); } @@ -365,7 +366,7 @@ public static string MockCombinationClass( sb.Append("\t\t#region IMockVerifyFor").Append(item.Name).AppendLine(); sb.AppendLine(); - ImplementVerifyInterface(sb, item.Class, mockRegistryName, $"IMockVerifyFor{item.Name}", MemberType.Public, memberIds, memberIdPrefix, false); + ImplementVerifyInterface(sb, item.Class, mockRegistryName, $"IMockVerifyFor{item.Name}", MemberType.Public, memberIds, memberIdPrefix, false, useUnionOverloads); sb.Append("\t\t#endregion IMockVerifyFor").Append(item.Name).AppendLine(); @@ -376,7 +377,7 @@ public static string MockCombinationClass( sb.Append("\t\t#region IMockStaticVerifyFor").Append(item.Name).AppendLine(); sb.AppendLine(); - ImplementVerifyInterface(sb, item.Class, mockRegistryName, $"IMockStaticVerifyFor{item.Name}", MemberType.Static, memberIds, memberIdPrefix, false); + ImplementVerifyInterface(sb, item.Class, mockRegistryName, $"IMockStaticVerifyFor{item.Name}", MemberType.Static, memberIds, memberIdPrefix, false, useUnionOverloads); sb.Append("\t\t#endregion IMockStaticVerifyFor").Append(item.Name).AppendLine(); } diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.MockDelegate.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.MockDelegate.cs index a750d8fd..9db1f01d 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.MockDelegate.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.MockDelegate.cs @@ -7,7 +7,8 @@ namespace Mockolate.SourceGenerators.Sources; internal static partial class Sources { - public static string MockDelegate(string name, MockClass @class, Method delegateMethod) + public static string MockDelegate(string name, MockClass @class, Method delegateMethod, + bool useUnionOverloads = false) { string mockRegistryName = @class.GetUniqueName("MockRegistry", "MockolateMockRegistry"); string escapedClassName = @class.ClassFullName.EscapeForXmlDoc(); @@ -200,50 +201,72 @@ public static string MockDelegate(string name, MockClass @class, Method delegate sb.Append("\t\t\t=> \"").Append(@class.DisplayString).Append(" mock\";").AppendLine(); sb.AppendLine(); - AppendMethodSetupImplementation(sb, delegateMethod, mockRegistryName, $"IMockSetupFor{name}", false, memberIds, memberIdPrefix, "Setup"); - - if (delegateMethod.Parameters.Count > 0) + if (UseUnionOverloads(delegateMethod, true, useUnionOverloads)) { AppendMethodSetupImplementation(sb, delegateMethod, mockRegistryName, $"IMockSetupFor{name}", true, memberIds, memberIdPrefix, "Setup"); - } - - if (delegateMethod.Parameters.Count is > 0 and <= MaxExplicitParameters) - { - foreach (bool[] valueFlags in GenerateValueFlagCombinations(delegateMethod.Parameters)) + foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(delegateMethod.Parameters)) { - AppendMethodSetupImplementation(sb, delegateMethod, mockRegistryName, $"IMockSetupFor{name}", false, memberIds, memberIdPrefix, "Setup", valueFlags); + AppendUnionMethodSetupImplementation(sb, delegateMethod, mockRegistryName, $"IMockSetupFor{name}", memberIds, memberIdPrefix, slots, "Setup"); } } - else if (delegateMethod.Parameters.Count > MaxExplicitParameters) + else { - bool[] allValueFlags = delegateMethod.Parameters.Select(p => p.CanUseNullableParameterOverload()).ToArray(); - if (allValueFlags.Any(f => f)) + AppendMethodSetupImplementation(sb, delegateMethod, mockRegistryName, $"IMockSetupFor{name}", false, memberIds, memberIdPrefix, "Setup"); + + if (delegateMethod.Parameters.Count > 0) + { + AppendMethodSetupImplementation(sb, delegateMethod, mockRegistryName, $"IMockSetupFor{name}", true, memberIds, memberIdPrefix, "Setup"); + } + + if (delegateMethod.Parameters.Count is > 0 and <= MaxExplicitParameters) { - AppendMethodSetupImplementation(sb, delegateMethod, mockRegistryName, $"IMockSetupFor{name}", false, memberIds, memberIdPrefix, "Setup", allValueFlags); + foreach (bool[] valueFlags in GenerateValueFlagCombinations(delegateMethod.Parameters)) + { + AppendMethodSetupImplementation(sb, delegateMethod, mockRegistryName, $"IMockSetupFor{name}", false, memberIds, memberIdPrefix, "Setup", valueFlags); + } + } + else if (delegateMethod.Parameters.Count > MaxExplicitParameters) + { + bool[] allValueFlags = delegateMethod.Parameters.Select(p => p.CanUseNullableParameterOverload()).ToArray(); + if (allValueFlags.Any(f => f)) + { + AppendMethodSetupImplementation(sb, delegateMethod, mockRegistryName, $"IMockSetupFor{name}", false, memberIds, memberIdPrefix, "Setup", allValueFlags); + } } } // Delegate mocks use a plain MockRegistry (no FastMockInteractions), so emit the slow Verify path. - AppendMethodVerifyImplementation(sb, delegateMethod, mockRegistryName, $"IMockVerifyFor{name}", false, memberIds, memberIdPrefix, false, "Verify"); - if (delegateMethod.Parameters.Count > 0) + if (UseUnionOverloads(delegateMethod, true, useUnionOverloads)) { AppendMethodVerifyImplementation(sb, delegateMethod, mockRegistryName, $"IMockVerifyFor{name}", true, memberIds, memberIdPrefix, false, "Verify"); - } - - if (delegateMethod.Parameters.Count is > 0 and <= MaxExplicitParameters) - { - foreach (bool[] valueFlags in GenerateValueFlagCombinations(delegateMethod.Parameters)) + foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(delegateMethod.Parameters)) { - AppendMethodVerifyImplementation(sb, delegateMethod, mockRegistryName, $"IMockVerifyFor{name}", false, memberIds, memberIdPrefix, false, "Verify", valueFlags); + AppendUnionMethodVerifyImplementation(sb, delegateMethod, mockRegistryName, $"IMockVerifyFor{name}", memberIds, memberIdPrefix, false, slots, "Verify"); } } - else if (delegateMethod.Parameters.Count > MaxExplicitParameters) + else { - bool[] allValueFlags = delegateMethod.Parameters.Select(p => p.CanUseNullableParameterOverload()).ToArray(); - if (allValueFlags.Any(f => f)) + AppendMethodVerifyImplementation(sb, delegateMethod, mockRegistryName, $"IMockVerifyFor{name}", false, memberIds, memberIdPrefix, false, "Verify"); + if (delegateMethod.Parameters.Count > 0) + { + AppendMethodVerifyImplementation(sb, delegateMethod, mockRegistryName, $"IMockVerifyFor{name}", true, memberIds, memberIdPrefix, false, "Verify"); + } + + if (delegateMethod.Parameters.Count is > 0 and <= MaxExplicitParameters) + { + foreach (bool[] valueFlags in GenerateValueFlagCombinations(delegateMethod.Parameters)) + { + AppendMethodVerifyImplementation(sb, delegateMethod, mockRegistryName, $"IMockVerifyFor{name}", false, memberIds, memberIdPrefix, false, "Verify", valueFlags); + } + } + else if (delegateMethod.Parameters.Count > MaxExplicitParameters) { - AppendMethodVerifyImplementation(sb, delegateMethod, mockRegistryName, $"IMockVerifyFor{name}", false, - memberIds, memberIdPrefix, false, "Verify", allValueFlags); + bool[] allValueFlags = delegateMethod.Parameters.Select(p => p.CanUseNullableParameterOverload()).ToArray(); + if (allValueFlags.Any(f => f)) + { + AppendMethodVerifyImplementation(sb, delegateMethod, mockRegistryName, $"IMockVerifyFor{name}", false, + memberIds, memberIdPrefix, false, "Verify", allValueFlags); + } } } @@ -288,26 +311,37 @@ public static string MockDelegate(string name, MockClass @class, Method delegate sb.AppendLine(); // Delegate mocks use a plain MockRegistry (no FastMockInteractions), so emit the slow Verify path. - AppendMethodVerifyImplementation(sb, delegateMethod, mockRegistryName, $"IMockVerifyFor{name}", false, memberIds, memberIdPrefix, false, "Verify"); - - if (delegateMethod.Parameters.Count > 0) + if (UseUnionOverloads(delegateMethod, true, useUnionOverloads)) { AppendMethodVerifyImplementation(sb, delegateMethod, mockRegistryName, $"IMockVerifyFor{name}", true, memberIds, memberIdPrefix, false, "Verify"); - } - - if (delegateMethod.Parameters.Count is > 0 and <= MaxExplicitParameters) - { - foreach (bool[] valueFlags in GenerateValueFlagCombinations(delegateMethod.Parameters)) + foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(delegateMethod.Parameters)) { - AppendMethodVerifyImplementation(sb, delegateMethod, mockRegistryName, $"IMockVerifyFor{name}", false, memberIds, memberIdPrefix, false, "Verify", valueFlags); + AppendUnionMethodVerifyImplementation(sb, delegateMethod, mockRegistryName, $"IMockVerifyFor{name}", memberIds, memberIdPrefix, false, slots, "Verify"); } } - else if (delegateMethod.Parameters.Count > MaxExplicitParameters) + else { - bool[] allValueFlags = delegateMethod.Parameters.Select(p => p.CanUseNullableParameterOverload()).ToArray(); - if (allValueFlags.Any(f => f)) + AppendMethodVerifyImplementation(sb, delegateMethod, mockRegistryName, $"IMockVerifyFor{name}", false, memberIds, memberIdPrefix, false, "Verify"); + + if (delegateMethod.Parameters.Count > 0) + { + AppendMethodVerifyImplementation(sb, delegateMethod, mockRegistryName, $"IMockVerifyFor{name}", true, memberIds, memberIdPrefix, false, "Verify"); + } + + if (delegateMethod.Parameters.Count is > 0 and <= MaxExplicitParameters) + { + foreach (bool[] valueFlags in GenerateValueFlagCombinations(delegateMethod.Parameters)) + { + AppendMethodVerifyImplementation(sb, delegateMethod, mockRegistryName, $"IMockVerifyFor{name}", false, memberIds, memberIdPrefix, false, "Verify", valueFlags); + } + } + else if (delegateMethod.Parameters.Count > MaxExplicitParameters) { - AppendMethodVerifyImplementation(sb, delegateMethod, mockRegistryName, $"IMockVerifyFor{name}", false, memberIds, memberIdPrefix, false, "Verify", allValueFlags); + bool[] allValueFlags = delegateMethod.Parameters.Select(p => p.CanUseNullableParameterOverload()).ToArray(); + if (allValueFlags.Any(f => f)) + { + AppendMethodVerifyImplementation(sb, delegateMethod, mockRegistryName, $"IMockVerifyFor{name}", false, memberIds, memberIdPrefix, false, "Verify", allValueFlags); + } } } @@ -350,26 +384,37 @@ public static string MockDelegate(string name, MockClass @class, Method delegate sb.Append("\tinternal interface IMockSetupFor").Append(name).Append(" : global::Mockolate.Setup.IMockSetup<").Append(@class.ClassFullName).Append(">").AppendLine(); sb.Append("\t{").AppendLine(); - AppendMethodSetupDefinition(sb, @class, delegateMethod, false, "Setup"); - - if (delegateMethod.Parameters.Count > 0) + if (UseUnionOverloads(delegateMethod, true, useUnionOverloads)) { AppendMethodSetupDefinition(sb, @class, delegateMethod, true, "Setup"); - } - - if (delegateMethod.Parameters.Count is > 0 and <= MaxExplicitParameters) - { - foreach (bool[] valueFlags in GenerateValueFlagCombinations(delegateMethod.Parameters)) + foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(delegateMethod.Parameters)) { - AppendMethodSetupDefinition(sb, @class, delegateMethod, false, "Setup", valueFlags); + AppendUnionMethodSetupDefinition(sb, @class, delegateMethod, slots, "Setup"); } } - else if (delegateMethod.Parameters.Count > MaxExplicitParameters) + else { - bool[] allValueFlags = delegateMethod.Parameters.Select(p => p.CanUseNullableParameterOverload()).ToArray(); - if (allValueFlags.Any(f => f)) + AppendMethodSetupDefinition(sb, @class, delegateMethod, false, "Setup"); + + if (delegateMethod.Parameters.Count > 0) + { + AppendMethodSetupDefinition(sb, @class, delegateMethod, true, "Setup"); + } + + if (delegateMethod.Parameters.Count is > 0 and <= MaxExplicitParameters) { - AppendMethodSetupDefinition(sb, @class, delegateMethod, false, "Setup", allValueFlags); + foreach (bool[] valueFlags in GenerateValueFlagCombinations(delegateMethod.Parameters)) + { + AppendMethodSetupDefinition(sb, @class, delegateMethod, false, "Setup", valueFlags); + } + } + else if (delegateMethod.Parameters.Count > MaxExplicitParameters) + { + bool[] allValueFlags = delegateMethod.Parameters.Select(p => p.CanUseNullableParameterOverload()).ToArray(); + if (allValueFlags.Any(f => f)) + { + AppendMethodSetupDefinition(sb, @class, delegateMethod, false, "Setup", allValueFlags); + } } } @@ -384,27 +429,38 @@ public static string MockDelegate(string name, MockClass @class, Method delegate sb.Append("\tinternal interface IMockVerifyFor").Append(name).Append(" : global::Mockolate.Verify.IMockVerify<").Append(@class.ClassFullName).Append(">").AppendLine(); sb.Append("\t{").AppendLine(); - AppendMethodVerifyDefinition(sb, delegateMethod, $"IMockVerifyFor{name}", false, "Verify"); - - if (delegateMethod.Parameters.Count > 0) + if (UseUnionOverloads(delegateMethod, true, useUnionOverloads)) { AppendMethodVerifyDefinition(sb, delegateMethod, $"IMockVerifyFor{name}", true, "Verify"); - } - - if (delegateMethod.Parameters.Count is > 0 and <= MaxExplicitParameters) - { - foreach (bool[] valueFlags in GenerateValueFlagCombinations(delegateMethod.Parameters)) + foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(delegateMethod.Parameters)) { - AppendMethodVerifyDefinition(sb, delegateMethod, $"IMockVerifyFor{name}", false, "Verify", valueFlags); + AppendUnionMethodVerifyDefinition(sb, @class, delegateMethod, $"IMockVerifyFor{name}", slots, "Verify"); } } - else if (delegateMethod.Parameters.Count > MaxExplicitParameters) + else { - bool[] allValueFlags = delegateMethod.Parameters.Select(p => p.CanUseNullableParameterOverload()).ToArray(); - if (allValueFlags.Any(f => f)) + AppendMethodVerifyDefinition(sb, delegateMethod, $"IMockVerifyFor{name}", false, "Verify"); + + if (delegateMethod.Parameters.Count > 0) { - AppendMethodVerifyDefinition(sb, delegateMethod, $"IMockVerifyFor{name}", false, "Verify", - allValueFlags); + AppendMethodVerifyDefinition(sb, delegateMethod, $"IMockVerifyFor{name}", true, "Verify"); + } + + if (delegateMethod.Parameters.Count is > 0 and <= MaxExplicitParameters) + { + foreach (bool[] valueFlags in GenerateValueFlagCombinations(delegateMethod.Parameters)) + { + AppendMethodVerifyDefinition(sb, delegateMethod, $"IMockVerifyFor{name}", false, "Verify", valueFlags); + } + } + else if (delegateMethod.Parameters.Count > MaxExplicitParameters) + { + bool[] allValueFlags = delegateMethod.Parameters.Select(p => p.CanUseNullableParameterOverload()).ToArray(); + if (allValueFlags.Any(f => f)) + { + AppendMethodVerifyDefinition(sb, delegateMethod, $"IMockVerifyFor{name}", false, "Verify", + allValueFlags); + } } } diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.ParameterArg.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.ParameterArg.cs index dbdf5d2a..f4a0dec5 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.ParameterArg.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.ParameterArg.cs @@ -15,28 +15,75 @@ internal static partial class Sources /// System.Runtime.CompilerServices.UnionAttribute (it ships with .NET 11), so the file has to /// declare it. /// - public static string ParameterArg(bool emitUnionAttributePolyfill) + /// + /// when OverloadResolutionPriorityAttribute (ships with .NET 9) is missing; the + /// union-mode overloads rely on it to keep and arguments + /// unambiguous, and the compiler honours a source-declared copy. + /// + /// + /// when CallerArgumentExpressionAttribute (ships with .NET 6) is missing; the + /// predicate overloads use it to keep the predicate text in failure messages. + /// + public static string ParameterArg(bool emitUnionAttributePolyfill, + bool emitOverloadResolutionPriorityPolyfill = false, bool emitCallerArgumentExpressionPolyfill = false) { StringBuilder sb = InitializeBuilder(); sb.AppendLine("#nullable enable"); sb.AppendLine(); - if (emitUnionAttributePolyfill) + if (emitUnionAttributePolyfill || emitOverloadResolutionPriorityPolyfill || emitCallerArgumentExpressionPolyfill) { - sb.Append(""" - namespace System.Runtime.CompilerServices - { - /// - /// Polyfill for the attribute that marks a union type; the runtime ships it starting with .NET 11. - /// - [global::System.AttributeUsage(global::System.AttributeTargets.Class | global::System.AttributeTargets.Struct, AllowMultiple = false)] - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal sealed class UnionAttribute : global::System.Attribute - { - } - } - - """); + sb.AppendLine("namespace System.Runtime.CompilerServices"); + sb.AppendLine("{"); + if (emitUnionAttributePolyfill) + { + sb.Append(""" + /// + /// Polyfill for the attribute that marks a union type; the runtime ships it starting with .NET 11. + /// + [global::System.AttributeUsage(global::System.AttributeTargets.Class | global::System.AttributeTargets.Struct, AllowMultiple = false)] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal sealed class UnionAttribute : global::System.Attribute + { + } + + """); + } + + if (emitOverloadResolutionPriorityPolyfill) + { + sb.Append(""" + /// + /// Polyfill for the overload priority attribute; the runtime ships it starting with .NET 9. + /// + [global::System.AttributeUsage(global::System.AttributeTargets.Method | global::System.AttributeTargets.Constructor | global::System.AttributeTargets.Property, AllowMultiple = false, Inherited = false)] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal sealed class OverloadResolutionPriorityAttribute(int priority) : global::System.Attribute + { + public int Priority { get; } = priority; + } + + """); + } + + if (emitCallerArgumentExpressionPolyfill) + { + sb.Append(""" + /// + /// Polyfill for the caller argument expression attribute; the runtime ships it starting with .NET 6. + /// + [global::System.AttributeUsage(global::System.AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal sealed class CallerArgumentExpressionAttribute(string parameterName) : global::System.Attribute + { + public string ParameterName { get; } = parameterName; + } + + """); + } + + sb.AppendLine("}"); + sb.AppendLine(); } sb.Append(""" diff --git a/Source/Mockolate/build/Mockolate.props b/Source/Mockolate/build/Mockolate.props index 6f2b5d36..acd623d7 100644 --- a/Source/Mockolate/build/Mockolate.props +++ b/Source/Mockolate/build/Mockolate.props @@ -5,6 +5,11 @@ to keep the classic matcher/value overloads even when the compiler supports unions. --> + + diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/MethodSetups.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/MethodSetups.g.cs new file mode 100644 index 00000000..be5c6940 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/MethodSetups.g.cs @@ -0,0 +1,771 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +#nullable enable + +namespace Mockolate.Setup +{ + /// + /// Sets up a method with 6 parameters , , , , and returning . + /// + internal interface IReturnMethodSetup : global::Mockolate.Setup.IMethodSetup + { + /// + /// Overrides SkipBaseClass for this method only. + /// + /// + /// If not specified, use SkipBaseClass. + /// + global::Mockolate.Setup.IReturnMethodSetup SkippingBaseClass(bool skipBaseClass = true); + + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Transitions the scenario to the given when the method is called. + /// + global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder TransitionTo(string scenario); + + /// + /// Registers a to setup the return value for this method. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(global::System.Func callback); + + /// + /// Registers the for this method. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(TReturn returnValue); + + /// + /// Registers an to throw when the method is invoked. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws() + where TException : global::System.Exception, new(); + + /// + /// Registers an to throw when the method is invoked. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(global::System.Exception exception); + + /// + /// Registers a that will calculate the exception to throw when the method is invoked. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(global::System.Func callback); + } + + /// + /// Sets up a method with 6 parameters , , , , and returning with callback support for the parameters. + /// + internal interface IReturnMethodSetupWithCallback : global::Mockolate.Setup.IReturnMethodSetup + { + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Registers a to setup the return value for this method. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(global::System.Func callback); + + /// + /// Registers a that will calculate the exception to throw when the method is invoked. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(global::System.Func callback); + } + + /// + /// Sets up a callback for a method with 6 parameters , , , , and returning . + /// + internal interface IReturnMethodSetupCallbackBuilder : global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder + { + /// + /// Runs the callback in parallel to the other callbacks. + /// + global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder InParallel(); + } + + /// + /// Sets up a parallel callback for a method with 6 parameters , , , , and returning . + /// + internal interface IReturnMethodSetupParallelCallbackBuilder : global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder + { + /// + /// Limits the callback to only execute for method invocations where the predicate returns true. + /// + /// + /// Provides a zero-based counter indicating how many times the method has been invoked so far. + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder When(global::System.Func predicate); + } + + /// + /// Sets up a when callback for a method with 6 parameters , , , , and returning . + /// + internal interface IReturnMethodSetupCallbackWhenBuilder : global::Mockolate.Setup.IReturnMethodSetupWithCallback + { + /// + /// Repeats the callback for the given number of . + /// + /// + /// The number of times is only counted for actual executions (IReturnMethodSetupParallelCallbackBuilder<TReturn, T1, T2, T3, T4, T5, T6>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder For(int times); + + /// + /// Deactivates the callback after the given number of . + /// + /// + /// The number of times is only counted for actual executions (IReturnMethodSetupParallelCallbackBuilder<TReturn, T1, T2, T3, T4, T5, T6>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IReturnMethodSetup Only(int times); + } + + /// + /// Sets up a return callback for a method with 6 parameters , , , , and returning . + /// + internal interface IReturnMethodSetupReturnBuilder : global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder + { + /// + /// Limits the return/throw to only execute for method invocations where the predicate returns true. + /// + /// + /// Provides a zero-based counter indicating how many times the method has been invoked so far. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder When(global::System.Func predicate); + } + + /// + /// Sets up a when return callback for a method with 6 parameters , , , , and returning . + /// + internal interface IReturnMethodSetupReturnWhenBuilder : global::Mockolate.Setup.IReturnMethodSetupWithCallback + { + /// + /// Repeats the callback for the given number of . + /// + /// + /// The number of times is only counted for actual executions (IReturnMethodSetupReturnBuilder<TReturn, T1, T2, T3, T4, T5, T6>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder For(int times); + + /// + /// Deactivates the return/throw after the given number of . + /// + /// + /// The number of times is only counted for actual executions (IReturnMethodSetupReturnBuilder<TReturn, T1, T2, T3, T4, T5, T6>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IReturnMethodSetup Only(int times); + } + + /// + /// Allows ignoring the provided parameters. + /// + internal interface IReturnMethodSetupParameterIgnorer : global::Mockolate.Setup.IReturnMethodSetupWithCallback + { + /// + /// Replaces the explicit parameter matcher with AnyParameters(). + /// + global::Mockolate.Setup.IReturnMethodSetup AnyParameters(); + } + + /// + /// Sets up a method with 6 parameters , , , , and returning . + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal abstract class ReturnMethodSetup : global::Mockolate.Setup.MethodSetup, + global::Mockolate.Setup.IReturnMethodSetupWithCallback, + global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder, + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder + { + private readonly global::Mockolate.MockRegistry _mockRegistry; + private global::Mockolate.Setup.Callbacks>? _callbacks = []; + private global::Mockolate.Setup.Callbacks>? _returnCallbacks = []; + private bool? _skipBaseClass; + + protected ReturnMethodSetup(global::Mockolate.MockRegistry mockRegistry, string name) + : base(name) + { + _mockRegistry = mockRegistry; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetup.SkippingBaseClass(bool skipBaseClass) + { + _skipBaseClass = skipBaseClass; + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder global::Mockolate.Setup.IReturnMethodSetup.Do(global::System.Action callback) + { + global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _, _) => callback()); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Do(global::System.Action callback) + { + global::Mockolate.Setup.Callback>? currentCallback = new((_, p1, p2, p3, p4, p5, p6) => callback(p1, p2, p3, p4, p5, p6)); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Do(global::System.Action callback) + { + global::Mockolate.Setup.Callback>? currentCallback = new(callback); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IReturnMethodSetup.TransitionTo(string scenario) + { + global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _, _) => _mockRegistry.TransitionTo(scenario)); + currentCallback.InParallel(); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Returns(global::System.Func callback) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, p1, p2, p3, p4, p5, p6) => callback(p1, p2, p3, p4, p5, p6)); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Returns(global::System.Func callback) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _) => callback()); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Returns(TReturn returnValue) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _) => returnValue); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Throws() + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _) => throw new TException()); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Throws(global::System.Exception exception) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _) => throw exception); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Throws(global::System.Func callback) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, p1, p2, p3, p4, p5, p6) => throw callback(p1, p2, p3, p4, p5, p6)); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Throws(global::System.Func callback) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _) => throw callback()); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder.InParallel() + { + _callbacks?.Active?.InParallel(); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder.When(global::System.Func predicate) + { + _callbacks?.Active?.When(predicate); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder.For(int times) + { + _callbacks?.Active?.For(times); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder.Only(int times) + { + _callbacks?.Active?.Only(times); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder global::Mockolate.Setup.IReturnMethodSetupReturnBuilder.When(global::System.Func predicate) + { + _returnCallbacks?.Active?.When(predicate); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder.For(int times) + { + _returnCallbacks?.Active?.For(times); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder.Only(int times) + { + _returnCallbacks?.Active?.Only(times); + return this; + } + + /// + protected override bool MatchesInteraction(global::Mockolate.Interactions.IMethodInteraction interaction) + { + if (interaction is global::Mockolate.Interactions.MethodInvocation invocation) + { + return Matches(invocation.Parameter1, invocation.Parameter2, invocation.Parameter3, invocation.Parameter4, invocation.Parameter5, invocation.Parameter6); + } + return false; + } + + /// + /// Flag indicating, if any return callbacks have been registered on this setup. + /// + public bool HasReturnCallbacks + => _returnCallbacks is { Count: > 0, }; + + /// + /// Gets the flag indicating if the base class implementation should be skipped. + /// + public bool SkipBaseClass(global::Mockolate.MockBehavior behavior) + => _skipBaseClass ?? behavior.SkipBaseClass; + + /// + /// Gets the registered return value. + /// + public bool TryGetReturnValue(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, out TReturn returnValue) + { + if (_returnCallbacks != null) + { + foreach (var _ in _returnCallbacks) + { + var returnCallback = _returnCallbacks[_returnCallbacks.CurrentIndex % _returnCallbacks.Count]; + if (returnCallback.Invoke(ref _returnCallbacks.CurrentIndex, (p1, p2, p3, p4, p5, p6), + static (invocationCount, @delegate, state) => @delegate(invocationCount, state.p1, state.p2, state.p3, state.p4, state.p5, state.p6), + out TReturn? newValue)) + { + returnValue = newValue; + return true; + } + } + } + returnValue = default!; + return false; + } + + /// + /// Checks if the given parameters match the setup. + /// + public abstract bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value); + + /// + /// Triggers any configured parameter callbacks for the method setup with the specified parameters. + /// + public virtual void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6) + { + if (_callbacks is not null) + { + bool wasInvoked = false; + int currentCallbacksIndex = _callbacks.CurrentIndex; + for (int i = 0; i < _callbacks.Count; i++) + { + var callback = _callbacks[(currentCallbacksIndex + i) % _callbacks.Count]; + if (callback.Invoke(wasInvoked, ref _callbacks.CurrentIndex, (parameter1, parameter2, parameter3, parameter4, parameter5, parameter6), + static (invocationCount, @delegate, state) => @delegate(invocationCount, state.parameter1, state.parameter2, state.parameter3, state.parameter4, state.parameter5, state.parameter6))) + { + wasInvoked = true; + } + } + } + } + + /// Setup for a method with 6 parameters matching against IParameters. + internal class WithParameters : ReturnMethodSetup + { + private readonly string _parameterName1; + private readonly string _parameterName2; + private readonly string _parameterName3; + private readonly string _parameterName4; + private readonly string _parameterName5; + private readonly string _parameterName6; + + /// + public WithParameters(global::Mockolate.MockRegistry mockRegistry, string name, global::Mockolate.Parameters.IParameters parameters, string parameterName1, string parameterName2, string parameterName3, string parameterName4, string parameterName5, string parameterName6) + : base(mockRegistry, name) + { + Parameters = parameters; + _parameterName1 = parameterName1; + _parameterName2 = parameterName2; + _parameterName3 = parameterName3; + _parameterName4 = parameterName4; + _parameterName5 = parameterName5; + _parameterName6 = parameterName6; + } + + private global::Mockolate.Parameters.IParameters Parameters { get; } + + /// + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value) + => Parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([p1Value, p2Value, p3Value, p4Value, p5Value, p6Value]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([(_parameterName1, p1Value), (_parameterName2, p2Value), (_parameterName3, p3Value), (_parameterName4, p4Value), (_parameterName5, p5Value), (_parameterName6, p6Value)]), + _ => true, + }; + + /// + public override string ToString() + { + return $"{FormatType(typeof(TReturn))} {SubstringAfterLast(Name, '.')}({Parameters})"; + static string SubstringAfterLast(string name, char c) + { + int index = name.LastIndexOf(c); + return index >= 0 ? name.Substring(index + 1) : name; + } + } + } + + /// Setup for a method with 6 parameters matching against individual IParameterMatch<T>. + internal class WithParameterCollection : ReturnMethodSetup, + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer + { + private bool _matchAnyParameters; + + /// + public WithParameterCollection( + global::Mockolate.MockRegistry mockRegistry, + string name, + global::Mockolate.Parameters.IParameterMatch parameter1, + global::Mockolate.Parameters.IParameterMatch parameter2, + global::Mockolate.Parameters.IParameterMatch parameter3, + global::Mockolate.Parameters.IParameterMatch parameter4, + global::Mockolate.Parameters.IParameterMatch parameter5, + global::Mockolate.Parameters.IParameterMatch parameter6) + : base(mockRegistry, name) + { + Parameter1 = parameter1; + Parameter2 = parameter2; + Parameter3 = parameter3; + Parameter4 = parameter4; + Parameter5 = parameter5; + Parameter6 = parameter6; + } + + /// The first parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter1 { get; } + + /// The second parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter2 { get; } + + /// The third parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter3 { get; } + + /// The 4th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter4 { get; } + + /// The 5th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter5 { get; } + + /// The 6th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter6 { get; } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer.AnyParameters() + { + _matchAnyParameters = true; + return this; + } + + /// + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value) + => _matchAnyParameters || (Parameter1.Matches(p1Value) && Parameter2.Matches(p2Value) && Parameter3.Matches(p3Value) && Parameter4.Matches(p4Value) && Parameter5.Matches(p5Value) && Parameter6.Matches(p6Value)); + + /// + public override void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6) + { + Parameter1?.InvokeCallbacks(parameter1); + Parameter2?.InvokeCallbacks(parameter2); + Parameter3?.InvokeCallbacks(parameter3); + Parameter4?.InvokeCallbacks(parameter4); + Parameter5?.InvokeCallbacks(parameter5); + Parameter6?.InvokeCallbacks(parameter6); + base.TriggerCallbacks(parameter1, parameter2, parameter3, parameter4, parameter5, parameter6); + } + + /// + public override string ToString() + { + return $"{FormatType(typeof(TReturn))} {SubstringAfterLast(Name, '.')}({Parameter1}, {Parameter2}, {Parameter3}, {Parameter4}, {Parameter5}, {Parameter6})"; + static string SubstringAfterLast(string name, char c) + { + int index = name.LastIndexOf(c); + return index >= 0 ? name.Substring(index + 1) : name; + } + } + } + } + +} + +namespace Mockolate +{ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal static class MethodSetupExtensions + { + + /// + /// Extensions for method callback setup returning with 6 parameters. + /// + extension(global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder setup) + { + /// + /// Executes the callback only once. + /// + public global::Mockolate.Setup.IReturnMethodSetup OnlyOnce() + => setup.Only(1); + } + + /// + /// Extensions for method setup returning with 6 parameters. + /// + extension(global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder setup) + { + /// + /// Returns/throws forever. + /// + public void Forever() + { + setup.For(int.MaxValue); + } + + /// + /// Uses the return value only once. + /// + public global::Mockolate.Setup.IReturnMethodSetup OnlyOnce() + => setup.Only(1); + } + } +} +namespace Mockolate.Interactions +{ + /// + /// An invocation of a method with 6 parameters , , , , and . + /// + [global::System.Diagnostics.DebuggerDisplay("{ToString()}")] + internal class MethodInvocation(string name, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6) : IMethodInteraction + { + /// + /// The name of the method. + /// + public string Name { get; } = name; + /// + /// The first parameter value of the method. + /// + public T1 Parameter1 { get; } = parameter1; + /// + /// The second parameter value of the method. + /// + public T2 Parameter2 { get; } = parameter2; + /// + /// The third parameter value of the method. + /// + public T3 Parameter3 { get; } = parameter3; + /// + /// The 4th parameter value of the method. + /// + public T4 Parameter4 { get; } = parameter4; + /// + /// The 5th parameter value of the method. + /// + public T5 Parameter5 { get; } = parameter5; + /// + /// The 6th parameter value of the method. + /// + public T6 Parameter6 { get; } = parameter6; + /// + public override string ToString() + { + return $"invoke method {SubstringAfterLast(Name, '.')}({Parameter1?.ToString() ?? "null"}, {Parameter2?.ToString() ?? "null"}, {Parameter3?.ToString() ?? "null"}, {Parameter4?.ToString() ?? "null"}, {Parameter5?.ToString() ?? "null"}, {Parameter6?.ToString() ?? "null"})"; + static string SubstringAfterLast(string name, char c) + { + int index = name.LastIndexOf(c); + return index >= 0 ? name.Substring(index + 1) : name; + } + } + } + /// + /// Per-member buffer for 6-parameter methods, synthesized for arity 6 use sites. + /// + [global::System.Diagnostics.DebuggerDisplay("{Count} method calls")] + internal sealed class FastMethod6Buffer : IFastMemberBuffer + { + private readonly FastMockInteractions _owner; +#if NET10_0_OR_GREATER + private readonly global::System.Threading.Lock _growLock = new(); +#else + private readonly object _growLock = new(); +#endif + private Record[] _records = new Record[4]; + private bool[] _verifiedSlots = new bool[4]; + private int _reserved; + private int _published; + + internal FastMethod6Buffer(FastMockInteractions owner) => _owner = owner; + + public int Count => global::System.Threading.Volatile.Read(ref _published); + + public void Append(string name, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6) + { + long seq = _owner.NextSequence(); + int slot = global::System.Threading.Interlocked.Increment(ref _reserved) - 1; + Record[] records = global::System.Threading.Volatile.Read(ref _records); + if (slot >= records.Length) records = GrowToFit(slot); + + records[slot].Seq = seq; + records[slot].Name = name; + records[slot].P1 = parameter1; + records[slot].P2 = parameter2; + records[slot].P3 = parameter3; + records[slot].P4 = parameter4; + records[slot].P5 = parameter5; + records[slot].P6 = parameter6; + records[slot].Boxed = null; + global::System.Threading.Interlocked.Increment(ref _published); + + if (_owner.HasInteractionAddedSubscribers) _owner.RaiseAdded(); + } + + private Record[] GrowToFit(int slot) + { + lock (_growLock) + { + Record[] records = _records; + while (slot >= records.Length) + { + Record[] bigger = new Record[records.Length * 2]; + global::System.Array.Copy(records, bigger, records.Length); + records = bigger; + } + global::System.Threading.Volatile.Write(ref _records, records); + if (_verifiedSlots.Length < records.Length) + { + bool[] biggerBits = new bool[records.Length]; + global::System.Array.Copy(_verifiedSlots, biggerBits, _verifiedSlots.Length); + _verifiedSlots = biggerBits; + } + return records; + } + } + + public void Clear() + { + lock (_growLock) { global::System.Array.Clear(_records, 0, _published); _reserved = 0; global::System.Threading.Volatile.Write(ref _published, 0); global::System.Array.Clear(_verifiedSlots, 0, _verifiedSlots.Length); } + } + + void IFastMemberBuffer.AppendBoxed(global::System.Collections.Generic.List> dest) + { + lock (_growLock) + { + int n = _published; + Record[] records = _records; + for (int i = 0; i < n; i++) + { + ref Record r = ref records[i]; + r.Boxed ??= new MethodInvocation(r.Name, r.P1, r.P2, r.P3, r.P4, r.P5, r.P6); + dest.Add(new global::System.ValueTuple(r.Seq, r.Boxed)); + } + } + } + + void IFastMemberBuffer.AppendBoxedUnverified(global::System.Collections.Generic.List> dest) + { + lock (_growLock) + { + int n = _published; + Record[] records = _records; + bool[] verified = _verifiedSlots; + for (int i = 0; i < n; i++) + { + if (verified[i]) continue; + ref Record r = ref records[i]; + r.Boxed ??= new MethodInvocation(r.Name, r.P1, r.P2, r.P3, r.P4, r.P5, r.P6); + dest.Add(new global::System.ValueTuple(r.Seq, r.Boxed)); + } + } + } + + public int ConsumeMatching(global::Mockolate.Parameters.IParameterMatch match1, global::Mockolate.Parameters.IParameterMatch match2, global::Mockolate.Parameters.IParameterMatch match3, global::Mockolate.Parameters.IParameterMatch match4, global::Mockolate.Parameters.IParameterMatch match5, global::Mockolate.Parameters.IParameterMatch match6) + { + int matches = 0; + lock (_growLock) + { + int n = _published; + Record[] records = _records; + bool[] verified = _verifiedSlots; + for (int i = 0; i < n; i++) + { + ref Record r = ref records[i]; + if (match1.Matches(r.P1) && match2.Matches(r.P2) && match3.Matches(r.P3) && match4.Matches(r.P4) && match5.Matches(r.P5) && match6.Matches(r.P6)) + { + matches++; + verified[i] = true; + } + } + } + + return matches; + } + + private struct Record + { + public long Seq; + public string Name; + public T1 P1; + public T2 P2; + public T3 P3; + public T4 P4; + public T5 P5; + public T6 P6; + public IInteraction? Boxed; + } + } +} + +#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/Mock.ComprehensiveDelegate.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/Mock.ComprehensiveDelegate.g.cs new file mode 100644 index 00000000..594f3711 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/Mock.ComprehensiveDelegate.g.cs @@ -0,0 +1,491 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +#nullable enable annotations +namespace Mockolate; + +internal static partial class Mock +{ + /// + /// A mock implementation for ComprehensiveDelegate. + /// + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal class ComprehensiveDelegate : + IMockForComprehensiveDelegate, + global::Mockolate.IMock + { + internal const int MemberId_Invoke = 0; + internal const int MemberCount = 1; + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.MockRegistry global::Mockolate.IMock.MockRegistry => this.MockRegistry; + private global::Mockolate.MockRegistry MockRegistry { get; } + + /// + public ComprehensiveDelegate(global::Mockolate.MockRegistry mockRegistry) + { + this.MockRegistry = mockRegistry; + } + + /// + /// Returns the actual delegate with the mock as target. + /// + public global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate Object => new(Invoke); + private global::System.Span Invoke(int x, ref int y, out string z, in long w) + { + var ref_y = y; + global::Mockolate.Setup.ReturnMethodSetup, int, int, string, long>? methodSetup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.ComprehensiveDelegate.MemberId_Invoke); + 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, int, int, string, long> s_methodSetup && s_methodSetup.Matches(x, ref_y, default, w)) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup, int, int, string, long> s_methodSetup in this.MockRegistry.GetMethodSetups, int, int, string, long>>("global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate.Invoke")) + { + if (s_methodSetup.Matches(x, ref_y, default, w)) + { + methodSetup = s_methodSetup; + break; + } + } + } + z = default!; + if (methodSetup is global::Mockolate.Setup.ReturnMethodSetup, int, int, string, long>.WithParameterCollection wpc) + { + if (wpc.Parameter2 is global::Mockolate.Parameters.IRefParameter refParam2) + { + y = refParam2.GetValue(y); + } + if (wpc.Parameter3 is not global::Mockolate.Parameters.IOutParameter outParam3 || !outParam3.TryGetValue(out z)) + { + z = this.MockRegistry.Behavior.DefaultValue.Generate(default(string)!); + } + } + if (MockRegistry.Behavior.SkipInteractionRecording == false) + { + MockRegistry.RegisterInteraction(new global::Mockolate.Interactions.MethodInvocation("global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate.Invoke", x, y, z, w)); + } + if (methodSetup is null && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate.Invoke(int, int, string, long)' was invoked without prior setup."); + } + methodSetup?.TriggerCallbacks(x, y, z, w); + return methodSetup?.TryGetReturnValue(x, y, z, w, out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(global::Mockolate.Setup.SpanWrapper)!); + } + + /// + string global::Mockolate.IMock.ToString() + => "Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate mock"; + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback, int, int, string, long> global::Mockolate.Mock.IMockSetupForComprehensiveDelegate.Setup(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, int, int, string, long>.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate.Invoke", parameters, "x", "y", "z", "w"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.ComprehensiveDelegate.MemberId_Invoke, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int, int, string, long> global::Mockolate.Mock.IMockSetupForComprehensiveDelegate.Setup(global::Mockolate.ParameterArg? x, global::Mockolate.Parameters.IRefParameter y, global::Mockolate.Parameters.IOutParameter z, global::Mockolate.ParameterArg? w) + { + global::Mockolate.ParameterArg xArg = x ?? default; + global::Mockolate.ParameterArg wArg = w ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, int, int, string, long>.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate.Invoke", xArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)(y), (global::Mockolate.Parameters.IParameterMatch)(z), wArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.ComprehensiveDelegate.MemberId_Invoke, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int, int, string, long>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int, int, string, long> global::Mockolate.Mock.IMockSetupForComprehensiveDelegate.Setup(global::System.Func x, global::Mockolate.Parameters.IRefParameter y, global::Mockolate.Parameters.IOutParameter z, global::Mockolate.ParameterArg? w, string xExpression) + { + global::Mockolate.ParameterArg wArg = w ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, int, int, string, long>.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate.Invoke", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(x, xExpression), (global::Mockolate.Parameters.IParameterMatch)(y), (global::Mockolate.Parameters.IParameterMatch)(z), wArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.ComprehensiveDelegate.MemberId_Invoke, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int, int, string, long>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int, int, string, long> global::Mockolate.Mock.IMockSetupForComprehensiveDelegate.Setup(global::Mockolate.ParameterArg? x, global::Mockolate.Parameters.IRefParameter y, global::Mockolate.Parameters.IOutParameter z, global::System.Func w, string wExpression) + { + global::Mockolate.ParameterArg xArg = x ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, int, int, string, long>.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate.Invoke", xArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)(y), (global::Mockolate.Parameters.IParameterMatch)(z), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(w, wExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.ComprehensiveDelegate.MemberId_Invoke, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int, int, string, long>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int, int, string, long> global::Mockolate.Mock.IMockSetupForComprehensiveDelegate.Setup(global::System.Func x, global::Mockolate.Parameters.IRefParameter y, global::Mockolate.Parameters.IOutParameter z, global::System.Func w, string xExpression, string wExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, int, int, string, long>.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate.Invoke", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(x, xExpression), (global::Mockolate.Parameters.IParameterMatch)(y), (global::Mockolate.Parameters.IParameterMatch)(z), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(w, wExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.ComprehensiveDelegate.MemberId_Invoke, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int, int, string, long>)methodSetup; + } + + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForComprehensiveDelegate.Verify(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, -1, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate.Invoke", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2, __i.Parameter3, __i.Parameter4]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("x", __i.Parameter1), ("y", __i.Parameter2), ("z", __i.Parameter3), ("w", __i.Parameter4)]), + _ => true + }, () => $"Invoke({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForComprehensiveDelegate.Verify(global::Mockolate.ParameterArg? x, global::Mockolate.Parameters.IVerifyRefParameter y, global::Mockolate.Parameters.IVerifyOutParameter z, global::Mockolate.ParameterArg? w) + { + global::Mockolate.ParameterArg xArg = x ?? default; + global::Mockolate.ParameterArg wArg = w ?? default; + global::Mockolate.Parameters.IParameterMatch xMatch = xArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch wMatch = wArg.ToParameterMatch(); + return this.MockRegistry.VerifyMethod>(this, -1, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate.Invoke", __i => + (xMatch.Matches(__i.Parameter1)) && + (y is global::Mockolate.Parameters.IParameterMatch yMatch ? yMatch.Matches(__i.Parameter2) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter2, default(int))) && + (z is global::Mockolate.Parameters.IParameterMatch zMatch ? zMatch.Matches(__i.Parameter3) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter3, default(string))) && + (wMatch.Matches(__i.Parameter4)), () => $"Invoke({xArg}, {y}, {z}, {wArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForComprehensiveDelegate.Verify(global::System.Func x, global::Mockolate.Parameters.IVerifyRefParameter y, global::Mockolate.Parameters.IVerifyOutParameter z, global::Mockolate.ParameterArg? w, string xExpression) + { + global::Mockolate.ParameterArg wArg = w ?? default; + global::Mockolate.Parameters.IParameterMatch xMatch = (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(x, xExpression); + global::Mockolate.Parameters.IParameterMatch wMatch = wArg.ToParameterMatch(); + return this.MockRegistry.VerifyMethod>(this, -1, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate.Invoke", __i => + (xMatch.Matches(__i.Parameter1)) && + (y is global::Mockolate.Parameters.IParameterMatch yMatch ? yMatch.Matches(__i.Parameter2) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter2, default(int))) && + (z is global::Mockolate.Parameters.IParameterMatch zMatch ? zMatch.Matches(__i.Parameter3) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter3, default(string))) && + (wMatch.Matches(__i.Parameter4)), () => $"Invoke({xExpression}, {y}, {z}, {wArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForComprehensiveDelegate.Verify(global::Mockolate.ParameterArg? x, global::Mockolate.Parameters.IVerifyRefParameter y, global::Mockolate.Parameters.IVerifyOutParameter z, global::System.Func w, string wExpression) + { + global::Mockolate.ParameterArg xArg = x ?? default; + global::Mockolate.Parameters.IParameterMatch xMatch = xArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch wMatch = (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(w, wExpression); + return this.MockRegistry.VerifyMethod>(this, -1, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate.Invoke", __i => + (xMatch.Matches(__i.Parameter1)) && + (y is global::Mockolate.Parameters.IParameterMatch yMatch ? yMatch.Matches(__i.Parameter2) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter2, default(int))) && + (z is global::Mockolate.Parameters.IParameterMatch zMatch ? zMatch.Matches(__i.Parameter3) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter3, default(string))) && + (wMatch.Matches(__i.Parameter4)), () => $"Invoke({xArg}, {y}, {z}, {wExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForComprehensiveDelegate.Verify(global::System.Func x, global::Mockolate.Parameters.IVerifyRefParameter y, global::Mockolate.Parameters.IVerifyOutParameter z, global::System.Func w, string xExpression, string wExpression) + { + global::Mockolate.Parameters.IParameterMatch xMatch = (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(x, xExpression); + global::Mockolate.Parameters.IParameterMatch wMatch = (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(w, wExpression); + return this.MockRegistry.VerifyMethod>(this, -1, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate.Invoke", __i => + (xMatch.Matches(__i.Parameter1)) && + (y is global::Mockolate.Parameters.IParameterMatch yMatch ? yMatch.Matches(__i.Parameter2) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter2, default(int))) && + (z is global::Mockolate.Parameters.IParameterMatch zMatch ? zMatch.Matches(__i.Parameter3) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter3, default(string))) && + (wMatch.Matches(__i.Parameter4)), () => $"Invoke({xExpression}, {y}, {z}, {wExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult IMockForComprehensiveDelegate.VerifySetup(global::Mockolate.Setup.IMethodSetup setup) + => this.MockRegistry.Method(this, setup); + + /// + bool IMockForComprehensiveDelegate.VerifyThatAllInteractionsAreVerified() + => this.MockRegistry.Interactions.GetUnverifiedInteractions().Count == 0; + + /// + bool IMockForComprehensiveDelegate.VerifyThatAllSetupsAreUsed() + => this.MockRegistry.GetUnusedSetups(this.MockRegistry.Interactions).Count == 0; + + /// + void IMockForComprehensiveDelegate.ClearAllInteractions() + => this.MockRegistry.ClearAllInteractions(); + + /// + global::Mockolate.Monitor.MockMonitor IMockForComprehensiveDelegate.Monitor() + => new global::Mockolate.Monitor.MockMonitor(this.MockRegistry.Interactions, interactions => new VerifyMonitorComprehensiveDelegate(new global::Mockolate.MockRegistry(this.MockRegistry, interactions))); + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class VerifyMonitorComprehensiveDelegate(global::Mockolate.MockRegistry mockRegistry) : global::Mockolate.Mock.IMockVerifyForComprehensiveDelegate + { + private global::Mockolate.MockRegistry MockRegistry { get; } = mockRegistry; + + #region IMockVerifyForComprehensiveDelegate + + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForComprehensiveDelegate.Verify(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, -1, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate.Invoke", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2, __i.Parameter3, __i.Parameter4]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("x", __i.Parameter1), ("y", __i.Parameter2), ("z", __i.Parameter3), ("w", __i.Parameter4)]), + _ => true + }, () => $"Invoke({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForComprehensiveDelegate.Verify(global::Mockolate.ParameterArg? x, global::Mockolate.Parameters.IVerifyRefParameter y, global::Mockolate.Parameters.IVerifyOutParameter z, global::Mockolate.ParameterArg? w) + { + global::Mockolate.ParameterArg xArg = x ?? default; + global::Mockolate.ParameterArg wArg = w ?? default; + global::Mockolate.Parameters.IParameterMatch xMatch = xArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch wMatch = wArg.ToParameterMatch(); + return this.MockRegistry.VerifyMethod>(this, -1, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate.Invoke", __i => + (xMatch.Matches(__i.Parameter1)) && + (y is global::Mockolate.Parameters.IParameterMatch yMatch ? yMatch.Matches(__i.Parameter2) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter2, default(int))) && + (z is global::Mockolate.Parameters.IParameterMatch zMatch ? zMatch.Matches(__i.Parameter3) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter3, default(string))) && + (wMatch.Matches(__i.Parameter4)), () => $"Invoke({xArg}, {y}, {z}, {wArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForComprehensiveDelegate.Verify(global::System.Func x, global::Mockolate.Parameters.IVerifyRefParameter y, global::Mockolate.Parameters.IVerifyOutParameter z, global::Mockolate.ParameterArg? w, string xExpression) + { + global::Mockolate.ParameterArg wArg = w ?? default; + global::Mockolate.Parameters.IParameterMatch xMatch = (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(x, xExpression); + global::Mockolate.Parameters.IParameterMatch wMatch = wArg.ToParameterMatch(); + return this.MockRegistry.VerifyMethod>(this, -1, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate.Invoke", __i => + (xMatch.Matches(__i.Parameter1)) && + (y is global::Mockolate.Parameters.IParameterMatch yMatch ? yMatch.Matches(__i.Parameter2) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter2, default(int))) && + (z is global::Mockolate.Parameters.IParameterMatch zMatch ? zMatch.Matches(__i.Parameter3) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter3, default(string))) && + (wMatch.Matches(__i.Parameter4)), () => $"Invoke({xExpression}, {y}, {z}, {wArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForComprehensiveDelegate.Verify(global::Mockolate.ParameterArg? x, global::Mockolate.Parameters.IVerifyRefParameter y, global::Mockolate.Parameters.IVerifyOutParameter z, global::System.Func w, string wExpression) + { + global::Mockolate.ParameterArg xArg = x ?? default; + global::Mockolate.Parameters.IParameterMatch xMatch = xArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch wMatch = (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(w, wExpression); + return this.MockRegistry.VerifyMethod>(this, -1, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate.Invoke", __i => + (xMatch.Matches(__i.Parameter1)) && + (y is global::Mockolate.Parameters.IParameterMatch yMatch ? yMatch.Matches(__i.Parameter2) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter2, default(int))) && + (z is global::Mockolate.Parameters.IParameterMatch zMatch ? zMatch.Matches(__i.Parameter3) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter3, default(string))) && + (wMatch.Matches(__i.Parameter4)), () => $"Invoke({xArg}, {y}, {z}, {wExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForComprehensiveDelegate.Verify(global::System.Func x, global::Mockolate.Parameters.IVerifyRefParameter y, global::Mockolate.Parameters.IVerifyOutParameter z, global::System.Func w, string xExpression, string wExpression) + { + global::Mockolate.Parameters.IParameterMatch xMatch = (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(x, xExpression); + global::Mockolate.Parameters.IParameterMatch wMatch = (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(w, wExpression); + return this.MockRegistry.VerifyMethod>(this, -1, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate.Invoke", __i => + (xMatch.Matches(__i.Parameter1)) && + (y is global::Mockolate.Parameters.IParameterMatch yMatch ? yMatch.Matches(__i.Parameter2) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter2, default(int))) && + (z is global::Mockolate.Parameters.IParameterMatch zMatch ? zMatch.Matches(__i.Parameter3) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter3, default(string))) && + (wMatch.Matches(__i.Parameter4)), () => $"Invoke({xExpression}, {y}, {z}, {wExpression})"); + } + + #endregion IMockVerifyForComprehensiveDelegate + } + + /// + /// Accesses the mock of ComprehensiveDelegate. + /// + internal interface IMockForComprehensiveDelegate : + IMockSetupForComprehensiveDelegate, IMockVerifyForComprehensiveDelegate + { + /// + /// Verifies the method invocations for the on the mock. + /// + global::Mockolate.Verify.VerificationResult VerifySetup(global::Mockolate.Setup.IMethodSetup setup); + + /// + /// Gets a value indicating whether all expected interactions have been verified. + /// + bool VerifyThatAllInteractionsAreVerified(); + + /// + /// Gets a value indicating whether all registered setups were used. + /// + bool VerifyThatAllSetupsAreUsed(); + + /// + /// Clears all interactions recorded by the mock object. + /// + void ClearAllInteractions(); + + /// + /// Provides monitoring capabilities for a mocked instance of the specified type, allowing inspection of accessed properties, invoked methods, and event subscriptions. + /// + global::Mockolate.Monitor.MockMonitor Monitor(); + } + + /// + /// Set up the mock of ComprehensiveDelegate. + /// + internal interface IMockSetupForComprehensiveDelegate : global::Mockolate.Setup.IMockSetup + { + /// + /// Setup for the delegate ComprehensiveDelegate 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::Mockolate.Setup.IReturnMethodSetupWithCallback, int, int, string, long> Setup(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Setup for the delegate ComprehensiveDelegate with the given , , , . + /// + /// + /// This overload accepts an It matcher or a direct value for , and an It matcher for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int, int, string, long> Setup(global::Mockolate.ParameterArg? x, global::Mockolate.Parameters.IRefParameter y, global::Mockolate.Parameters.IOutParameter z, global::Mockolate.ParameterArg? w); + + /// + /// Setup for the delegate ComprehensiveDelegate with the given , , , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for and an It matcher for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(3)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int, int, string, long> Setup(global::System.Func x, global::Mockolate.Parameters.IRefParameter y, global::Mockolate.Parameters.IOutParameter z, global::Mockolate.ParameterArg? w, [global::System.Runtime.CompilerServices.CallerArgumentExpression("x")] string xExpression = ""); + + /// + /// Setup for the delegate ComprehensiveDelegate with the given , , , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for and an It matcher for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(3)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int, int, string, long> Setup(global::Mockolate.ParameterArg? x, global::Mockolate.Parameters.IRefParameter y, global::Mockolate.Parameters.IOutParameter z, global::System.Func w, [global::System.Runtime.CompilerServices.CallerArgumentExpression("w")] string wExpression = ""); + + /// + /// Setup for the delegate ComprehensiveDelegate with the given , , , . + /// + /// + /// This overload accepts a predicate for , and an It matcher for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int, int, string, long> Setup(global::System.Func x, global::Mockolate.Parameters.IRefParameter y, global::Mockolate.Parameters.IOutParameter z, global::System.Func w, [global::System.Runtime.CompilerServices.CallerArgumentExpression("x")] string xExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("w")] string wExpression = ""); + + } + + /// + /// Verify interactions with the mock of ComprehensiveDelegate. + /// + internal interface IMockVerifyForComprehensiveDelegate : global::Mockolate.Verify.IMockVerify + { + /// + /// Verify invocations for the delegate ComprehensiveDelegate 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::Mockolate.Verify.VerificationResult Verify(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Verify invocations for the delegate ComprehensiveDelegate with the given , , , . + /// + /// + /// This overload accepts an It matcher or a direct value for , and an It matcher for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters Verify(global::Mockolate.ParameterArg? x, global::Mockolate.Parameters.IVerifyRefParameter y, global::Mockolate.Parameters.IVerifyOutParameter z, global::Mockolate.ParameterArg? w); + + /// + /// Verify invocations for the delegate ComprehensiveDelegate with the given , , , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for and an It matcher for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(3)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters Verify(global::System.Func x, global::Mockolate.Parameters.IVerifyRefParameter y, global::Mockolate.Parameters.IVerifyOutParameter z, global::Mockolate.ParameterArg? w, [global::System.Runtime.CompilerServices.CallerArgumentExpression("x")] string xExpression = ""); + + /// + /// Verify invocations for the delegate ComprehensiveDelegate with the given , , , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for and an It matcher for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(3)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters Verify(global::Mockolate.ParameterArg? x, global::Mockolate.Parameters.IVerifyRefParameter y, global::Mockolate.Parameters.IVerifyOutParameter z, global::System.Func w, [global::System.Runtime.CompilerServices.CallerArgumentExpression("w")] string wExpression = ""); + + /// + /// Verify invocations for the delegate ComprehensiveDelegate with the given , , , . + /// + /// + /// This overload accepts a predicate for , and an It matcher for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters Verify(global::System.Func x, global::Mockolate.Parameters.IVerifyRefParameter y, global::Mockolate.Parameters.IVerifyOutParameter z, global::System.Func w, [global::System.Runtime.CompilerServices.CallerArgumentExpression("x")] string xExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("w")] string wExpression = ""); + + } +} + +/// +/// Mock extensions for ComprehensiveDelegate. +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal static partial class MockExtensionsForComprehensiveDelegate +{ + /// + extension(global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate mock) + { + /// + /// Get access to the mock of ComprehensiveDelegate. + /// + public global::Mockolate.Mock.IMockForComprehensiveDelegate Mock + { + get + { + if (mock.Target is global::Mockolate.Mock.IMockForComprehensiveDelegate mockInterface) + { + return mockInterface; + } + throw new global::Mockolate.Exceptions.MockException("The subject is no mock."); + } + } + + /// + /// Create a new mock of ComprehensiveDelegate with the default MockBehavior. + /// + public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate CreateMock() + => CreateMock(null, []); + + /// + /// Create a new mock of ComprehensiveDelegate with the default MockBehavior. + /// + /// + /// All provided are immediately applied to the mock. + /// + public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate CreateMock(params global::System.Action[] setups) + => CreateMock(null, setups); + + /// + /// Create a new mock of ComprehensiveDelegate with the given . + /// + /// + /// All provided are immediately applied to the mock. + /// + public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate CreateMock(global::Mockolate.MockBehavior? mockBehavior = null, params global::System.Action[] setups) + { + mockBehavior ??= global::Mockolate.MockBehavior.Default; + var mockRegistry = new global::Mockolate.MockRegistry(mockBehavior, new global::Mockolate.Interactions.FastMockInteractions(0, mockBehavior.SkipInteractionRecording)); + global::Mockolate.Mock.ComprehensiveDelegate mockTarget = new global::Mockolate.Mock.ComprehensiveDelegate(mockRegistry); + if (setups.Length > 0) + { + foreach (var setup in setups) + { + setup.Invoke(mockTarget); + } + } + return mockTarget.Object; + } + } +} +#nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/Mock.g.cs new file mode 100644 index 00000000..3ce28555 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/Mock.g.cs @@ -0,0 +1,133 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +namespace Mockolate; + +#nullable enable +/// +/// Create new mocks by calling the static T.CreateMock() method on your type T. +/// +/// +/// You can also provide a MockBehavior parameter to customize how the mock should behave in certain scenarios.
+/// If your type is a class without a default constructor, you can provide constructor parameters by passing an object?[]? to the corresponding CreateMock(...) overload. +///
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal static partial class Mock +{ + /// + /// This interface should never be used. If it is, this is an indication that the Mockolate source generator did not run correctly or that the used type is not mockable. + /// + /// + /// The source generator creates overloads with correct return values. + /// + internal interface IMockGenerationDidNotRun {} + + /// + /// Create a new mock of with the default MockBehavior. + /// + /// Type to mock, which can be an interface or a class. + /// + /// Any interface type can be used for mocking, but for classes, only abstract and virtual members can be mocked. + /// + extension(T _) + { + /// + /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when + /// is not mockable. Calling it always throws a MockException. + /// + /// Ignored; reserved for the generator-emitted overload. + /// This method never returns - it always throws. + /// + /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. + /// If you see this fallback resolved in your IDE, the generator did not run for ; + /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. + /// + /// Always thrown: the source generator did not run or is not mockable. + public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior = null) + { + throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); + } + + /// + /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when + /// is not mockable. Calling it always throws a MockException. + /// + /// Ignored; reserved for the generator-emitted overload. + /// Ignored; reserved for the generator-emitted overload. + /// This method never returns - it always throws. + /// + /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. + /// If you see this fallback resolved in your IDE, the generator did not run for ; + /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. + /// + /// Always thrown: the source generator did not run or is not mockable. + public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior, object?[]? constructorParameters) + { + throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); + } + + /// + /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when + /// is not mockable. Calling it always throws a MockException. + /// + /// Ignored; reserved for the generator-emitted overload. + /// This method never returns - it always throws. + /// + /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. + /// If you see this fallback resolved in your IDE, the generator did not run for ; + /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. + /// + /// Always thrown: the source generator did not run or is not mockable. + public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(object?[]? constructorParameters) + { + throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); + } + } + + extension(global::Mockolate.Mock.IMockGenerationDidNotRun _) + { + /// + /// Fallback Implementing that is only resolved when the Mockolate source generator did not run or when + /// is not mockable. Calling it always throws a MockException. + /// + /// Additional interface the mock should implement. + /// This method never returns - it always throws. + /// + /// The source generator emits a concrete Implementing overload per mockable type with the same shape. + /// If you see this fallback resolved in your IDE, the generator did not run for ; + /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. + /// + /// Always thrown: the source generator did not run or is not mockable. + public global::Mockolate.Mock.IMockGenerationDidNotRun Implementing() where TInterface : class + { + throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(TInterface)}' is not mockable or the source generator did not run correctly."); + } + } + + /// + /// Adapts an IParameter (non-generic) to + /// IParameterMatch<T> so that covariant parameter + /// references (e.g. an IParameter<Derived> passed through an IParameter<Base> + /// slot) can still be invoked at setup/verify time. Only allocated when the direct + /// IParameterMatch<T> cast fails. + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch + { + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); + } +} +#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/MockBehaviorExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/MockBehaviorExtensions.g.cs new file mode 100644 index 00000000..888d2c2c --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/MockBehaviorExtensions.g.cs @@ -0,0 +1,285 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +namespace Mockolate; + +#nullable enable annotations + +/// +/// Extensions for MockBehavior. +/// +internal static partial class Mock +{ + private static readonly global::Mockolate.MockBehavior _default; + + static Mock() + { + _default = new global::Mockolate.MockBehavior(new DefaultValueGenerator()); + } + + extension(global::Mockolate.MockBehavior) + { + /// + /// The default MockBehavior - the starting point for configuring a mock. + /// + /// + /// Un-configured members return the generator-provided default value (empty strings/collections, completed + /// Tasks, otherwise), base-class + /// implementations run for class mocks, and every invocation is recorded for later verification. + /// + /// Chain SkippingBaseClass(), ThrowingWhenNotSetup(), SkippingInteractionRecording(), + /// WithDefaultValueFor<T>(...) or UseConstructorParametersFor<T>(...) to derive + /// a customized MockBehavior; because it is a , + /// each call returns a new instance and this shared default stays unchanged. + /// + public static global::Mockolate.MockBehavior Default => _default; + } + + /// + /// Defines a factory for creating default values for a specified type. + /// + public interface IDefaultValueFactory + { + /// + /// Determines whether the specified can be created by this factory. + /// + bool IsMatch(global::System.Type type); + + /// + /// Creates a new instance of the specified type. + /// + object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, object?[] parameters); + } + + /// + /// A IDefaultValueFactory that returns a specified for the given type + /// parameter . + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal class TypedDefaultValueFactory(T value) : IDefaultValueFactory + { + /// + public bool IsMatch(global::System.Type type) + => type == typeof(T); + + /// + public object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) + => value; + } + + /// + /// Provides default values for common types used in mocking scenarios. + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private class DefaultValueGenerator : IDefaultValueGenerator + { + private static readonly global::System.Collections.Concurrent.ConcurrentQueue _factories = new([ + new TypedDefaultValueFactory(""), + new CancellableTaskFactory(), + #if NET8_0_OR_GREATER + new CancellableValueTaskFactory(), + #endif + new TypedDefaultValueFactory(global::System.Threading.CancellationToken.None), + new TypedDefaultValueFactory(global::System.Array.Empty()), + ]); + + /// + public object? GenerateValue(global::System.Type type, params object?[] parameters) + { + if (TryGenerate(type, parameters, out object? value)) + { + return value; + } + + return null; + } + + /// + /// Registers a to provide default values for a specific type. + /// + public static void Register(IDefaultValueFactory defaultValueFactory) + => _factories.Enqueue(defaultValueFactory); + + /// + /// Tries to generate a default value for the specified type. + /// + protected virtual bool TryGenerate(global::System.Type type, object?[] parameters, out object? value) + { + IDefaultValueFactory? matchingFactory = global::System.Linq.Enumerable.FirstOrDefault(_factories, Predicate); + if (matchingFactory is not null) + { + value = matchingFactory.Create(type, this, parameters); + return true; + } + + value = null; + return false; + + bool Predicate(global::Mockolate.Mock.IDefaultValueFactory f) + => f.IsMatch(type); + } + + private static bool HasCanceledCancellationToken(object?[] parameters, out global::System.Threading.CancellationToken cancellationToken) + { + global::System.Threading.CancellationToken parameter = global::System.Linq.Enumerable.FirstOrDefault(global::System.Linq.Enumerable.OfType(parameters)); + if (parameter.IsCancellationRequested) + { + cancellationToken = parameter; + return true; + } + + cancellationToken = global::System.Threading.CancellationToken.None; + return false; + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class CancellableTaskFactory : IDefaultValueFactory + { + /// + public bool IsMatch(global::System.Type type) + => type == typeof(global::System.Threading.Tasks.Task); + + /// + public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) + { + if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) + { + return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); + } + + return global::System.Threading.Tasks.Task.CompletedTask; + } + } + #if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class CancellableValueTaskFactory : IDefaultValueFactory + { + /// + public bool IsMatch(global::System.Type type) + => type == typeof(global::System.Threading.Tasks.ValueTask); + + /// + public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) + { + if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) + { + return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); + } + + return global::System.Threading.Tasks.ValueTask.CompletedTask; + } + } + #endif + } +} + +/// +/// Extensions on IDefaultValueGenerator +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal static class DefaultValueGeneratorExtensions +{ + /// + /// Adds a generic Generate method for specific types. + /// + extension(IDefaultValueGenerator generator) + { + /// + /// Generates a Task of , with + /// the for context. + /// + public global::System.Threading.Tasks.Task Generate(global::System.Threading.Tasks.Task nullValue, T value, params object?[] parameters) + { + global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( + global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; + if (cancellationToken.IsCancellationRequested) + { + return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); + } + + return global::System.Threading.Tasks.Task.FromResult(value); + } + +#if NET8_0_OR_GREATER + /// + /// Generates a ValueTask of , with + /// the for context. + /// + public global::System.Threading.Tasks.ValueTask Generate(global::System.Threading.Tasks.ValueTask nullValue, T value, params object?[] parameters) + { + global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( + global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; + if (cancellationToken.IsCancellationRequested) + { + return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); + } + + return global::System.Threading.Tasks.ValueTask.FromResult(value); + } +#endif + + /// + /// Generates an empty enumerable of , with + /// the for context. + /// + public global::System.Collections.Generic.IEnumerable Generate(global::System.Collections.Generic.IEnumerable nullValue, params object?[] parameters) + => global::System.Array.Empty(); + + /// + /// Generates an empty enumerable of , with + /// the for context. + /// + public global::System.Collections.Generic.List Generate(global::System.Collections.Generic.List nullValue, params object?[] parameters) + => new global::System.Collections.Generic.List(); + + /// + /// Generates an empty array of , with + /// the for context. + /// + public T[] Generate(T[] nullValue, params object?[] parameters) + => global::System.Array.Empty(); + + /// + /// Generates an empty two-dimensional array of , with + /// the for context. + /// + public T[,] Generate(T[,] nullValue, params object?[] parameters) + => new T[,] { }; + + /// + /// Generates an empty three-dimensional array of , with + /// the for context. + /// + public T[,,] Generate(T[,,] nullValue, params object?[] parameters) + => new T[,,] { }; + + /// + /// Generates an empty four-dimensional array of , with + /// the for context. + /// + public T[,,,] Generate(T[,,,] nullValue, params object?[] parameters) + => new T[,,,] { }; + + /// + /// Generates a default value of type , with + /// the for context. + /// + public T Generate(T nullValue, params object?[] parameters) + { + if (generator.GenerateValue(typeof(T), parameters) is T value) + { + return value; + } + + return nullValue; + } + } +} + +#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/ParameterArg.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/ParameterArg.g.cs new file mode 100644 index 00000000..50826154 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/ParameterArg.g.cs @@ -0,0 +1,133 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +#nullable enable + +namespace Mockolate +{ + /// + /// A setup or verify argument that is either an It matcher + /// (IParameter<T>) or a literal value of type . + /// + /// + /// Both case types convert implicitly, so Setup.Method(42) and Setup.Method(It.IsAny<int>()) + /// bind to the same overload. A instance stands for the literal default(T). + /// + [global::System.Runtime.CompilerServices.Union] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal readonly struct ParameterArg + { + private const byte MatcherTag = 1; + private const byte LiteralTag = 2; + + private readonly global::Mockolate.Parameters.IParameter? _matcher; + private readonly T? _literal; + private readonly byte _tag; + + /// + /// Creates the matcher case. + /// + public ParameterArg(global::Mockolate.Parameters.IParameter matcher) + { + _matcher = matcher; + _literal = default; + _tag = MatcherTag; + } + + /// + /// Creates the literal value case. + /// + public ParameterArg(T? literal) + { + _matcher = null; + _literal = literal; + _tag = LiteralTag; + } + + /// + /// The contained matcher or literal value, boxed. Part of the union pattern; the generated mocks use the + /// typed accessors instead. + /// + public object? Value => _tag switch + { + MatcherTag => _matcher, + LiteralTag => _literal, + _ => null, + }; + + /// + /// unless this is the instance. + /// + public bool HasValue => _tag != 0; + + /// + /// when the argument is a literal value (including the instance). + /// + public bool IsLiteral => _tag != MatcherTag; + + /// + /// The literal value; default(T) for the matcher case and the instance. + /// + public T? Literal => _literal; + + /// + /// Gets the matcher, when this is the matcher case. + /// + public bool TryGetValue(out global::Mockolate.Parameters.IParameter? matcher) + { + matcher = _matcher; + return _tag == MatcherTag; + } + + /// + /// Gets the literal value, when this is the literal case. + /// + public bool TryGetValue(out T? literal) + { + literal = _literal; + return _tag == LiteralTag; + } + + /// + /// The IParameterMatch<T> for this argument: the matcher itself, + /// or an equality match for the literal value. + /// + public global::Mockolate.Parameters.IParameterMatch ToParameterMatch() + { + if (_tag != MatcherTag) + { + return (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(_literal!); + } + + if (_matcher is null) + { + return (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsNull("null"); + } + + return _matcher is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantAdapter(_matcher); + } + + /// + public override string ToString() => _tag switch + { + MatcherTag => _matcher?.ToString() ?? "null", + _ => _literal?.ToString() ?? "null", + }; + + private sealed class CovariantAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch + { + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + } + } +} +#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/ReturnsThrowsAsyncExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/ReturnsThrowsAsyncExtensions.g.cs new file mode 100644 index 00000000..bffa4be5 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/ReturnsThrowsAsyncExtensions.g.cs @@ -0,0 +1,156 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +namespace Mockolate; + +#nullable enable + +/// +/// Extensions for setting up return values and throwing exceptions for methods. +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal static class ReturnsThrowsAsyncExtensions2 +{ + /// + /// Appends to the sequence - the next matching invocation returns a completed + /// Task<TReturn> carrying this value. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6> setup, TReturn returnValue) + => setup.Returns(global::System.Threading.Tasks.Task.FromResult(returnValue)); + + /// + /// Appends a lazy async return to the sequence; is invoked on each matching + /// invocation and its result is wrapped in a completed Task<TReturn>. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6> setup, global::System.Func callback) + => setup.Returns(() => global::System.Threading.Tasks.Task.FromResult(callback())); + + /// + /// Appends a lazy async return that receives the method's arguments and produces the value wrapped in a + /// completed Task<TReturn>. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5, T6> setup, global::System.Func callback) + => setup.Returns((v1, v2, v3, v4, v5, v6) => global::System.Threading.Tasks.Task.FromResult(callback(v1, v2, v3, v4, v5, v6))); + + /// + /// Appends an entry that faults the returned Task<TReturn> with + /// so awaiting it throws. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6> setup, global::System.Exception exception) + => setup.Returns(global::System.Threading.Tasks.Task.FromException(exception)); + + /// + /// Appends an entry that invokes to build the exception the returned + /// Task<TReturn> is faulted with. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6> setup, global::System.Func callback) + => setup.Returns(() => global::System.Threading.Tasks.Task.FromException(callback())); + + /// + /// Appends an entry that invokes with the method's arguments to build the + /// exception the returned Task<TReturn> is faulted with. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5, T6> setup, global::System.Func callback) + => setup.Returns((v1, v2, v3, v4, v5, v6) => global::System.Threading.Tasks.Task.FromException(callback(v1, v2, v3, v4, v5, v6))); + +#if NET8_0_OR_GREATER + + /// + /// Appends to the sequence - the next matching invocation returns a completed + /// ValueTask<TReturn> carrying this value. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6> setup, TReturn returnValue) + => setup.Returns(global::System.Threading.Tasks.ValueTask.FromResult(returnValue)); + + /// + /// Appends a lazy async return to the sequence; is invoked on each matching + /// invocation and its result is wrapped in a completed ValueTask<TReturn>. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6> setup, global::System.Func callback) + => setup.Returns(() => global::System.Threading.Tasks.ValueTask.FromResult(callback())); + + /// + /// Appends a lazy async return that receives the method's arguments and produces the value wrapped in a + /// completed ValueTask<TReturn>. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5, T6> setup, global::System.Func callback) + => setup.Returns((v1, v2, v3, v4, v5, v6) => global::System.Threading.Tasks.ValueTask.FromResult(callback(v1, v2, v3, v4, v5, v6))); + + /// + /// Appends an entry that faults the returned ValueTask<TReturn> with + /// so awaiting it throws. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6> setup, global::System.Exception exception) + => setup.Returns(global::System.Threading.Tasks.ValueTask.FromException(exception)); + + /// + /// Appends an entry that invokes to build the exception the returned + /// ValueTask<TReturn> is faulted with. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6> setup, global::System.Func callback) + => setup.Returns(() => global::System.Threading.Tasks.ValueTask.FromException(callback())); + + /// + /// Appends an entry that invokes with the method's arguments to build the + /// exception the returned ValueTask<TReturn> is faulted with. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5, T6> setup, global::System.Func callback) + => setup.Returns((v1, v2, v3, v4, v5, v6) => global::System.Threading.Tasks.ValueTask.FromException(callback(v1, v2, v3, v4, v5, v6))); + +#endif +} +#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ActionFunc.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ActionFunc.g.cs new file mode 100644 index 00000000..5bf20d0a --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ActionFunc.g.cs @@ -0,0 +1,34 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +namespace System; + +#nullable enable + +/// +/// Encapsulates a method that has 17 parameters and does not return a value. +/// +public delegate void Action(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16, T17 arg17); + +/// +/// Encapsulates a method that has 17 parameters and returns a value of the type specified by the parameter. +/// +public delegate TResult Func(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16, T17 arg17); + +/// +/// Encapsulates a method that has 18 parameters and does not return a value. +/// +public delegate void Action(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16, T17 arg17, T18 arg18); + +/// +/// Encapsulates a method that has 18 parameters and returns a value of the type specified by the parameter. +/// +public delegate TResult Func(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16, T17 arg17, T18 arg18); + +#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/IndexerSetups.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/IndexerSetups.g.cs new file mode 100644 index 00000000..426a1255 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/IndexerSetups.g.cs @@ -0,0 +1,1618 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +#nullable enable + +namespace Mockolate.Setup +{ + /// + /// Sets up a indexer getter for , , , and . + /// + internal interface IIndexerGetterSetup + { + /// + /// Registers a to be invoked whenever the indexer's getter is accessed. + /// + IIndexerGetterSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Transitions the scenario to the given whenever the indexer is read. + /// + IIndexerGetterSetupParallelCallbackBuilder TransitionTo(string scenario); + } + + /// + /// Sets up a indexer getter for , , , and with callback support for the parameters. + /// + internal interface IIndexerGetterSetupWithCallback : global::Mockolate.Setup.IIndexerGetterSetup + { + /// + /// Registers a to be invoked whenever the indexer's getter is accessed. + /// + /// + /// The callback receives the parameters of the indexer. + /// + IIndexerGetterSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Registers a to be invoked whenever the indexer's getter is accessed. + /// + /// + /// The callback receives the parameters of the indexer and the value of the indexer as last parameter. + /// + IIndexerGetterSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Registers a to be invoked whenever the indexer's getter is accessed. + /// + /// + /// The callback receives an incrementing access counter as first parameter, the parameters of the indexer and the value of the indexer as last parameter. + /// + IIndexerGetterSetupCallbackBuilder Do(global::System.Action callback); + } + + /// + /// Sets up a indexer setter for , , , and . + /// + internal interface IIndexerSetterSetup + { + /// + /// Registers a to be invoked whenever the indexer's setter is accessed. + /// + IIndexerSetterSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Registers a to be invoked whenever the indexer's setter is accessed. + /// + /// + /// The callback receives the value the indexer is set to as single parameter. + /// + IIndexerSetterSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Transitions the scenario to the given whenever the indexer is written to. + /// + IIndexerSetterSetupParallelCallbackBuilder TransitionTo(string scenario); + } + + /// + /// Sets up a indexer setter for , , , and with callback support for the parameters. + /// + internal interface IIndexerSetterSetupWithCallback : global::Mockolate.Setup.IIndexerSetterSetup + { + /// + /// Registers a to be invoked whenever the indexer's setter is accessed. + /// + /// + /// The callback receives the parameters of the indexer and the value the indexer is set to as last parameter. + /// + IIndexerSetterSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Registers a to be invoked whenever the indexer's setter is accessed. + /// + /// + /// The callback receives an incrementing access counter as first parameter, the parameters of the indexer and the value the indexer is set to as last parameter. + /// + IIndexerSetterSetupCallbackBuilder Do(global::System.Action callback); + } + + /// + /// Sets up a indexer for , , , and . + /// + internal interface IIndexerSetup + { + /// + /// Sets up callbacks on the getter. + /// + IIndexerGetterSetupWithCallback OnGet { get; } + + /// + /// Sets up callbacks on the setter. + /// + IIndexerSetterSetupWithCallback OnSet { get; } + + /// + /// Overrides SkipBaseClass for this indexer only. + /// + /// + /// If not specified, use SkipBaseClass. + /// + global::Mockolate.Setup.IIndexerSetup SkippingBaseClass(bool skipBaseClass = true); + + /// + /// Initializes the indexer with the given . + /// + global::Mockolate.Setup.IIndexerSetup InitializeWith(TValue value); + + /// + /// Registers the for this indexer. + /// + IIndexerSetupReturnBuilder Returns(TValue returnValue); + + /// + /// Registers a to setup the return value for this indexer. + /// + IIndexerSetupReturnBuilder Returns(global::System.Func callback); + + /// + /// Registers an to throw when the indexer is read. + /// + IIndexerSetupReturnBuilder Throws() + where TException : global::System.Exception, new(); + + /// + /// Registers an to throw when the indexer is read. + /// + IIndexerSetupReturnBuilder Throws(global::System.Exception exception); + + /// + /// Registers a that will calculate the exception to throw when the indexer is read. + /// + IIndexerSetupReturnBuilder Throws(global::System.Func callback); + } + + /// + /// Sets up a indexer for , , , and with callback support for the parameters. + /// + internal interface IIndexerSetupWithCallback : global::Mockolate.Setup.IIndexerSetup + { + /// + /// Initializes the indexer according to the given . + /// + global::Mockolate.Setup.IIndexerSetup InitializeWith(global::System.Func valueGenerator); + + /// + /// Registers a to setup the return value for this indexer. + /// + /// + /// The callback receives the parameters of the indexer. + /// + IIndexerSetupReturnBuilder Returns(global::System.Func callback); + + /// + /// Registers a to setup the return value for this indexer. + /// + /// + /// The callback receives the parameters of the indexer and the value of the indexer as last parameter. + /// + IIndexerSetupReturnBuilder Returns(global::System.Func callback); + + /// + /// Registers a that will calculate the exception to throw when the indexer is read. + /// + /// + /// The callback receives the parameters of the indexer. + /// + IIndexerSetupReturnBuilder Throws(global::System.Func callback); + + /// + /// Registers a that will calculate the exception to throw when the indexer is read. + /// + /// + /// The callback receives the parameters of the indexer and the value of the indexer as last parameter. + /// + IIndexerSetupReturnBuilder Throws(global::System.Func callback); + } + + /// + /// Sets up a getter callback for a indexer for , , , and . + /// + internal interface IIndexerGetterSetupCallbackBuilder : IIndexerGetterSetupParallelCallbackBuilder + { + /// + /// Runs the callback in parallel to the other callbacks. + /// + IIndexerGetterSetupParallelCallbackBuilder InParallel(); + } + + /// + /// Sets up a parallel getter callback for a indexer for , , , and . + /// + internal interface IIndexerGetterSetupParallelCallbackBuilder : IIndexerGetterSetupCallbackWhenBuilder + { + /// + /// Limits the callback to only execute for indexer accesses where the predicate returns true. + /// + /// + /// Provides a zero-based counter indicating how many times the indexer has been accessed so far. + /// + IIndexerGetterSetupCallbackWhenBuilder When(global::System.Func predicate); + } + + /// + /// Sets up a when getter callback for a indexer for , , , and . + /// + internal interface IIndexerGetterSetupCallbackWhenBuilder : global::Mockolate.Setup.IIndexerSetupWithCallback + { + /// + /// Repeats the callback for the given number of . + /// + /// + /// The number of times is only counted for actual executions (IIndexerGetterSetupParallelCallbackBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). + /// + IIndexerGetterSetupCallbackWhenBuilder For(int times); + + /// + /// Deactivates the callback after the given number of . + /// + /// + /// The number of times is only counted for actual executions (IIndexerGetterSetupParallelCallbackBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IIndexerSetup Only(int times); + } + + /// + /// Sets up a setter callback for a indexer for , , , and . + /// + internal interface IIndexerSetterSetupCallbackBuilder : IIndexerSetterSetupParallelCallbackBuilder + { + /// + /// Runs the callback in parallel to the other callbacks. + /// + IIndexerSetterSetupParallelCallbackBuilder InParallel(); + } + + /// + /// Sets up a parallel setter callback for a indexer for , , , and . + /// + internal interface IIndexerSetterSetupParallelCallbackBuilder : IIndexerSetterSetupCallbackWhenBuilder + { + /// + /// Limits the callback to only execute for indexer accesses where the predicate returns true. + /// + /// + /// Provides a zero-based counter indicating how many times the indexer has been accessed so far. + /// + IIndexerSetterSetupCallbackWhenBuilder When(global::System.Func predicate); + } + + /// + /// Sets up a when setter callback for a indexer for , , , and . + /// + internal interface IIndexerSetterSetupCallbackWhenBuilder : global::Mockolate.Setup.IIndexerSetupWithCallback + { + /// + /// Repeats the callback for the given number of . + /// + /// + /// The number of times is only counted for actual executions (IIndexerSetterSetupParallelCallbackBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). + /// + IIndexerSetterSetupCallbackWhenBuilder For(int times); + + /// + /// Deactivates the callback after the given number of . + /// + /// + /// The number of times is only counted for actual executions (IIndexerSetterSetupParallelCallbackBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IIndexerSetup Only(int times); + } + + /// + /// Sets up a return/throw callback for a indexer for , , , and . + /// + internal interface IIndexerSetupReturnBuilder : IIndexerSetupReturnWhenBuilder + { + /// + /// Limits the return/throw callback to only execute for indexer accesses where the predicate returns true. + /// + /// + /// Provides a zero-based counter indicating how many times the indexer has been accessed so far. + /// + IIndexerSetupReturnWhenBuilder When(global::System.Func predicate); + } + + /// + /// Sets up a when return/throw callback for a indexer for , , , and . + /// + internal interface IIndexerSetupReturnWhenBuilder : global::Mockolate.Setup.IIndexerSetupWithCallback + { + /// + /// Repeats the return/throw callback for the given number of . + /// + /// + /// The number of times is only counted for actual executions (IIndexerSetupReturnBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). + /// + IIndexerSetupReturnWhenBuilder For(int times); + + /// + /// Deactivates the return/throw after the given number of . + /// + /// + /// The number of times is only counted for actual executions (IIndexerSetupReturnBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IIndexerSetup Only(int times); + } + + /// + /// Sets up a indexer for , , , and . + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal class IndexerSetup(global::Mockolate.MockRegistry mockRegistry, global::Mockolate.Parameters.IParameterMatch parameter1, global::Mockolate.Parameters.IParameterMatch parameter2, global::Mockolate.Parameters.IParameterMatch parameter3, global::Mockolate.Parameters.IParameterMatch parameter4, global::Mockolate.Parameters.IParameterMatch parameter5) : global::Mockolate.Setup.IndexerSetup(mockRegistry), + global::Mockolate.Setup.IIndexerSetupWithCallback, + global::Mockolate.Setup.IIndexerGetterSetupCallbackBuilder, + global::Mockolate.Setup.IIndexerSetterSetupCallbackBuilder, + global::Mockolate.Setup.IIndexerSetupReturnBuilder, + global::Mockolate.Setup.IIndexerGetterSetupWithCallback, + global::Mockolate.Setup.IIndexerSetterSetupWithCallback, + global::Mockolate.Setup.IIndexerGetterOnlySetup, + global::Mockolate.Setup.IIndexerGetterOnlyGetterSetup, + global::Mockolate.Setup.IIndexerGetterOnlySetupCallbackBuilder, + global::Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder, + global::Mockolate.Setup.IIndexerSetterOnlySetup, + global::Mockolate.Setup.IIndexerSetterOnlySetterSetup, + global::Mockolate.Setup.IIndexerSetterOnlySetupCallbackBuilder + { + private Callbacks>? _getterCallbacks; + private Callbacks>? _setterCallbacks; + private Callbacks>? _returnCallbacks; + private bool? _skipBaseClass; + private global::System.Func? _initialization; + + /// + public global::Mockolate.Setup.IIndexerSetup SkippingBaseClass(bool skipBaseClass = true) + { + _skipBaseClass = skipBaseClass; + return this; + } + + /// + public global::Mockolate.Setup.IIndexerSetupWithCallback InitializeWith(TValue value) + { + if (_initialization is not null) + { + throw new global::Mockolate.Exceptions.MockException("The indexer is already initialized. You cannot initialize it twice."); + } + + _initialization = (_, _, _, _, _) => value; + return this; + } + + global::Mockolate.Setup.IIndexerSetup global::Mockolate.Setup.IIndexerSetup.InitializeWith(TValue value) + => InitializeWith(value); + + /// + public global::Mockolate.Setup.IIndexerSetup InitializeWith(global::System.Func valueGenerator) + { + if (_initialization is not null) + { + throw new global::Mockolate.Exceptions.MockException("The indexer is already initialized. You cannot initialize it twice."); + } + + _initialization = valueGenerator; + return this; + } + + /// + public IIndexerGetterSetupWithCallback OnGet + => this; + + /// + IIndexerGetterSetupCallbackBuilder IIndexerGetterSetup.Do(global::System.Action callback) + { + Callback>? currentCallback = new((_, _, _, _, _, _, _) => callback()); + _getterCallbacks = _getterCallbacks.Register(currentCallback); + return this; + } + + /// + IIndexerGetterSetupCallbackBuilder IIndexerGetterSetupWithCallback.Do(global::System.Action callback) + { + Callback>? currentCallback = new((_, p1, p2, p3, p4, p5, _) => callback(p1, p2, p3, p4, p5)); + _getterCallbacks = _getterCallbacks.Register(currentCallback); + return this; + } + + /// + IIndexerGetterSetupCallbackBuilder IIndexerGetterSetupWithCallback.Do(global::System.Action callback) + { + Callback>? currentCallback = new((_, p1, p2, p3, p4, p5, v) => callback(p1, p2, p3, p4, p5, v)); + _getterCallbacks = _getterCallbacks.Register(currentCallback); + return this; + } + + /// + IIndexerGetterSetupCallbackBuilder IIndexerGetterSetupWithCallback.Do(global::System.Action callback) + { + Callback>? currentCallback = new(callback); + _getterCallbacks = _getterCallbacks.Register(currentCallback); + return this; + } + + IIndexerGetterSetupParallelCallbackBuilder IIndexerGetterSetup.TransitionTo(string scenario) + { + Callback>? currentCallback = new((_, _, _, _, _, _, _) => TransitionScenario(scenario)); + currentCallback.InParallel(); + _getterCallbacks = _getterCallbacks.Register(currentCallback); + return this; + } + + /// + public IIndexerSetterSetupWithCallback OnSet + => this; + + /// + IIndexerSetterSetupCallbackBuilder IIndexerSetterSetup.Do(global::System.Action callback) + { + Callback>? currentCallback = new((_, _, _, _, _, _, _) => callback()); + _setterCallbacks = _setterCallbacks.Register(currentCallback); + return this; + } + + /// + IIndexerSetterSetupCallbackBuilder IIndexerSetterSetup.Do(global::System.Action callback) + { + Callback>? currentCallback = new((_, _, _, _, _, _, v) => callback(v)); + _setterCallbacks = _setterCallbacks.Register(currentCallback); + return this; + } + + /// + IIndexerSetterSetupCallbackBuilder IIndexerSetterSetupWithCallback.Do(global::System.Action callback) + { + Callback>? currentCallback = new((_, p1, p2, p3, p4, p5, v) => callback(p1, p2, p3, p4, p5, v)); + _setterCallbacks = _setterCallbacks.Register(currentCallback); + return this; + } + + /// + IIndexerSetterSetupCallbackBuilder IIndexerSetterSetupWithCallback.Do(global::System.Action callback) + { + Callback>? currentCallback = new(callback); + _setterCallbacks = _setterCallbacks.Register(currentCallback); + return this; + } + + IIndexerSetterSetupParallelCallbackBuilder IIndexerSetterSetup.TransitionTo(string scenario) + { + Callback>? currentCallback = new((_, _, _, _, _, _, _) => TransitionScenario(scenario)); + currentCallback.InParallel(); + _setterCallbacks = _setterCallbacks.Register(currentCallback); + return this; + } + + /// + public IIndexerSetupReturnBuilder Returns(TValue returnValue) + { + var currentCallback = new Callback>((_, _, _, _, _, _, _) => returnValue); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + public IIndexerSetupReturnBuilder Returns(global::System.Func callback) + { + var currentCallback = new Callback>((_, _, _, _, _, _, _) => callback()); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + public IIndexerSetupReturnBuilder Returns(global::System.Func callback) + { + var currentCallback = new Callback>((_, p1, p2, p3, p4, p5, _) => callback(p1, p2, p3, p4, p5)); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + public IIndexerSetupReturnBuilder Returns(global::System.Func callback) + { + var currentCallback = new Callback>((_, v, p1, p2, p3, p4, p5) => callback(v, p1, p2, p3, p4, p5)); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + public IIndexerSetupReturnBuilder Throws() + where TException : global::System.Exception, new() + { + var currentCallback = new Callback>((_, _, _, _, _, _, _) => throw new TException()); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + public IIndexerSetupReturnBuilder Throws(global::System.Exception exception) + { + var currentCallback = new Callback>((_, _, _, _, _, _, _) => throw exception); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + public IIndexerSetupReturnBuilder Throws(global::System.Func callback) + { + var currentCallback = new Callback>((_, _, _, _, _, _, _) => throw callback()); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + public IIndexerSetupReturnBuilder Throws(global::System.Func callback) + { + var currentCallback = new Callback>((_, p1, p2, p3, p4, p5, _) => throw callback(p1, p2, p3, p4, p5)); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + public IIndexerSetupReturnBuilder Throws(global::System.Func callback) + { + var currentCallback = new Callback>((_, p1, p2, p3, p4, p5, v) => throw callback(p1, p2, p3, p4, p5, v)); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + IIndexerGetterSetupCallbackWhenBuilder IIndexerGetterSetupParallelCallbackBuilder.When(global::System.Func predicate) + { + _getterCallbacks?.Active?.When(predicate); + return this; + } + + /// + IIndexerGetterSetupParallelCallbackBuilder IIndexerGetterSetupCallbackBuilder.InParallel() + { + _getterCallbacks?.Active?.InParallel(); + return this; + } + + /// + IIndexerGetterSetupCallbackWhenBuilder IIndexerGetterSetupCallbackWhenBuilder.For(int times) + { + _getterCallbacks?.Active?.For(times); + return this; + } + + /// + global::Mockolate.Setup.IIndexerSetup IIndexerGetterSetupCallbackWhenBuilder.Only(int times) + { + _getterCallbacks?.Active?.Only(times); + return this; + } + + /// + IIndexerSetterSetupCallbackWhenBuilder IIndexerSetterSetupParallelCallbackBuilder.When(global::System.Func predicate) + { + _setterCallbacks?.Active?.When(predicate); + return this; + } + + /// + IIndexerSetterSetupParallelCallbackBuilder IIndexerSetterSetupCallbackBuilder.InParallel() + { + _setterCallbacks?.Active?.InParallel(); + return this; + } + + /// + IIndexerSetterSetupCallbackWhenBuilder IIndexerSetterSetupCallbackWhenBuilder.For(int times) + { + _setterCallbacks?.Active?.For(times); + return this; + } + + /// + global::Mockolate.Setup.IIndexerSetup IIndexerSetterSetupCallbackWhenBuilder.Only(int times) + { + _setterCallbacks?.Active?.Only(times); + return this; + } + + /// + IIndexerSetupReturnWhenBuilder IIndexerSetupReturnBuilder.When(global::System.Func predicate) + { + _returnCallbacks?.Active?.When(predicate); + return this; + } + + /// + IIndexerSetupReturnWhenBuilder IIndexerSetupReturnWhenBuilder.For(int times) + { + _returnCallbacks?.Active?.For(times); + return this; + } + + /// + global::Mockolate.Setup.IIndexerSetup IIndexerSetupReturnWhenBuilder.Only(int times) + { + _returnCallbacks?.Active?.Only(times); + return this; + } + + /// + /// Check if the setup matches the specified parameter values. + /// + public virtual bool Matches(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5) + { + if (!parameter1.Matches(p1) || !parameter2.Matches(p2) || !parameter3.Matches(p3) || !parameter4.Matches(p4) || !parameter5.Matches(p5)) + { + return false; + } + + parameter1.InvokeCallbacks(p1); + parameter2.InvokeCallbacks(p2); + parameter3.InvokeCallbacks(p3); + parameter4.InvokeCallbacks(p4); + parameter5.InvokeCallbacks(p5); + return true; + } + + /// + /// Check if the setup matches the specified parameter values. + /// + public virtual bool Matches(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, TValue value) + => Matches(p1, p2, p3, p4, p5); + + /// + protected override bool MatchesAccess(global::Mockolate.Interactions.IndexerAccess access) + { + if (access is global::Mockolate.Interactions.IndexerGetterAccess getter) + { + return Matches(getter.Parameter1, getter.Parameter2, getter.Parameter3, getter.Parameter4, getter.Parameter5); + } + + if (access is global::Mockolate.Interactions.IndexerSetterAccess setter) + { + return Matches(setter.Parameter1, setter.Parameter2, setter.Parameter3, setter.Parameter4, setter.Parameter5, setter.TypedValue); + } + + return false; + } + + /// + public override bool? SkipBaseClass() + => _skipBaseClass; + + /// + public override TResult GetResult(global::Mockolate.Interactions.IndexerAccess access, global::Mockolate.MockBehavior behavior, TResult baseValue) + { + if (!TryExtractParameters(access, out T1 p1, out T2 p2, out T3 p3, out T4 p4, out T5 p5)) + { + return baseValue; + } + + TValue currentValue = TryCast(baseValue, out TValue casted, behavior) ? casted : default!; + currentValue = ExecuteGetterCallbacks(p1, p2, p3, p4, p5, currentValue); + currentValue = ExecuteReturnCallbacks(p1, p2, p3, p4, p5, currentValue); + access.StoreValue(currentValue); + return TryCast(currentValue, out TResult result, behavior) ? result : baseValue; + } + + /// + public override TResult GetResult(global::Mockolate.Interactions.IndexerAccess access, global::Mockolate.MockBehavior behavior) + { + if (!TryExtractParameters(access, out T1 p1, out T2 p2, out T3 p3, out T4 p4, out T5 p5)) + { + return behavior.DefaultValue.Generate(default(TResult)!); + } + + TValue currentValue; + if (access.TryFindStoredValue(out TValue existing)) + { + currentValue = existing; + } + else if (_initialization is not null) + { + currentValue = _initialization.Invoke(p1, p2, p3, p4, p5); + } + else + { + currentValue = TryCast(behavior.DefaultValue.Generate(default(TValue)!), out TValue casted, behavior) ? casted : default!; + } + + currentValue = ExecuteGetterCallbacks(p1, p2, p3, p4, p5, currentValue); + currentValue = ExecuteReturnCallbacks(p1, p2, p3, p4, p5, currentValue); + access.StoreValue(currentValue); + return TryCast(currentValue, out TResult result, behavior) ? result : behavior.DefaultValue.Generate(default(TResult)!); + } + + /// + public override TResult GetResult(global::Mockolate.Interactions.IndexerAccess access, global::Mockolate.MockBehavior behavior, global::System.Func defaultValueGenerator) + { + if (!TryExtractParameters(access, out T1 p1, out T2 p2, out T3 p3, out T4 p4, out T5 p5)) + { + return defaultValueGenerator(); + } + + TValue currentValue; + if (access.TryFindStoredValue(out TValue existing)) + { + currentValue = existing; + } + else if (_initialization is not null) + { + currentValue = _initialization.Invoke(p1, p2, p3, p4, p5); + } + else + { + currentValue = TryCast(defaultValueGenerator(), out TValue casted, behavior) ? casted : default!; + } + + currentValue = ExecuteGetterCallbacks(p1, p2, p3, p4, p5, currentValue); + currentValue = ExecuteReturnCallbacks(p1, p2, p3, p4, p5, currentValue); + access.StoreValue(currentValue); + return TryCast(currentValue, out TResult result, behavior) ? result : defaultValueGenerator(); + } + + /// + public override void SetResult(global::Mockolate.Interactions.IndexerAccess access, global::Mockolate.MockBehavior behavior, TResult value) + { + access.StoreValue(value); + if (!TryExtractParameters(access, out T1 p1, out T2 p2, out T3 p3, out T4 p4, out T5 p5)) + { + return; + } + + if (!TryCast(value, out TValue resultValue, behavior)) + { + return; + } + + if (_setterCallbacks is not null) + { + bool wasInvoked = false; + int currentSetterCallbacksIndex = _setterCallbacks.CurrentIndex; + for (int i = 0; i < _setterCallbacks.Count; i++) + { + Callback> setterCallback = + _setterCallbacks[(currentSetterCallbacksIndex + i) % _setterCallbacks.Count]; + if (setterCallback.Invoke(wasInvoked, ref _setterCallbacks.CurrentIndex, (p1, p2, p3, p4, p5, resultValue), + static (count, @delegate, state) => @delegate(count, state.p1, state.p2, state.p3, state.p4, state.p5, state.resultValue))) + { + wasInvoked = true; + } + } + } + } + + private TValue ExecuteGetterCallbacks(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, TValue currentValue) + { + if (_getterCallbacks is not null) + { + bool wasInvoked = false; + int currentGetterCallbacksIndex = _getterCallbacks.CurrentIndex; + for (int i = 0; i < _getterCallbacks.Count; i++) + { + Callback> getterCallback = + _getterCallbacks[(currentGetterCallbacksIndex + i) % _getterCallbacks.Count]; + if (getterCallback.Invoke(wasInvoked, ref _getterCallbacks.CurrentIndex, (p1, p2, p3, p4, p5, currentValue), + static (count, @delegate, state) => @delegate(count, state.p1, state.p2, state.p3, state.p4, state.p5, state.currentValue))) + { + wasInvoked = true; + } + } + } + + return currentValue; + } + + private TValue ExecuteReturnCallbacks(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, TValue currentValue) + { + if (_returnCallbacks is not null) + { + foreach (Callback> _ in _returnCallbacks) + { + Callback> returnCallback = + _returnCallbacks[_returnCallbacks.CurrentIndex % _returnCallbacks.Count]; + if (returnCallback.Invoke(ref _returnCallbacks.CurrentIndex, (p1, p2, p3, p4, p5, currentValue), + static (count, @delegate, state) => @delegate(count, state.p1, state.p2, state.p3, state.p4, state.p5, state.currentValue), + out TValue? newValue)) + { + return newValue!; + } + } + } + + return currentValue; + } + + private static bool TryExtractParameters(global::Mockolate.Interactions.IndexerAccess access, out T1 p1, out T2 p2, out T3 p3, out T4 p4, out T5 p5) + { + if (access is global::Mockolate.Interactions.IndexerGetterAccess getter) + { + p1 = getter.Parameter1; + p2 = getter.Parameter2; + p3 = getter.Parameter3; + p4 = getter.Parameter4; + p5 = getter.Parameter5; + return true; + } + + if (access is global::Mockolate.Interactions.IndexerSetterAccess setter) + { + p1 = setter.Parameter1; + p2 = setter.Parameter2; + p3 = setter.Parameter3; + p4 = setter.Parameter4; + p5 = setter.Parameter5; + return true; + } + + p1 = default!; + p2 = default!; + p3 = default!; + p4 = default!; + p5 = default!; + return false; + } + + /// + public override string ToString() + => $"{FormatType(typeof(TValue))} this[{parameter1}, {parameter2}, {parameter3}, {parameter4}, {parameter5}]"; + + /// + IIndexerGetterOnlySetup IIndexerGetterOnlySetup.SkippingBaseClass(bool skipBaseClass) + { + SkippingBaseClass(skipBaseClass); + return this; + } + + /// + IIndexerGetterOnlySetup IIndexerGetterOnlySetup.InitializeWith(TValue value) + { + InitializeWith(value); + return this; + } + + /// + IIndexerGetterOnlySetup IIndexerGetterOnlySetup.InitializeWith(global::System.Func valueGenerator) + { + InitializeWith(valueGenerator); + return this; + } + + /// + IIndexerGetterOnlyGetterSetup IIndexerGetterOnlySetup.OnGet + => this; + + /// + IIndexerGetterOnlySetupCallbackBuilder IIndexerGetterOnlyGetterSetup.Do(global::System.Action callback) + { + ((IIndexerGetterSetup)this).Do(callback); + return this; + } + + /// + IIndexerGetterOnlySetupCallbackBuilder IIndexerGetterOnlyGetterSetup.Do(global::System.Action callback) + { + ((IIndexerGetterSetupWithCallback)this).Do(callback); + return this; + } + + /// + IIndexerGetterOnlySetupCallbackBuilder IIndexerGetterOnlyGetterSetup.Do(global::System.Action callback) + { + ((IIndexerGetterSetupWithCallback)this).Do(callback); + return this; + } + + /// + IIndexerGetterOnlySetupCallbackBuilder IIndexerGetterOnlyGetterSetup.Do(global::System.Action callback) + { + ((IIndexerGetterSetupWithCallback)this).Do(callback); + return this; + } + + /// + IIndexerGetterOnlySetupParallelCallbackBuilder IIndexerGetterOnlyGetterSetup.TransitionTo(string scenario) + { + ((IIndexerGetterSetup)this).TransitionTo(scenario); + return this; + } + + /// + IIndexerGetterOnlySetupParallelCallbackBuilder IIndexerGetterOnlySetupCallbackBuilder.InParallel() + { + ((IIndexerGetterSetupCallbackBuilder)this).InParallel(); + return this; + } + + /// + IIndexerGetterOnlySetupCallbackWhenBuilder IIndexerGetterOnlySetupParallelCallbackBuilder.When(global::System.Func predicate) + { + ((IIndexerGetterSetupParallelCallbackBuilder)this).When(predicate); + return this; + } + + /// + IIndexerGetterOnlySetupCallbackWhenBuilder IIndexerGetterOnlySetupCallbackWhenBuilder.For(int times) + { + ((IIndexerGetterSetupCallbackWhenBuilder)this).For(times); + return this; + } + + /// + IIndexerGetterOnlySetup IIndexerGetterOnlySetupCallbackWhenBuilder.Only(int times) + { + ((IIndexerGetterSetupCallbackWhenBuilder)this).Only(times); + return this; + } + + /// + IIndexerGetterOnlySetupReturnBuilder IIndexerGetterOnlySetup.Returns(TValue returnValue) + { + Returns(returnValue); + return this; + } + + /// + IIndexerGetterOnlySetupReturnBuilder IIndexerGetterOnlySetup.Returns(global::System.Func callback) + { + Returns(callback); + return this; + } + + /// + IIndexerGetterOnlySetupReturnBuilder IIndexerGetterOnlySetup.Returns(global::System.Func callback) + { + Returns(callback); + return this; + } + + /// + IIndexerGetterOnlySetupReturnBuilder IIndexerGetterOnlySetup.Returns(global::System.Func callback) + { + Returns(callback); + return this; + } + + /// + IIndexerGetterOnlySetupReturnBuilder IIndexerGetterOnlySetup.Throws() + { + Throws(); + return this; + } + + /// + IIndexerGetterOnlySetupReturnBuilder IIndexerGetterOnlySetup.Throws(global::System.Exception exception) + { + Throws(exception); + return this; + } + + /// + IIndexerGetterOnlySetupReturnBuilder IIndexerGetterOnlySetup.Throws(global::System.Func callback) + { + Throws(callback); + return this; + } + + /// + IIndexerGetterOnlySetupReturnBuilder IIndexerGetterOnlySetup.Throws(global::System.Func callback) + { + Throws(callback); + return this; + } + + /// + IIndexerGetterOnlySetupReturnBuilder IIndexerGetterOnlySetup.Throws(global::System.Func callback) + { + Throws(callback); + return this; + } + + /// + IIndexerGetterOnlySetupReturnWhenBuilder IIndexerGetterOnlySetupReturnBuilder.When(global::System.Func predicate) + { + ((IIndexerSetupReturnBuilder)this).When(predicate); + return this; + } + + /// + IIndexerGetterOnlySetupReturnWhenBuilder IIndexerGetterOnlySetupReturnWhenBuilder.For(int times) + { + ((IIndexerSetupReturnWhenBuilder)this).For(times); + return this; + } + + /// + IIndexerGetterOnlySetup IIndexerGetterOnlySetupReturnWhenBuilder.Only(int times) + { + ((IIndexerSetupReturnWhenBuilder)this).Only(times); + return this; + } + + /// + IIndexerSetterOnlySetup IIndexerSetterOnlySetup.SkippingBaseClass(bool skipBaseClass) + { + SkippingBaseClass(skipBaseClass); + return this; + } + + /// + IIndexerSetterOnlySetterSetup IIndexerSetterOnlySetup.OnSet + => this; + + /// + IIndexerSetterOnlySetupCallbackBuilder IIndexerSetterOnlySetterSetup.Do(global::System.Action callback) + { + ((IIndexerSetterSetup)this).Do(callback); + return this; + } + + /// + IIndexerSetterOnlySetupCallbackBuilder IIndexerSetterOnlySetterSetup.Do(global::System.Action callback) + { + ((IIndexerSetterSetup)this).Do(callback); + return this; + } + + /// + IIndexerSetterOnlySetupCallbackBuilder IIndexerSetterOnlySetterSetup.Do(global::System.Action callback) + { + ((IIndexerSetterSetupWithCallback)this).Do(callback); + return this; + } + + /// + IIndexerSetterOnlySetupCallbackBuilder IIndexerSetterOnlySetterSetup.Do(global::System.Action callback) + { + ((IIndexerSetterSetupWithCallback)this).Do(callback); + return this; + } + + /// + IIndexerSetterOnlySetupParallelCallbackBuilder IIndexerSetterOnlySetterSetup.TransitionTo(string scenario) + { + ((IIndexerSetterSetup)this).TransitionTo(scenario); + return this; + } + + /// + IIndexerSetterOnlySetupParallelCallbackBuilder IIndexerSetterOnlySetupCallbackBuilder.InParallel() + { + ((IIndexerSetterSetupCallbackBuilder)this).InParallel(); + return this; + } + + /// + IIndexerSetterOnlySetupCallbackWhenBuilder IIndexerSetterOnlySetupParallelCallbackBuilder.When(global::System.Func predicate) + { + ((IIndexerSetterSetupParallelCallbackBuilder)this).When(predicate); + return this; + } + + /// + IIndexerSetterOnlySetupCallbackWhenBuilder IIndexerSetterOnlySetupCallbackWhenBuilder.For(int times) + { + ((IIndexerSetterSetupCallbackWhenBuilder)this).For(times); + return this; + } + + /// + IIndexerSetterOnlySetup IIndexerSetterOnlySetupCallbackWhenBuilder.Only(int times) + { + ((IIndexerSetterSetupCallbackWhenBuilder)this).Only(times); + return this; + } + + } + + /// + /// Setup for a mocked indexer for , , , and that the mock only reads. + /// + /// + /// Used instead of IIndexerSetup<TValue, T1, T2, T3, T4, T5> when the mock has no setter to intercept, either + /// because the indexer is declared without one or because its setter is not accessible from the mock's assembly. + /// Writes then never reach the mock, so IIndexerSetup<TValue, T1, T2, T3, T4, T5>.OnSet is not offered. + /// + internal interface IIndexerGetterOnlySetup + { + /// + IIndexerGetterOnlyGetterSetup OnGet { get; } + + /// + IIndexerGetterOnlySetup SkippingBaseClass(bool skipBaseClass = true); + + /// + /// + /// Seeds the value that reads return. Unlike a read-write indexer there is no setter to update the + /// slot afterwards, so it stays at unless a Returns entry applies. + /// + IIndexerGetterOnlySetup InitializeWith(TValue value); + + /// + IIndexerGetterOnlySetup InitializeWith(global::System.Func valueGenerator); + + /// + IIndexerGetterOnlySetupReturnBuilder Returns(TValue returnValue); + + /// + IIndexerGetterOnlySetupReturnBuilder Returns(global::System.Func callback); + + /// + IIndexerGetterOnlySetupReturnBuilder Returns(global::System.Func callback); + + /// + IIndexerGetterOnlySetupReturnBuilder Returns(global::System.Func callback); + + /// + IIndexerGetterOnlySetupReturnBuilder Throws() + where TException : global::System.Exception, new(); + + /// + IIndexerGetterOnlySetupReturnBuilder Throws(global::System.Exception exception); + + /// + IIndexerGetterOnlySetupReturnBuilder Throws(global::System.Func callback); + + /// + IIndexerGetterOnlySetupReturnBuilder Throws(global::System.Func callback); + + /// + IIndexerGetterOnlySetupReturnBuilder Throws(global::System.Func callback); + } + + /// + /// Setup for attaching side-effects to the getter of a get-only indexer for , , , and . + /// + /// + /// The counterpart of IIndexerGetterSetupWithCallback<TValue, T1, T2, T3, T4, T5> for + /// IIndexerGetterOnlySetup<TValue, T1, T2, T3, T4, T5>: the returned builders stay on the getter-only surface, + /// so chaining can never reach IIndexerSetup<TValue, T1, T2, T3, T4, T5>.OnSet. + /// + internal interface IIndexerGetterOnlyGetterSetup + { + /// + IIndexerGetterOnlySetupCallbackBuilder Do(global::System.Action callback); + + /// + IIndexerGetterOnlySetupCallbackBuilder Do(global::System.Action callback); + + /// + IIndexerGetterOnlySetupCallbackBuilder Do(global::System.Action callback); + + /// + IIndexerGetterOnlySetupCallbackBuilder Do(global::System.Action callback); + + /// + IIndexerGetterOnlySetupParallelCallbackBuilder TransitionTo(string scenario); + } + + /// + /// Sets up a callback for a get-only indexer for , , , and . + /// + internal interface IIndexerGetterOnlySetupCallbackBuilder + : IIndexerGetterOnlySetupParallelCallbackBuilder + { + /// + IIndexerGetterOnlySetupParallelCallbackBuilder InParallel(); + } + + /// + /// Sets up a parallel callback for a get-only indexer for , , , and . + /// + internal interface IIndexerGetterOnlySetupParallelCallbackBuilder + : IIndexerGetterOnlySetupCallbackWhenBuilder + { + /// + IIndexerGetterOnlySetupCallbackWhenBuilder When(global::System.Func predicate); + } + + /// + /// Sets up a when callback for a get-only indexer for , , , and . + /// + internal interface IIndexerGetterOnlySetupCallbackWhenBuilder + : IIndexerGetterOnlySetup + { + /// + IIndexerGetterOnlySetupCallbackWhenBuilder For(int times); + + /// + IIndexerGetterOnlySetup Only(int times); + } + + /// + /// Sets up a return/throw builder for a get-only indexer for , , , and . + /// + internal interface IIndexerGetterOnlySetupReturnBuilder + : IIndexerGetterOnlySetupReturnWhenBuilder + { + /// + IIndexerGetterOnlySetupReturnWhenBuilder When(global::System.Func predicate); + } + + /// + /// Sets up a when builder for returns/throws for a get-only indexer for , , , and . + /// + internal interface IIndexerGetterOnlySetupReturnWhenBuilder + : IIndexerGetterOnlySetup + { + /// + IIndexerGetterOnlySetupReturnWhenBuilder For(int times); + + /// + IIndexerGetterOnlySetup Only(int times); + } + + /// + /// Setup for a mocked indexer for , , , and that the mock only writes. + /// + /// + /// The write-only counterpart of IIndexerGetterOnlySetup<TValue, T1, T2, T3, T4, T5>: the mock has no getter to + /// intercept, so IIndexerSetup<TValue, T1, T2, T3, T4, T5>.OnGet, InitializeWith and the + /// Returns/Throws read-sequence are not offered. + /// + internal interface IIndexerSetterOnlySetup + { + /// + IIndexerSetterOnlySetterSetup OnSet { get; } + + /// + IIndexerSetterOnlySetup SkippingBaseClass(bool skipBaseClass = true); + } + + /// + /// Setup for attaching side-effects to the setter of a set-only indexer for , , , and . + /// + /// + /// The counterpart of IIndexerSetterSetupWithCallback<TValue, T1, T2, T3, T4, T5> for + /// IIndexerSetterOnlySetup<TValue, T1, T2, T3, T4, T5>: the returned builders stay on the setter-only surface, + /// so chaining can never reach IIndexerSetup<TValue, T1, T2, T3, T4, T5>.OnGet or the + /// Returns/Throws read-sequence. + /// + internal interface IIndexerSetterOnlySetterSetup + { + /// + IIndexerSetterOnlySetupCallbackBuilder Do(global::System.Action callback); + + /// + IIndexerSetterOnlySetupCallbackBuilder Do(global::System.Action callback); + + /// + IIndexerSetterOnlySetupCallbackBuilder Do(global::System.Action callback); + + /// + IIndexerSetterOnlySetupCallbackBuilder Do(global::System.Action callback); + + /// + IIndexerSetterOnlySetupParallelCallbackBuilder TransitionTo(string scenario); + } + + /// + /// Sets up a setter callback for a set-only indexer for , , , and . + /// + internal interface IIndexerSetterOnlySetupCallbackBuilder + : IIndexerSetterOnlySetupParallelCallbackBuilder + { + /// + IIndexerSetterOnlySetupParallelCallbackBuilder InParallel(); + } + + /// + /// Sets up a parallel setter callback for a set-only indexer for , , , and . + /// + internal interface IIndexerSetterOnlySetupParallelCallbackBuilder + : IIndexerSetterOnlySetupCallbackWhenBuilder + { + /// + IIndexerSetterOnlySetupCallbackWhenBuilder When(global::System.Func predicate); + } + + /// + /// Sets up a when setter callback for a set-only indexer for , , , and . + /// + internal interface IIndexerSetterOnlySetupCallbackWhenBuilder + : IIndexerSetterOnlySetup + { + /// + IIndexerSetterOnlySetupCallbackWhenBuilder For(int times); + + /// + IIndexerSetterOnlySetup Only(int times); + } + +} + +namespace Mockolate +{ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal static class IndexerSetupExtensions + { + + /// + /// Extensions for indexer getter callback setups with 5 parameters. + /// + extension(Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder setup) + { + /// + /// Executes the callback only once. + /// + public global::Mockolate.Setup.IIndexerSetup OnlyOnce() + => setup.Only(1); + } + + /// + /// Extensions for indexer setter callback setups with 5 parameters. + /// + extension(Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder setup) + { + /// + /// Executes the callback only once. + /// + public global::Mockolate.Setup.IIndexerSetup OnlyOnce() + => setup.Only(1); + } + + /// + /// Extensions for indexer setups with 5 parameters. + /// + extension(Mockolate.Setup.IIndexerSetupReturnWhenBuilder setup) + { + /// + /// Returns/throws forever. + /// + public void Forever() + { + setup.For(int.MaxValue); + } + + /// + /// Uses the return value only once. + /// + public global::Mockolate.Setup.IIndexerSetup OnlyOnce() + => setup.Only(1); + } + + /// + /// Extensions for setups of get-only indexers with 5 parameters. + /// + extension(Mockolate.Setup.IIndexerGetterOnlySetupReturnWhenBuilder setup) + { + /// + /// Returns/throws forever. + /// + public void Forever() + { + setup.For(int.MaxValue); + } + + /// + /// Uses the return value only once. + /// + public global::Mockolate.Setup.IIndexerGetterOnlySetup OnlyOnce() + => setup.Only(1); + } + + /// + /// Extensions for getter callback setups of get-only indexers with 5 parameters. + /// + extension(Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder setup) + { + /// + /// Executes the callback only once. + /// + public global::Mockolate.Setup.IIndexerGetterOnlySetup OnlyOnce() + => setup.Only(1); + } + + /// + /// Extensions for setter callback setups of set-only indexers with 5 parameters. + /// + extension(Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder setup) + { + /// + /// Executes the callback only once. + /// + public global::Mockolate.Setup.IIndexerSetterOnlySetup OnlyOnce() + => setup.Only(1); + } + } +} +namespace Mockolate.Interactions +{ + /// + /// An access of an indexer getter with 5 typed parameters. + /// + [global::System.Diagnostics.DebuggerDisplay("{ToString()}")] + internal class IndexerGetterAccess(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5) + : global::Mockolate.Interactions.IndexerAccess + { + /// + /// The value of parameter 1. + /// + public T1 Parameter1 { get; } = parameter1; + /// + /// The value of parameter 2. + /// + public T2 Parameter2 { get; } = parameter2; + /// + /// The value of parameter 3. + /// + public T3 Parameter3 { get; } = parameter3; + /// + /// The value of parameter 4. + /// + public T4 Parameter4 { get; } = parameter4; + /// + /// The value of parameter 5. + /// + public T5 Parameter5 { get; } = parameter5; + /// + public override int ParameterCount => 5; + /// + public override object? GetParameterValueAt(int index) + => index switch + { + 0 => Parameter1, + 1 => Parameter2, + 2 => Parameter3, + 3 => Parameter4, + 4 => Parameter5, + _ => null, + }; + /// + protected override global::Mockolate.Setup.IndexerValueStorage? TraverseStorage(global::Mockolate.Setup.IndexerValueStorage? storage, bool createMissing) + { + global::Mockolate.Setup.IndexerValueStorage? s = storage; + if (s is null) + { + return null; + } + s = createMissing ? s.GetOrAddChildDispatch(Parameter1) : s.GetChildDispatch(Parameter1); + if (s is null) + { + return null; + } + s = createMissing ? s.GetOrAddChildDispatch(Parameter2) : s.GetChildDispatch(Parameter2); + if (s is null) + { + return null; + } + s = createMissing ? s.GetOrAddChildDispatch(Parameter3) : s.GetChildDispatch(Parameter3); + if (s is null) + { + return null; + } + s = createMissing ? s.GetOrAddChildDispatch(Parameter4) : s.GetChildDispatch(Parameter4); + if (s is null) + { + return null; + } + return createMissing ? s.GetOrAddChildDispatch(Parameter5) : s.GetChildDispatch(Parameter5); + } + /// + public override string ToString() + => $"get indexer [{Parameter1?.ToString() ?? "null"}, {Parameter2?.ToString() ?? "null"}, {Parameter3?.ToString() ?? "null"}, {Parameter4?.ToString() ?? "null"}, {Parameter5?.ToString() ?? "null"}]"; + } + /// + /// An access of an indexer setter with 5 typed parameters. + /// + [global::System.Diagnostics.DebuggerDisplay("{ToString()}")] + internal class IndexerSetterAccess(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, TValue value) + : global::Mockolate.Interactions.IndexerAccess + { + /// + /// The value of parameter 1. + /// + public T1 Parameter1 { get; } = parameter1; + /// + /// The value of parameter 2. + /// + public T2 Parameter2 { get; } = parameter2; + /// + /// The value of parameter 3. + /// + public T3 Parameter3 { get; } = parameter3; + /// + /// The value of parameter 4. + /// + public T4 Parameter4 { get; } = parameter4; + /// + /// The value of parameter 5. + /// + public T5 Parameter5 { get; } = parameter5; + /// + /// The typed value the indexer was being set to. + /// + public TValue TypedValue { get; } = value; + /// + public override int ParameterCount => 5; + /// + public override object? GetParameterValueAt(int index) + => index switch + { + 0 => Parameter1, + 1 => Parameter2, + 2 => Parameter3, + 3 => Parameter4, + 4 => Parameter5, + _ => null, + }; + /// + protected override global::Mockolate.Setup.IndexerValueStorage? TraverseStorage(global::Mockolate.Setup.IndexerValueStorage? storage, bool createMissing) + { + global::Mockolate.Setup.IndexerValueStorage? s = storage; + if (s is null) + { + return null; + } + s = createMissing ? s.GetOrAddChildDispatch(Parameter1) : s.GetChildDispatch(Parameter1); + if (s is null) + { + return null; + } + s = createMissing ? s.GetOrAddChildDispatch(Parameter2) : s.GetChildDispatch(Parameter2); + if (s is null) + { + return null; + } + s = createMissing ? s.GetOrAddChildDispatch(Parameter3) : s.GetChildDispatch(Parameter3); + if (s is null) + { + return null; + } + s = createMissing ? s.GetOrAddChildDispatch(Parameter4) : s.GetChildDispatch(Parameter4); + if (s is null) + { + return null; + } + return createMissing ? s.GetOrAddChildDispatch(Parameter5) : s.GetChildDispatch(Parameter5); + } + /// + public override string ToString() + => $"set indexer [{Parameter1?.ToString() ?? "null"}, {Parameter2?.ToString() ?? "null"}, {Parameter3?.ToString() ?? "null"}, {Parameter4?.ToString() ?? "null"}, {Parameter5?.ToString() ?? "null"}] to {TypedValue?.ToString() ?? "null"}"; + } +} + +namespace Mockolate.Verify +{ + /// + /// Verifications on a 5-key indexer for , , , and that the mock only reads. + /// + /// + /// Used instead of VerificationIndexerResult<TSubject, TParameter> when the + /// mock has no setter to intercept. Writes then never reach the mock, so offering Set(...) here would + /// always report zero interactions. + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal class VerificationIndexerGetterResult( + TSubject subject, + global::Mockolate.MockRegistry mockRegistry, + int getMemberId, + global::System.Func gotPredicate, + global::System.Func parametersDescription) + { + /// + public global::Mockolate.Verify.VerificationResult Got() + => mockRegistry.IndexerGot(subject, getMemberId, gotPredicate, parametersDescription); + } + /// + /// Verifications on a 5-key indexer of type for , , , and that the mock only writes. + /// + /// + /// Used instead of VerificationIndexerResult<TSubject, TParameter> when the + /// mock has no getter to intercept, so Got() is not offered. + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal class VerificationIndexerSetterResult( + TSubject subject, + global::Mockolate.MockRegistry mockRegistry, + int setMemberId, + global::System.Func, bool> setPredicate, + global::System.Func parametersDescription) + { + /// + public global::Mockolate.Verify.VerificationResult Set(global::Mockolate.Parameters.IParameter value) + => mockRegistry.IndexerSet(subject, setMemberId, setPredicate, + (global::Mockolate.Parameters.IParameterMatch)value, parametersDescription); + + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + /// + /// Verifies the indexer write access on the mock with the given . + /// + public global::Mockolate.Verify.VerificationResult Set(TParameter value) + => mockRegistry.IndexerSet(subject, setMemberId, setPredicate, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(value), parametersDescription); + } +} + +#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/MethodSetups.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/MethodSetups.g.cs new file mode 100644 index 00000000..e9e03399 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/MethodSetups.g.cs @@ -0,0 +1,3557 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +#nullable enable + +namespace Mockolate.Setup +{ + /// + /// Sets up a method with 5 parameters , , , and returning . + /// + internal interface IReturnMethodSetup : global::Mockolate.Setup.IMethodSetup + { + /// + /// Overrides SkipBaseClass for this method only. + /// + /// + /// If not specified, use SkipBaseClass. + /// + global::Mockolate.Setup.IReturnMethodSetup SkippingBaseClass(bool skipBaseClass = true); + + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Transitions the scenario to the given when the method is called. + /// + global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder TransitionTo(string scenario); + + /// + /// Registers a to setup the return value for this method. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(global::System.Func callback); + + /// + /// Registers the for this method. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(TReturn returnValue); + + /// + /// Registers an to throw when the method is invoked. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws() + where TException : global::System.Exception, new(); + + /// + /// Registers an to throw when the method is invoked. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(global::System.Exception exception); + + /// + /// Registers a that will calculate the exception to throw when the method is invoked. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(global::System.Func callback); + } + + /// + /// Sets up a method with 5 parameters , , , and returning with callback support for the parameters. + /// + internal interface IReturnMethodSetupWithCallback : global::Mockolate.Setup.IReturnMethodSetup + { + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Registers a to setup the return value for this method. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(global::System.Func callback); + + /// + /// Registers a that will calculate the exception to throw when the method is invoked. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(global::System.Func callback); + } + + /// + /// Sets up a callback for a method with 5 parameters , , , and returning . + /// + internal interface IReturnMethodSetupCallbackBuilder : global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder + { + /// + /// Runs the callback in parallel to the other callbacks. + /// + global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder InParallel(); + } + + /// + /// Sets up a parallel callback for a method with 5 parameters , , , and returning . + /// + internal interface IReturnMethodSetupParallelCallbackBuilder : global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder + { + /// + /// Limits the callback to only execute for method invocations where the predicate returns true. + /// + /// + /// Provides a zero-based counter indicating how many times the method has been invoked so far. + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder When(global::System.Func predicate); + } + + /// + /// Sets up a when callback for a method with 5 parameters , , , and returning . + /// + internal interface IReturnMethodSetupCallbackWhenBuilder : global::Mockolate.Setup.IReturnMethodSetupWithCallback + { + /// + /// Repeats the callback for the given number of . + /// + /// + /// The number of times is only counted for actual executions (IReturnMethodSetupParallelCallbackBuilder<TReturn, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder For(int times); + + /// + /// Deactivates the callback after the given number of . + /// + /// + /// The number of times is only counted for actual executions (IReturnMethodSetupParallelCallbackBuilder<TReturn, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IReturnMethodSetup Only(int times); + } + + /// + /// Sets up a return callback for a method with 5 parameters , , , and returning . + /// + internal interface IReturnMethodSetupReturnBuilder : global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder + { + /// + /// Limits the return/throw to only execute for method invocations where the predicate returns true. + /// + /// + /// Provides a zero-based counter indicating how many times the method has been invoked so far. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder When(global::System.Func predicate); + } + + /// + /// Sets up a when return callback for a method with 5 parameters , , , and returning . + /// + internal interface IReturnMethodSetupReturnWhenBuilder : global::Mockolate.Setup.IReturnMethodSetupWithCallback + { + /// + /// Repeats the callback for the given number of . + /// + /// + /// The number of times is only counted for actual executions (IReturnMethodSetupReturnBuilder<TReturn, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder For(int times); + + /// + /// Deactivates the return/throw after the given number of . + /// + /// + /// The number of times is only counted for actual executions (IReturnMethodSetupReturnBuilder<TReturn, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IReturnMethodSetup Only(int times); + } + + /// + /// Allows ignoring the provided parameters. + /// + internal interface IReturnMethodSetupParameterIgnorer : global::Mockolate.Setup.IReturnMethodSetupWithCallback + { + /// + /// Replaces the explicit parameter matcher with AnyParameters(). + /// + global::Mockolate.Setup.IReturnMethodSetup AnyParameters(); + } + + /// + /// Sets up a method with 5 parameters , , , and returning . + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal abstract class ReturnMethodSetup : global::Mockolate.Setup.MethodSetup, + global::Mockolate.Setup.IReturnMethodSetupWithCallback, + global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder, + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder + { + private readonly global::Mockolate.MockRegistry _mockRegistry; + private global::Mockolate.Setup.Callbacks>? _callbacks = []; + private global::Mockolate.Setup.Callbacks>? _returnCallbacks = []; + private bool? _skipBaseClass; + + protected ReturnMethodSetup(global::Mockolate.MockRegistry mockRegistry, string name) + : base(name) + { + _mockRegistry = mockRegistry; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetup.SkippingBaseClass(bool skipBaseClass) + { + _skipBaseClass = skipBaseClass; + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder global::Mockolate.Setup.IReturnMethodSetup.Do(global::System.Action callback) + { + global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _) => callback()); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Do(global::System.Action callback) + { + global::Mockolate.Setup.Callback>? currentCallback = new((_, p1, p2, p3, p4, p5) => callback(p1, p2, p3, p4, p5)); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Do(global::System.Action callback) + { + global::Mockolate.Setup.Callback>? currentCallback = new(callback); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IReturnMethodSetup.TransitionTo(string scenario) + { + global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _) => _mockRegistry.TransitionTo(scenario)); + currentCallback.InParallel(); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Returns(global::System.Func callback) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, p1, p2, p3, p4, p5) => callback(p1, p2, p3, p4, p5)); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Returns(global::System.Func callback) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _) => callback()); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Returns(TReturn returnValue) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _) => returnValue); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Throws() + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _) => throw new TException()); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Throws(global::System.Exception exception) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _) => throw exception); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Throws(global::System.Func callback) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, p1, p2, p3, p4, p5) => throw callback(p1, p2, p3, p4, p5)); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Throws(global::System.Func callback) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _) => throw callback()); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder.InParallel() + { + _callbacks?.Active?.InParallel(); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder.When(global::System.Func predicate) + { + _callbacks?.Active?.When(predicate); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder.For(int times) + { + _callbacks?.Active?.For(times); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder.Only(int times) + { + _callbacks?.Active?.Only(times); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder global::Mockolate.Setup.IReturnMethodSetupReturnBuilder.When(global::System.Func predicate) + { + _returnCallbacks?.Active?.When(predicate); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder.For(int times) + { + _returnCallbacks?.Active?.For(times); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder.Only(int times) + { + _returnCallbacks?.Active?.Only(times); + return this; + } + + /// + protected override bool MatchesInteraction(global::Mockolate.Interactions.IMethodInteraction interaction) + { + if (interaction is global::Mockolate.Interactions.MethodInvocation invocation) + { + return Matches(invocation.Parameter1, invocation.Parameter2, invocation.Parameter3, invocation.Parameter4, invocation.Parameter5); + } + return false; + } + + /// + /// Flag indicating, if any return callbacks have been registered on this setup. + /// + public bool HasReturnCallbacks + => _returnCallbacks is { Count: > 0, }; + + /// + /// Gets the flag indicating if the base class implementation should be skipped. + /// + public bool SkipBaseClass(global::Mockolate.MockBehavior behavior) + => _skipBaseClass ?? behavior.SkipBaseClass; + + /// + /// Gets the registered return value. + /// + public bool TryGetReturnValue(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, out TReturn returnValue) + { + if (_returnCallbacks != null) + { + foreach (var _ in _returnCallbacks) + { + var returnCallback = _returnCallbacks[_returnCallbacks.CurrentIndex % _returnCallbacks.Count]; + if (returnCallback.Invoke(ref _returnCallbacks.CurrentIndex, (p1, p2, p3, p4, p5), + static (invocationCount, @delegate, state) => @delegate(invocationCount, state.p1, state.p2, state.p3, state.p4, state.p5), + out TReturn? newValue)) + { + returnValue = newValue; + return true; + } + } + } + returnValue = default!; + return false; + } + + /// + /// Checks if the given parameters match the setup. + /// + public abstract bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value); + + /// + /// Triggers any configured parameter callbacks for the method setup with the specified parameters. + /// + public virtual void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5) + { + if (_callbacks is not null) + { + bool wasInvoked = false; + int currentCallbacksIndex = _callbacks.CurrentIndex; + for (int i = 0; i < _callbacks.Count; i++) + { + var callback = _callbacks[(currentCallbacksIndex + i) % _callbacks.Count]; + if (callback.Invoke(wasInvoked, ref _callbacks.CurrentIndex, (parameter1, parameter2, parameter3, parameter4, parameter5), + static (invocationCount, @delegate, state) => @delegate(invocationCount, state.parameter1, state.parameter2, state.parameter3, state.parameter4, state.parameter5))) + { + wasInvoked = true; + } + } + } + } + + /// Setup for a method with 5 parameters matching against IParameters. + internal class WithParameters : ReturnMethodSetup + { + private readonly string _parameterName1; + private readonly string _parameterName2; + private readonly string _parameterName3; + private readonly string _parameterName4; + private readonly string _parameterName5; + + /// + public WithParameters(global::Mockolate.MockRegistry mockRegistry, string name, global::Mockolate.Parameters.IParameters parameters, string parameterName1, string parameterName2, string parameterName3, string parameterName4, string parameterName5) + : base(mockRegistry, name) + { + Parameters = parameters; + _parameterName1 = parameterName1; + _parameterName2 = parameterName2; + _parameterName3 = parameterName3; + _parameterName4 = parameterName4; + _parameterName5 = parameterName5; + } + + private global::Mockolate.Parameters.IParameters Parameters { get; } + + /// + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value) + => Parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([p1Value, p2Value, p3Value, p4Value, p5Value]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([(_parameterName1, p1Value), (_parameterName2, p2Value), (_parameterName3, p3Value), (_parameterName4, p4Value), (_parameterName5, p5Value)]), + _ => true, + }; + + /// + public override string ToString() + { + return $"{FormatType(typeof(TReturn))} {SubstringAfterLast(Name, '.')}({Parameters})"; + static string SubstringAfterLast(string name, char c) + { + int index = name.LastIndexOf(c); + return index >= 0 ? name.Substring(index + 1) : name; + } + } + } + + /// Setup for a method with 5 parameters matching against individual IParameterMatch<T>. + internal class WithParameterCollection : ReturnMethodSetup, + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer + { + private bool _matchAnyParameters; + + /// + public WithParameterCollection( + global::Mockolate.MockRegistry mockRegistry, + string name, + global::Mockolate.Parameters.IParameterMatch parameter1, + global::Mockolate.Parameters.IParameterMatch parameter2, + global::Mockolate.Parameters.IParameterMatch parameter3, + global::Mockolate.Parameters.IParameterMatch parameter4, + global::Mockolate.Parameters.IParameterMatch parameter5) + : base(mockRegistry, name) + { + Parameter1 = parameter1; + Parameter2 = parameter2; + Parameter3 = parameter3; + Parameter4 = parameter4; + Parameter5 = parameter5; + } + + /// The first parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter1 { get; } + + /// The second parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter2 { get; } + + /// The third parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter3 { get; } + + /// The 4th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter4 { get; } + + /// The 5th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter5 { get; } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer.AnyParameters() + { + _matchAnyParameters = true; + return this; + } + + /// + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value) + => _matchAnyParameters || (Parameter1.Matches(p1Value) && Parameter2.Matches(p2Value) && Parameter3.Matches(p3Value) && Parameter4.Matches(p4Value) && Parameter5.Matches(p5Value)); + + /// + public override void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5) + { + Parameter1?.InvokeCallbacks(parameter1); + Parameter2?.InvokeCallbacks(parameter2); + Parameter3?.InvokeCallbacks(parameter3); + Parameter4?.InvokeCallbacks(parameter4); + Parameter5?.InvokeCallbacks(parameter5); + base.TriggerCallbacks(parameter1, parameter2, parameter3, parameter4, parameter5); + } + + /// + public override string ToString() + { + return $"{FormatType(typeof(TReturn))} {SubstringAfterLast(Name, '.')}({Parameter1}, {Parameter2}, {Parameter3}, {Parameter4}, {Parameter5})"; + static string SubstringAfterLast(string name, char c) + { + int index = name.LastIndexOf(c); + return index >= 0 ? name.Substring(index + 1) : name; + } + } + } + } + + + /// + /// Sets up a method with 5 parameters , , , and returning . + /// + internal interface IVoidMethodSetup : IMethodSetup + { + /// + /// Overrides SkipBaseClass for this method only. + /// + /// + /// If not specified, use SkipBaseClass. + /// + global::Mockolate.Setup.IVoidMethodSetup SkippingBaseClass(bool skipBaseClass = true); + + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Transitions the scenario to the given when the method is called. + /// + global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder TransitionTo(string scenario); + + /// + /// Registers an iteration in the sequence of method invocations, that does not throw. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder DoesNotThrow(); + + /// + /// Registers an to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws() + where TException : global::System.Exception, new(); + + /// + /// Registers an to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(global::System.Exception exception); + + /// + /// Registers a that will calculate the exception to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(global::System.Func callback); +} + + /// + /// Sets up a method with 5 parameters , , , and returning with callback support for the parameters. + /// + internal interface IVoidMethodSetupWithCallback : global::Mockolate.Setup.IVoidMethodSetup + { + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Registers a that will calculate the exception to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(global::System.Func callback); +} + + /// + /// Sets up a callback for a method with 5 parameters , , , and returning . + /// + internal interface IVoidMethodSetupCallbackBuilder : global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder + { + /// + /// Runs the callback in parallel to the other callbacks. + /// + global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder InParallel(); + } + + /// + /// Sets up a callback for a method with 5 parameters , , , and returning . + /// + internal interface IVoidMethodSetupParallelCallbackBuilder : global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder + { + /// + /// Limits the callback to only execute for method invocations where the predicate returns true. + /// + /// + /// Provides a zero-based counter indicating how many times the method has been invoked so far. + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder When(global::System.Func predicate); + } + + /// + /// Sets up a when callback for a method with 5 parameters , , , and returning . + /// + internal interface IVoidMethodSetupCallbackWhenBuilder : global::Mockolate.Setup.IVoidMethodSetupWithCallback + { + /// + /// Repeats the callback for the given number of . + /// + /// + /// The number of times is only counted for actual executions (IVoidMethodSetupParallelCallbackBuilder<T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder For(int times); + + /// + /// Deactivates the callback after the given number of . + /// + /// + /// The number of times is only counted for actual executions (IVoidMethodSetupParallelCallbackBuilder<T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IVoidMethodSetup Only(int times); + } + + /// + /// Sets up a return callback for a method with 5 parameters , , , and returning . + /// + internal interface IVoidMethodSetupReturnBuilder : global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder + { + /// + /// Limits the throw to only execute for method invocations where the predicate returns true. + /// + /// + /// Provides a zero-based counter indicating how many times the method has been invoked so far. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder When(global::System.Func predicate); + } + + /// + /// Sets up a when return callback for a method with 5 parameters , , , and returning . + /// + internal interface IVoidMethodSetupReturnWhenBuilder : global::Mockolate.Setup.IVoidMethodSetupWithCallback + { + /// + /// Repeats the throw for the given number of . + /// + /// + /// The number of times is only counted for actual executions (IVoidMethodSetupReturnBuilder<T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder For(int times); + + /// + /// Deactivates the throw after the given number of . + /// + /// + /// The number of times is only counted for actual executions (IVoidMethodSetupReturnBuilder<T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IVoidMethodSetup Only(int times); + } + + /// + /// Allows ignoring the provided parameters. + /// + internal interface IVoidMethodSetupParameterIgnorer : global::Mockolate.Setup.IVoidMethodSetupWithCallback + { + /// + /// Replaces the explicit parameter matcher with AnyParameters(). + /// + global::Mockolate.Setup.IVoidMethodSetup AnyParameters(); + } + + /// + /// Sets up a method with 5 parameters , , , and returning . + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal abstract class VoidMethodSetup : global::Mockolate.Setup.MethodSetup, + global::Mockolate.Setup.IVoidMethodSetupWithCallback, + global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder, + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder +{ + private readonly global::Mockolate.MockRegistry _mockRegistry; + private global::Mockolate.Setup.Callbacks>? _callbacks = []; + private global::Mockolate.Setup.Callbacks>? _returnCallbacks = []; + private bool? _skipBaseClass; + + protected VoidMethodSetup(global::Mockolate.MockRegistry mockRegistry, string name) + : base(name) + { + _mockRegistry = mockRegistry; + } + + /// + /// Overrides SkipBaseClass for this method only. + /// + /// + /// If not specified, use SkipBaseClass. + /// + global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetup.SkippingBaseClass(bool skipBaseClass) + { + _skipBaseClass = skipBaseClass; + return this; + } + + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder global::Mockolate.Setup.IVoidMethodSetup.Do(global::System.Action callback) + { + global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _) => callback()); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder global::Mockolate.Setup.IVoidMethodSetupWithCallback.Do(global::System.Action callback) + { + global::Mockolate.Setup.Callback>? currentCallback = new((_, p1, p2, p3, p4, p5) => callback(p1, p2, p3, p4, p5)); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder global::Mockolate.Setup.IVoidMethodSetupWithCallback.Do(global::System.Action callback) + { + global::Mockolate.Setup.Callback>? currentCallback = new(callback); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IVoidMethodSetup.TransitionTo(string scenario) + { + global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _) => _mockRegistry.TransitionTo(scenario)); + currentCallback.InParallel(); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + /// Registers an iteration in the sequence of method invocations, that does not throw. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.DoesNotThrow() + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _) => { }); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + /// Registers an to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.Throws() + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _) => throw new TException()); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + /// Registers an to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.Throws(global::System.Exception exception) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _) => throw exception); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + /// Registers a that will calculate the exception to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetupWithCallback.Throws(global::System.Func callback) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, p1, p2, p3, p4, p5) => throw callback(p1, p2, p3, p4, p5)); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + /// Registers a that will calculate the exception to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.Throws(global::System.Func callback) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _) => throw callback()); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder.InParallel() + { + _callbacks?.Active?.InParallel(); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder.When(global::System.Func predicate) + { + _callbacks?.Active?.When(predicate); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder.For(int times) + { + _callbacks?.Active?.For(times); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder.Only(int times) + { + _callbacks?.Active?.Only(times); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder global::Mockolate.Setup.IVoidMethodSetupReturnBuilder.When(global::System.Func predicate) + { + _returnCallbacks?.Active?.When(predicate); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder.For(int times) + { + _returnCallbacks?.Active?.For(times); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder.Only(int times) + { + _returnCallbacks?.Active?.Only(times); + return this; + } + + /// + protected override bool MatchesInteraction(global::Mockolate.Interactions.IMethodInteraction interaction) + { + if (interaction is global::Mockolate.Interactions.MethodInvocation invocation) + { + return Matches(invocation.Parameter1, invocation.Parameter2, invocation.Parameter3, invocation.Parameter4, invocation.Parameter5); + } + return false; + } + + /// + /// Gets the flag indicating if the base class implementation should be skipped. + /// + public bool SkipBaseClass(global::Mockolate.MockBehavior behavior) + => _skipBaseClass ?? behavior.SkipBaseClass; + + /// + /// Checks if the given parameters match the setup. + /// + public abstract bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value); + + /// + /// Triggers any configured parameter callbacks for the method setup with the specified parameters. + /// + public virtual void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5) + { + if (_callbacks is not null) + { + bool wasInvoked = false; + int currentCallbacksIndex = _callbacks.CurrentIndex; + for (int i = 0; i < _callbacks.Count; i++) + { + var callback = _callbacks[(currentCallbacksIndex + i) % _callbacks.Count]; + if (callback.Invoke(wasInvoked, ref _callbacks.CurrentIndex, (parameter1, parameter2, parameter3, parameter4, parameter5), + static (invocationCount, @delegate, state) => @delegate(invocationCount, state.parameter1, state.parameter2, state.parameter3, state.parameter4, state.parameter5))) + { + wasInvoked = true; + } + } + } + if (_returnCallbacks is not null) + { + foreach (var _ in _returnCallbacks) + { + var returnCallback = _returnCallbacks[_returnCallbacks.CurrentIndex % _returnCallbacks.Count]; + if (returnCallback.Invoke(ref _returnCallbacks.CurrentIndex, (parameter1, parameter2, parameter3, parameter4, parameter5), + static (invocationCount, @delegate, state) => @delegate(invocationCount, state.parameter1, state.parameter2, state.parameter3, state.parameter4, state.parameter5))) + { + return; + } + } + } + } + + /// Setup for a method with 5 parameters matching against IParameters. + internal class WithParameters : VoidMethodSetup + { + private readonly string _parameterName1; + private readonly string _parameterName2; + private readonly string _parameterName3; + private readonly string _parameterName4; + private readonly string _parameterName5; + + /// + public WithParameters(global::Mockolate.MockRegistry mockRegistry, string name, global::Mockolate.Parameters.IParameters parameters, string parameterName1, string parameterName2, string parameterName3, string parameterName4, string parameterName5) + : base(mockRegistry, name) + { + Parameters = parameters; + _parameterName1 = parameterName1; + _parameterName2 = parameterName2; + _parameterName3 = parameterName3; + _parameterName4 = parameterName4; + _parameterName5 = parameterName5; + } + + private global::Mockolate.Parameters.IParameters Parameters { get; } + + /// + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value) + => Parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([p1Value, p2Value, p3Value, p4Value, p5Value]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([(_parameterName1, p1Value), (_parameterName2, p2Value), (_parameterName3, p3Value), (_parameterName4, p4Value), (_parameterName5, p5Value)]), + _ => true, + }; + + /// + public override string ToString() + { + return $"void {SubstringAfterLast(Name, '.')}({Parameters})"; + static string SubstringAfterLast(string name, char c) + { + int index = name.LastIndexOf(c); + return index >= 0 ? name.Substring(index + 1) : name; + } + } + } + + /// Setup for a method with 5 parameters matching against individual IParameterMatch<T>. + internal class WithParameterCollection : VoidMethodSetup, + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer + { + private bool _matchAnyParameters; + + /// + public WithParameterCollection( + global::Mockolate.MockRegistry mockRegistry, + string name, + global::Mockolate.Parameters.IParameterMatch parameter1, + global::Mockolate.Parameters.IParameterMatch parameter2, + global::Mockolate.Parameters.IParameterMatch parameter3, + global::Mockolate.Parameters.IParameterMatch parameter4, + global::Mockolate.Parameters.IParameterMatch parameter5) + : base(mockRegistry, name) + { + Parameter1 = parameter1; + Parameter2 = parameter2; + Parameter3 = parameter3; + Parameter4 = parameter4; + Parameter5 = parameter5; + } + + /// The first parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter1 { get; } + + /// The second parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter2 { get; } + + /// The third parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter3 { get; } + + /// The 4th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter4 { get; } + + /// The 5th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter5 { get; } + + /// + global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer.AnyParameters() + { + _matchAnyParameters = true; + return this; + } + + /// + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value) + => _matchAnyParameters || (Parameter1.Matches(p1Value) && Parameter2.Matches(p2Value) && Parameter3.Matches(p3Value) && Parameter4.Matches(p4Value) && Parameter5.Matches(p5Value)); + + /// + public override void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5) + { + Parameter1?.InvokeCallbacks(parameter1); + Parameter2?.InvokeCallbacks(parameter2); + Parameter3?.InvokeCallbacks(parameter3); + Parameter4?.InvokeCallbacks(parameter4); + Parameter5?.InvokeCallbacks(parameter5); + base.TriggerCallbacks(parameter1, parameter2, parameter3, parameter4, parameter5); + } + + /// + public override string ToString() + { + return $"void {SubstringAfterLast(Name, '.')}({Parameter1}, {Parameter2}, {Parameter3}, {Parameter4}, {Parameter5})"; + static string SubstringAfterLast(string name, char c) + { + int index = name.LastIndexOf(c); + return index >= 0 ? name.Substring(index + 1) : name; + } + } + } + } + + + /// + /// Sets up a method with 7 parameters , , , , , and returning . + /// + internal interface IVoidMethodSetup : IMethodSetup + { + /// + /// Overrides SkipBaseClass for this method only. + /// + /// + /// If not specified, use SkipBaseClass. + /// + global::Mockolate.Setup.IVoidMethodSetup SkippingBaseClass(bool skipBaseClass = true); + + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Transitions the scenario to the given when the method is called. + /// + global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder TransitionTo(string scenario); + + /// + /// Registers an iteration in the sequence of method invocations, that does not throw. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder DoesNotThrow(); + + /// + /// Registers an to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws() + where TException : global::System.Exception, new(); + + /// + /// Registers an to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(global::System.Exception exception); + + /// + /// Registers a that will calculate the exception to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(global::System.Func callback); +} + + /// + /// Sets up a method with 7 parameters , , , , , and returning with callback support for the parameters. + /// + internal interface IVoidMethodSetupWithCallback : global::Mockolate.Setup.IVoidMethodSetup + { + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Registers a that will calculate the exception to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(global::System.Func callback); +} + + /// + /// Sets up a callback for a method with 7 parameters , , , , , and returning . + /// + internal interface IVoidMethodSetupCallbackBuilder : global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder + { + /// + /// Runs the callback in parallel to the other callbacks. + /// + global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder InParallel(); + } + + /// + /// Sets up a callback for a method with 7 parameters , , , , , and returning . + /// + internal interface IVoidMethodSetupParallelCallbackBuilder : global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder + { + /// + /// Limits the callback to only execute for method invocations where the predicate returns true. + /// + /// + /// Provides a zero-based counter indicating how many times the method has been invoked so far. + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder When(global::System.Func predicate); + } + + /// + /// Sets up a when callback for a method with 7 parameters , , , , , and returning . + /// + internal interface IVoidMethodSetupCallbackWhenBuilder : global::Mockolate.Setup.IVoidMethodSetupWithCallback + { + /// + /// Repeats the callback for the given number of . + /// + /// + /// The number of times is only counted for actual executions (IVoidMethodSetupParallelCallbackBuilder<T1, T2, T3, T4, T5, T6, T7>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder For(int times); + + /// + /// Deactivates the callback after the given number of . + /// + /// + /// The number of times is only counted for actual executions (IVoidMethodSetupParallelCallbackBuilder<T1, T2, T3, T4, T5, T6, T7>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IVoidMethodSetup Only(int times); + } + + /// + /// Sets up a return callback for a method with 7 parameters , , , , , and returning . + /// + internal interface IVoidMethodSetupReturnBuilder : global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder + { + /// + /// Limits the throw to only execute for method invocations where the predicate returns true. + /// + /// + /// Provides a zero-based counter indicating how many times the method has been invoked so far. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder When(global::System.Func predicate); + } + + /// + /// Sets up a when return callback for a method with 7 parameters , , , , , and returning . + /// + internal interface IVoidMethodSetupReturnWhenBuilder : global::Mockolate.Setup.IVoidMethodSetupWithCallback + { + /// + /// Repeats the throw for the given number of . + /// + /// + /// The number of times is only counted for actual executions (IVoidMethodSetupReturnBuilder<T1, T2, T3, T4, T5, T6, T7>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder For(int times); + + /// + /// Deactivates the throw after the given number of . + /// + /// + /// The number of times is only counted for actual executions (IVoidMethodSetupReturnBuilder<T1, T2, T3, T4, T5, T6, T7>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IVoidMethodSetup Only(int times); + } + + /// + /// Allows ignoring the provided parameters. + /// + internal interface IVoidMethodSetupParameterIgnorer : global::Mockolate.Setup.IVoidMethodSetupWithCallback + { + /// + /// Replaces the explicit parameter matcher with AnyParameters(). + /// + global::Mockolate.Setup.IVoidMethodSetup AnyParameters(); + } + + /// + /// Sets up a method with 7 parameters , , , , , and returning . + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal abstract class VoidMethodSetup : global::Mockolate.Setup.MethodSetup, + global::Mockolate.Setup.IVoidMethodSetupWithCallback, + global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder, + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder +{ + private readonly global::Mockolate.MockRegistry _mockRegistry; + private global::Mockolate.Setup.Callbacks>? _callbacks = []; + private global::Mockolate.Setup.Callbacks>? _returnCallbacks = []; + private bool? _skipBaseClass; + + protected VoidMethodSetup(global::Mockolate.MockRegistry mockRegistry, string name) + : base(name) + { + _mockRegistry = mockRegistry; + } + + /// + /// Overrides SkipBaseClass for this method only. + /// + /// + /// If not specified, use SkipBaseClass. + /// + global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetup.SkippingBaseClass(bool skipBaseClass) + { + _skipBaseClass = skipBaseClass; + return this; + } + + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder global::Mockolate.Setup.IVoidMethodSetup.Do(global::System.Action callback) + { + global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _, _, _) => callback()); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder global::Mockolate.Setup.IVoidMethodSetupWithCallback.Do(global::System.Action callback) + { + global::Mockolate.Setup.Callback>? currentCallback = new((_, p1, p2, p3, p4, p5, p6, p7) => callback(p1, p2, p3, p4, p5, p6, p7)); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder global::Mockolate.Setup.IVoidMethodSetupWithCallback.Do(global::System.Action callback) + { + global::Mockolate.Setup.Callback>? currentCallback = new(callback); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IVoidMethodSetup.TransitionTo(string scenario) + { + global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _, _, _) => _mockRegistry.TransitionTo(scenario)); + currentCallback.InParallel(); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + /// Registers an iteration in the sequence of method invocations, that does not throw. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.DoesNotThrow() + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _) => { }); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + /// Registers an to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.Throws() + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _) => throw new TException()); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + /// Registers an to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.Throws(global::System.Exception exception) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _) => throw exception); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + /// Registers a that will calculate the exception to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetupWithCallback.Throws(global::System.Func callback) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, p1, p2, p3, p4, p5, p6, p7) => throw callback(p1, p2, p3, p4, p5, p6, p7)); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + /// Registers a that will calculate the exception to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.Throws(global::System.Func callback) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _) => throw callback()); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder.InParallel() + { + _callbacks?.Active?.InParallel(); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder.When(global::System.Func predicate) + { + _callbacks?.Active?.When(predicate); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder.For(int times) + { + _callbacks?.Active?.For(times); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder.Only(int times) + { + _callbacks?.Active?.Only(times); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder global::Mockolate.Setup.IVoidMethodSetupReturnBuilder.When(global::System.Func predicate) + { + _returnCallbacks?.Active?.When(predicate); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder.For(int times) + { + _returnCallbacks?.Active?.For(times); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder.Only(int times) + { + _returnCallbacks?.Active?.Only(times); + return this; + } + + /// + protected override bool MatchesInteraction(global::Mockolate.Interactions.IMethodInteraction interaction) + { + if (interaction is global::Mockolate.Interactions.MethodInvocation invocation) + { + return Matches(invocation.Parameter1, invocation.Parameter2, invocation.Parameter3, invocation.Parameter4, invocation.Parameter5, invocation.Parameter6, invocation.Parameter7); + } + return false; + } + + /// + /// Gets the flag indicating if the base class implementation should be skipped. + /// + public bool SkipBaseClass(global::Mockolate.MockBehavior behavior) + => _skipBaseClass ?? behavior.SkipBaseClass; + + /// + /// Checks if the given parameters match the setup. + /// + public abstract bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value, T7 p7Value); + + /// + /// Triggers any configured parameter callbacks for the method setup with the specified parameters. + /// + public virtual void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7) + { + if (_callbacks is not null) + { + bool wasInvoked = false; + int currentCallbacksIndex = _callbacks.CurrentIndex; + for (int i = 0; i < _callbacks.Count; i++) + { + var callback = _callbacks[(currentCallbacksIndex + i) % _callbacks.Count]; + if (callback.Invoke(wasInvoked, ref _callbacks.CurrentIndex, (parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7), + static (invocationCount, @delegate, state) => @delegate(invocationCount, state.parameter1, state.parameter2, state.parameter3, state.parameter4, state.parameter5, state.parameter6, state.parameter7))) + { + wasInvoked = true; + } + } + } + if (_returnCallbacks is not null) + { + foreach (var _ in _returnCallbacks) + { + var returnCallback = _returnCallbacks[_returnCallbacks.CurrentIndex % _returnCallbacks.Count]; + if (returnCallback.Invoke(ref _returnCallbacks.CurrentIndex, (parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7), + static (invocationCount, @delegate, state) => @delegate(invocationCount, state.parameter1, state.parameter2, state.parameter3, state.parameter4, state.parameter5, state.parameter6, state.parameter7))) + { + return; + } + } + } + } + + /// Setup for a method with 7 parameters matching against IParameters. + internal class WithParameters : VoidMethodSetup + { + private readonly string _parameterName1; + private readonly string _parameterName2; + private readonly string _parameterName3; + private readonly string _parameterName4; + private readonly string _parameterName5; + private readonly string _parameterName6; + private readonly string _parameterName7; + + /// + public WithParameters(global::Mockolate.MockRegistry mockRegistry, string name, global::Mockolate.Parameters.IParameters parameters, string parameterName1, string parameterName2, string parameterName3, string parameterName4, string parameterName5, string parameterName6, string parameterName7) + : base(mockRegistry, name) + { + Parameters = parameters; + _parameterName1 = parameterName1; + _parameterName2 = parameterName2; + _parameterName3 = parameterName3; + _parameterName4 = parameterName4; + _parameterName5 = parameterName5; + _parameterName6 = parameterName6; + _parameterName7 = parameterName7; + } + + private global::Mockolate.Parameters.IParameters Parameters { get; } + + /// + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value, T7 p7Value) + => Parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([p1Value, p2Value, p3Value, p4Value, p5Value, p6Value, p7Value]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([(_parameterName1, p1Value), (_parameterName2, p2Value), (_parameterName3, p3Value), (_parameterName4, p4Value), (_parameterName5, p5Value), (_parameterName6, p6Value), (_parameterName7, p7Value)]), + _ => true, + }; + + /// + public override string ToString() + { + return $"void {SubstringAfterLast(Name, '.')}({Parameters})"; + static string SubstringAfterLast(string name, char c) + { + int index = name.LastIndexOf(c); + return index >= 0 ? name.Substring(index + 1) : name; + } + } + } + + /// Setup for a method with 7 parameters matching against individual IParameterMatch<T>. + internal class WithParameterCollection : VoidMethodSetup, + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer + { + private bool _matchAnyParameters; + + /// + public WithParameterCollection( + global::Mockolate.MockRegistry mockRegistry, + string name, + global::Mockolate.Parameters.IParameterMatch parameter1, + global::Mockolate.Parameters.IParameterMatch parameter2, + global::Mockolate.Parameters.IParameterMatch parameter3, + global::Mockolate.Parameters.IParameterMatch parameter4, + global::Mockolate.Parameters.IParameterMatch parameter5, + global::Mockolate.Parameters.IParameterMatch parameter6, + global::Mockolate.Parameters.IParameterMatch parameter7) + : base(mockRegistry, name) + { + Parameter1 = parameter1; + Parameter2 = parameter2; + Parameter3 = parameter3; + Parameter4 = parameter4; + Parameter5 = parameter5; + Parameter6 = parameter6; + Parameter7 = parameter7; + } + + /// The first parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter1 { get; } + + /// The second parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter2 { get; } + + /// The third parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter3 { get; } + + /// The 4th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter4 { get; } + + /// The 5th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter5 { get; } + + /// The 6th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter6 { get; } + + /// The 7th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter7 { get; } + + /// + global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer.AnyParameters() + { + _matchAnyParameters = true; + return this; + } + + /// + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value, T7 p7Value) + => _matchAnyParameters || (Parameter1.Matches(p1Value) && Parameter2.Matches(p2Value) && Parameter3.Matches(p3Value) && Parameter4.Matches(p4Value) && Parameter5.Matches(p5Value) && Parameter6.Matches(p6Value) && Parameter7.Matches(p7Value)); + + /// + public override void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7) + { + Parameter1?.InvokeCallbacks(parameter1); + Parameter2?.InvokeCallbacks(parameter2); + Parameter3?.InvokeCallbacks(parameter3); + Parameter4?.InvokeCallbacks(parameter4); + Parameter5?.InvokeCallbacks(parameter5); + Parameter6?.InvokeCallbacks(parameter6); + Parameter7?.InvokeCallbacks(parameter7); + base.TriggerCallbacks(parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7); + } + + /// + public override string ToString() + { + return $"void {SubstringAfterLast(Name, '.')}({Parameter1}, {Parameter2}, {Parameter3}, {Parameter4}, {Parameter5}, {Parameter6}, {Parameter7})"; + static string SubstringAfterLast(string name, char c) + { + int index = name.LastIndexOf(c); + return index >= 0 ? name.Substring(index + 1) : name; + } + } + } + } + + + /// + /// Sets up a method with 17 parameters , , , , , , , , , , , , , , , and returning . + /// + internal interface IReturnMethodSetup : global::Mockolate.Setup.IMethodSetup + { + /// + /// Overrides SkipBaseClass for this method only. + /// + /// + /// If not specified, use SkipBaseClass. + /// + global::Mockolate.Setup.IReturnMethodSetup SkippingBaseClass(bool skipBaseClass = true); + + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Transitions the scenario to the given when the method is called. + /// + global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder TransitionTo(string scenario); + + /// + /// Registers a to setup the return value for this method. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(global::System.Func callback); + + /// + /// Registers the for this method. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(TReturn returnValue); + + /// + /// Registers an to throw when the method is invoked. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws() + where TException : global::System.Exception, new(); + + /// + /// Registers an to throw when the method is invoked. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(global::System.Exception exception); + + /// + /// Registers a that will calculate the exception to throw when the method is invoked. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(global::System.Func callback); + } + + /// + /// Sets up a method with 17 parameters , , , , , , , , , , , , , , , and returning with callback support for the parameters. + /// + internal interface IReturnMethodSetupWithCallback : global::Mockolate.Setup.IReturnMethodSetup + { + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Registers a to setup the return value for this method. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(global::System.Func callback); + + /// + /// Registers a that will calculate the exception to throw when the method is invoked. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(global::System.Func callback); + } + + /// + /// Sets up a callback for a method with 17 parameters , , , , , , , , , , , , , , , and returning . + /// + internal interface IReturnMethodSetupCallbackBuilder : global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder + { + /// + /// Runs the callback in parallel to the other callbacks. + /// + global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder InParallel(); + } + + /// + /// Sets up a parallel callback for a method with 17 parameters , , , , , , , , , , , , , , , and returning . + /// + internal interface IReturnMethodSetupParallelCallbackBuilder : global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder + { + /// + /// Limits the callback to only execute for method invocations where the predicate returns true. + /// + /// + /// Provides a zero-based counter indicating how many times the method has been invoked so far. + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder When(global::System.Func predicate); + } + + /// + /// Sets up a when callback for a method with 17 parameters , , , , , , , , , , , , , , , and returning . + /// + internal interface IReturnMethodSetupCallbackWhenBuilder : global::Mockolate.Setup.IReturnMethodSetupWithCallback + { + /// + /// Repeats the callback for the given number of . + /// + /// + /// The number of times is only counted for actual executions (IReturnMethodSetupParallelCallbackBuilder<TReturn, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder For(int times); + + /// + /// Deactivates the callback after the given number of . + /// + /// + /// The number of times is only counted for actual executions (IReturnMethodSetupParallelCallbackBuilder<TReturn, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IReturnMethodSetup Only(int times); + } + + /// + /// Sets up a return callback for a method with 17 parameters , , , , , , , , , , , , , , , and returning . + /// + internal interface IReturnMethodSetupReturnBuilder : global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder + { + /// + /// Limits the return/throw to only execute for method invocations where the predicate returns true. + /// + /// + /// Provides a zero-based counter indicating how many times the method has been invoked so far. + /// + global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder When(global::System.Func predicate); + } + + /// + /// Sets up a when return callback for a method with 17 parameters , , , , , , , , , , , , , , , and returning . + /// + internal interface IReturnMethodSetupReturnWhenBuilder : global::Mockolate.Setup.IReturnMethodSetupWithCallback + { + /// + /// Repeats the callback for the given number of . + /// + /// + /// The number of times is only counted for actual executions (IReturnMethodSetupReturnBuilder<TReturn, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder For(int times); + + /// + /// Deactivates the return/throw after the given number of . + /// + /// + /// The number of times is only counted for actual executions (IReturnMethodSetupReturnBuilder<TReturn, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IReturnMethodSetup Only(int times); + } + + /// + /// Allows ignoring the provided parameters. + /// + internal interface IReturnMethodSetupParameterIgnorer : global::Mockolate.Setup.IReturnMethodSetupWithCallback + { + /// + /// Replaces the explicit parameter matcher with AnyParameters(). + /// + global::Mockolate.Setup.IReturnMethodSetup AnyParameters(); + } + + /// + /// Sets up a method with 17 parameters , , , , , , , , , , , , , , , and returning . + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal abstract class ReturnMethodSetup : global::Mockolate.Setup.MethodSetup, + global::Mockolate.Setup.IReturnMethodSetupWithCallback, + global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder, + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder + { + private readonly global::Mockolate.MockRegistry _mockRegistry; + private global::Mockolate.Setup.Callbacks>? _callbacks = []; + private global::Mockolate.Setup.Callbacks>? _returnCallbacks = []; + private bool? _skipBaseClass; + + protected ReturnMethodSetup(global::Mockolate.MockRegistry mockRegistry, string name) + : base(name) + { + _mockRegistry = mockRegistry; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetup.SkippingBaseClass(bool skipBaseClass) + { + _skipBaseClass = skipBaseClass; + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder global::Mockolate.Setup.IReturnMethodSetup.Do(global::System.Action callback) + { + global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => callback()); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Do(global::System.Action callback) + { + global::Mockolate.Setup.Callback>? currentCallback = new((_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17) => callback(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17)); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Do(global::System.Action callback) + { + global::Mockolate.Setup.Callback>? currentCallback = new(callback); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IReturnMethodSetup.TransitionTo(string scenario) + { + global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => _mockRegistry.TransitionTo(scenario)); + currentCallback.InParallel(); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Returns(global::System.Func callback) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17) => callback(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17)); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Returns(global::System.Func callback) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => callback()); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Returns(TReturn returnValue) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => returnValue); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Throws() + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => throw new TException()); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Throws(global::System.Exception exception) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => throw exception); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Throws(global::System.Func callback) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17) => throw callback(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17)); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Throws(global::System.Func callback) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => throw callback()); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder.InParallel() + { + _callbacks?.Active?.InParallel(); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder.When(global::System.Func predicate) + { + _callbacks?.Active?.When(predicate); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder.For(int times) + { + _callbacks?.Active?.For(times); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder.Only(int times) + { + _callbacks?.Active?.Only(times); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder global::Mockolate.Setup.IReturnMethodSetupReturnBuilder.When(global::System.Func predicate) + { + _returnCallbacks?.Active?.When(predicate); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder.For(int times) + { + _returnCallbacks?.Active?.For(times); + return this; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder.Only(int times) + { + _returnCallbacks?.Active?.Only(times); + return this; + } + + /// + protected override bool MatchesInteraction(global::Mockolate.Interactions.IMethodInteraction interaction) + { + if (interaction is global::Mockolate.Interactions.MethodInvocation invocation) + { + return Matches(invocation.Parameter1, invocation.Parameter2, invocation.Parameter3, invocation.Parameter4, invocation.Parameter5, invocation.Parameter6, invocation.Parameter7, invocation.Parameter8, invocation.Parameter9, invocation.Parameter10, invocation.Parameter11, invocation.Parameter12, invocation.Parameter13, invocation.Parameter14, invocation.Parameter15, invocation.Parameter16, invocation.Parameter17); + } + return false; + } + + /// + /// Flag indicating, if any return callbacks have been registered on this setup. + /// + public bool HasReturnCallbacks + => _returnCallbacks is { Count: > 0, }; + + /// + /// Gets the flag indicating if the base class implementation should be skipped. + /// + public bool SkipBaseClass(global::Mockolate.MockBehavior behavior) + => _skipBaseClass ?? behavior.SkipBaseClass; + + /// + /// Gets the registered return value. + /// + public bool TryGetReturnValue(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7, T8 p8, T9 p9, T10 p10, T11 p11, T12 p12, T13 p13, T14 p14, T15 p15, T16 p16, T17 p17, out TReturn returnValue) + { + if (_returnCallbacks != null) + { + foreach (var _ in _returnCallbacks) + { + var returnCallback = _returnCallbacks[_returnCallbacks.CurrentIndex % _returnCallbacks.Count]; + if (returnCallback.Invoke(ref _returnCallbacks.CurrentIndex, (p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17), + static (invocationCount, @delegate, state) => @delegate(invocationCount, state.p1, state.p2, state.p3, state.p4, state.p5, state.p6, state.p7, state.p8, state.p9, state.p10, state.p11, state.p12, state.p13, state.p14, state.p15, state.p16, state.p17), + out TReturn? newValue)) + { + returnValue = newValue; + return true; + } + } + } + returnValue = default!; + return false; + } + + /// + /// Checks if the given parameters match the setup. + /// + public abstract bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value, T7 p7Value, T8 p8Value, T9 p9Value, T10 p10Value, T11 p11Value, T12 p12Value, T13 p13Value, T14 p14Value, T15 p15Value, T16 p16Value, T17 p17Value); + + /// + /// Triggers any configured parameter callbacks for the method setup with the specified parameters. + /// + public virtual void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7, T8 parameter8, T9 parameter9, T10 parameter10, T11 parameter11, T12 parameter12, T13 parameter13, T14 parameter14, T15 parameter15, T16 parameter16, T17 parameter17) + { + if (_callbacks is not null) + { + bool wasInvoked = false; + int currentCallbacksIndex = _callbacks.CurrentIndex; + for (int i = 0; i < _callbacks.Count; i++) + { + var callback = _callbacks[(currentCallbacksIndex + i) % _callbacks.Count]; + if (callback.Invoke(wasInvoked, ref _callbacks.CurrentIndex, (parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7, parameter8, parameter9, parameter10, parameter11, parameter12, parameter13, parameter14, parameter15, parameter16, parameter17), + static (invocationCount, @delegate, state) => @delegate(invocationCount, state.parameter1, state.parameter2, state.parameter3, state.parameter4, state.parameter5, state.parameter6, state.parameter7, state.parameter8, state.parameter9, state.parameter10, state.parameter11, state.parameter12, state.parameter13, state.parameter14, state.parameter15, state.parameter16, state.parameter17))) + { + wasInvoked = true; + } + } + } + } + + /// Setup for a method with 17 parameters matching against IParameters. + internal class WithParameters : ReturnMethodSetup + { + private readonly string _parameterName1; + private readonly string _parameterName2; + private readonly string _parameterName3; + private readonly string _parameterName4; + private readonly string _parameterName5; + private readonly string _parameterName6; + private readonly string _parameterName7; + private readonly string _parameterName8; + private readonly string _parameterName9; + private readonly string _parameterName10; + private readonly string _parameterName11; + private readonly string _parameterName12; + private readonly string _parameterName13; + private readonly string _parameterName14; + private readonly string _parameterName15; + private readonly string _parameterName16; + private readonly string _parameterName17; + + /// + public WithParameters(global::Mockolate.MockRegistry mockRegistry, string name, global::Mockolate.Parameters.IParameters parameters, string parameterName1, string parameterName2, string parameterName3, string parameterName4, string parameterName5, string parameterName6, string parameterName7, string parameterName8, string parameterName9, string parameterName10, string parameterName11, string parameterName12, string parameterName13, string parameterName14, string parameterName15, string parameterName16, string parameterName17) + : base(mockRegistry, name) + { + Parameters = parameters; + _parameterName1 = parameterName1; + _parameterName2 = parameterName2; + _parameterName3 = parameterName3; + _parameterName4 = parameterName4; + _parameterName5 = parameterName5; + _parameterName6 = parameterName6; + _parameterName7 = parameterName7; + _parameterName8 = parameterName8; + _parameterName9 = parameterName9; + _parameterName10 = parameterName10; + _parameterName11 = parameterName11; + _parameterName12 = parameterName12; + _parameterName13 = parameterName13; + _parameterName14 = parameterName14; + _parameterName15 = parameterName15; + _parameterName16 = parameterName16; + _parameterName17 = parameterName17; + } + + private global::Mockolate.Parameters.IParameters Parameters { get; } + + /// + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value, T7 p7Value, T8 p8Value, T9 p9Value, T10 p10Value, T11 p11Value, T12 p12Value, T13 p13Value, T14 p14Value, T15 p15Value, T16 p16Value, T17 p17Value) + => Parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([p1Value, p2Value, p3Value, p4Value, p5Value, p6Value, p7Value, p8Value, p9Value, p10Value, p11Value, p12Value, p13Value, p14Value, p15Value, p16Value, p17Value]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([(_parameterName1, p1Value), (_parameterName2, p2Value), (_parameterName3, p3Value), (_parameterName4, p4Value), (_parameterName5, p5Value), (_parameterName6, p6Value), (_parameterName7, p7Value), (_parameterName8, p8Value), (_parameterName9, p9Value), (_parameterName10, p10Value), (_parameterName11, p11Value), (_parameterName12, p12Value), (_parameterName13, p13Value), (_parameterName14, p14Value), (_parameterName15, p15Value), (_parameterName16, p16Value), (_parameterName17, p17Value)]), + _ => true, + }; + + /// + public override string ToString() + { + return $"{FormatType(typeof(TReturn))} {SubstringAfterLast(Name, '.')}({Parameters})"; + static string SubstringAfterLast(string name, char c) + { + int index = name.LastIndexOf(c); + return index >= 0 ? name.Substring(index + 1) : name; + } + } + } + + /// Setup for a method with 17 parameters matching against individual IParameterMatch<T>. + internal class WithParameterCollection : ReturnMethodSetup, + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer + { + private bool _matchAnyParameters; + + /// + public WithParameterCollection( + global::Mockolate.MockRegistry mockRegistry, + string name, + global::Mockolate.Parameters.IParameterMatch parameter1, + global::Mockolate.Parameters.IParameterMatch parameter2, + global::Mockolate.Parameters.IParameterMatch parameter3, + global::Mockolate.Parameters.IParameterMatch parameter4, + global::Mockolate.Parameters.IParameterMatch parameter5, + global::Mockolate.Parameters.IParameterMatch parameter6, + global::Mockolate.Parameters.IParameterMatch parameter7, + global::Mockolate.Parameters.IParameterMatch parameter8, + global::Mockolate.Parameters.IParameterMatch parameter9, + global::Mockolate.Parameters.IParameterMatch parameter10, + global::Mockolate.Parameters.IParameterMatch parameter11, + global::Mockolate.Parameters.IParameterMatch parameter12, + global::Mockolate.Parameters.IParameterMatch parameter13, + global::Mockolate.Parameters.IParameterMatch parameter14, + global::Mockolate.Parameters.IParameterMatch parameter15, + global::Mockolate.Parameters.IParameterMatch parameter16, + global::Mockolate.Parameters.IParameterMatch parameter17) + : base(mockRegistry, name) + { + Parameter1 = parameter1; + Parameter2 = parameter2; + Parameter3 = parameter3; + Parameter4 = parameter4; + Parameter5 = parameter5; + Parameter6 = parameter6; + Parameter7 = parameter7; + Parameter8 = parameter8; + Parameter9 = parameter9; + Parameter10 = parameter10; + Parameter11 = parameter11; + Parameter12 = parameter12; + Parameter13 = parameter13; + Parameter14 = parameter14; + Parameter15 = parameter15; + Parameter16 = parameter16; + Parameter17 = parameter17; + } + + /// The first parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter1 { get; } + + /// The second parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter2 { get; } + + /// The third parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter3 { get; } + + /// The 4th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter4 { get; } + + /// The 5th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter5 { get; } + + /// The 6th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter6 { get; } + + /// The 7th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter7 { get; } + + /// The 8th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter8 { get; } + + /// The 9th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter9 { get; } + + /// The 10th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter10 { get; } + + /// The 11th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter11 { get; } + + /// The 12th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter12 { get; } + + /// The 13th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter13 { get; } + + /// The 14th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter14 { get; } + + /// The 15th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter15 { get; } + + /// The 16th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter16 { get; } + + /// The 17th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter17 { get; } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer.AnyParameters() + { + _matchAnyParameters = true; + return this; + } + + /// + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value, T7 p7Value, T8 p8Value, T9 p9Value, T10 p10Value, T11 p11Value, T12 p12Value, T13 p13Value, T14 p14Value, T15 p15Value, T16 p16Value, T17 p17Value) + => _matchAnyParameters || (Parameter1.Matches(p1Value) && Parameter2.Matches(p2Value) && Parameter3.Matches(p3Value) && Parameter4.Matches(p4Value) && Parameter5.Matches(p5Value) && Parameter6.Matches(p6Value) && Parameter7.Matches(p7Value) && Parameter8.Matches(p8Value) && Parameter9.Matches(p9Value) && Parameter10.Matches(p10Value) && Parameter11.Matches(p11Value) && Parameter12.Matches(p12Value) && Parameter13.Matches(p13Value) && Parameter14.Matches(p14Value) && Parameter15.Matches(p15Value) && Parameter16.Matches(p16Value) && Parameter17.Matches(p17Value)); + + /// + public override void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7, T8 parameter8, T9 parameter9, T10 parameter10, T11 parameter11, T12 parameter12, T13 parameter13, T14 parameter14, T15 parameter15, T16 parameter16, T17 parameter17) + { + Parameter1?.InvokeCallbacks(parameter1); + Parameter2?.InvokeCallbacks(parameter2); + Parameter3?.InvokeCallbacks(parameter3); + Parameter4?.InvokeCallbacks(parameter4); + Parameter5?.InvokeCallbacks(parameter5); + Parameter6?.InvokeCallbacks(parameter6); + Parameter7?.InvokeCallbacks(parameter7); + Parameter8?.InvokeCallbacks(parameter8); + Parameter9?.InvokeCallbacks(parameter9); + Parameter10?.InvokeCallbacks(parameter10); + Parameter11?.InvokeCallbacks(parameter11); + Parameter12?.InvokeCallbacks(parameter12); + Parameter13?.InvokeCallbacks(parameter13); + Parameter14?.InvokeCallbacks(parameter14); + Parameter15?.InvokeCallbacks(parameter15); + Parameter16?.InvokeCallbacks(parameter16); + Parameter17?.InvokeCallbacks(parameter17); + base.TriggerCallbacks(parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7, parameter8, parameter9, parameter10, parameter11, parameter12, parameter13, parameter14, parameter15, parameter16, parameter17); + } + + /// + public override string ToString() + { + return $"{FormatType(typeof(TReturn))} {SubstringAfterLast(Name, '.')}({Parameter1}, {Parameter2}, {Parameter3}, {Parameter4}, {Parameter5}, {Parameter6}, {Parameter7}, {Parameter8}, {Parameter9}, {Parameter10}, {Parameter11}, {Parameter12}, {Parameter13}, {Parameter14}, {Parameter15}, {Parameter16}, {Parameter17})"; + static string SubstringAfterLast(string name, char c) + { + int index = name.LastIndexOf(c); + return index >= 0 ? name.Substring(index + 1) : name; + } + } + } + } + + + /// + /// Sets up a method with 17 parameters , , , , , , , , , , , , , , , and returning . + /// + internal interface IVoidMethodSetup : IMethodSetup + { + /// + /// Overrides SkipBaseClass for this method only. + /// + /// + /// If not specified, use SkipBaseClass. + /// + global::Mockolate.Setup.IVoidMethodSetup SkippingBaseClass(bool skipBaseClass = true); + + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Transitions the scenario to the given when the method is called. + /// + global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder TransitionTo(string scenario); + + /// + /// Registers an iteration in the sequence of method invocations, that does not throw. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder DoesNotThrow(); + + /// + /// Registers an to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws() + where TException : global::System.Exception, new(); + + /// + /// Registers an to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(global::System.Exception exception); + + /// + /// Registers a that will calculate the exception to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(global::System.Func callback); +} + + /// + /// Sets up a method with 17 parameters , , , , , , , , , , , , , , , and returning with callback support for the parameters. + /// + internal interface IVoidMethodSetupWithCallback : global::Mockolate.Setup.IVoidMethodSetup + { + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Registers a that will calculate the exception to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(global::System.Func callback); +} + + /// + /// Sets up a callback for a method with 17 parameters , , , , , , , , , , , , , , , and returning . + /// + internal interface IVoidMethodSetupCallbackBuilder : global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder + { + /// + /// Runs the callback in parallel to the other callbacks. + /// + global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder InParallel(); + } + + /// + /// Sets up a callback for a method with 17 parameters , , , , , , , , , , , , , , , and returning . + /// + internal interface IVoidMethodSetupParallelCallbackBuilder : global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder + { + /// + /// Limits the callback to only execute for method invocations where the predicate returns true. + /// + /// + /// Provides a zero-based counter indicating how many times the method has been invoked so far. + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder When(global::System.Func predicate); + } + + /// + /// Sets up a when callback for a method with 17 parameters , , , , , , , , , , , , , , , and returning . + /// + internal interface IVoidMethodSetupCallbackWhenBuilder : global::Mockolate.Setup.IVoidMethodSetupWithCallback + { + /// + /// Repeats the callback for the given number of . + /// + /// + /// The number of times is only counted for actual executions (IVoidMethodSetupParallelCallbackBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder For(int times); + + /// + /// Deactivates the callback after the given number of . + /// + /// + /// The number of times is only counted for actual executions (IVoidMethodSetupParallelCallbackBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IVoidMethodSetup Only(int times); + } + + /// + /// Sets up a return callback for a method with 17 parameters , , , , , , , , , , , , , , , and returning . + /// + internal interface IVoidMethodSetupReturnBuilder : global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder + { + /// + /// Limits the throw to only execute for method invocations where the predicate returns true. + /// + /// + /// Provides a zero-based counter indicating how many times the method has been invoked so far. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder When(global::System.Func predicate); + } + + /// + /// Sets up a when return callback for a method with 17 parameters , , , , , , , , , , , , , , , and returning . + /// + internal interface IVoidMethodSetupReturnWhenBuilder : global::Mockolate.Setup.IVoidMethodSetupWithCallback + { + /// + /// Repeats the throw for the given number of . + /// + /// + /// The number of times is only counted for actual executions (IVoidMethodSetupReturnBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder For(int times); + + /// + /// Deactivates the throw after the given number of . + /// + /// + /// The number of times is only counted for actual executions (IVoidMethodSetupReturnBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IVoidMethodSetup Only(int times); + } + + /// + /// Allows ignoring the provided parameters. + /// + internal interface IVoidMethodSetupParameterIgnorer : global::Mockolate.Setup.IVoidMethodSetupWithCallback + { + /// + /// Replaces the explicit parameter matcher with AnyParameters(). + /// + global::Mockolate.Setup.IVoidMethodSetup AnyParameters(); + } + + /// + /// Sets up a method with 17 parameters , , , , , , , , , , , , , , , and returning . + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal abstract class VoidMethodSetup : global::Mockolate.Setup.MethodSetup, + global::Mockolate.Setup.IVoidMethodSetupWithCallback, + global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder, + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder +{ + private readonly global::Mockolate.MockRegistry _mockRegistry; + private global::Mockolate.Setup.Callbacks>? _callbacks = []; + private global::Mockolate.Setup.Callbacks>? _returnCallbacks = []; + private bool? _skipBaseClass; + + protected VoidMethodSetup(global::Mockolate.MockRegistry mockRegistry, string name) + : base(name) + { + _mockRegistry = mockRegistry; + } + + /// + /// Overrides SkipBaseClass for this method only. + /// + /// + /// If not specified, use SkipBaseClass. + /// + global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetup.SkippingBaseClass(bool skipBaseClass) + { + _skipBaseClass = skipBaseClass; + return this; + } + + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder global::Mockolate.Setup.IVoidMethodSetup.Do(global::System.Action callback) + { + global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => callback()); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder global::Mockolate.Setup.IVoidMethodSetupWithCallback.Do(global::System.Action callback) + { + global::Mockolate.Setup.Callback>? currentCallback = new((_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17) => callback(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17)); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + /// Registers a to execute when the method is called. + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder global::Mockolate.Setup.IVoidMethodSetupWithCallback.Do(global::System.Action callback) + { + global::Mockolate.Setup.Callback>? currentCallback = new(callback); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IVoidMethodSetup.TransitionTo(string scenario) + { + global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => _mockRegistry.TransitionTo(scenario)); + currentCallback.InParallel(); + _callbacks = _callbacks.Register(currentCallback); + return this; + } + + /// + /// Registers an iteration in the sequence of method invocations, that does not throw. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.DoesNotThrow() + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => { }); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + /// Registers an to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.Throws() + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => throw new TException()); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + /// Registers an to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.Throws(global::System.Exception exception) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => throw exception); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + /// Registers a that will calculate the exception to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetupWithCallback.Throws(global::System.Func callback) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17) => throw callback(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17)); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + /// Registers a that will calculate the exception to throw when the method is invoked. + /// + global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.Throws(global::System.Func callback) + { + var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => throw callback()); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder.InParallel() + { + _callbacks?.Active?.InParallel(); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder.When(global::System.Func predicate) + { + _callbacks?.Active?.When(predicate); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder.For(int times) + { + _callbacks?.Active?.For(times); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder.Only(int times) + { + _callbacks?.Active?.Only(times); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder global::Mockolate.Setup.IVoidMethodSetupReturnBuilder.When(global::System.Func predicate) + { + _returnCallbacks?.Active?.When(predicate); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder.For(int times) + { + _returnCallbacks?.Active?.For(times); + return this; + } + + /// + global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder.Only(int times) + { + _returnCallbacks?.Active?.Only(times); + return this; + } + + /// + protected override bool MatchesInteraction(global::Mockolate.Interactions.IMethodInteraction interaction) + { + if (interaction is global::Mockolate.Interactions.MethodInvocation invocation) + { + return Matches(invocation.Parameter1, invocation.Parameter2, invocation.Parameter3, invocation.Parameter4, invocation.Parameter5, invocation.Parameter6, invocation.Parameter7, invocation.Parameter8, invocation.Parameter9, invocation.Parameter10, invocation.Parameter11, invocation.Parameter12, invocation.Parameter13, invocation.Parameter14, invocation.Parameter15, invocation.Parameter16, invocation.Parameter17); + } + return false; + } + + /// + /// Gets the flag indicating if the base class implementation should be skipped. + /// + public bool SkipBaseClass(global::Mockolate.MockBehavior behavior) + => _skipBaseClass ?? behavior.SkipBaseClass; + + /// + /// Checks if the given parameters match the setup. + /// + public abstract bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value, T7 p7Value, T8 p8Value, T9 p9Value, T10 p10Value, T11 p11Value, T12 p12Value, T13 p13Value, T14 p14Value, T15 p15Value, T16 p16Value, T17 p17Value); + + /// + /// Triggers any configured parameter callbacks for the method setup with the specified parameters. + /// + public virtual void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7, T8 parameter8, T9 parameter9, T10 parameter10, T11 parameter11, T12 parameter12, T13 parameter13, T14 parameter14, T15 parameter15, T16 parameter16, T17 parameter17) + { + if (_callbacks is not null) + { + bool wasInvoked = false; + int currentCallbacksIndex = _callbacks.CurrentIndex; + for (int i = 0; i < _callbacks.Count; i++) + { + var callback = _callbacks[(currentCallbacksIndex + i) % _callbacks.Count]; + if (callback.Invoke(wasInvoked, ref _callbacks.CurrentIndex, (parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7, parameter8, parameter9, parameter10, parameter11, parameter12, parameter13, parameter14, parameter15, parameter16, parameter17), + static (invocationCount, @delegate, state) => @delegate(invocationCount, state.parameter1, state.parameter2, state.parameter3, state.parameter4, state.parameter5, state.parameter6, state.parameter7, state.parameter8, state.parameter9, state.parameter10, state.parameter11, state.parameter12, state.parameter13, state.parameter14, state.parameter15, state.parameter16, state.parameter17))) + { + wasInvoked = true; + } + } + } + if (_returnCallbacks is not null) + { + foreach (var _ in _returnCallbacks) + { + var returnCallback = _returnCallbacks[_returnCallbacks.CurrentIndex % _returnCallbacks.Count]; + if (returnCallback.Invoke(ref _returnCallbacks.CurrentIndex, (parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7, parameter8, parameter9, parameter10, parameter11, parameter12, parameter13, parameter14, parameter15, parameter16, parameter17), + static (invocationCount, @delegate, state) => @delegate(invocationCount, state.parameter1, state.parameter2, state.parameter3, state.parameter4, state.parameter5, state.parameter6, state.parameter7, state.parameter8, state.parameter9, state.parameter10, state.parameter11, state.parameter12, state.parameter13, state.parameter14, state.parameter15, state.parameter16, state.parameter17))) + { + return; + } + } + } + } + + /// Setup for a method with 17 parameters matching against IParameters. + internal class WithParameters : VoidMethodSetup + { + private readonly string _parameterName1; + private readonly string _parameterName2; + private readonly string _parameterName3; + private readonly string _parameterName4; + private readonly string _parameterName5; + private readonly string _parameterName6; + private readonly string _parameterName7; + private readonly string _parameterName8; + private readonly string _parameterName9; + private readonly string _parameterName10; + private readonly string _parameterName11; + private readonly string _parameterName12; + private readonly string _parameterName13; + private readonly string _parameterName14; + private readonly string _parameterName15; + private readonly string _parameterName16; + private readonly string _parameterName17; + + /// + public WithParameters(global::Mockolate.MockRegistry mockRegistry, string name, global::Mockolate.Parameters.IParameters parameters, string parameterName1, string parameterName2, string parameterName3, string parameterName4, string parameterName5, string parameterName6, string parameterName7, string parameterName8, string parameterName9, string parameterName10, string parameterName11, string parameterName12, string parameterName13, string parameterName14, string parameterName15, string parameterName16, string parameterName17) + : base(mockRegistry, name) + { + Parameters = parameters; + _parameterName1 = parameterName1; + _parameterName2 = parameterName2; + _parameterName3 = parameterName3; + _parameterName4 = parameterName4; + _parameterName5 = parameterName5; + _parameterName6 = parameterName6; + _parameterName7 = parameterName7; + _parameterName8 = parameterName8; + _parameterName9 = parameterName9; + _parameterName10 = parameterName10; + _parameterName11 = parameterName11; + _parameterName12 = parameterName12; + _parameterName13 = parameterName13; + _parameterName14 = parameterName14; + _parameterName15 = parameterName15; + _parameterName16 = parameterName16; + _parameterName17 = parameterName17; + } + + private global::Mockolate.Parameters.IParameters Parameters { get; } + + /// + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value, T7 p7Value, T8 p8Value, T9 p9Value, T10 p10Value, T11 p11Value, T12 p12Value, T13 p13Value, T14 p14Value, T15 p15Value, T16 p16Value, T17 p17Value) + => Parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([p1Value, p2Value, p3Value, p4Value, p5Value, p6Value, p7Value, p8Value, p9Value, p10Value, p11Value, p12Value, p13Value, p14Value, p15Value, p16Value, p17Value]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([(_parameterName1, p1Value), (_parameterName2, p2Value), (_parameterName3, p3Value), (_parameterName4, p4Value), (_parameterName5, p5Value), (_parameterName6, p6Value), (_parameterName7, p7Value), (_parameterName8, p8Value), (_parameterName9, p9Value), (_parameterName10, p10Value), (_parameterName11, p11Value), (_parameterName12, p12Value), (_parameterName13, p13Value), (_parameterName14, p14Value), (_parameterName15, p15Value), (_parameterName16, p16Value), (_parameterName17, p17Value)]), + _ => true, + }; + + /// + public override string ToString() + { + return $"void {SubstringAfterLast(Name, '.')}({Parameters})"; + static string SubstringAfterLast(string name, char c) + { + int index = name.LastIndexOf(c); + return index >= 0 ? name.Substring(index + 1) : name; + } + } + } + + /// Setup for a method with 17 parameters matching against individual IParameterMatch<T>. + internal class WithParameterCollection : VoidMethodSetup, + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer + { + private bool _matchAnyParameters; + + /// + public WithParameterCollection( + global::Mockolate.MockRegistry mockRegistry, + string name, + global::Mockolate.Parameters.IParameterMatch parameter1, + global::Mockolate.Parameters.IParameterMatch parameter2, + global::Mockolate.Parameters.IParameterMatch parameter3, + global::Mockolate.Parameters.IParameterMatch parameter4, + global::Mockolate.Parameters.IParameterMatch parameter5, + global::Mockolate.Parameters.IParameterMatch parameter6, + global::Mockolate.Parameters.IParameterMatch parameter7, + global::Mockolate.Parameters.IParameterMatch parameter8, + global::Mockolate.Parameters.IParameterMatch parameter9, + global::Mockolate.Parameters.IParameterMatch parameter10, + global::Mockolate.Parameters.IParameterMatch parameter11, + global::Mockolate.Parameters.IParameterMatch parameter12, + global::Mockolate.Parameters.IParameterMatch parameter13, + global::Mockolate.Parameters.IParameterMatch parameter14, + global::Mockolate.Parameters.IParameterMatch parameter15, + global::Mockolate.Parameters.IParameterMatch parameter16, + global::Mockolate.Parameters.IParameterMatch parameter17) + : base(mockRegistry, name) + { + Parameter1 = parameter1; + Parameter2 = parameter2; + Parameter3 = parameter3; + Parameter4 = parameter4; + Parameter5 = parameter5; + Parameter6 = parameter6; + Parameter7 = parameter7; + Parameter8 = parameter8; + Parameter9 = parameter9; + Parameter10 = parameter10; + Parameter11 = parameter11; + Parameter12 = parameter12; + Parameter13 = parameter13; + Parameter14 = parameter14; + Parameter15 = parameter15; + Parameter16 = parameter16; + Parameter17 = parameter17; + } + + /// The first parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter1 { get; } + + /// The second parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter2 { get; } + + /// The third parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter3 { get; } + + /// The 4th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter4 { get; } + + /// The 5th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter5 { get; } + + /// The 6th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter6 { get; } + + /// The 7th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter7 { get; } + + /// The 8th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter8 { get; } + + /// The 9th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter9 { get; } + + /// The 10th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter10 { get; } + + /// The 11th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter11 { get; } + + /// The 12th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter12 { get; } + + /// The 13th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter13 { get; } + + /// The 14th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter14 { get; } + + /// The 15th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter15 { get; } + + /// The 16th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter16 { get; } + + /// The 17th parameter of the method. + public global::Mockolate.Parameters.IParameterMatch Parameter17 { get; } + + /// + global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer.AnyParameters() + { + _matchAnyParameters = true; + return this; + } + + /// + public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value, T7 p7Value, T8 p8Value, T9 p9Value, T10 p10Value, T11 p11Value, T12 p12Value, T13 p13Value, T14 p14Value, T15 p15Value, T16 p16Value, T17 p17Value) + => _matchAnyParameters || (Parameter1.Matches(p1Value) && Parameter2.Matches(p2Value) && Parameter3.Matches(p3Value) && Parameter4.Matches(p4Value) && Parameter5.Matches(p5Value) && Parameter6.Matches(p6Value) && Parameter7.Matches(p7Value) && Parameter8.Matches(p8Value) && Parameter9.Matches(p9Value) && Parameter10.Matches(p10Value) && Parameter11.Matches(p11Value) && Parameter12.Matches(p12Value) && Parameter13.Matches(p13Value) && Parameter14.Matches(p14Value) && Parameter15.Matches(p15Value) && Parameter16.Matches(p16Value) && Parameter17.Matches(p17Value)); + + /// + public override void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7, T8 parameter8, T9 parameter9, T10 parameter10, T11 parameter11, T12 parameter12, T13 parameter13, T14 parameter14, T15 parameter15, T16 parameter16, T17 parameter17) + { + Parameter1?.InvokeCallbacks(parameter1); + Parameter2?.InvokeCallbacks(parameter2); + Parameter3?.InvokeCallbacks(parameter3); + Parameter4?.InvokeCallbacks(parameter4); + Parameter5?.InvokeCallbacks(parameter5); + Parameter6?.InvokeCallbacks(parameter6); + Parameter7?.InvokeCallbacks(parameter7); + Parameter8?.InvokeCallbacks(parameter8); + Parameter9?.InvokeCallbacks(parameter9); + Parameter10?.InvokeCallbacks(parameter10); + Parameter11?.InvokeCallbacks(parameter11); + Parameter12?.InvokeCallbacks(parameter12); + Parameter13?.InvokeCallbacks(parameter13); + Parameter14?.InvokeCallbacks(parameter14); + Parameter15?.InvokeCallbacks(parameter15); + Parameter16?.InvokeCallbacks(parameter16); + Parameter17?.InvokeCallbacks(parameter17); + base.TriggerCallbacks(parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7, parameter8, parameter9, parameter10, parameter11, parameter12, parameter13, parameter14, parameter15, parameter16, parameter17); + } + + /// + public override string ToString() + { + return $"void {SubstringAfterLast(Name, '.')}({Parameter1}, {Parameter2}, {Parameter3}, {Parameter4}, {Parameter5}, {Parameter6}, {Parameter7}, {Parameter8}, {Parameter9}, {Parameter10}, {Parameter11}, {Parameter12}, {Parameter13}, {Parameter14}, {Parameter15}, {Parameter16}, {Parameter17})"; + static string SubstringAfterLast(string name, char c) + { + int index = name.LastIndexOf(c); + return index >= 0 ? name.Substring(index + 1) : name; + } + } + } + } + +} + +namespace Mockolate +{ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal static class MethodSetupExtensions + { + + /// + /// Extensions for method callback setup returning with 5 parameters. + /// + extension(global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder setup) + { + /// + /// Executes the callback only once. + /// + public global::Mockolate.Setup.IReturnMethodSetup OnlyOnce() + => setup.Only(1); + } + + /// + /// Extensions for method setup returning with 5 parameters. + /// + extension(global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder setup) + { + /// + /// Returns/throws forever. + /// + public void Forever() + { + setup.For(int.MaxValue); + } + + /// + /// Uses the return value only once. + /// + public global::Mockolate.Setup.IReturnMethodSetup OnlyOnce() + => setup.Only(1); + } + /// + /// Extensions for method callback setup returning void with 5 parameters. + /// + extension(global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder setup) + { + /// + /// Executes the callback only once. + /// + public global::Mockolate.Setup.IVoidMethodSetup OnlyOnce() + => setup.Only(1); + } + + /// + /// Extensions for method setup returning void with 5 parameters. + /// + extension(global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder setup) + { + /// + /// Returns/throws forever. + /// + public void Forever() + { + setup.For(int.MaxValue); + } + + /// + /// Uses the return value only once. + /// + public global::Mockolate.Setup.IVoidMethodSetup OnlyOnce() + => setup.Only(1); + } + /// + /// Extensions for method callback setup returning void with 7 parameters. + /// + extension(global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder setup) + { + /// + /// Executes the callback only once. + /// + public global::Mockolate.Setup.IVoidMethodSetup OnlyOnce() + => setup.Only(1); + } + + /// + /// Extensions for method setup returning void with 7 parameters. + /// + extension(global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder setup) + { + /// + /// Returns/throws forever. + /// + public void Forever() + { + setup.For(int.MaxValue); + } + + /// + /// Uses the return value only once. + /// + public global::Mockolate.Setup.IVoidMethodSetup OnlyOnce() + => setup.Only(1); + } + /// + /// Extensions for method callback setup returning with 17 parameters. + /// + extension(global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder setup) + { + /// + /// Executes the callback only once. + /// + public global::Mockolate.Setup.IReturnMethodSetup OnlyOnce() + => setup.Only(1); + } + + /// + /// Extensions for method setup returning with 17 parameters. + /// + extension(global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder setup) + { + /// + /// Returns/throws forever. + /// + public void Forever() + { + setup.For(int.MaxValue); + } + + /// + /// Uses the return value only once. + /// + public global::Mockolate.Setup.IReturnMethodSetup OnlyOnce() + => setup.Only(1); + } + /// + /// Extensions for method callback setup returning void with 17 parameters. + /// + extension(global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder setup) + { + /// + /// Executes the callback only once. + /// + public global::Mockolate.Setup.IVoidMethodSetup OnlyOnce() + => setup.Only(1); + } + + /// + /// Extensions for method setup returning void with 17 parameters. + /// + extension(global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder setup) + { + /// + /// Returns/throws forever. + /// + public void Forever() + { + setup.For(int.MaxValue); + } + + /// + /// Uses the return value only once. + /// + public global::Mockolate.Setup.IVoidMethodSetup OnlyOnce() + => setup.Only(1); + } + } +} +namespace Mockolate.Interactions +{ + /// + /// An invocation of a method with 5 parameters , , , and . + /// + [global::System.Diagnostics.DebuggerDisplay("{ToString()}")] + internal class MethodInvocation(string name, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5) : IMethodInteraction + { + /// + /// The name of the method. + /// + public string Name { get; } = name; + /// + /// The first parameter value of the method. + /// + public T1 Parameter1 { get; } = parameter1; + /// + /// The second parameter value of the method. + /// + public T2 Parameter2 { get; } = parameter2; + /// + /// The third parameter value of the method. + /// + public T3 Parameter3 { get; } = parameter3; + /// + /// The 4th parameter value of the method. + /// + public T4 Parameter4 { get; } = parameter4; + /// + /// The 5th parameter value of the method. + /// + public T5 Parameter5 { get; } = parameter5; + /// + public override string ToString() + { + return $"invoke method {SubstringAfterLast(Name, '.')}({Parameter1?.ToString() ?? "null"}, {Parameter2?.ToString() ?? "null"}, {Parameter3?.ToString() ?? "null"}, {Parameter4?.ToString() ?? "null"}, {Parameter5?.ToString() ?? "null"})"; + static string SubstringAfterLast(string name, char c) + { + int index = name.LastIndexOf(c); + return index >= 0 ? name.Substring(index + 1) : name; + } + } + } + /// + /// Per-member buffer for 5-parameter methods, synthesized for arity 5 use sites. + /// + [global::System.Diagnostics.DebuggerDisplay("{Count} method calls")] + internal sealed class FastMethod5Buffer : IFastMemberBuffer + { + private readonly FastMockInteractions _owner; +#if NET10_0_OR_GREATER + private readonly global::System.Threading.Lock _growLock = new(); +#else + private readonly object _growLock = new(); +#endif + private Record[] _records = new Record[4]; + private bool[] _verifiedSlots = new bool[4]; + private int _reserved; + private int _published; + + internal FastMethod5Buffer(FastMockInteractions owner) => _owner = owner; + + public int Count => global::System.Threading.Volatile.Read(ref _published); + + public void Append(string name, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5) + { + long seq = _owner.NextSequence(); + int slot = global::System.Threading.Interlocked.Increment(ref _reserved) - 1; + Record[] records = global::System.Threading.Volatile.Read(ref _records); + if (slot >= records.Length) records = GrowToFit(slot); + + records[slot].Seq = seq; + records[slot].Name = name; + records[slot].P1 = parameter1; + records[slot].P2 = parameter2; + records[slot].P3 = parameter3; + records[slot].P4 = parameter4; + records[slot].P5 = parameter5; + records[slot].Boxed = null; + global::System.Threading.Interlocked.Increment(ref _published); + + if (_owner.HasInteractionAddedSubscribers) _owner.RaiseAdded(); + } + + private Record[] GrowToFit(int slot) + { + lock (_growLock) + { + Record[] records = _records; + while (slot >= records.Length) + { + Record[] bigger = new Record[records.Length * 2]; + global::System.Array.Copy(records, bigger, records.Length); + records = bigger; + } + global::System.Threading.Volatile.Write(ref _records, records); + if (_verifiedSlots.Length < records.Length) + { + bool[] biggerBits = new bool[records.Length]; + global::System.Array.Copy(_verifiedSlots, biggerBits, _verifiedSlots.Length); + _verifiedSlots = biggerBits; + } + return records; + } + } + + public void Clear() + { + lock (_growLock) { global::System.Array.Clear(_records, 0, _published); _reserved = 0; global::System.Threading.Volatile.Write(ref _published, 0); global::System.Array.Clear(_verifiedSlots, 0, _verifiedSlots.Length); } + } + + void IFastMemberBuffer.AppendBoxed(global::System.Collections.Generic.List> dest) + { + lock (_growLock) + { + int n = _published; + Record[] records = _records; + for (int i = 0; i < n; i++) + { + ref Record r = ref records[i]; + r.Boxed ??= new MethodInvocation(r.Name, r.P1, r.P2, r.P3, r.P4, r.P5); + dest.Add(new global::System.ValueTuple(r.Seq, r.Boxed)); + } + } + } + + void IFastMemberBuffer.AppendBoxedUnverified(global::System.Collections.Generic.List> dest) + { + lock (_growLock) + { + int n = _published; + Record[] records = _records; + bool[] verified = _verifiedSlots; + for (int i = 0; i < n; i++) + { + if (verified[i]) continue; + ref Record r = ref records[i]; + r.Boxed ??= new MethodInvocation(r.Name, r.P1, r.P2, r.P3, r.P4, r.P5); + dest.Add(new global::System.ValueTuple(r.Seq, r.Boxed)); + } + } + } + + public int ConsumeMatching(global::Mockolate.Parameters.IParameterMatch match1, global::Mockolate.Parameters.IParameterMatch match2, global::Mockolate.Parameters.IParameterMatch match3, global::Mockolate.Parameters.IParameterMatch match4, global::Mockolate.Parameters.IParameterMatch match5) + { + int matches = 0; + lock (_growLock) + { + int n = _published; + Record[] records = _records; + bool[] verified = _verifiedSlots; + for (int i = 0; i < n; i++) + { + ref Record r = ref records[i]; + if (match1.Matches(r.P1) && match2.Matches(r.P2) && match3.Matches(r.P3) && match4.Matches(r.P4) && match5.Matches(r.P5)) + { + matches++; + verified[i] = true; + } + } + } + + return matches; + } + + private struct Record + { + public long Seq; + public string Name; + public T1 P1; + public T2 P2; + public T3 P3; + public T4 P4; + public T5 P5; + public IInteraction? Boxed; + } + } + /// + /// An invocation of a method with 7 parameters , , , , , and . + /// + [global::System.Diagnostics.DebuggerDisplay("{ToString()}")] + internal class MethodInvocation(string name, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7) : IMethodInteraction + { + /// + /// The name of the method. + /// + public string Name { get; } = name; + /// + /// The first parameter value of the method. + /// + public T1 Parameter1 { get; } = parameter1; + /// + /// The second parameter value of the method. + /// + public T2 Parameter2 { get; } = parameter2; + /// + /// The third parameter value of the method. + /// + public T3 Parameter3 { get; } = parameter3; + /// + /// The 4th parameter value of the method. + /// + public T4 Parameter4 { get; } = parameter4; + /// + /// The 5th parameter value of the method. + /// + public T5 Parameter5 { get; } = parameter5; + /// + /// The 6th parameter value of the method. + /// + public T6 Parameter6 { get; } = parameter6; + /// + /// The 7th parameter value of the method. + /// + public T7 Parameter7 { get; } = parameter7; + /// + public override string ToString() + { + return $"invoke method {SubstringAfterLast(Name, '.')}({Parameter1?.ToString() ?? "null"}, {Parameter2?.ToString() ?? "null"}, {Parameter3?.ToString() ?? "null"}, {Parameter4?.ToString() ?? "null"}, {Parameter5?.ToString() ?? "null"}, {Parameter6?.ToString() ?? "null"}, {Parameter7?.ToString() ?? "null"})"; + static string SubstringAfterLast(string name, char c) + { + int index = name.LastIndexOf(c); + return index >= 0 ? name.Substring(index + 1) : name; + } + } + } + /// + /// Per-member buffer for 7-parameter methods, synthesized for arity 7 use sites. + /// + [global::System.Diagnostics.DebuggerDisplay("{Count} method calls")] + internal sealed class FastMethod7Buffer : IFastMemberBuffer + { + private readonly FastMockInteractions _owner; +#if NET10_0_OR_GREATER + private readonly global::System.Threading.Lock _growLock = new(); +#else + private readonly object _growLock = new(); +#endif + private Record[] _records = new Record[4]; + private bool[] _verifiedSlots = new bool[4]; + private int _reserved; + private int _published; + + internal FastMethod7Buffer(FastMockInteractions owner) => _owner = owner; + + public int Count => global::System.Threading.Volatile.Read(ref _published); + + public void Append(string name, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7) + { + long seq = _owner.NextSequence(); + int slot = global::System.Threading.Interlocked.Increment(ref _reserved) - 1; + Record[] records = global::System.Threading.Volatile.Read(ref _records); + if (slot >= records.Length) records = GrowToFit(slot); + + records[slot].Seq = seq; + records[slot].Name = name; + records[slot].P1 = parameter1; + records[slot].P2 = parameter2; + records[slot].P3 = parameter3; + records[slot].P4 = parameter4; + records[slot].P5 = parameter5; + records[slot].P6 = parameter6; + records[slot].P7 = parameter7; + records[slot].Boxed = null; + global::System.Threading.Interlocked.Increment(ref _published); + + if (_owner.HasInteractionAddedSubscribers) _owner.RaiseAdded(); + } + + private Record[] GrowToFit(int slot) + { + lock (_growLock) + { + Record[] records = _records; + while (slot >= records.Length) + { + Record[] bigger = new Record[records.Length * 2]; + global::System.Array.Copy(records, bigger, records.Length); + records = bigger; + } + global::System.Threading.Volatile.Write(ref _records, records); + if (_verifiedSlots.Length < records.Length) + { + bool[] biggerBits = new bool[records.Length]; + global::System.Array.Copy(_verifiedSlots, biggerBits, _verifiedSlots.Length); + _verifiedSlots = biggerBits; + } + return records; + } + } + + public void Clear() + { + lock (_growLock) { global::System.Array.Clear(_records, 0, _published); _reserved = 0; global::System.Threading.Volatile.Write(ref _published, 0); global::System.Array.Clear(_verifiedSlots, 0, _verifiedSlots.Length); } + } + + void IFastMemberBuffer.AppendBoxed(global::System.Collections.Generic.List> dest) + { + lock (_growLock) + { + int n = _published; + Record[] records = _records; + for (int i = 0; i < n; i++) + { + ref Record r = ref records[i]; + r.Boxed ??= new MethodInvocation(r.Name, r.P1, r.P2, r.P3, r.P4, r.P5, r.P6, r.P7); + dest.Add(new global::System.ValueTuple(r.Seq, r.Boxed)); + } + } + } + + void IFastMemberBuffer.AppendBoxedUnverified(global::System.Collections.Generic.List> dest) + { + lock (_growLock) + { + int n = _published; + Record[] records = _records; + bool[] verified = _verifiedSlots; + for (int i = 0; i < n; i++) + { + if (verified[i]) continue; + ref Record r = ref records[i]; + r.Boxed ??= new MethodInvocation(r.Name, r.P1, r.P2, r.P3, r.P4, r.P5, r.P6, r.P7); + dest.Add(new global::System.ValueTuple(r.Seq, r.Boxed)); + } + } + } + + public int ConsumeMatching(global::Mockolate.Parameters.IParameterMatch match1, global::Mockolate.Parameters.IParameterMatch match2, global::Mockolate.Parameters.IParameterMatch match3, global::Mockolate.Parameters.IParameterMatch match4, global::Mockolate.Parameters.IParameterMatch match5, global::Mockolate.Parameters.IParameterMatch match6, global::Mockolate.Parameters.IParameterMatch match7) + { + int matches = 0; + lock (_growLock) + { + int n = _published; + Record[] records = _records; + bool[] verified = _verifiedSlots; + for (int i = 0; i < n; i++) + { + ref Record r = ref records[i]; + if (match1.Matches(r.P1) && match2.Matches(r.P2) && match3.Matches(r.P3) && match4.Matches(r.P4) && match5.Matches(r.P5) && match6.Matches(r.P6) && match7.Matches(r.P7)) + { + matches++; + verified[i] = true; + } + } + } + + return matches; + } + + private struct Record + { + public long Seq; + public string Name; + public T1 P1; + public T2 P2; + public T3 P3; + public T4 P4; + public T5 P5; + public T6 P6; + public T7 P7; + public IInteraction? Boxed; + } + } + /// + /// An invocation of a method with 17 parameters , , , , , , , , , , , , , , , and . + /// + [global::System.Diagnostics.DebuggerDisplay("{ToString()}")] + internal class MethodInvocation(string name, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7, T8 parameter8, T9 parameter9, T10 parameter10, T11 parameter11, T12 parameter12, T13 parameter13, T14 parameter14, T15 parameter15, T16 parameter16, T17 parameter17) : IMethodInteraction + { + /// + /// The name of the method. + /// + public string Name { get; } = name; + /// + /// The first parameter value of the method. + /// + public T1 Parameter1 { get; } = parameter1; + /// + /// The second parameter value of the method. + /// + public T2 Parameter2 { get; } = parameter2; + /// + /// The third parameter value of the method. + /// + public T3 Parameter3 { get; } = parameter3; + /// + /// The 4th parameter value of the method. + /// + public T4 Parameter4 { get; } = parameter4; + /// + /// The 5th parameter value of the method. + /// + public T5 Parameter5 { get; } = parameter5; + /// + /// The 6th parameter value of the method. + /// + public T6 Parameter6 { get; } = parameter6; + /// + /// The 7th parameter value of the method. + /// + public T7 Parameter7 { get; } = parameter7; + /// + /// The 8th parameter value of the method. + /// + public T8 Parameter8 { get; } = parameter8; + /// + /// The 9th parameter value of the method. + /// + public T9 Parameter9 { get; } = parameter9; + /// + /// The 10th parameter value of the method. + /// + public T10 Parameter10 { get; } = parameter10; + /// + /// The 11th parameter value of the method. + /// + public T11 Parameter11 { get; } = parameter11; + /// + /// The 12th parameter value of the method. + /// + public T12 Parameter12 { get; } = parameter12; + /// + /// The 13th parameter value of the method. + /// + public T13 Parameter13 { get; } = parameter13; + /// + /// The 14th parameter value of the method. + /// + public T14 Parameter14 { get; } = parameter14; + /// + /// The 15th parameter value of the method. + /// + public T15 Parameter15 { get; } = parameter15; + /// + /// The 16th parameter value of the method. + /// + public T16 Parameter16 { get; } = parameter16; + /// + /// The 17th parameter value of the method. + /// + public T17 Parameter17 { get; } = parameter17; + /// + public override string ToString() + { + return $"invoke method {SubstringAfterLast(Name, '.')}({Parameter1?.ToString() ?? "null"}, {Parameter2?.ToString() ?? "null"}, {Parameter3?.ToString() ?? "null"}, {Parameter4?.ToString() ?? "null"}, {Parameter5?.ToString() ?? "null"}, {Parameter6?.ToString() ?? "null"}, {Parameter7?.ToString() ?? "null"}, {Parameter8?.ToString() ?? "null"}, {Parameter9?.ToString() ?? "null"}, {Parameter10?.ToString() ?? "null"}, {Parameter11?.ToString() ?? "null"}, {Parameter12?.ToString() ?? "null"}, {Parameter13?.ToString() ?? "null"}, {Parameter14?.ToString() ?? "null"}, {Parameter15?.ToString() ?? "null"}, {Parameter16?.ToString() ?? "null"}, {Parameter17?.ToString() ?? "null"})"; + static string SubstringAfterLast(string name, char c) + { + int index = name.LastIndexOf(c); + return index >= 0 ? name.Substring(index + 1) : name; + } + } + } + /// + /// Per-member buffer for 17-parameter methods, synthesized for arity 17 use sites. + /// + [global::System.Diagnostics.DebuggerDisplay("{Count} method calls")] + internal sealed class FastMethod17Buffer : IFastMemberBuffer + { + private readonly FastMockInteractions _owner; +#if NET10_0_OR_GREATER + private readonly global::System.Threading.Lock _growLock = new(); +#else + private readonly object _growLock = new(); +#endif + private Record[] _records = new Record[4]; + private bool[] _verifiedSlots = new bool[4]; + private int _reserved; + private int _published; + + internal FastMethod17Buffer(FastMockInteractions owner) => _owner = owner; + + public int Count => global::System.Threading.Volatile.Read(ref _published); + + public void Append(string name, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7, T8 parameter8, T9 parameter9, T10 parameter10, T11 parameter11, T12 parameter12, T13 parameter13, T14 parameter14, T15 parameter15, T16 parameter16, T17 parameter17) + { + long seq = _owner.NextSequence(); + int slot = global::System.Threading.Interlocked.Increment(ref _reserved) - 1; + Record[] records = global::System.Threading.Volatile.Read(ref _records); + if (slot >= records.Length) records = GrowToFit(slot); + + records[slot].Seq = seq; + records[slot].Name = name; + records[slot].P1 = parameter1; + records[slot].P2 = parameter2; + records[slot].P3 = parameter3; + records[slot].P4 = parameter4; + records[slot].P5 = parameter5; + records[slot].P6 = parameter6; + records[slot].P7 = parameter7; + records[slot].P8 = parameter8; + records[slot].P9 = parameter9; + records[slot].P10 = parameter10; + records[slot].P11 = parameter11; + records[slot].P12 = parameter12; + records[slot].P13 = parameter13; + records[slot].P14 = parameter14; + records[slot].P15 = parameter15; + records[slot].P16 = parameter16; + records[slot].P17 = parameter17; + records[slot].Boxed = null; + global::System.Threading.Interlocked.Increment(ref _published); + + if (_owner.HasInteractionAddedSubscribers) _owner.RaiseAdded(); + } + + private Record[] GrowToFit(int slot) + { + lock (_growLock) + { + Record[] records = _records; + while (slot >= records.Length) + { + Record[] bigger = new Record[records.Length * 2]; + global::System.Array.Copy(records, bigger, records.Length); + records = bigger; + } + global::System.Threading.Volatile.Write(ref _records, records); + if (_verifiedSlots.Length < records.Length) + { + bool[] biggerBits = new bool[records.Length]; + global::System.Array.Copy(_verifiedSlots, biggerBits, _verifiedSlots.Length); + _verifiedSlots = biggerBits; + } + return records; + } + } + + public void Clear() + { + lock (_growLock) { global::System.Array.Clear(_records, 0, _published); _reserved = 0; global::System.Threading.Volatile.Write(ref _published, 0); global::System.Array.Clear(_verifiedSlots, 0, _verifiedSlots.Length); } + } + + void IFastMemberBuffer.AppendBoxed(global::System.Collections.Generic.List> dest) + { + lock (_growLock) + { + int n = _published; + Record[] records = _records; + for (int i = 0; i < n; i++) + { + ref Record r = ref records[i]; + r.Boxed ??= new MethodInvocation(r.Name, r.P1, r.P2, r.P3, r.P4, r.P5, r.P6, r.P7, r.P8, r.P9, r.P10, r.P11, r.P12, r.P13, r.P14, r.P15, r.P16, r.P17); + dest.Add(new global::System.ValueTuple(r.Seq, r.Boxed)); + } + } + } + + void IFastMemberBuffer.AppendBoxedUnverified(global::System.Collections.Generic.List> dest) + { + lock (_growLock) + { + int n = _published; + Record[] records = _records; + bool[] verified = _verifiedSlots; + for (int i = 0; i < n; i++) + { + if (verified[i]) continue; + ref Record r = ref records[i]; + r.Boxed ??= new MethodInvocation(r.Name, r.P1, r.P2, r.P3, r.P4, r.P5, r.P6, r.P7, r.P8, r.P9, r.P10, r.P11, r.P12, r.P13, r.P14, r.P15, r.P16, r.P17); + dest.Add(new global::System.ValueTuple(r.Seq, r.Boxed)); + } + } + } + + public int ConsumeMatching(global::Mockolate.Parameters.IParameterMatch match1, global::Mockolate.Parameters.IParameterMatch match2, global::Mockolate.Parameters.IParameterMatch match3, global::Mockolate.Parameters.IParameterMatch match4, global::Mockolate.Parameters.IParameterMatch match5, global::Mockolate.Parameters.IParameterMatch match6, global::Mockolate.Parameters.IParameterMatch match7, global::Mockolate.Parameters.IParameterMatch match8, global::Mockolate.Parameters.IParameterMatch match9, global::Mockolate.Parameters.IParameterMatch match10, global::Mockolate.Parameters.IParameterMatch match11, global::Mockolate.Parameters.IParameterMatch match12, global::Mockolate.Parameters.IParameterMatch match13, global::Mockolate.Parameters.IParameterMatch match14, global::Mockolate.Parameters.IParameterMatch match15, global::Mockolate.Parameters.IParameterMatch match16, global::Mockolate.Parameters.IParameterMatch match17) + { + int matches = 0; + lock (_growLock) + { + int n = _published; + Record[] records = _records; + bool[] verified = _verifiedSlots; + for (int i = 0; i < n; i++) + { + ref Record r = ref records[i]; + if (match1.Matches(r.P1) && match2.Matches(r.P2) && match3.Matches(r.P3) && match4.Matches(r.P4) && match5.Matches(r.P5) && match6.Matches(r.P6) && match7.Matches(r.P7) && match8.Matches(r.P8) && match9.Matches(r.P9) && match10.Matches(r.P10) && match11.Matches(r.P11) && match12.Matches(r.P12) && match13.Matches(r.P13) && match14.Matches(r.P14) && match15.Matches(r.P15) && match16.Matches(r.P16) && match17.Matches(r.P17)) + { + matches++; + verified[i] = true; + } + } + } + + return matches; + } + + private struct Record + { + public long Seq; + public string Name; + public T1 P1; + public T2 P2; + public T3 P3; + public T4 P4; + public T5 P5; + public T6 P6; + public T7 P7; + public T8 P8; + public T9 P9; + public T10 P10; + public T11 P11; + public T12 P12; + public T13 P13; + public T14 P14; + public T15 P15; + public T16 P16; + public T17 P17; + public IInteraction? Boxed; + } + } +} + +#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/Mock.IComprehensiveInterface.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/Mock.IComprehensiveInterface.g.cs new file mode 100644 index 00000000..b0b8c9aa --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/Mock.IComprehensiveInterface.g.cs @@ -0,0 +1,7030 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +#nullable enable annotations +namespace Mockolate; + +internal static partial class Mock +{ + /// + /// A mock implementation for IComprehensiveInterface. + /// + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal class IComprehensiveInterface : + global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface, IMockForIComprehensiveInterface, IMockSetupForIComprehensiveInterface, IMockStaticSetupForIComprehensiveInterface, IMockRaiseOnIComprehensiveInterface, IMockVerifyForIComprehensiveInterface, IMockStaticVerifyForIComprehensiveInterface, + global::Mockolate.IMock + { + internal const int MemberId_GetSet_Get = 0; + internal const int MemberId_GetSet_Set = 1; + internal const int MemberId_GetOnly_Get = 2; + internal const int MemberId_GetOnly_Set = 3; + internal const int MemberId_SetOnly_Get = 4; + internal const int MemberId_SetOnly_Set = 5; + internal const int MemberId_NullableProp_Get = 6; + internal const int MemberId_NullableProp_Set = 7; + internal const int MemberId_InitOnly_Get = 8; + internal const int MemberId_InitOnly_Set = 9; + internal const int MemberId_StaticAbstractValue_Get = 10; + internal const int MemberId_StaticAbstractValue_Set = 11; + internal const int MemberId_PlainEvent_Subscribe = 12; + internal const int MemberId_PlainEvent_Unsubscribe = 13; + internal const int MemberId_TypedEvent_Subscribe = 14; + internal const int MemberId_TypedEvent_Unsubscribe = 15; + internal const int MemberId_CustomEvent_Subscribe = 16; + internal const int MemberId_CustomEvent_Unsubscribe = 17; + internal const int MemberId_Indexer_int_Get = 18; + internal const int MemberId_Indexer_int_Set = 19; + internal const int MemberId_Indexer_int_int_int_int_int_Get = 20; + internal const int MemberId_Indexer_int_int_int_int_int_Set = 21; + internal const int MemberId_Indexer_byte_byte_byte_byte_byte_Get = 22; + internal const int MemberId_Indexer_byte_byte_byte_byte_byte_Set = 23; + internal const int MemberId_Indexer_short_short_short_short_short_Get = 24; + internal const int MemberId_Indexer_short_short_short_short_short_Set = 25; + internal const int MemberId_Indexer_double_Get = 26; + internal const int MemberId_Indexer_double_Set = 27; + internal const int MemberId_Indexer_char_Get = 28; + internal const int MemberId_Indexer_char_Set = 29; + internal const int MemberId_StaticAbstractMethod = 30; + internal const int MemberId_WithModifiers = 31; + internal const int MemberId_WithDefaults = 32; + internal const int MemberId_WithCollidingNames = 33; + internal const int MemberId_GetMaybeNull = 34; + internal const int MemberId_TakeObject = 35; + internal const int MemberId_TakeTwoObjects = 36; + internal const int MemberId_TakeIntAndObject = 37; + internal const int MemberId_DoTask = 38; + internal const int MemberId_DoTaskOf = 39; + internal const int MemberId_DoVT = 40; + internal const int MemberId_DoVTOf = 41; + internal const int MemberId_GetTuple = 42; + internal const int MemberId_GetNullable = 43; + internal const int MemberId_GetSpan = 44; + internal const int MemberId_GetROSpan = 45; + internal const int MemberId_GetByRef = 46; + internal const int MemberId_GetByRefReadonly = 47; + internal const int MemberId_G1_T_ = 48; + internal const int MemberId_G2_T_ = 49; + internal const int MemberId_G3_T_ = 50; + internal const int MemberId_G4_T_ = 51; + internal const int MemberId_G5_T_ = 52; + internal const int MemberId_G6_T_ = 53; + internal const int MemberId_G7_T_ = 54; + internal const int MemberId_G8_T_ = 55; + internal const int MemberId_Five = 56; + internal const int MemberId_Seventeen = 57; + internal const int MemberId_SeventeenVoid = 58; + internal const int MemberCount = 59; + 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"); + internal static readonly global::Mockolate.Interactions.PropertyGetterAccess PropertyAccess_NullableProp_Get = new global::Mockolate.Interactions.PropertyGetterAccess("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.NullableProp"); + internal static readonly global::Mockolate.Interactions.PropertyGetterAccess PropertyAccess_InitOnly_Get = new global::Mockolate.Interactions.PropertyGetterAccess("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.InitOnly"); + internal static readonly global::Mockolate.Interactions.PropertyGetterAccess PropertyAccess_StaticAbstractValue_Get = new global::Mockolate.Interactions.PropertyGetterAccess("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.StaticAbstractValue"); + + /// + /// Creates a FastMockInteractions sized to MemberCount for use as the mock's interaction store. + /// Per-member buffers are not allocated up-front: the recording hot paths call GetOrCreateBuffer<TBuffer>(int, Func<FastMockInteractions, TBuffer>) so a slot is materialized only when its member is first invoked. + /// + internal static global::Mockolate.Interactions.FastMockInteractions CreateFastInteractions(global::Mockolate.MockBehavior behavior) + => new global::Mockolate.Interactions.FastMockInteractions(MemberCount, behavior.SkipInteractionRecording); + + /// + /// Builds a MockRegistry backed by a typed-buffer-sized FastMockInteractions from . + /// + private static global::Mockolate.MockRegistry MockolateCreateRegistryFromBehavior(global::Mockolate.MockBehavior behavior) + { + global::Mockolate.MockRegistry registry = new global::Mockolate.MockRegistry(behavior, MemberCount); + MockRegistryProvider.Value = registry; + return registry; + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.MockRegistry global::Mockolate.IMock.MockRegistry => this.MockRegistry; + private global::Mockolate.MockRegistry MockRegistry { get; } + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + internal static readonly global::System.Threading.AsyncLocal MockRegistryProvider = new global::System.Threading.AsyncLocal(); + + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastIndexerGetterBuffer MockolateBuffer_Indexer_int_Get + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_int_Get, static fast => new global::Mockolate.Interactions.FastIndexerGetterBuffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastIndexerSetterBuffer MockolateBuffer_Indexer_int_Set + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_int_Set, static fast => new global::Mockolate.Interactions.FastIndexerSetterBuffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastIndexerGetterBuffer MockolateBuffer_Indexer_double_Get + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_double_Get, static fast => new global::Mockolate.Interactions.FastIndexerGetterBuffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastIndexerSetterBuffer MockolateBuffer_Indexer_double_Set + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_double_Set, static fast => new global::Mockolate.Interactions.FastIndexerSetterBuffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastIndexerGetterBuffer MockolateBuffer_Indexer_char_Get + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_char_Get, static fast => new global::Mockolate.Interactions.FastIndexerGetterBuffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastIndexerSetterBuffer MockolateBuffer_Indexer_char_Set + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_char_Set, static fast => new global::Mockolate.Interactions.FastIndexerSetterBuffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod4Buffer MockolateBuffer_WithModifiers + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, static fast => new global::Mockolate.Interactions.FastMethod4Buffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod7Buffer MockolateBuffer_WithDefaults + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithDefaults, static fast => new global::Mockolate.Interactions.FastMethod7Buffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod5Buffer MockolateBuffer_WithCollidingNames + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithCollidingNames, static fast => new global::Mockolate.Interactions.FastMethod5Buffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + 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)] + private global::Mockolate.Interactions.FastMethod0Buffer MockolateBuffer_DoTaskOf + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_DoTaskOf, static fast => new global::Mockolate.Interactions.FastMethod0Buffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod0Buffer MockolateBuffer_DoVT + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_DoVT, static fast => new global::Mockolate.Interactions.FastMethod0Buffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod0Buffer MockolateBuffer_DoVTOf + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_DoVTOf, static fast => new global::Mockolate.Interactions.FastMethod0Buffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod0Buffer MockolateBuffer_GetTuple + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetTuple, static fast => new global::Mockolate.Interactions.FastMethod0Buffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod0Buffer MockolateBuffer_GetNullable + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetNullable, static fast => new global::Mockolate.Interactions.FastMethod0Buffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod1Buffer MockolateBuffer_GetSpan + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSpan, static fast => new global::Mockolate.Interactions.FastMethod1Buffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod1Buffer MockolateBuffer_GetROSpan + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetROSpan, static fast => new global::Mockolate.Interactions.FastMethod1Buffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod0Buffer MockolateBuffer_GetByRef + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetByRef, static fast => new global::Mockolate.Interactions.FastMethod0Buffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod0Buffer MockolateBuffer_GetByRefReadonly + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetByRefReadonly, static fast => new global::Mockolate.Interactions.FastMethod0Buffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod5Buffer MockolateBuffer_Five + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Five, static fast => new global::Mockolate.Interactions.FastMethod5Buffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod17Buffer MockolateBuffer_Seventeen + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Seventeen, static fast => new global::Mockolate.Interactions.FastMethod17Buffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod17Buffer MockolateBuffer_SeventeenVoid + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IComprehensiveInterface.MemberId_SeventeenVoid, static fast => new global::Mockolate.Interactions.FastMethod17Buffer(fast))); + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + IMockSetupForIComprehensiveInterface IMockForIComprehensiveInterface.Setup + => this; + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + IMockStaticSetupForIComprehensiveInterface IMockForIComprehensiveInterface.SetupStatic + => this; + /// + IMockInScenarioForIComprehensiveInterface IMockForIComprehensiveInterface.InScenario(string scenario) + => new MockInScenarioForIComprehensiveInterface(this.MockRegistry, scenario); + + /// + IMockForIComprehensiveInterface IMockForIComprehensiveInterface.InScenario(string scenario, global::System.Action setup) + { + setup.Invoke(new MockInScenarioForIComprehensiveInterface(this.MockRegistry, scenario)); + return this; + } + + /// + IMockForIComprehensiveInterface IMockForIComprehensiveInterface.TransitionTo(string scenario) + { + this.MockRegistry.TransitionTo(scenario); + return this; + } + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + IMockRaiseOnIComprehensiveInterface IMockForIComprehensiveInterface.Raise + => this; + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + IMockVerifyForIComprehensiveInterface IMockForIComprehensiveInterface.Verify + => this; + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + IMockStaticVerifyForIComprehensiveInterface IMockForIComprehensiveInterface.VerifyStatic + => this; + /// + global::Mockolate.Verify.VerificationResult IMockForIComprehensiveInterface.VerifySetup(global::Mockolate.Setup.IMethodSetup setup) + => this.MockRegistry.Method(this, setup); + /// + bool IMockForIComprehensiveInterface.VerifyThatAllInteractionsAreVerified() + => this.MockRegistry.Interactions.GetUnverifiedInteractions().Count == 0; + /// + bool IMockForIComprehensiveInterface.VerifyThatAllSetupsAreUsed() + => this.MockRegistry.GetUnusedSetups(this.MockRegistry.Interactions).Count == 0; + /// + void IMockForIComprehensiveInterface.ClearAllInteractions() + => this.MockRegistry.ClearAllInteractions(); + /// + global::Mockolate.Monitor.MockMonitor IMockForIComprehensiveInterface.Monitor() + => new global::Mockolate.Monitor.MockMonitor(this.MockRegistry.Interactions, interactions => new VerifyMonitorIComprehensiveInterface(new global::Mockolate.MockRegistry(this.MockRegistry, interactions))); + + /// + string global::Mockolate.IMock.ToString() + => "Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface mock"; + + /// + public IComprehensiveInterface(global::Mockolate.MockRegistry mockRegistry) + { + this.MockRegistry = mockRegistry; + MockRegistryProvider.Value = mockRegistry; + } + + /// + public IComprehensiveInterface(global::Mockolate.MockBehavior behavior) + : this(MockolateCreateRegistryFromBehavior(behavior)) + { + } + + #region Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface + + private global::System.EventHandler? _mockolateEvent_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_PlainEvent; + /// + public event global::System.EventHandler PlainEvent + { + add + { + if (value is not null) + { + this.MockRegistry.AddEvent(global::Mockolate.Mock.IComprehensiveInterface.MemberId_PlainEvent_Subscribe, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.PlainEvent", value.Target, value.Method); + } + this._mockolateEvent_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_PlainEvent += value; + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wraps.PlainEvent += value; + } + } + remove + { + if (value is not null) + { + this.MockRegistry.RemoveEvent(global::Mockolate.Mock.IComprehensiveInterface.MemberId_PlainEvent_Unsubscribe, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.PlainEvent", value.Target, value.Method); + } + this._mockolateEvent_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_PlainEvent -= value; + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wraps.PlainEvent -= value; + } + } + } + + private global::System.EventHandler? _mockolateEvent_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_TypedEvent; + /// + public event global::System.EventHandler TypedEvent + { + add + { + if (value is not null) + { + this.MockRegistry.AddEvent(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TypedEvent_Subscribe, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TypedEvent", value.Target, value.Method); + } + this._mockolateEvent_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_TypedEvent += value; + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wraps.TypedEvent += value; + } + } + remove + { + if (value is not null) + { + this.MockRegistry.RemoveEvent(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TypedEvent_Unsubscribe, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TypedEvent", value.Target, value.Method); + } + this._mockolateEvent_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_TypedEvent -= value; + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wraps.TypedEvent -= value; + } + } + } + + private global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate? _mockolateEvent_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_CustomEvent; + /// + public event global::Mockolate.Tests.GeneratorCoverage.ComprehensiveDelegate CustomEvent + { + add + { + if (value is not null) + { + this.MockRegistry.AddEvent(global::Mockolate.Mock.IComprehensiveInterface.MemberId_CustomEvent_Subscribe, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.CustomEvent", value.Target, value.Method); + } + this._mockolateEvent_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_CustomEvent += value; + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wraps.CustomEvent += value; + } + } + remove + { + if (value is not null) + { + this.MockRegistry.RemoveEvent(global::Mockolate.Mock.IComprehensiveInterface.MemberId_CustomEvent_Unsubscribe, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.CustomEvent", value.Target, value.Method); + } + this._mockolateEvent_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_CustomEvent -= value; + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wraps.CustomEvent -= value; + } + } + } + + /// + public int GetSet + { + get + { + return this.MockRegistry.GetPropertyFast(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSet_Get, global::Mockolate.Mock.IComprehensiveInterface.PropertyAccess_GetSet_Get, static b => b.DefaultValue.Generate(default(int)!), this.MockRegistry.Wraps is not global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps ? null : () => wraps.GetSet); + } + set + { + this.MockRegistry.SetPropertyFast(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSet_Get, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSet_Set, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSet", value); + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wraps.GetSet = value; + } + } + } + + /// + public int GetOnly + { + get + { + return this.MockRegistry.GetPropertyFast(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetOnly_Get, global::Mockolate.Mock.IComprehensiveInterface.PropertyAccess_GetOnly_Get, static b => b.DefaultValue.Generate(default(int)!), this.MockRegistry.Wraps is not global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps ? null : () => wraps.GetOnly); + } + } + + /// + public int SetOnly + { + set + { + this.MockRegistry.SetPropertyFast(global::Mockolate.Mock.IComprehensiveInterface.MemberId_SetOnly_Get, global::Mockolate.Mock.IComprehensiveInterface.MemberId_SetOnly_Set, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.SetOnly", value); + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wraps.SetOnly = value; + } + } + } + + /// + public string? NullableProp + { + get + { + return this.MockRegistry.GetPropertyFast(global::Mockolate.Mock.IComprehensiveInterface.MemberId_NullableProp_Get, global::Mockolate.Mock.IComprehensiveInterface.PropertyAccess_NullableProp_Get, static b => b.DefaultValue.Generate(default(string?)!), this.MockRegistry.Wraps is not global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps ? null : () => wraps.NullableProp); + } + set + { + this.MockRegistry.SetPropertyFast(global::Mockolate.Mock.IComprehensiveInterface.MemberId_NullableProp_Get, global::Mockolate.Mock.IComprehensiveInterface.MemberId_NullableProp_Set, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.NullableProp", value); + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wraps.NullableProp = value; + } + } + } + + /// + public string InitOnly + { + get + { + return this.MockRegistry.GetPropertyFast(global::Mockolate.Mock.IComprehensiveInterface.MemberId_InitOnly_Get, global::Mockolate.Mock.IComprehensiveInterface.PropertyAccess_InitOnly_Get, static b => b.DefaultValue.Generate(default(string)!), this.MockRegistry.Wraps is not global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps ? null : () => wraps.InitOnly); + } + init + { + this.MockRegistry.SetPropertyFast(global::Mockolate.Mock.IComprehensiveInterface.MemberId_InitOnly_Get, global::Mockolate.Mock.IComprehensiveInterface.MemberId_InitOnly_Set, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.InitOnly", value); + } + } + + /// + public string this[int i] + { + get + { + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_Indexer_int_Get.Append(i); + } + global::Mockolate.Setup.IndexerSetup? setup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.IndexerSetup[]? snapshot_setup = this.MockRegistry.GetIndexerSetupSnapshot(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_int_Get); + if (snapshot_setup is not null) + { + for (int i_setup = snapshot_setup.Length - 1; i_setup >= 0; i_setup--) + { + if (snapshot_setup[i_setup] is global::Mockolate.Setup.IndexerSetup s_setup && s_setup.Matches(i)) + { + setup = s_setup; + break; + } + } + } + } + global::Mockolate.Interactions.IndexerGetterAccess access = new(i); + setup ??= this.MockRegistry.GetIndexerSetup>(access); + if (this.MockRegistry.Wraps is not global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + return setup is null + ? this.MockRegistry.GetIndexerFallback(access, 0) + : this.MockRegistry.ApplyIndexerSetup(access, setup, 0); + } + string baseResult = wraps[i]; + return this.MockRegistry.ApplyIndexerGetter(access, setup, baseResult, 0); + } + set + { + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_Indexer_int_Set.Append(i, value); + } + global::Mockolate.Setup.IndexerSetup? setup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.IndexerSetup[]? snapshot_setup = this.MockRegistry.GetIndexerSetupSnapshot(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_int_Get); + if (snapshot_setup is not null) + { + for (int i_setup = snapshot_setup.Length - 1; i_setup >= 0; i_setup--) + { + if (snapshot_setup[i_setup] is global::Mockolate.Setup.IndexerSetup s_setup && s_setup.Matches(i, value)) + { + setup = s_setup; + break; + } + } + } + } + global::Mockolate.Interactions.IndexerSetterAccess access = new(i, value); + setup ??= this.MockRegistry.GetIndexerSetup>(access); + this.MockRegistry.ApplyIndexerSetter(access, setup, value, 0); + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wraps[i] = value; + } + } + } + + /// + public string this[int a, int b, int c, int d, int e] + { + get + { + global::Mockolate.Interactions.IndexerGetterAccess access = new(a, b, c, d, e); + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockRegistry.RegisterInteraction(access); + } + global::Mockolate.Setup.IndexerSetup? setup = this.MockRegistry.GetIndexerSetup>(access); + if (this.MockRegistry.Wraps is not global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + return setup is null + ? this.MockRegistry.GetIndexerFallback(access, 1) + : this.MockRegistry.ApplyIndexerSetup(access, setup, 1); + } + string baseResult = wraps[a, b, c, d, e]; + return this.MockRegistry.ApplyIndexerGetter(access, setup, baseResult, 1); + } + set + { + global::Mockolate.Interactions.IndexerSetterAccess access = new(a, b, c, d, e, value); + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockRegistry.RegisterInteraction(access); + } + global::Mockolate.Setup.IndexerSetup? setup = this.MockRegistry.GetIndexerSetup>(access); + this.MockRegistry.ApplyIndexerSetter(access, setup, value, 1); + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wraps[a, b, c, d, e] = value; + } + } + } + + /// + public long this[byte a, byte b, byte c, byte d, byte e] + { + get + { + global::Mockolate.Interactions.IndexerGetterAccess access = new(a, b, c, d, e); + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockRegistry.RegisterInteraction(access); + } + global::Mockolate.Setup.IndexerSetup? setup = this.MockRegistry.GetIndexerSetup>(access); + if (this.MockRegistry.Wraps is not global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + return setup is null + ? this.MockRegistry.GetIndexerFallback(access, 2) + : this.MockRegistry.ApplyIndexerSetup(access, setup, 2); + } + long baseResult = wraps[a, b, c, d, e]; + return this.MockRegistry.ApplyIndexerGetter(access, setup, baseResult, 2); + } + } + + /// + public long this[short a, short b, short c, short d, short e] + { + set + { + global::Mockolate.Interactions.IndexerSetterAccess access = new(a, b, c, d, e, value); + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockRegistry.RegisterInteraction(access); + } + global::Mockolate.Setup.IndexerSetup? setup = this.MockRegistry.GetIndexerSetup>(access); + this.MockRegistry.ApplyIndexerSetter(access, setup, value, 3); + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wraps[a, b, c, d, e] = value; + } + } + } + + /// + public string this[double key] + { + get + { + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_Indexer_double_Get.Append(key); + } + global::Mockolate.Setup.IndexerSetup? setup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.IndexerSetup[]? snapshot_setup = this.MockRegistry.GetIndexerSetupSnapshot(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_double_Get); + if (snapshot_setup is not null) + { + for (int i_setup = snapshot_setup.Length - 1; i_setup >= 0; i_setup--) + { + if (snapshot_setup[i_setup] is global::Mockolate.Setup.IndexerSetup s_setup && s_setup.Matches(key)) + { + setup = s_setup; + break; + } + } + } + } + global::Mockolate.Interactions.IndexerGetterAccess access = new(key); + setup ??= this.MockRegistry.GetIndexerSetup>(access); + if (this.MockRegistry.Wraps is not global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + return setup is null + ? this.MockRegistry.GetIndexerFallback(access, 4) + : this.MockRegistry.ApplyIndexerSetup(access, setup, 4); + } + string baseResult = wraps[key]; + return this.MockRegistry.ApplyIndexerGetter(access, setup, baseResult, 4); + } + } + + /// + public string this[char key] + { + set + { + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_Indexer_char_Set.Append(key, value); + } + global::Mockolate.Setup.IndexerSetup? setup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.IndexerSetup[]? snapshot_setup = this.MockRegistry.GetIndexerSetupSnapshot(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_char_Get); + if (snapshot_setup is not null) + { + for (int i_setup = snapshot_setup.Length - 1; i_setup >= 0; i_setup--) + { + if (snapshot_setup[i_setup] is global::Mockolate.Setup.IndexerSetup s_setup && s_setup.Matches(key, value)) + { + setup = s_setup; + break; + } + } + } + } + global::Mockolate.Interactions.IndexerSetterAccess access = new(key, value); + setup ??= this.MockRegistry.GetIndexerSetup>(access); + this.MockRegistry.ApplyIndexerSetter(access, setup, value, 5); + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wraps[key] = value; + } + } + } + + /// + public static int StaticAbstractValue + { + get + { + return MockRegistryProvider.Value.GetProperty(global::Mockolate.Mock.IComprehensiveInterface.PropertyAccess_StaticAbstractValue_Get, () => MockRegistryProvider.Value.Behavior.DefaultValue.Generate(default(int)!), null); + } + } + + /// + public static int StaticAbstractMethod() + { + global::Mockolate.Setup.ReturnMethodSetup? methodSetup = null; + if (string.IsNullOrEmpty(MockRegistryProvider.Value.Scenario)) + { + global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = MockRegistryProvider.Value.GetMethodSetupSnapshot(global::Mockolate.Mock.IComprehensiveInterface.MemberId_StaticAbstractMethod); + 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()) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in MockRegistryProvider.Value.GetMethodSetups>("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.StaticAbstractMethod")) + { + if (s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + int wrappedResult = default!; + if (MockRegistryProvider.Value.Behavior.SkipInteractionRecording == false) + { + ((global::Mockolate.Interactions.FastMockInteractions)MockRegistryProvider.Value.Interactions).GetOrCreateBuffer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_StaticAbstractMethod, static fast => new global::Mockolate.Interactions.FastMethod0Buffer(fast)).Append("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.StaticAbstractMethod"); + } + try + { + } + finally + { + methodSetup?.TriggerCallbacks(); + } + if (methodSetup is null && !hasWrappedResult && MockRegistryProvider.Value.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.StaticAbstractMethod()' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(out var returnValue) == true ? returnValue : MockRegistryProvider.Value.Behavior.DefaultValue.Generate(default(int)!); + } + + /// + public void WithModifiers(ref int a, out string b, in long c, params int[] tail) + { + var ref_a = a; + var ref_c = c; + global::Mockolate.Setup.VoidMethodSetup? methodSetup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers); + 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.VoidMethodSetup s_methodSetup && s_methodSetup.Matches(ref_a, default, ref_c, tail)) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.VoidMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers")) + { + if (s_methodSetup.Matches(ref_a, default, ref_c, tail)) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + b = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_WithModifiers.Append("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", a, b, c, tail); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wraps.WithModifiers(ref a, out b, in c, tail); + hasWrappedResult = true; + } + if (!hasWrappedResult || methodSetup is global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection) + { + if (methodSetup is global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection wpc) + { + if (wpc.Parameter1 is global::Mockolate.Parameters.IRefParameter refParam1) + { + a = refParam1.GetValue(a); + } + if (wpc.Parameter2 is not global::Mockolate.Parameters.IOutParameter outParam2 || !outParam2.TryGetValue(out b)) + { + b = this.MockRegistry.Behavior.DefaultValue.Generate(default(string)!); + } + } + else + { + b = this.MockRegistry.Behavior.DefaultValue.Generate(default(string)!); + } + } + } + finally + { + methodSetup?.TriggerCallbacks(a, b, c, tail); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers(int, string, long, int[])' was invoked without prior setup."); + } + } + + /// + public void WithDefaults(int i = 5, global::Mockolate.Tests.GeneratorCoverage.MyEnum e = (global::Mockolate.Tests.GeneratorCoverage.MyEnum)1, decimal d = 1.5m, float f = 0.25f, char c = 'x', string? s = null, global::Mockolate.Tests.GeneratorCoverage.MyStruct st = default) + { + global::Mockolate.Setup.VoidMethodSetup? methodSetup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithDefaults); + 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.VoidMethodSetup s_methodSetup && s_methodSetup.Matches(i, e, d, f, c, s, st)) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.VoidMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithDefaults")) + { + if (s_methodSetup.Matches(i, e, d, f, c, s, st)) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_WithDefaults.Append("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithDefaults", i, e, d, f, c, s, st); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wraps.WithDefaults(i, e, d, f, c, s, st); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(i, e, d, f, c, s, st); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithDefaults(int, MyEnum, decimal, float, char, string?, MyStruct)' was invoked without prior setup."); + } + } + + /// + public void WithCollidingNames(int wraps, int result, int outParam1, int methodExecution, int returnValue) + { + global::Mockolate.Setup.VoidMethodSetup? methodSetup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithCollidingNames); + 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.VoidMethodSetup s_methodSetup && s_methodSetup.Matches(wraps, result, outParam1, methodExecution, returnValue)) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.VoidMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithCollidingNames")) + { + if (s_methodSetup.Matches(wraps, result, outParam1, methodExecution, returnValue)) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_WithCollidingNames.Append("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithCollidingNames", wraps, result, outParam1, methodExecution, returnValue); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps1) + { + wraps1.WithCollidingNames(wraps, result, outParam1, methodExecution, returnValue); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(wraps, result, outParam1, methodExecution, returnValue); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithCollidingNames(int, int, int, int, int)' was invoked without prior setup."); + } + } + + /// + public string? GetMaybeNull(string? s) + { + 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_GetMaybeNull); + 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(s)) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetMaybeNull")) + { + if (s_methodSetup.Matches(s)) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + string? wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_GetMaybeNull.Append("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetMaybeNull", s); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.GetMaybeNull(s); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(s); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetMaybeNull(string?)' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + 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() + { + 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_DoTask); + 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()) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoTask")) + { + if (s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + global::System.Threading.Tasks.Task wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_DoTask.Append("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoTask"); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.DoTask(); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoTask()' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(global::System.Threading.Tasks.Task)!); + } + + /// + public global::System.Threading.Tasks.Task DoTaskOf() + { + 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_DoTaskOf); + 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()) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup> s_methodSetup in this.MockRegistry.GetMethodSetups>>("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoTaskOf")) + { + if (s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + global::System.Threading.Tasks.Task wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_DoTaskOf.Append("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoTaskOf"); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.DoTaskOf(); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoTaskOf()' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(global::System.Threading.Tasks.Task)!, this.MockRegistry.Behavior.DefaultValue.Generate(default(int)!)); + } + + /// + public global::System.Threading.Tasks.ValueTask DoVT() + { + 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_DoVT); + 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()) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoVT")) + { + if (s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + global::System.Threading.Tasks.ValueTask wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_DoVT.Append("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoVT"); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.DoVT(); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoVT()' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(global::System.Threading.Tasks.ValueTask)!); + } + + /// + public global::System.Threading.Tasks.ValueTask DoVTOf() + { + 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_DoVTOf); + 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()) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup> s_methodSetup in this.MockRegistry.GetMethodSetups>>("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoVTOf")) + { + if (s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + global::System.Threading.Tasks.ValueTask wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_DoVTOf.Append("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoVTOf"); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.DoVTOf(); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoVTOf()' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(global::System.Threading.Tasks.ValueTask)!, this.MockRegistry.Behavior.DefaultValue.Generate(default(int)!)); + } + + /// + public (int Code, string Msg) GetTuple() + { + global::Mockolate.Setup.ReturnMethodSetup<(int Code, string Msg)>? methodSetup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetTuple); + 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<(int Code, string Msg)> s_methodSetup && s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup<(int Code, string Msg)> s_methodSetup in this.MockRegistry.GetMethodSetups>("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetTuple")) + { + if (s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + (int Code, string Msg) wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_GetTuple.Append("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetTuple"); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.GetTuple(); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetTuple()' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(out var returnValue) == true ? returnValue : (this.MockRegistry.Behavior.DefaultValue.Generate(default(int)!), this.MockRegistry.Behavior.DefaultValue.Generate(default(string)!)); + } + + /// + public int? GetNullable() + { + 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_GetNullable); + 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()) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetNullable")) + { + if (s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + int? wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_GetNullable.Append("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetNullable"); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.GetNullable(); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetNullable()' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(int?)!); + } + + /// + public global::System.Span GetSpan(int n) + { + global::Mockolate.Setup.ReturnMethodSetup, int>? methodSetup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSpan); + 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, int> s_methodSetup && s_methodSetup.Matches(n)) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup, int> s_methodSetup in this.MockRegistry.GetMethodSetups, int>>("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSpan")) + { + if (s_methodSetup.Matches(n)) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + global::System.Span wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_GetSpan.Append("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSpan", n); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.GetSpan(n); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(n); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSpan(int)' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(n, out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(global::Mockolate.Setup.SpanWrapper)!, n); + } + + /// + public global::System.ReadOnlySpan GetROSpan(int n) + { + global::Mockolate.Setup.ReturnMethodSetup, int>? methodSetup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetROSpan); + 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, int> s_methodSetup && s_methodSetup.Matches(n)) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup, int> s_methodSetup in this.MockRegistry.GetMethodSetups, int>>("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetROSpan")) + { + if (s_methodSetup.Matches(n)) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + global::System.ReadOnlySpan wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_GetROSpan.Append("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetROSpan", n); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.GetROSpan(n); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(n); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetROSpan(int)' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(n, out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(global::Mockolate.Setup.ReadOnlySpanWrapper)!, n); + } + + private int _refReturnStorage_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_GetByRef; + /// + public ref int GetByRef() + { + 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_GetByRef); + 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()) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetByRef")) + { + if (s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + int wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_GetByRef.Append("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetByRef"); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.GetByRef(); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetByRef()' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + this._refReturnStorage_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_GetByRef = wrappedResult; + return ref this._refReturnStorage_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_GetByRef; + } + this._refReturnStorage_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_GetByRef = methodSetup?.TryGetReturnValue(out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(int)!); + return ref this._refReturnStorage_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_GetByRef; + } + + private int _refReturnStorage_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_GetByRefReadonly; + /// + public ref readonly int GetByRefReadonly() + { + 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_GetByRefReadonly); + 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()) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetByRefReadonly")) + { + if (s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + int wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_GetByRefReadonly.Append("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetByRefReadonly"); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.GetByRefReadonly(); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetByRefReadonly()' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + this._refReturnStorage_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_GetByRefReadonly = wrappedResult; + return ref this._refReturnStorage_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_GetByRefReadonly; + } + this._refReturnStorage_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_GetByRefReadonly = methodSetup?.TryGetReturnValue(out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(int)!); + return ref this._refReturnStorage_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_GetByRefReadonly; + } + + /// + public T G1() + where T : class + { + 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_G1_T_); + string name_methodSetup = $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G1<{typeof(T)}>"; + 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.Name == name_methodSetup && s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>($"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G1<{typeof(T)}>")) + { + if (s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + T wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockRegistry.RegisterInteraction(new global::Mockolate.Interactions.MethodInvocation($"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G1<{typeof(T)}>")); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.G1(); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G1()' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(T)!); + } + + /// + public T G2() + where T : struct + { + 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_G2_T_); + string name_methodSetup = $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G2<{typeof(T)}>"; + 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.Name == name_methodSetup && s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>($"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G2<{typeof(T)}>")) + { + if (s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + T wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockRegistry.RegisterInteraction(new global::Mockolate.Interactions.MethodInvocation($"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G2<{typeof(T)}>")); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.G2(); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G2()' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(T)!); + } + + /// + public T G3() + where T : new() + { + 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_G3_T_); + string name_methodSetup = $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G3<{typeof(T)}>"; + 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.Name == name_methodSetup && s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>($"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G3<{typeof(T)}>")) + { + if (s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + T wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockRegistry.RegisterInteraction(new global::Mockolate.Interactions.MethodInvocation($"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G3<{typeof(T)}>")); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.G3(); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G3()' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(T)!); + } + + /// + public T G4() + where T : unmanaged + { + 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_G4_T_); + string name_methodSetup = $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G4<{typeof(T)}>"; + 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.Name == name_methodSetup && s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>($"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G4<{typeof(T)}>")) + { + if (s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + T wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockRegistry.RegisterInteraction(new global::Mockolate.Interactions.MethodInvocation($"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G4<{typeof(T)}>")); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.G4(); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G4()' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(T)!); + } + + /// + public T G5() + where T : notnull + { + 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_G5_T_); + string name_methodSetup = $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G5<{typeof(T)}>"; + 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.Name == name_methodSetup && s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>($"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G5<{typeof(T)}>")) + { + if (s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + T wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockRegistry.RegisterInteraction(new global::Mockolate.Interactions.MethodInvocation($"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G5<{typeof(T)}>")); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.G5(); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G5()' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(T)!); + } + + /// + public T G6() + where T : global::Mockolate.Tests.GeneratorCoverage.MyBase, global::System.IComparable + { + 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_G6_T_); + string name_methodSetup = $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G6<{typeof(T)}>"; + 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.Name == name_methodSetup && s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>($"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G6<{typeof(T)}>")) + { + if (s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + T wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockRegistry.RegisterInteraction(new global::Mockolate.Interactions.MethodInvocation($"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G6<{typeof(T)}>")); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.G6(); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G6()' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(T)!); + } + + /// + public T? G7() + where T : class? + { + 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_G7_T_); + string name_methodSetup = $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G7<{typeof(T)}>"; + 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.Name == name_methodSetup && s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>($"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G7<{typeof(T)}>")) + { + if (s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + T? wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockRegistry.RegisterInteraction(new global::Mockolate.Interactions.MethodInvocation($"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G7<{typeof(T)}>")); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.G7(); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G7()' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(T?)!); + } + + /// + public T G8() + where T : allows ref struct + { + throw new global::System.NotSupportedException("Mockolate: methods with a generic type parameter declaring 'allows ref struct' are not supported. Method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G8'."); + } + + /// + public int Five(int a, int b, int c, int d, int e) + { + 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_Five); + 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(a, b, c, d, e)) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.Five")) + { + if (s_methodSetup.Matches(a, b, c, d, e)) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + int wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_Five.Append("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.Five", a, b, c, d, e); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.Five(a, b, c, d, e); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(a, b, c, d, e); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.Five(int, int, int, int, int)' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(a, b, c, d, e, out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(int)!, a, b, c, d, e); + } + + /// + public int 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) + { + 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_Seventeen); + 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(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17)) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.Seventeen")) + { + if (s_methodSetup.Matches(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17)) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + int wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_Seventeen.Append("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.Seventeen", a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wrappedResult = wraps.Seventeen(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.Seventeen(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int)' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(int)!, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); + } + + /// + public void 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) + { + global::Mockolate.Setup.VoidMethodSetup? methodSetup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.IComprehensiveInterface.MemberId_SeventeenVoid); + 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.VoidMethodSetup s_methodSetup && s_methodSetup.Matches(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17)) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.VoidMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.SeventeenVoid")) + { + if (s_methodSetup.Matches(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17)) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_SeventeenVoid.Append("global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.SeventeenVoid", a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface wraps) + { + wraps.SeventeenVoid(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.SeventeenVoid(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int)' was invoked without prior setup."); + } + } + + #endregion Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface + + #region IMockSetupForIComprehensiveInterface + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.PropertySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetSet + { + get + { + var propertySetup = new global::Mockolate.Setup.PropertySetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSet"); + this.MockRegistry.SetupProperty(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSet_Get, propertySetup); + return propertySetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IPropertyGetterOnlySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetOnly + { + get + { + var propertySetup = new global::Mockolate.Setup.PropertySetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetOnly"); + this.MockRegistry.SetupProperty(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetOnly_Get, propertySetup); + return propertySetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IPropertySetterOnlySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.SetOnly + { + get + { + var propertySetup = new global::Mockolate.Setup.PropertySetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.SetOnly"); + this.MockRegistry.SetupProperty(global::Mockolate.Mock.IComprehensiveInterface.MemberId_SetOnly_Get, propertySetup); + return propertySetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.PropertySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.NullableProp + { + get + { + var propertySetup = new global::Mockolate.Setup.PropertySetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.NullableProp"); + this.MockRegistry.SetupProperty(global::Mockolate.Mock.IComprehensiveInterface.MemberId_NullableProp_Get, propertySetup); + return propertySetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.PropertySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.InitOnly + { + get + { + var propertySetup = new global::Mockolate.Setup.PropertySetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.InitOnly"); + this.MockRegistry.SetupProperty(global::Mockolate.Mock.IComprehensiveInterface.MemberId_InitOnly_Get, propertySetup); + return propertySetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.EventSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.PlainEvent + { + get + { + global::Mockolate.Setup.EventSetup eventSetup = new global::Mockolate.Setup.EventSetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.PlainEvent"); + this.MockRegistry.SetupEvent(global::Mockolate.Mock.IComprehensiveInterface.MemberId_PlainEvent_Subscribe, eventSetup); + return eventSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.EventSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TypedEvent + { + get + { + global::Mockolate.Setup.EventSetup eventSetup = new global::Mockolate.Setup.EventSetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TypedEvent"); + this.MockRegistry.SetupEvent(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TypedEvent_Subscribe, eventSetup); + return eventSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.EventSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.CustomEvent + { + get + { + global::Mockolate.Setup.EventSetup eventSetup = new global::Mockolate.Setup.EventSetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.CustomEvent"); + this.MockRegistry.SetupEvent(global::Mockolate.Mock.IComprehensiveInterface.MemberId_CustomEvent_Subscribe, eventSetup); + return eventSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[global::Mockolate.Parameters.IParameter? parameter1] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, CovariantParameterAdapter.Wrap(parameter1 ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_int_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[int parameter1] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter1)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_int_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[global::Mockolate.Parameters.IParameter? parameter1, global::Mockolate.Parameters.IParameter? parameter2, global::Mockolate.Parameters.IParameter? parameter3, global::Mockolate.Parameters.IParameter? parameter4, global::Mockolate.Parameters.IParameter? parameter5] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, CovariantParameterAdapter.Wrap(parameter1 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter2 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter3 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter4 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter5 ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_int_int_int_int_int_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[int parameter1, int parameter2, int parameter3, int parameter4, int parameter5] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter1), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter2), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter3), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter4), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter5)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_int_int_int_int_int_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[global::Mockolate.Parameters.IParameter? parameter1, global::Mockolate.Parameters.IParameter? parameter2, global::Mockolate.Parameters.IParameter? parameter3, global::Mockolate.Parameters.IParameter? parameter4, global::Mockolate.Parameters.IParameter? parameter5] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, CovariantParameterAdapter.Wrap(parameter1 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter2 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter3 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter4 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter5 ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_byte_byte_byte_byte_byte_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[byte parameter1, byte parameter2, byte parameter3, byte parameter4, byte parameter5] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter1), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter2), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter3), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter4), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter5)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_byte_byte_byte_byte_byte_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[global::Mockolate.Parameters.IParameter? parameter1, global::Mockolate.Parameters.IParameter? parameter2, global::Mockolate.Parameters.IParameter? parameter3, global::Mockolate.Parameters.IParameter? parameter4, global::Mockolate.Parameters.IParameter? parameter5] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, CovariantParameterAdapter.Wrap(parameter1 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter2 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter3 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter4 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter5 ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_short_short_short_short_short_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[short parameter1, short parameter2, short parameter3, short parameter4, short parameter5] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter1), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter2), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter3), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter4), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter5)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_short_short_short_short_short_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[global::Mockolate.Parameters.IParameter? parameter1] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, CovariantParameterAdapter.Wrap(parameter1 ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_double_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[double parameter1] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter1)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_double_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[global::Mockolate.Parameters.IParameter? parameter1] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, CovariantParameterAdapter.Wrap(parameter1 ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_char_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[char parameter1] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter1)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_char_Get, indexerSetup); + return indexerSetup; + } + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", parameters, "a", "b", "c", "tail"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IRefParameter a, global::Mockolate.Parameters.IOutParameter b, global::Mockolate.Parameters.IParameter? c, global::Mockolate.Parameters.IParameter? tail) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", (global::Mockolate.Parameters.IParameterMatch)(a), (global::Mockolate.Parameters.IParameterMatch)(b), (global::Mockolate.Parameters.IParameterMatch)(c ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(tail ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IRefParameter a, global::Mockolate.Parameters.IOutParameter b, global::Mockolate.Parameters.IParameter? c, params global::Mockolate.Parameters.IParameter[] tail) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", (global::Mockolate.Parameters.IParameterMatch)(a), (global::Mockolate.Parameters.IParameterMatch)(b), (global::Mockolate.Parameters.IParameterMatch)(c ?? global::Mockolate.It.IsNull("null")), new global::Mockolate.Parameters.ParamsArrayParameterMatch(tail)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IRefParameter a, global::Mockolate.Parameters.IOutParameter b, long c, global::Mockolate.Parameters.IParameter? tail) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", (global::Mockolate.Parameters.IParameterMatch)(a), (global::Mockolate.Parameters.IParameterMatch)(b), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(c), CovariantParameterAdapter.Wrap(tail ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IRefParameter a, global::Mockolate.Parameters.IOutParameter b, global::Mockolate.Parameters.IParameter? c, params int[] tail) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", (global::Mockolate.Parameters.IParameterMatch)(a), (global::Mockolate.Parameters.IParameterMatch)(b), (global::Mockolate.Parameters.IParameterMatch)(c ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(global::Mockolate.It.SequenceEquals(tail))); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IRefParameter a, global::Mockolate.Parameters.IOutParameter b, long c, params int[] tail) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", (global::Mockolate.Parameters.IParameterMatch)(a), (global::Mockolate.Parameters.IParameterMatch)(b), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(c), CovariantParameterAdapter.Wrap(global::Mockolate.It.SequenceEquals(tail))); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.WithDefaults(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithDefaults", parameters, "i", "e", "d", "f", "c", "s", "st"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithDefaults, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.WithDefaults(global::Mockolate.ParameterArg? i, global::Mockolate.ParameterArg? e, global::Mockolate.ParameterArg? d, global::Mockolate.ParameterArg? f, global::Mockolate.ParameterArg? c, global::Mockolate.ParameterArg? s, global::Mockolate.ParameterArg? st) + { + global::Mockolate.ParameterArg iArg = i ?? new global::Mockolate.ParameterArg((int)(5)); + global::Mockolate.ParameterArg eArg = e ?? new global::Mockolate.ParameterArg((global::Mockolate.Tests.GeneratorCoverage.MyEnum)((global::Mockolate.Tests.GeneratorCoverage.MyEnum)1)); + global::Mockolate.ParameterArg dArg = d ?? new global::Mockolate.ParameterArg((decimal)(1.5m)); + global::Mockolate.ParameterArg fArg = f ?? new global::Mockolate.ParameterArg((float)(0.25f)); + global::Mockolate.ParameterArg cArg = c ?? new global::Mockolate.ParameterArg((char)('x')); + global::Mockolate.ParameterArg sArg = s ?? new global::Mockolate.ParameterArg((string?)(null)); + global::Mockolate.ParameterArg stArg = st ?? new global::Mockolate.ParameterArg((global::Mockolate.Tests.GeneratorCoverage.MyStruct)(default)); + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithDefaults", iArg.ToParameterMatch(), eArg.ToParameterMatch(), dArg.ToParameterMatch(), fArg.ToParameterMatch(), cArg.ToParameterMatch(), sArg.ToParameterMatch(), stArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithDefaults, methodSetup); + return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.WithCollidingNames(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithCollidingNames", parameters, "wraps", "result", "outParam1", "methodExecution", "returnValue"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithCollidingNames, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.WithCollidingNames(global::Mockolate.ParameterArg? wraps, global::Mockolate.ParameterArg? result, global::Mockolate.ParameterArg? outParam1, global::Mockolate.ParameterArg? methodExecution, global::Mockolate.ParameterArg? returnValue) + { + global::Mockolate.ParameterArg wrapsArg = wraps ?? default; + global::Mockolate.ParameterArg resultArg = result ?? default; + global::Mockolate.ParameterArg outParam1Arg = outParam1 ?? default; + global::Mockolate.ParameterArg methodExecutionArg = methodExecution ?? default; + global::Mockolate.ParameterArg returnValueArg = returnValue ?? default; + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithCollidingNames", wrapsArg.ToParameterMatch(), resultArg.ToParameterMatch(), outParam1Arg.ToParameterMatch(), methodExecutionArg.ToParameterMatch(), returnValueArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithCollidingNames, methodSetup); + return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetMaybeNull(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetMaybeNull", parameters, "s"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetMaybeNull, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetMaybeNull(global::Mockolate.ParameterArg? s) + { + global::Mockolate.ParameterArg sArg = s ?? default; + global::Mockolate.Setup.ReturnMethodSetup methodSetup; + if (sArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithLiteralValues(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetMaybeNull", sArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetMaybeNull", sArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetMaybeNull, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetMaybeNull(global::System.Func s, string sExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetMaybeNull", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(s, sExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetMaybeNull, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)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.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeObject(global::Mockolate.ParameterArg? obj) + { + global::Mockolate.ParameterArg objArg = obj ?? default; + global::Mockolate.Setup.ReturnMethodSetup methodSetup; + if (objArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithLiteralValues(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", objArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", objArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeObject(global::System.Func obj, string objExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(obj, objExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)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.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeTwoObjects(global::Mockolate.ParameterArg? first, global::Mockolate.ParameterArg? second) + { + global::Mockolate.ParameterArg firstArg = first ?? default; + global::Mockolate.ParameterArg secondArg = second ?? default; + global::Mockolate.Setup.ReturnMethodSetup methodSetup; + if (firstArg.IsLiteral && secondArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithLiteralValues(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", firstArg.Literal!, secondArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", firstArg.ToParameterMatch(), secondArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeTwoObjects(global::System.Func first, global::Mockolate.ParameterArg? second, string firstExpression) + { + global::Mockolate.ParameterArg secondArg = second ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(first, firstExpression), secondArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeTwoObjects(global::Mockolate.ParameterArg? first, global::System.Func second, string secondExpression) + { + global::Mockolate.ParameterArg firstArg = first ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", firstArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(second, secondExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeTwoObjects(global::System.Func first, global::System.Func second, string firstExpression, string secondExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(first, firstExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(second, secondExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)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.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeIntAndObject(global::Mockolate.ParameterArg? n, global::Mockolate.ParameterArg? obj) + { + global::Mockolate.ParameterArg nArg = n ?? default; + global::Mockolate.ParameterArg objArg = obj ?? default; + global::Mockolate.Setup.ReturnMethodSetup methodSetup; + if (nArg.IsLiteral && objArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithLiteralValues(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", nArg.Literal!, objArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", nArg.ToParameterMatch(), objArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeIntAndObject(global::System.Func n, global::Mockolate.ParameterArg? obj, string nExpression) + { + global::Mockolate.ParameterArg objArg = obj ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(n, nExpression), objArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeIntAndObject(global::Mockolate.ParameterArg? n, global::System.Func obj, string objExpression) + { + global::Mockolate.ParameterArg nArg = n ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", nArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(obj, objExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeIntAndObject(global::System.Func n, global::System.Func obj, string nExpression, string objExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(n, nExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(obj, objExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)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, 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, 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, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup> global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.DoVTOf() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup>.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoVTOf"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_DoVTOf, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup<(int Code, string Msg)> global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetTuple() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup<(int Code, string Msg)>.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetTuple"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetTuple, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetNullable() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetNullable"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetNullable, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback, int> global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetSpan(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, int>.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSpan", parameters, "n"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSpan, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int> global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetSpan(global::Mockolate.ParameterArg? n) + { + global::Mockolate.ParameterArg nArg = n ?? default; + global::Mockolate.Setup.ReturnMethodSetup, int> methodSetup; + if (nArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, int>.WithLiteralValues(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSpan", nArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, int>.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSpan", nArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSpan, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int> global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetSpan(global::System.Func n, string nExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, int>.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSpan", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(n, nExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSpan, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback, int> global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetROSpan(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, int>.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetROSpan", parameters, "n"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetROSpan, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int> global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetROSpan(global::Mockolate.ParameterArg? n) + { + global::Mockolate.ParameterArg nArg = n ?? default; + global::Mockolate.Setup.ReturnMethodSetup, int> methodSetup; + if (nArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, int>.WithLiteralValues(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetROSpan", nArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, int>.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetROSpan", nArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetROSpan, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int> global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetROSpan(global::System.Func n, string nExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, int>.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetROSpan", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(n, nExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetROSpan, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetByRef() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetByRef"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetByRef, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetByRefReadonly() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetByRefReadonly"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetByRefReadonly, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.G1() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G1<{typeof(T)}>"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_G1_T_, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.G2() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G2<{typeof(T)}>"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_G2_T_, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.G3() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G3<{typeof(T)}>"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_G3_T_, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.G4() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G4<{typeof(T)}>"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_G4_T_, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.G5() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G5<{typeof(T)}>"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_G5_T_, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.G6() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G6<{typeof(T)}>"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_G6_T_, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.G7() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G7<{typeof(T)}>"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_G7_T_, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.Five(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.Five", parameters, "a", "b", "c", "d", "e"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Five, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.Five(global::Mockolate.ParameterArg? a, global::Mockolate.ParameterArg? b, global::Mockolate.ParameterArg? c, global::Mockolate.ParameterArg? d, global::Mockolate.ParameterArg? e) + { + global::Mockolate.ParameterArg aArg = a ?? default; + global::Mockolate.ParameterArg bArg = b ?? default; + global::Mockolate.ParameterArg cArg = c ?? default; + global::Mockolate.ParameterArg dArg = d ?? default; + global::Mockolate.ParameterArg eArg = e ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.Five", aArg.ToParameterMatch(), bArg.ToParameterMatch(), cArg.ToParameterMatch(), dArg.ToParameterMatch(), eArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Five, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.Seventeen(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.Seventeen", parameters, "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15", "a16", "a17"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Seventeen, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.Seventeen(global::Mockolate.ParameterArg? a1, global::Mockolate.ParameterArg? a2, global::Mockolate.ParameterArg? a3, global::Mockolate.ParameterArg? a4, global::Mockolate.ParameterArg? a5, global::Mockolate.ParameterArg? a6, global::Mockolate.ParameterArg? a7, global::Mockolate.ParameterArg? a8, global::Mockolate.ParameterArg? a9, global::Mockolate.ParameterArg? a10, global::Mockolate.ParameterArg? a11, global::Mockolate.ParameterArg? a12, global::Mockolate.ParameterArg? a13, global::Mockolate.ParameterArg? a14, global::Mockolate.ParameterArg? a15, global::Mockolate.ParameterArg? a16, global::Mockolate.ParameterArg? a17) + { + global::Mockolate.ParameterArg a1Arg = a1 ?? default; + global::Mockolate.ParameterArg a2Arg = a2 ?? default; + global::Mockolate.ParameterArg a3Arg = a3 ?? default; + global::Mockolate.ParameterArg a4Arg = a4 ?? default; + global::Mockolate.ParameterArg a5Arg = a5 ?? default; + global::Mockolate.ParameterArg a6Arg = a6 ?? default; + global::Mockolate.ParameterArg a7Arg = a7 ?? default; + global::Mockolate.ParameterArg a8Arg = a8 ?? default; + global::Mockolate.ParameterArg a9Arg = a9 ?? default; + global::Mockolate.ParameterArg a10Arg = a10 ?? default; + global::Mockolate.ParameterArg a11Arg = a11 ?? default; + global::Mockolate.ParameterArg a12Arg = a12 ?? default; + global::Mockolate.ParameterArg a13Arg = a13 ?? default; + global::Mockolate.ParameterArg a14Arg = a14 ?? default; + global::Mockolate.ParameterArg a15Arg = a15 ?? default; + global::Mockolate.ParameterArg a16Arg = a16 ?? default; + global::Mockolate.ParameterArg a17Arg = a17 ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.Seventeen", a1Arg.ToParameterMatch(), a2Arg.ToParameterMatch(), a3Arg.ToParameterMatch(), a4Arg.ToParameterMatch(), a5Arg.ToParameterMatch(), a6Arg.ToParameterMatch(), a7Arg.ToParameterMatch(), a8Arg.ToParameterMatch(), a9Arg.ToParameterMatch(), a10Arg.ToParameterMatch(), a11Arg.ToParameterMatch(), a12Arg.ToParameterMatch(), a13Arg.ToParameterMatch(), a14Arg.ToParameterMatch(), a15Arg.ToParameterMatch(), a16Arg.ToParameterMatch(), a17Arg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Seventeen, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.SeventeenVoid(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.SeventeenVoid", parameters, "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15", "a16", "a17"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_SeventeenVoid, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.SeventeenVoid(global::Mockolate.ParameterArg? a1, global::Mockolate.ParameterArg? a2, global::Mockolate.ParameterArg? a3, global::Mockolate.ParameterArg? a4, global::Mockolate.ParameterArg? a5, global::Mockolate.ParameterArg? a6, global::Mockolate.ParameterArg? a7, global::Mockolate.ParameterArg? a8, global::Mockolate.ParameterArg? a9, global::Mockolate.ParameterArg? a10, global::Mockolate.ParameterArg? a11, global::Mockolate.ParameterArg? a12, global::Mockolate.ParameterArg? a13, global::Mockolate.ParameterArg? a14, global::Mockolate.ParameterArg? a15, global::Mockolate.ParameterArg? a16, global::Mockolate.ParameterArg? a17) + { + global::Mockolate.ParameterArg a1Arg = a1 ?? default; + global::Mockolate.ParameterArg a2Arg = a2 ?? default; + global::Mockolate.ParameterArg a3Arg = a3 ?? default; + global::Mockolate.ParameterArg a4Arg = a4 ?? default; + global::Mockolate.ParameterArg a5Arg = a5 ?? default; + global::Mockolate.ParameterArg a6Arg = a6 ?? default; + global::Mockolate.ParameterArg a7Arg = a7 ?? default; + global::Mockolate.ParameterArg a8Arg = a8 ?? default; + global::Mockolate.ParameterArg a9Arg = a9 ?? default; + global::Mockolate.ParameterArg a10Arg = a10 ?? default; + global::Mockolate.ParameterArg a11Arg = a11 ?? default; + global::Mockolate.ParameterArg a12Arg = a12 ?? default; + global::Mockolate.ParameterArg a13Arg = a13 ?? default; + global::Mockolate.ParameterArg a14Arg = a14 ?? default; + global::Mockolate.ParameterArg a15Arg = a15 ?? default; + global::Mockolate.ParameterArg a16Arg = a16 ?? default; + global::Mockolate.ParameterArg a17Arg = a17 ?? default; + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.SeventeenVoid", a1Arg.ToParameterMatch(), a2Arg.ToParameterMatch(), a3Arg.ToParameterMatch(), a4Arg.ToParameterMatch(), a5Arg.ToParameterMatch(), a6Arg.ToParameterMatch(), a7Arg.ToParameterMatch(), a8Arg.ToParameterMatch(), a9Arg.ToParameterMatch(), a10Arg.ToParameterMatch(), a11Arg.ToParameterMatch(), a12Arg.ToParameterMatch(), a13Arg.ToParameterMatch(), a14Arg.ToParameterMatch(), a15Arg.ToParameterMatch(), a16Arg.ToParameterMatch(), a17Arg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_SeventeenVoid, methodSetup); + return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; + } + + #endregion IMockSetupForIComprehensiveInterface + + #region IMockStaticSetupForIComprehensiveInterface + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IPropertyGetterOnlySetup global::Mockolate.Mock.IMockStaticSetupForIComprehensiveInterface.StaticAbstractValue + { + get + { + var propertySetup = new global::Mockolate.Setup.PropertySetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.StaticAbstractValue"); + this.MockRegistry.SetupProperty(global::Mockolate.Mock.IComprehensiveInterface.MemberId_StaticAbstractValue_Get, propertySetup); + return propertySetup; + } + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockStaticSetupForIComprehensiveInterface.StaticAbstractMethod() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.StaticAbstractMethod"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_StaticAbstractMethod, methodSetup); + return methodSetup; + } + + #endregion IMockStaticSetupForIComprehensiveInterface + + #region IMockRaiseOnIComprehensiveInterface + + /// + void IMockRaiseOnIComprehensiveInterface.PlainEvent(object? sender, global::System.EventArgs e) + { + this._mockolateEvent_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_PlainEvent?.Invoke(sender, e); + } + + /// + void IMockRaiseOnIComprehensiveInterface.TypedEvent(object? sender, global::Mockolate.Tests.GeneratorCoverage.MyEventArgs e) + { + this._mockolateEvent_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_TypedEvent?.Invoke(sender, e); + } + + /// + void IMockRaiseOnIComprehensiveInterface.CustomEvent(int x, ref int y, out string z, in long w) + { + z = default!; + this._mockolateEvent_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_CustomEvent?.Invoke(x, ref y, out z, in w); + } + + /// + void IMockRaiseOnIComprehensiveInterface.PlainEvent(global::Mockolate.Parameters.IDefaultEventParameters parameters) + { + global::Mockolate.MockBehavior mockBehavior = this.MockRegistry.Behavior; + this._mockolateEvent_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_PlainEvent?.Invoke(mockBehavior.DefaultValue.Generate(default(object)), mockBehavior.DefaultValue.Generate(default(global::System.EventArgs))); + } + + /// + void IMockRaiseOnIComprehensiveInterface.TypedEvent(global::Mockolate.Parameters.IDefaultEventParameters parameters) + { + global::Mockolate.MockBehavior mockBehavior = this.MockRegistry.Behavior; + this._mockolateEvent_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_TypedEvent?.Invoke(mockBehavior.DefaultValue.Generate(default(object)), mockBehavior.DefaultValue.Generate(default(global::Mockolate.Tests.GeneratorCoverage.MyEventArgs))); + } + + /// + void IMockRaiseOnIComprehensiveInterface.CustomEvent(global::Mockolate.Parameters.IDefaultEventParameters parameters) + { + global::Mockolate.MockBehavior mockBehavior = this.MockRegistry.Behavior; + int __arg1 = mockBehavior.DefaultValue.Generate(default(int)); + int __arg2 = mockBehavior.DefaultValue.Generate(default(int)); + string __arg3 = mockBehavior.DefaultValue.Generate(default(string)); + long __arg4 = mockBehavior.DefaultValue.Generate(default(long)); + this._mockolateEvent_global__Mockolate_Tests_GeneratorCoverage_IComprehensiveInterface_CustomEvent?.Invoke(__arg1, ref __arg2, out __arg3, in __arg4); + } + + #endregion IMockRaiseOnIComprehensiveInterface + + #region IMockVerifyForIComprehensiveInterface + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationPropertyResult IMockVerifyForIComprehensiveInterface.GetSet + { + get + { + return new global::Mockolate.Verify.VerificationPropertyResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSet_Get, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSet_Set, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSet"); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationPropertyGetterResult IMockVerifyForIComprehensiveInterface.GetOnly + { + get + { + return new global::Mockolate.Verify.VerificationPropertyGetterResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetOnly_Get, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetOnly"); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationPropertySetterResult IMockVerifyForIComprehensiveInterface.SetOnly + { + get + { + return new global::Mockolate.Verify.VerificationPropertySetterResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_SetOnly_Set, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.SetOnly"); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationPropertyResult IMockVerifyForIComprehensiveInterface.NullableProp + { + get + { + return new global::Mockolate.Verify.VerificationPropertyResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_NullableProp_Get, global::Mockolate.Mock.IComprehensiveInterface.MemberId_NullableProp_Set, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.NullableProp"); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationPropertyResult IMockVerifyForIComprehensiveInterface.InitOnly + { + get + { + return new global::Mockolate.Verify.VerificationPropertyResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_InitOnly_Get, global::Mockolate.Mock.IComprehensiveInterface.MemberId_InitOnly_Set, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.InitOnly"); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIComprehensiveInterface.this[global::Mockolate.Parameters.IParameter? i] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_int_Get, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_int_Set, + CovariantParameterAdapter.Wrap(i ?? global::Mockolate.It.IsNull("null")), + () => global::System.String.Format("[{0}]", (object?)i ?? "null")); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIComprehensiveInterface.this[int i] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_int_Get, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_int_Set, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(i, "i"), + () => global::System.String.Format("[{0}]", (object?)i)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIComprehensiveInterface.this[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] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, -1, -1, + interaction => interaction is global::Mockolate.Interactions.IndexerGetterAccess g && CovariantParameterAdapter.Wrap(a ?? global::Mockolate.It.IsNull("null")).Matches(g.Parameter1) && CovariantParameterAdapter.Wrap(b ?? global::Mockolate.It.IsNull("null")).Matches(g.Parameter2) && CovariantParameterAdapter.Wrap(c ?? global::Mockolate.It.IsNull("null")).Matches(g.Parameter3) && CovariantParameterAdapter.Wrap(d ?? global::Mockolate.It.IsNull("null")).Matches(g.Parameter4) && CovariantParameterAdapter.Wrap(e ?? global::Mockolate.It.IsNull("null")).Matches(g.Parameter5), + (interaction, value) => interaction is global::Mockolate.Interactions.IndexerSetterAccess s && CovariantParameterAdapter.Wrap(a ?? global::Mockolate.It.IsNull("null")).Matches(s.Parameter1) && CovariantParameterAdapter.Wrap(b ?? global::Mockolate.It.IsNull("null")).Matches(s.Parameter2) && CovariantParameterAdapter.Wrap(c ?? global::Mockolate.It.IsNull("null")).Matches(s.Parameter3) && CovariantParameterAdapter.Wrap(d ?? global::Mockolate.It.IsNull("null")).Matches(s.Parameter4) && CovariantParameterAdapter.Wrap(e ?? global::Mockolate.It.IsNull("null")).Matches(s.Parameter5) && value.Matches(s.TypedValue), + () => global::System.String.Format("[{0}, {1}, {2}, {3}, {4}]", (object?)a ?? "null", (object?)b ?? "null", (object?)c ?? "null", (object?)d ?? "null", (object?)e ?? "null")); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIComprehensiveInterface.this[int a, int b, int c, int d, int e] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, -1, -1, + interaction => interaction is global::Mockolate.Interactions.IndexerGetterAccess g && global::System.Collections.Generic.EqualityComparer.Default.Equals(a, g.Parameter1) && global::System.Collections.Generic.EqualityComparer.Default.Equals(b, g.Parameter2) && global::System.Collections.Generic.EqualityComparer.Default.Equals(c, g.Parameter3) && global::System.Collections.Generic.EqualityComparer.Default.Equals(d, g.Parameter4) && global::System.Collections.Generic.EqualityComparer.Default.Equals(e, g.Parameter5), + (interaction, value) => interaction is global::Mockolate.Interactions.IndexerSetterAccess s && global::System.Collections.Generic.EqualityComparer.Default.Equals(a, s.Parameter1) && global::System.Collections.Generic.EqualityComparer.Default.Equals(b, s.Parameter2) && global::System.Collections.Generic.EqualityComparer.Default.Equals(c, s.Parameter3) && global::System.Collections.Generic.EqualityComparer.Default.Equals(d, s.Parameter4) && global::System.Collections.Generic.EqualityComparer.Default.Equals(e, s.Parameter5) && value.Matches(s.TypedValue), + () => global::System.String.Format("[{0}, {1}, {2}, {3}, {4}]", (object?)a, (object?)b, (object?)c, (object?)d, (object?)e)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult IMockVerifyForIComprehensiveInterface.this[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] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult(this, this.MockRegistry, -1, + interaction => interaction is global::Mockolate.Interactions.IndexerGetterAccess g && CovariantParameterAdapter.Wrap(a ?? global::Mockolate.It.IsNull("null")).Matches(g.Parameter1) && CovariantParameterAdapter.Wrap(b ?? global::Mockolate.It.IsNull("null")).Matches(g.Parameter2) && CovariantParameterAdapter.Wrap(c ?? global::Mockolate.It.IsNull("null")).Matches(g.Parameter3) && CovariantParameterAdapter.Wrap(d ?? global::Mockolate.It.IsNull("null")).Matches(g.Parameter4) && CovariantParameterAdapter.Wrap(e ?? global::Mockolate.It.IsNull("null")).Matches(g.Parameter5), + () => global::System.String.Format("[{0}, {1}, {2}, {3}, {4}]", (object?)a ?? "null", (object?)b ?? "null", (object?)c ?? "null", (object?)d ?? "null", (object?)e ?? "null")); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult IMockVerifyForIComprehensiveInterface.this[byte a, byte b, byte c, byte d, byte e] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult(this, this.MockRegistry, -1, + interaction => interaction is global::Mockolate.Interactions.IndexerGetterAccess g && global::System.Collections.Generic.EqualityComparer.Default.Equals(a, g.Parameter1) && global::System.Collections.Generic.EqualityComparer.Default.Equals(b, g.Parameter2) && global::System.Collections.Generic.EqualityComparer.Default.Equals(c, g.Parameter3) && global::System.Collections.Generic.EqualityComparer.Default.Equals(d, g.Parameter4) && global::System.Collections.Generic.EqualityComparer.Default.Equals(e, g.Parameter5), + () => global::System.String.Format("[{0}, {1}, {2}, {3}, {4}]", (object?)a, (object?)b, (object?)c, (object?)d, (object?)e)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIComprehensiveInterface.this[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] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, -1, + (interaction, value) => interaction is global::Mockolate.Interactions.IndexerSetterAccess s && CovariantParameterAdapter.Wrap(a ?? global::Mockolate.It.IsNull("null")).Matches(s.Parameter1) && CovariantParameterAdapter.Wrap(b ?? global::Mockolate.It.IsNull("null")).Matches(s.Parameter2) && CovariantParameterAdapter.Wrap(c ?? global::Mockolate.It.IsNull("null")).Matches(s.Parameter3) && CovariantParameterAdapter.Wrap(d ?? global::Mockolate.It.IsNull("null")).Matches(s.Parameter4) && CovariantParameterAdapter.Wrap(e ?? global::Mockolate.It.IsNull("null")).Matches(s.Parameter5) && value.Matches(s.TypedValue), + () => global::System.String.Format("[{0}, {1}, {2}, {3}, {4}]", (object?)a ?? "null", (object?)b ?? "null", (object?)c ?? "null", (object?)d ?? "null", (object?)e ?? "null")); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIComprehensiveInterface.this[short a, short b, short c, short d, short e] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, -1, + (interaction, value) => interaction is global::Mockolate.Interactions.IndexerSetterAccess s && global::System.Collections.Generic.EqualityComparer.Default.Equals(a, s.Parameter1) && global::System.Collections.Generic.EqualityComparer.Default.Equals(b, s.Parameter2) && global::System.Collections.Generic.EqualityComparer.Default.Equals(c, s.Parameter3) && global::System.Collections.Generic.EqualityComparer.Default.Equals(d, s.Parameter4) && global::System.Collections.Generic.EqualityComparer.Default.Equals(e, s.Parameter5) && value.Matches(s.TypedValue), + () => global::System.String.Format("[{0}, {1}, {2}, {3}, {4}]", (object?)a, (object?)b, (object?)c, (object?)d, (object?)e)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult IMockVerifyForIComprehensiveInterface.this[global::Mockolate.Parameters.IParameter? key] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_double_Get, + CovariantParameterAdapter.Wrap(key ?? global::Mockolate.It.IsNull("null")), + () => global::System.String.Format("[{0}]", (object?)key ?? "null")); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult IMockVerifyForIComprehensiveInterface.this[double key] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_double_Get, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(key, "key"), + () => global::System.String.Format("[{0}]", (object?)key)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIComprehensiveInterface.this[global::Mockolate.Parameters.IParameter? key] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_char_Set, + CovariantParameterAdapter.Wrap(key ?? global::Mockolate.It.IsNull("null")), + () => global::System.String.Format("[{0}]", (object?)key ?? "null")); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIComprehensiveInterface.this[char key] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_char_Set, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(key, "key"), + () => global::System.String.Format("[{0}]", (object?)key)); + } + } + + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2, __i.Parameter3, __i.Parameter4]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("a", __i.Parameter1), ("b", __i.Parameter2), ("c", __i.Parameter3), ("tail", __i.Parameter4)]), + _ => true + }, () => $"WithModifiers({parameters})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IVerifyRefParameter a, global::Mockolate.Parameters.IVerifyOutParameter b, global::Mockolate.Parameters.IParameter? c, global::Mockolate.Parameters.IParameter? tail) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", __i => + (a is global::Mockolate.Parameters.IParameterMatch aMatch ? aMatch.Matches(__i.Parameter1) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter1, default(int))) && + (b is global::Mockolate.Parameters.IParameterMatch bMatch ? bMatch.Matches(__i.Parameter2) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter2, default(string))) && + (c is not null ? CovariantParameterAdapter.Wrap(c).Matches(__i.Parameter3) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter3, default(long))) && + (tail is not null ? CovariantParameterAdapter.Wrap(tail).Matches(__i.Parameter4) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter4, default(int[]))), () => $"WithModifiers({a}, {b}, {c}, {tail})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IVerifyRefParameter a, global::Mockolate.Parameters.IVerifyOutParameter b, global::Mockolate.Parameters.IParameter? c, params global::Mockolate.Parameters.IParameter[] tail) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", __i => + (a is global::Mockolate.Parameters.IParameterMatch aMatch ? aMatch.Matches(__i.Parameter1) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter1, default(int))) && + (b is global::Mockolate.Parameters.IParameterMatch bMatch ? bMatch.Matches(__i.Parameter2) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter2, default(string))) && + (c is not null ? CovariantParameterAdapter.Wrap(c).Matches(__i.Parameter3) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter3, default(long))) && + (new global::Mockolate.Parameters.ParamsArrayParameterMatch(tail).Matches(__i.Parameter4)), () => $"WithModifiers({a}, {b}, {c}, {tail})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IVerifyRefParameter a, global::Mockolate.Parameters.IVerifyOutParameter b, long c, global::Mockolate.Parameters.IParameter? tail) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", __i => + (a is global::Mockolate.Parameters.IParameterMatch aMatch ? aMatch.Matches(__i.Parameter1) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter1, default(int))) && + (b is global::Mockolate.Parameters.IParameterMatch bMatch ? bMatch.Matches(__i.Parameter2) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter2, default(string))) && + (global::System.Collections.Generic.EqualityComparer.Default.Equals(c, __i.Parameter3)) && + (tail is not null ? CovariantParameterAdapter.Wrap(tail).Matches(__i.Parameter4) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter4, default(int[]))), () => $"WithModifiers({a}, {b}, {c}, {tail})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IVerifyRefParameter a, global::Mockolate.Parameters.IVerifyOutParameter b, global::Mockolate.Parameters.IParameter? c, params int[] tail) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", __i => + (a is global::Mockolate.Parameters.IParameterMatch aMatch ? aMatch.Matches(__i.Parameter1) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter1, default(int))) && + (b is global::Mockolate.Parameters.IParameterMatch bMatch ? bMatch.Matches(__i.Parameter2) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter2, default(string))) && + (c is not null ? CovariantParameterAdapter.Wrap(c).Matches(__i.Parameter3) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter3, default(long))) && + (CovariantParameterAdapter.Wrap(global::Mockolate.It.SequenceEquals(tail)).Matches(__i.Parameter4)), () => $"WithModifiers({a}, {b}, {c}, {tail})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IVerifyRefParameter a, global::Mockolate.Parameters.IVerifyOutParameter b, long c, params int[] tail) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", __i => + (a is global::Mockolate.Parameters.IParameterMatch aMatch ? aMatch.Matches(__i.Parameter1) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter1, default(int))) && + (b is global::Mockolate.Parameters.IParameterMatch bMatch ? bMatch.Matches(__i.Parameter2) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter2, default(string))) && + (global::System.Collections.Generic.EqualityComparer.Default.Equals(c, __i.Parameter3)) && + (CovariantParameterAdapter.Wrap(global::Mockolate.It.SequenceEquals(tail)).Matches(__i.Parameter4)), () => $"WithModifiers({a}, {b}, {c}, {tail})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.WithDefaults(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithDefaults, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithDefaults", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2, __i.Parameter3, __i.Parameter4, __i.Parameter5, __i.Parameter6, __i.Parameter7]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("i", __i.Parameter1), ("e", __i.Parameter2), ("d", __i.Parameter3), ("f", __i.Parameter4), ("c", __i.Parameter5), ("s", __i.Parameter6), ("st", __i.Parameter7)]), + _ => true + }, () => $"WithDefaults({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.WithDefaults(global::Mockolate.ParameterArg? i, global::Mockolate.ParameterArg? e, global::Mockolate.ParameterArg? d, global::Mockolate.ParameterArg? f, global::Mockolate.ParameterArg? c, global::Mockolate.ParameterArg? s, global::Mockolate.ParameterArg? st) + { + global::Mockolate.ParameterArg iArg = i ?? new global::Mockolate.ParameterArg((int)(5)); + global::Mockolate.ParameterArg eArg = e ?? new global::Mockolate.ParameterArg((global::Mockolate.Tests.GeneratorCoverage.MyEnum)((global::Mockolate.Tests.GeneratorCoverage.MyEnum)1)); + global::Mockolate.ParameterArg dArg = d ?? new global::Mockolate.ParameterArg((decimal)(1.5m)); + global::Mockolate.ParameterArg fArg = f ?? new global::Mockolate.ParameterArg((float)(0.25f)); + global::Mockolate.ParameterArg cArg = c ?? new global::Mockolate.ParameterArg((char)('x')); + global::Mockolate.ParameterArg sArg = s ?? new global::Mockolate.ParameterArg((string?)(null)); + global::Mockolate.ParameterArg stArg = st ?? new global::Mockolate.ParameterArg((global::Mockolate.Tests.GeneratorCoverage.MyStruct)(default)); + global::Mockolate.Parameters.IParameterMatch iMatch = iArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch eMatch = eArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch dMatch = dArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch fMatch = fArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch cMatch = cArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch sMatch = sArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch stMatch = stArg.ToParameterMatch(); + return this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithDefaults, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithDefaults", __i => + (iMatch.Matches(__i.Parameter1)) && + (eMatch.Matches(__i.Parameter2)) && + (dMatch.Matches(__i.Parameter3)) && + (fMatch.Matches(__i.Parameter4)) && + (cMatch.Matches(__i.Parameter5)) && + (sMatch.Matches(__i.Parameter6)) && + (stMatch.Matches(__i.Parameter7)), () => $"WithDefaults({iArg}, {eArg}, {dArg}, {fArg}, {cArg}, {sArg}, {stArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.WithCollidingNames(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithCollidingNames, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithCollidingNames", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2, __i.Parameter3, __i.Parameter4, __i.Parameter5]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("wraps", __i.Parameter1), ("result", __i.Parameter2), ("outParam1", __i.Parameter3), ("methodExecution", __i.Parameter4), ("returnValue", __i.Parameter5)]), + _ => true + }, () => $"WithCollidingNames({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.WithCollidingNames(global::Mockolate.ParameterArg? wraps, global::Mockolate.ParameterArg? result, global::Mockolate.ParameterArg? outParam1, global::Mockolate.ParameterArg? methodExecution, global::Mockolate.ParameterArg? returnValue) + { + global::Mockolate.ParameterArg wrapsArg = wraps ?? default; + global::Mockolate.ParameterArg resultArg = result ?? default; + global::Mockolate.ParameterArg outParam1Arg = outParam1 ?? default; + global::Mockolate.ParameterArg methodExecutionArg = methodExecution ?? default; + global::Mockolate.ParameterArg returnValueArg = returnValue ?? default; + global::Mockolate.Parameters.IParameterMatch wrapsMatch = wrapsArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch resultMatch = resultArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch outParam1Match = outParam1Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch methodExecutionMatch = methodExecutionArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch returnValueMatch = returnValueArg.ToParameterMatch(); + return this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithCollidingNames, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithCollidingNames", __i => + (wrapsMatch.Matches(__i.Parameter1)) && + (resultMatch.Matches(__i.Parameter2)) && + (outParam1Match.Matches(__i.Parameter3)) && + (methodExecutionMatch.Matches(__i.Parameter4)) && + (returnValueMatch.Matches(__i.Parameter5)), () => $"WithCollidingNames({wrapsArg}, {resultArg}, {outParam1Arg}, {methodExecutionArg}, {returnValueArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.GetMaybeNull(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetMaybeNull, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetMaybeNull", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("s", __i.Parameter1)]), + _ => true + }, () => $"GetMaybeNull({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.GetMaybeNull(global::Mockolate.ParameterArg? s) + { + global::Mockolate.ParameterArg sArg = s ?? default; + if (sArg.IsLiteral) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetMaybeNull, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetMaybeNull", sArg.Literal!, () => $"GetMaybeNull({sArg})"); + } + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetMaybeNull, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetMaybeNull", sArg.ToParameterMatch(), () => $"GetMaybeNull({sArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.GetMaybeNull(global::System.Func s, string sExpression) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetMaybeNull, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetMaybeNull", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(s, sExpression), () => $"GetMaybeNull({sExpression})"); + } + + /// + 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.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeObject(global::Mockolate.ParameterArg? obj) + { + global::Mockolate.ParameterArg objArg = obj ?? default; + if (objArg.IsLiteral) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", objArg.Literal!, () => $"TakeObject({objArg})"); + } + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", objArg.ToParameterMatch(), () => $"TakeObject({objArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeObject(global::System.Func obj, string objExpression) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(obj, objExpression), () => $"TakeObject({objExpression})"); + } + + /// + 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.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeTwoObjects(global::Mockolate.ParameterArg? first, global::Mockolate.ParameterArg? second) + { + global::Mockolate.ParameterArg firstArg = first ?? default; + global::Mockolate.ParameterArg secondArg = second ?? default; + if (firstArg.IsLiteral && secondArg.IsLiteral) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", firstArg.Literal!, secondArg.Literal!, () => $"TakeTwoObjects({firstArg}, {secondArg})"); + } + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", firstArg.ToParameterMatch(), secondArg.ToParameterMatch(), () => $"TakeTwoObjects({firstArg}, {secondArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeTwoObjects(global::System.Func first, global::Mockolate.ParameterArg? second, string firstExpression) + { + global::Mockolate.ParameterArg secondArg = second ?? default; + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(first, firstExpression), secondArg.ToParameterMatch(), () => $"TakeTwoObjects({firstExpression}, {secondArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeTwoObjects(global::Mockolate.ParameterArg? first, global::System.Func second, string secondExpression) + { + global::Mockolate.ParameterArg firstArg = first ?? default; + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", firstArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(second, secondExpression), () => $"TakeTwoObjects({firstArg}, {secondExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeTwoObjects(global::System.Func first, global::System.Func second, string firstExpression, string secondExpression) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(first, firstExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(second, secondExpression), () => $"TakeTwoObjects({firstExpression}, {secondExpression})"); + } + + /// + 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.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeIntAndObject(global::Mockolate.ParameterArg? n, global::Mockolate.ParameterArg? obj) + { + global::Mockolate.ParameterArg nArg = n ?? default; + global::Mockolate.ParameterArg objArg = obj ?? default; + if (nArg.IsLiteral && objArg.IsLiteral) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", nArg.Literal!, objArg.Literal!, () => $"TakeIntAndObject({nArg}, {objArg})"); + } + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", nArg.ToParameterMatch(), objArg.ToParameterMatch(), () => $"TakeIntAndObject({nArg}, {objArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeIntAndObject(global::System.Func n, global::Mockolate.ParameterArg? obj, string nExpression) + { + global::Mockolate.ParameterArg objArg = obj ?? default; + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(n, nExpression), objArg.ToParameterMatch(), () => $"TakeIntAndObject({nExpression}, {objArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeIntAndObject(global::Mockolate.ParameterArg? n, global::System.Func obj, string objExpression) + { + global::Mockolate.ParameterArg nArg = n ?? default; + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", nArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(obj, objExpression), () => $"TakeIntAndObject({nArg}, {objExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeIntAndObject(global::System.Func n, global::System.Func obj, string nExpression, string objExpression) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(n, nExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(obj, objExpression), () => $"TakeIntAndObject({nExpression}, {objExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.DoTask() + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_DoTask, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoTask", () => $"DoTask()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.DoTaskOf() + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_DoTaskOf, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoTaskOf", () => $"DoTaskOf()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.DoVT() + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_DoVT, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoVT", () => $"DoVT()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.DoVTOf() + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_DoVTOf, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoVTOf", () => $"DoVTOf()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.GetTuple() + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetTuple, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetTuple", () => $"GetTuple()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.GetNullable() + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetNullable, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetNullable", () => $"GetNullable()"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.GetSpan(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSpan, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSpan", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("n", __i.Parameter1)]), + _ => true + }, () => $"GetSpan({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.GetSpan(global::Mockolate.ParameterArg? n) + { + global::Mockolate.ParameterArg nArg = n ?? default; + if (nArg.IsLiteral) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSpan, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSpan", nArg.Literal!, () => $"GetSpan({nArg})"); + } + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSpan, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSpan", nArg.ToParameterMatch(), () => $"GetSpan({nArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.GetSpan(global::System.Func n, string nExpression) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSpan, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSpan", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(n, nExpression), () => $"GetSpan({nExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.GetROSpan(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetROSpan, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetROSpan", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("n", __i.Parameter1)]), + _ => true + }, () => $"GetROSpan({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.GetROSpan(global::Mockolate.ParameterArg? n) + { + global::Mockolate.ParameterArg nArg = n ?? default; + if (nArg.IsLiteral) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetROSpan, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetROSpan", nArg.Literal!, () => $"GetROSpan({nArg})"); + } + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetROSpan, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetROSpan", nArg.ToParameterMatch(), () => $"GetROSpan({nArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.GetROSpan(global::System.Func n, string nExpression) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetROSpan, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetROSpan", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(n, nExpression), () => $"GetROSpan({nExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.GetByRef() + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetByRef, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetByRef", () => $"GetByRef()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.GetByRefReadonly() + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetByRefReadonly, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetByRefReadonly", () => $"GetByRefReadonly()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.G1() + => this.MockRegistry.VerifyMethod(this, -1, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G1<{typeof(T)}>", __i => true, () => $"G1()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.G2() + => this.MockRegistry.VerifyMethod(this, -1, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G2<{typeof(T)}>", __i => true, () => $"G2()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.G3() + => this.MockRegistry.VerifyMethod(this, -1, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G3<{typeof(T)}>", __i => true, () => $"G3()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.G4() + => this.MockRegistry.VerifyMethod(this, -1, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G4<{typeof(T)}>", __i => true, () => $"G4()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.G5() + => this.MockRegistry.VerifyMethod(this, -1, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G5<{typeof(T)}>", __i => true, () => $"G5()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.G6() + => this.MockRegistry.VerifyMethod(this, -1, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G6<{typeof(T)}>", __i => true, () => $"G6()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.G7() + => this.MockRegistry.VerifyMethod(this, -1, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G7<{typeof(T)}>", __i => true, () => $"G7()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.G8() + => this.MockRegistry.VerifyMethod(this, -1, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G8<{typeof(T)}>", __i => true, () => $"G8()"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.Five(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Five, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.Five", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2, __i.Parameter3, __i.Parameter4, __i.Parameter5]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("a", __i.Parameter1), ("b", __i.Parameter2), ("c", __i.Parameter3), ("d", __i.Parameter4), ("e", __i.Parameter5)]), + _ => true + }, () => $"Five({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.Five(global::Mockolate.ParameterArg? a, global::Mockolate.ParameterArg? b, global::Mockolate.ParameterArg? c, global::Mockolate.ParameterArg? d, global::Mockolate.ParameterArg? e) + { + global::Mockolate.ParameterArg aArg = a ?? default; + global::Mockolate.ParameterArg bArg = b ?? default; + global::Mockolate.ParameterArg cArg = c ?? default; + global::Mockolate.ParameterArg dArg = d ?? default; + global::Mockolate.ParameterArg eArg = e ?? default; + global::Mockolate.Parameters.IParameterMatch aMatch = aArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch bMatch = bArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch cMatch = cArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch dMatch = dArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch eMatch = eArg.ToParameterMatch(); + return this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Five, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.Five", __i => + (aMatch.Matches(__i.Parameter1)) && + (bMatch.Matches(__i.Parameter2)) && + (cMatch.Matches(__i.Parameter3)) && + (dMatch.Matches(__i.Parameter4)) && + (eMatch.Matches(__i.Parameter5)), () => $"Five({aArg}, {bArg}, {cArg}, {dArg}, {eArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.Seventeen(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Seventeen, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.Seventeen", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2, __i.Parameter3, __i.Parameter4, __i.Parameter5, __i.Parameter6, __i.Parameter7, __i.Parameter8, __i.Parameter9, __i.Parameter10, __i.Parameter11, __i.Parameter12, __i.Parameter13, __i.Parameter14, __i.Parameter15, __i.Parameter16, __i.Parameter17]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("a1", __i.Parameter1), ("a2", __i.Parameter2), ("a3", __i.Parameter3), ("a4", __i.Parameter4), ("a5", __i.Parameter5), ("a6", __i.Parameter6), ("a7", __i.Parameter7), ("a8", __i.Parameter8), ("a9", __i.Parameter9), ("a10", __i.Parameter10), ("a11", __i.Parameter11), ("a12", __i.Parameter12), ("a13", __i.Parameter13), ("a14", __i.Parameter14), ("a15", __i.Parameter15), ("a16", __i.Parameter16), ("a17", __i.Parameter17)]), + _ => true + }, () => $"Seventeen({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.Seventeen(global::Mockolate.ParameterArg? a1, global::Mockolate.ParameterArg? a2, global::Mockolate.ParameterArg? a3, global::Mockolate.ParameterArg? a4, global::Mockolate.ParameterArg? a5, global::Mockolate.ParameterArg? a6, global::Mockolate.ParameterArg? a7, global::Mockolate.ParameterArg? a8, global::Mockolate.ParameterArg? a9, global::Mockolate.ParameterArg? a10, global::Mockolate.ParameterArg? a11, global::Mockolate.ParameterArg? a12, global::Mockolate.ParameterArg? a13, global::Mockolate.ParameterArg? a14, global::Mockolate.ParameterArg? a15, global::Mockolate.ParameterArg? a16, global::Mockolate.ParameterArg? a17) + { + global::Mockolate.ParameterArg a1Arg = a1 ?? default; + global::Mockolate.ParameterArg a2Arg = a2 ?? default; + global::Mockolate.ParameterArg a3Arg = a3 ?? default; + global::Mockolate.ParameterArg a4Arg = a4 ?? default; + global::Mockolate.ParameterArg a5Arg = a5 ?? default; + global::Mockolate.ParameterArg a6Arg = a6 ?? default; + global::Mockolate.ParameterArg a7Arg = a7 ?? default; + global::Mockolate.ParameterArg a8Arg = a8 ?? default; + global::Mockolate.ParameterArg a9Arg = a9 ?? default; + global::Mockolate.ParameterArg a10Arg = a10 ?? default; + global::Mockolate.ParameterArg a11Arg = a11 ?? default; + global::Mockolate.ParameterArg a12Arg = a12 ?? default; + global::Mockolate.ParameterArg a13Arg = a13 ?? default; + global::Mockolate.ParameterArg a14Arg = a14 ?? default; + global::Mockolate.ParameterArg a15Arg = a15 ?? default; + global::Mockolate.ParameterArg a16Arg = a16 ?? default; + global::Mockolate.ParameterArg a17Arg = a17 ?? default; + global::Mockolate.Parameters.IParameterMatch a1Match = a1Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a2Match = a2Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a3Match = a3Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a4Match = a4Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a5Match = a5Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a6Match = a6Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a7Match = a7Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a8Match = a8Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a9Match = a9Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a10Match = a10Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a11Match = a11Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a12Match = a12Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a13Match = a13Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a14Match = a14Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a15Match = a15Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a16Match = a16Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a17Match = a17Arg.ToParameterMatch(); + return this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Seventeen, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.Seventeen", __i => + (a1Match.Matches(__i.Parameter1)) && + (a2Match.Matches(__i.Parameter2)) && + (a3Match.Matches(__i.Parameter3)) && + (a4Match.Matches(__i.Parameter4)) && + (a5Match.Matches(__i.Parameter5)) && + (a6Match.Matches(__i.Parameter6)) && + (a7Match.Matches(__i.Parameter7)) && + (a8Match.Matches(__i.Parameter8)) && + (a9Match.Matches(__i.Parameter9)) && + (a10Match.Matches(__i.Parameter10)) && + (a11Match.Matches(__i.Parameter11)) && + (a12Match.Matches(__i.Parameter12)) && + (a13Match.Matches(__i.Parameter13)) && + (a14Match.Matches(__i.Parameter14)) && + (a15Match.Matches(__i.Parameter15)) && + (a16Match.Matches(__i.Parameter16)) && + (a17Match.Matches(__i.Parameter17)), () => $"Seventeen({a1Arg}, {a2Arg}, {a3Arg}, {a4Arg}, {a5Arg}, {a6Arg}, {a7Arg}, {a8Arg}, {a9Arg}, {a10Arg}, {a11Arg}, {a12Arg}, {a13Arg}, {a14Arg}, {a15Arg}, {a16Arg}, {a17Arg})"); + } + + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.SeventeenVoid(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_SeventeenVoid, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.SeventeenVoid", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2, __i.Parameter3, __i.Parameter4, __i.Parameter5, __i.Parameter6, __i.Parameter7, __i.Parameter8, __i.Parameter9, __i.Parameter10, __i.Parameter11, __i.Parameter12, __i.Parameter13, __i.Parameter14, __i.Parameter15, __i.Parameter16, __i.Parameter17]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("a1", __i.Parameter1), ("a2", __i.Parameter2), ("a3", __i.Parameter3), ("a4", __i.Parameter4), ("a5", __i.Parameter5), ("a6", __i.Parameter6), ("a7", __i.Parameter7), ("a8", __i.Parameter8), ("a9", __i.Parameter9), ("a10", __i.Parameter10), ("a11", __i.Parameter11), ("a12", __i.Parameter12), ("a13", __i.Parameter13), ("a14", __i.Parameter14), ("a15", __i.Parameter15), ("a16", __i.Parameter16), ("a17", __i.Parameter17)]), + _ => true + }, () => $"SeventeenVoid({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.SeventeenVoid(global::Mockolate.ParameterArg? a1, global::Mockolate.ParameterArg? a2, global::Mockolate.ParameterArg? a3, global::Mockolate.ParameterArg? a4, global::Mockolate.ParameterArg? a5, global::Mockolate.ParameterArg? a6, global::Mockolate.ParameterArg? a7, global::Mockolate.ParameterArg? a8, global::Mockolate.ParameterArg? a9, global::Mockolate.ParameterArg? a10, global::Mockolate.ParameterArg? a11, global::Mockolate.ParameterArg? a12, global::Mockolate.ParameterArg? a13, global::Mockolate.ParameterArg? a14, global::Mockolate.ParameterArg? a15, global::Mockolate.ParameterArg? a16, global::Mockolate.ParameterArg? a17) + { + global::Mockolate.ParameterArg a1Arg = a1 ?? default; + global::Mockolate.ParameterArg a2Arg = a2 ?? default; + global::Mockolate.ParameterArg a3Arg = a3 ?? default; + global::Mockolate.ParameterArg a4Arg = a4 ?? default; + global::Mockolate.ParameterArg a5Arg = a5 ?? default; + global::Mockolate.ParameterArg a6Arg = a6 ?? default; + global::Mockolate.ParameterArg a7Arg = a7 ?? default; + global::Mockolate.ParameterArg a8Arg = a8 ?? default; + global::Mockolate.ParameterArg a9Arg = a9 ?? default; + global::Mockolate.ParameterArg a10Arg = a10 ?? default; + global::Mockolate.ParameterArg a11Arg = a11 ?? default; + global::Mockolate.ParameterArg a12Arg = a12 ?? default; + global::Mockolate.ParameterArg a13Arg = a13 ?? default; + global::Mockolate.ParameterArg a14Arg = a14 ?? default; + global::Mockolate.ParameterArg a15Arg = a15 ?? default; + global::Mockolate.ParameterArg a16Arg = a16 ?? default; + global::Mockolate.ParameterArg a17Arg = a17 ?? default; + global::Mockolate.Parameters.IParameterMatch a1Match = a1Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a2Match = a2Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a3Match = a3Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a4Match = a4Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a5Match = a5Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a6Match = a6Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a7Match = a7Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a8Match = a8Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a9Match = a9Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a10Match = a10Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a11Match = a11Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a12Match = a12Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a13Match = a13Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a14Match = a14Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a15Match = a15Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a16Match = a16Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a17Match = a17Arg.ToParameterMatch(); + return this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_SeventeenVoid, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.SeventeenVoid", __i => + (a1Match.Matches(__i.Parameter1)) && + (a2Match.Matches(__i.Parameter2)) && + (a3Match.Matches(__i.Parameter3)) && + (a4Match.Matches(__i.Parameter4)) && + (a5Match.Matches(__i.Parameter5)) && + (a6Match.Matches(__i.Parameter6)) && + (a7Match.Matches(__i.Parameter7)) && + (a8Match.Matches(__i.Parameter8)) && + (a9Match.Matches(__i.Parameter9)) && + (a10Match.Matches(__i.Parameter10)) && + (a11Match.Matches(__i.Parameter11)) && + (a12Match.Matches(__i.Parameter12)) && + (a13Match.Matches(__i.Parameter13)) && + (a14Match.Matches(__i.Parameter14)) && + (a15Match.Matches(__i.Parameter15)) && + (a16Match.Matches(__i.Parameter16)) && + (a17Match.Matches(__i.Parameter17)), () => $"SeventeenVoid({a1Arg}, {a2Arg}, {a3Arg}, {a4Arg}, {a5Arg}, {a6Arg}, {a7Arg}, {a8Arg}, {a9Arg}, {a10Arg}, {a11Arg}, {a12Arg}, {a13Arg}, {a14Arg}, {a15Arg}, {a16Arg}, {a17Arg})"); + } + + /// + /// Verify subscriptions on the PlainEvent event PlainEvent. + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationEventResult IMockVerifyForIComprehensiveInterface.PlainEvent + { + get + { + return new global::Mockolate.Verify.VerificationEventResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_PlainEvent_Subscribe, global::Mockolate.Mock.IComprehensiveInterface.MemberId_PlainEvent_Unsubscribe, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.PlainEvent"); + } + } + + /// + /// Verify subscriptions on the TypedEvent event TypedEvent. + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationEventResult IMockVerifyForIComprehensiveInterface.TypedEvent + { + get + { + return new global::Mockolate.Verify.VerificationEventResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TypedEvent_Subscribe, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TypedEvent_Unsubscribe, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TypedEvent"); + } + } + + /// + /// Verify subscriptions on the CustomEvent event CustomEvent. + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationEventResult IMockVerifyForIComprehensiveInterface.CustomEvent + { + get + { + return new global::Mockolate.Verify.VerificationEventResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_CustomEvent_Subscribe, global::Mockolate.Mock.IComprehensiveInterface.MemberId_CustomEvent_Unsubscribe, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.CustomEvent"); + } + } + + #endregion IMockVerifyForIComprehensiveInterface + + #region IMockStaticVerifyForIComprehensiveInterface + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationPropertyGetterResult IMockStaticVerifyForIComprehensiveInterface.StaticAbstractValue + { + get + { + return new global::Mockolate.Verify.VerificationPropertyGetterResult(this, this.MockRegistry, -1, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.StaticAbstractValue"); + } + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockStaticVerifyForIComprehensiveInterface.StaticAbstractMethod() + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_StaticAbstractMethod, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.StaticAbstractMethod", () => $"StaticAbstractMethod()"); + #endregion IMockStaticVerifyForIComprehensiveInterface + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class VerifyMonitorIComprehensiveInterface(global::Mockolate.MockRegistry mockRegistry) : global::Mockolate.Mock.IMockVerifyForIComprehensiveInterface + { + private global::Mockolate.MockRegistry MockRegistry { get; } = mockRegistry; + + #region IMockVerifyForIComprehensiveInterface + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationPropertyResult IMockVerifyForIComprehensiveInterface.GetSet + { + get + { + return new global::Mockolate.Verify.VerificationPropertyResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSet_Get, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSet_Set, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSet"); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationPropertyGetterResult IMockVerifyForIComprehensiveInterface.GetOnly + { + get + { + return new global::Mockolate.Verify.VerificationPropertyGetterResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetOnly_Get, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetOnly"); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationPropertySetterResult IMockVerifyForIComprehensiveInterface.SetOnly + { + get + { + return new global::Mockolate.Verify.VerificationPropertySetterResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_SetOnly_Set, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.SetOnly"); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationPropertyResult IMockVerifyForIComprehensiveInterface.NullableProp + { + get + { + return new global::Mockolate.Verify.VerificationPropertyResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_NullableProp_Get, global::Mockolate.Mock.IComprehensiveInterface.MemberId_NullableProp_Set, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.NullableProp"); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationPropertyResult IMockVerifyForIComprehensiveInterface.InitOnly + { + get + { + return new global::Mockolate.Verify.VerificationPropertyResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_InitOnly_Get, global::Mockolate.Mock.IComprehensiveInterface.MemberId_InitOnly_Set, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.InitOnly"); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIComprehensiveInterface.this[global::Mockolate.Parameters.IParameter? i] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_int_Get, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_int_Set, + CovariantParameterAdapter.Wrap(i ?? global::Mockolate.It.IsNull("null")), + () => global::System.String.Format("[{0}]", (object?)i ?? "null")); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIComprehensiveInterface.this[int i] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_int_Get, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_int_Set, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(i, "i"), + () => global::System.String.Format("[{0}]", (object?)i)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIComprehensiveInterface.this[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] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, -1, -1, + interaction => interaction is global::Mockolate.Interactions.IndexerGetterAccess g && CovariantParameterAdapter.Wrap(a ?? global::Mockolate.It.IsNull("null")).Matches(g.Parameter1) && CovariantParameterAdapter.Wrap(b ?? global::Mockolate.It.IsNull("null")).Matches(g.Parameter2) && CovariantParameterAdapter.Wrap(c ?? global::Mockolate.It.IsNull("null")).Matches(g.Parameter3) && CovariantParameterAdapter.Wrap(d ?? global::Mockolate.It.IsNull("null")).Matches(g.Parameter4) && CovariantParameterAdapter.Wrap(e ?? global::Mockolate.It.IsNull("null")).Matches(g.Parameter5), + (interaction, value) => interaction is global::Mockolate.Interactions.IndexerSetterAccess s && CovariantParameterAdapter.Wrap(a ?? global::Mockolate.It.IsNull("null")).Matches(s.Parameter1) && CovariantParameterAdapter.Wrap(b ?? global::Mockolate.It.IsNull("null")).Matches(s.Parameter2) && CovariantParameterAdapter.Wrap(c ?? global::Mockolate.It.IsNull("null")).Matches(s.Parameter3) && CovariantParameterAdapter.Wrap(d ?? global::Mockolate.It.IsNull("null")).Matches(s.Parameter4) && CovariantParameterAdapter.Wrap(e ?? global::Mockolate.It.IsNull("null")).Matches(s.Parameter5) && value.Matches(s.TypedValue), + () => global::System.String.Format("[{0}, {1}, {2}, {3}, {4}]", (object?)a ?? "null", (object?)b ?? "null", (object?)c ?? "null", (object?)d ?? "null", (object?)e ?? "null")); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIComprehensiveInterface.this[int a, int b, int c, int d, int e] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, -1, -1, + interaction => interaction is global::Mockolate.Interactions.IndexerGetterAccess g && global::System.Collections.Generic.EqualityComparer.Default.Equals(a, g.Parameter1) && global::System.Collections.Generic.EqualityComparer.Default.Equals(b, g.Parameter2) && global::System.Collections.Generic.EqualityComparer.Default.Equals(c, g.Parameter3) && global::System.Collections.Generic.EqualityComparer.Default.Equals(d, g.Parameter4) && global::System.Collections.Generic.EqualityComparer.Default.Equals(e, g.Parameter5), + (interaction, value) => interaction is global::Mockolate.Interactions.IndexerSetterAccess s && global::System.Collections.Generic.EqualityComparer.Default.Equals(a, s.Parameter1) && global::System.Collections.Generic.EqualityComparer.Default.Equals(b, s.Parameter2) && global::System.Collections.Generic.EqualityComparer.Default.Equals(c, s.Parameter3) && global::System.Collections.Generic.EqualityComparer.Default.Equals(d, s.Parameter4) && global::System.Collections.Generic.EqualityComparer.Default.Equals(e, s.Parameter5) && value.Matches(s.TypedValue), + () => global::System.String.Format("[{0}, {1}, {2}, {3}, {4}]", (object?)a, (object?)b, (object?)c, (object?)d, (object?)e)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult IMockVerifyForIComprehensiveInterface.this[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] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult(this, this.MockRegistry, -1, + interaction => interaction is global::Mockolate.Interactions.IndexerGetterAccess g && CovariantParameterAdapter.Wrap(a ?? global::Mockolate.It.IsNull("null")).Matches(g.Parameter1) && CovariantParameterAdapter.Wrap(b ?? global::Mockolate.It.IsNull("null")).Matches(g.Parameter2) && CovariantParameterAdapter.Wrap(c ?? global::Mockolate.It.IsNull("null")).Matches(g.Parameter3) && CovariantParameterAdapter.Wrap(d ?? global::Mockolate.It.IsNull("null")).Matches(g.Parameter4) && CovariantParameterAdapter.Wrap(e ?? global::Mockolate.It.IsNull("null")).Matches(g.Parameter5), + () => global::System.String.Format("[{0}, {1}, {2}, {3}, {4}]", (object?)a ?? "null", (object?)b ?? "null", (object?)c ?? "null", (object?)d ?? "null", (object?)e ?? "null")); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult IMockVerifyForIComprehensiveInterface.this[byte a, byte b, byte c, byte d, byte e] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult(this, this.MockRegistry, -1, + interaction => interaction is global::Mockolate.Interactions.IndexerGetterAccess g && global::System.Collections.Generic.EqualityComparer.Default.Equals(a, g.Parameter1) && global::System.Collections.Generic.EqualityComparer.Default.Equals(b, g.Parameter2) && global::System.Collections.Generic.EqualityComparer.Default.Equals(c, g.Parameter3) && global::System.Collections.Generic.EqualityComparer.Default.Equals(d, g.Parameter4) && global::System.Collections.Generic.EqualityComparer.Default.Equals(e, g.Parameter5), + () => global::System.String.Format("[{0}, {1}, {2}, {3}, {4}]", (object?)a, (object?)b, (object?)c, (object?)d, (object?)e)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIComprehensiveInterface.this[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] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, -1, + (interaction, value) => interaction is global::Mockolate.Interactions.IndexerSetterAccess s && CovariantParameterAdapter.Wrap(a ?? global::Mockolate.It.IsNull("null")).Matches(s.Parameter1) && CovariantParameterAdapter.Wrap(b ?? global::Mockolate.It.IsNull("null")).Matches(s.Parameter2) && CovariantParameterAdapter.Wrap(c ?? global::Mockolate.It.IsNull("null")).Matches(s.Parameter3) && CovariantParameterAdapter.Wrap(d ?? global::Mockolate.It.IsNull("null")).Matches(s.Parameter4) && CovariantParameterAdapter.Wrap(e ?? global::Mockolate.It.IsNull("null")).Matches(s.Parameter5) && value.Matches(s.TypedValue), + () => global::System.String.Format("[{0}, {1}, {2}, {3}, {4}]", (object?)a ?? "null", (object?)b ?? "null", (object?)c ?? "null", (object?)d ?? "null", (object?)e ?? "null")); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIComprehensiveInterface.this[short a, short b, short c, short d, short e] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, -1, + (interaction, value) => interaction is global::Mockolate.Interactions.IndexerSetterAccess s && global::System.Collections.Generic.EqualityComparer.Default.Equals(a, s.Parameter1) && global::System.Collections.Generic.EqualityComparer.Default.Equals(b, s.Parameter2) && global::System.Collections.Generic.EqualityComparer.Default.Equals(c, s.Parameter3) && global::System.Collections.Generic.EqualityComparer.Default.Equals(d, s.Parameter4) && global::System.Collections.Generic.EqualityComparer.Default.Equals(e, s.Parameter5) && value.Matches(s.TypedValue), + () => global::System.String.Format("[{0}, {1}, {2}, {3}, {4}]", (object?)a, (object?)b, (object?)c, (object?)d, (object?)e)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult IMockVerifyForIComprehensiveInterface.this[global::Mockolate.Parameters.IParameter? key] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_double_Get, + CovariantParameterAdapter.Wrap(key ?? global::Mockolate.It.IsNull("null")), + () => global::System.String.Format("[{0}]", (object?)key ?? "null")); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult IMockVerifyForIComprehensiveInterface.this[double key] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_double_Get, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(key, "key"), + () => global::System.String.Format("[{0}]", (object?)key)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIComprehensiveInterface.this[global::Mockolate.Parameters.IParameter? key] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_char_Set, + CovariantParameterAdapter.Wrap(key ?? global::Mockolate.It.IsNull("null")), + () => global::System.String.Format("[{0}]", (object?)key ?? "null")); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIComprehensiveInterface.this[char key] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_char_Set, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(key, "key"), + () => global::System.String.Format("[{0}]", (object?)key)); + } + } + + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2, __i.Parameter3, __i.Parameter4]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("a", __i.Parameter1), ("b", __i.Parameter2), ("c", __i.Parameter3), ("tail", __i.Parameter4)]), + _ => true + }, () => $"WithModifiers({parameters})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IVerifyRefParameter a, global::Mockolate.Parameters.IVerifyOutParameter b, global::Mockolate.Parameters.IParameter? c, global::Mockolate.Parameters.IParameter? tail) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", __i => + (a is global::Mockolate.Parameters.IParameterMatch aMatch ? aMatch.Matches(__i.Parameter1) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter1, default(int))) && + (b is global::Mockolate.Parameters.IParameterMatch bMatch ? bMatch.Matches(__i.Parameter2) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter2, default(string))) && + (c is not null ? CovariantParameterAdapter.Wrap(c).Matches(__i.Parameter3) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter3, default(long))) && + (tail is not null ? CovariantParameterAdapter.Wrap(tail).Matches(__i.Parameter4) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter4, default(int[]))), () => $"WithModifiers({a}, {b}, {c}, {tail})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IVerifyRefParameter a, global::Mockolate.Parameters.IVerifyOutParameter b, global::Mockolate.Parameters.IParameter? c, params global::Mockolate.Parameters.IParameter[] tail) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", __i => + (a is global::Mockolate.Parameters.IParameterMatch aMatch ? aMatch.Matches(__i.Parameter1) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter1, default(int))) && + (b is global::Mockolate.Parameters.IParameterMatch bMatch ? bMatch.Matches(__i.Parameter2) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter2, default(string))) && + (c is not null ? CovariantParameterAdapter.Wrap(c).Matches(__i.Parameter3) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter3, default(long))) && + (new global::Mockolate.Parameters.ParamsArrayParameterMatch(tail).Matches(__i.Parameter4)), () => $"WithModifiers({a}, {b}, {c}, {tail})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IVerifyRefParameter a, global::Mockolate.Parameters.IVerifyOutParameter b, long c, global::Mockolate.Parameters.IParameter? tail) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", __i => + (a is global::Mockolate.Parameters.IParameterMatch aMatch ? aMatch.Matches(__i.Parameter1) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter1, default(int))) && + (b is global::Mockolate.Parameters.IParameterMatch bMatch ? bMatch.Matches(__i.Parameter2) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter2, default(string))) && + (global::System.Collections.Generic.EqualityComparer.Default.Equals(c, __i.Parameter3)) && + (tail is not null ? CovariantParameterAdapter.Wrap(tail).Matches(__i.Parameter4) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter4, default(int[]))), () => $"WithModifiers({a}, {b}, {c}, {tail})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IVerifyRefParameter a, global::Mockolate.Parameters.IVerifyOutParameter b, global::Mockolate.Parameters.IParameter? c, params int[] tail) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", __i => + (a is global::Mockolate.Parameters.IParameterMatch aMatch ? aMatch.Matches(__i.Parameter1) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter1, default(int))) && + (b is global::Mockolate.Parameters.IParameterMatch bMatch ? bMatch.Matches(__i.Parameter2) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter2, default(string))) && + (c is not null ? CovariantParameterAdapter.Wrap(c).Matches(__i.Parameter3) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter3, default(long))) && + (CovariantParameterAdapter.Wrap(global::Mockolate.It.SequenceEquals(tail)).Matches(__i.Parameter4)), () => $"WithModifiers({a}, {b}, {c}, {tail})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IVerifyRefParameter a, global::Mockolate.Parameters.IVerifyOutParameter b, long c, params int[] tail) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", __i => + (a is global::Mockolate.Parameters.IParameterMatch aMatch ? aMatch.Matches(__i.Parameter1) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter1, default(int))) && + (b is global::Mockolate.Parameters.IParameterMatch bMatch ? bMatch.Matches(__i.Parameter2) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter2, default(string))) && + (global::System.Collections.Generic.EqualityComparer.Default.Equals(c, __i.Parameter3)) && + (CovariantParameterAdapter.Wrap(global::Mockolate.It.SequenceEquals(tail)).Matches(__i.Parameter4)), () => $"WithModifiers({a}, {b}, {c}, {tail})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.WithDefaults(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithDefaults, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithDefaults", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2, __i.Parameter3, __i.Parameter4, __i.Parameter5, __i.Parameter6, __i.Parameter7]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("i", __i.Parameter1), ("e", __i.Parameter2), ("d", __i.Parameter3), ("f", __i.Parameter4), ("c", __i.Parameter5), ("s", __i.Parameter6), ("st", __i.Parameter7)]), + _ => true + }, () => $"WithDefaults({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.WithDefaults(global::Mockolate.ParameterArg? i, global::Mockolate.ParameterArg? e, global::Mockolate.ParameterArg? d, global::Mockolate.ParameterArg? f, global::Mockolate.ParameterArg? c, global::Mockolate.ParameterArg? s, global::Mockolate.ParameterArg? st) + { + global::Mockolate.ParameterArg iArg = i ?? new global::Mockolate.ParameterArg((int)(5)); + global::Mockolate.ParameterArg eArg = e ?? new global::Mockolate.ParameterArg((global::Mockolate.Tests.GeneratorCoverage.MyEnum)((global::Mockolate.Tests.GeneratorCoverage.MyEnum)1)); + global::Mockolate.ParameterArg dArg = d ?? new global::Mockolate.ParameterArg((decimal)(1.5m)); + global::Mockolate.ParameterArg fArg = f ?? new global::Mockolate.ParameterArg((float)(0.25f)); + global::Mockolate.ParameterArg cArg = c ?? new global::Mockolate.ParameterArg((char)('x')); + global::Mockolate.ParameterArg sArg = s ?? new global::Mockolate.ParameterArg((string?)(null)); + global::Mockolate.ParameterArg stArg = st ?? new global::Mockolate.ParameterArg((global::Mockolate.Tests.GeneratorCoverage.MyStruct)(default)); + global::Mockolate.Parameters.IParameterMatch iMatch = iArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch eMatch = eArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch dMatch = dArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch fMatch = fArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch cMatch = cArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch sMatch = sArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch stMatch = stArg.ToParameterMatch(); + return this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithDefaults, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithDefaults", __i => + (iMatch.Matches(__i.Parameter1)) && + (eMatch.Matches(__i.Parameter2)) && + (dMatch.Matches(__i.Parameter3)) && + (fMatch.Matches(__i.Parameter4)) && + (cMatch.Matches(__i.Parameter5)) && + (sMatch.Matches(__i.Parameter6)) && + (stMatch.Matches(__i.Parameter7)), () => $"WithDefaults({iArg}, {eArg}, {dArg}, {fArg}, {cArg}, {sArg}, {stArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.WithCollidingNames(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithCollidingNames, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithCollidingNames", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2, __i.Parameter3, __i.Parameter4, __i.Parameter5]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("wraps", __i.Parameter1), ("result", __i.Parameter2), ("outParam1", __i.Parameter3), ("methodExecution", __i.Parameter4), ("returnValue", __i.Parameter5)]), + _ => true + }, () => $"WithCollidingNames({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.WithCollidingNames(global::Mockolate.ParameterArg? wraps, global::Mockolate.ParameterArg? result, global::Mockolate.ParameterArg? outParam1, global::Mockolate.ParameterArg? methodExecution, global::Mockolate.ParameterArg? returnValue) + { + global::Mockolate.ParameterArg wrapsArg = wraps ?? default; + global::Mockolate.ParameterArg resultArg = result ?? default; + global::Mockolate.ParameterArg outParam1Arg = outParam1 ?? default; + global::Mockolate.ParameterArg methodExecutionArg = methodExecution ?? default; + global::Mockolate.ParameterArg returnValueArg = returnValue ?? default; + global::Mockolate.Parameters.IParameterMatch wrapsMatch = wrapsArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch resultMatch = resultArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch outParam1Match = outParam1Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch methodExecutionMatch = methodExecutionArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch returnValueMatch = returnValueArg.ToParameterMatch(); + return this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithCollidingNames, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithCollidingNames", __i => + (wrapsMatch.Matches(__i.Parameter1)) && + (resultMatch.Matches(__i.Parameter2)) && + (outParam1Match.Matches(__i.Parameter3)) && + (methodExecutionMatch.Matches(__i.Parameter4)) && + (returnValueMatch.Matches(__i.Parameter5)), () => $"WithCollidingNames({wrapsArg}, {resultArg}, {outParam1Arg}, {methodExecutionArg}, {returnValueArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.GetMaybeNull(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetMaybeNull, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetMaybeNull", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("s", __i.Parameter1)]), + _ => true + }, () => $"GetMaybeNull({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.GetMaybeNull(global::Mockolate.ParameterArg? s) + { + global::Mockolate.ParameterArg sArg = s ?? default; + if (sArg.IsLiteral) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetMaybeNull, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetMaybeNull", sArg.Literal!, () => $"GetMaybeNull({sArg})"); + } + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetMaybeNull, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetMaybeNull", sArg.ToParameterMatch(), () => $"GetMaybeNull({sArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.GetMaybeNull(global::System.Func s, string sExpression) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetMaybeNull, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetMaybeNull", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(s, sExpression), () => $"GetMaybeNull({sExpression})"); + } + + /// + 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.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeObject(global::Mockolate.ParameterArg? obj) + { + global::Mockolate.ParameterArg objArg = obj ?? default; + if (objArg.IsLiteral) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", objArg.Literal!, () => $"TakeObject({objArg})"); + } + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", objArg.ToParameterMatch(), () => $"TakeObject({objArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeObject(global::System.Func obj, string objExpression) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(obj, objExpression), () => $"TakeObject({objExpression})"); + } + + /// + 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.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeTwoObjects(global::Mockolate.ParameterArg? first, global::Mockolate.ParameterArg? second) + { + global::Mockolate.ParameterArg firstArg = first ?? default; + global::Mockolate.ParameterArg secondArg = second ?? default; + if (firstArg.IsLiteral && secondArg.IsLiteral) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", firstArg.Literal!, secondArg.Literal!, () => $"TakeTwoObjects({firstArg}, {secondArg})"); + } + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", firstArg.ToParameterMatch(), secondArg.ToParameterMatch(), () => $"TakeTwoObjects({firstArg}, {secondArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeTwoObjects(global::System.Func first, global::Mockolate.ParameterArg? second, string firstExpression) + { + global::Mockolate.ParameterArg secondArg = second ?? default; + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(first, firstExpression), secondArg.ToParameterMatch(), () => $"TakeTwoObjects({firstExpression}, {secondArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeTwoObjects(global::Mockolate.ParameterArg? first, global::System.Func second, string secondExpression) + { + global::Mockolate.ParameterArg firstArg = first ?? default; + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", firstArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(second, secondExpression), () => $"TakeTwoObjects({firstArg}, {secondExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeTwoObjects(global::System.Func first, global::System.Func second, string firstExpression, string secondExpression) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(first, firstExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(second, secondExpression), () => $"TakeTwoObjects({firstExpression}, {secondExpression})"); + } + + /// + 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.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeIntAndObject(global::Mockolate.ParameterArg? n, global::Mockolate.ParameterArg? obj) + { + global::Mockolate.ParameterArg nArg = n ?? default; + global::Mockolate.ParameterArg objArg = obj ?? default; + if (nArg.IsLiteral && objArg.IsLiteral) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", nArg.Literal!, objArg.Literal!, () => $"TakeIntAndObject({nArg}, {objArg})"); + } + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", nArg.ToParameterMatch(), objArg.ToParameterMatch(), () => $"TakeIntAndObject({nArg}, {objArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeIntAndObject(global::System.Func n, global::Mockolate.ParameterArg? obj, string nExpression) + { + global::Mockolate.ParameterArg objArg = obj ?? default; + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(n, nExpression), objArg.ToParameterMatch(), () => $"TakeIntAndObject({nExpression}, {objArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeIntAndObject(global::Mockolate.ParameterArg? n, global::System.Func obj, string objExpression) + { + global::Mockolate.ParameterArg nArg = n ?? default; + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", nArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(obj, objExpression), () => $"TakeIntAndObject({nArg}, {objExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.TakeIntAndObject(global::System.Func n, global::System.Func obj, string nExpression, string objExpression) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(n, nExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(obj, objExpression), () => $"TakeIntAndObject({nExpression}, {objExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.DoTask() + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_DoTask, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoTask", () => $"DoTask()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.DoTaskOf() + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_DoTaskOf, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoTaskOf", () => $"DoTaskOf()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.DoVT() + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_DoVT, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoVT", () => $"DoVT()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.DoVTOf() + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_DoVTOf, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoVTOf", () => $"DoVTOf()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.GetTuple() + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetTuple, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetTuple", () => $"GetTuple()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.GetNullable() + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetNullable, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetNullable", () => $"GetNullable()"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.GetSpan(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSpan, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSpan", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("n", __i.Parameter1)]), + _ => true + }, () => $"GetSpan({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.GetSpan(global::Mockolate.ParameterArg? n) + { + global::Mockolate.ParameterArg nArg = n ?? default; + if (nArg.IsLiteral) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSpan, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSpan", nArg.Literal!, () => $"GetSpan({nArg})"); + } + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSpan, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSpan", nArg.ToParameterMatch(), () => $"GetSpan({nArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.GetSpan(global::System.Func n, string nExpression) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSpan, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSpan", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(n, nExpression), () => $"GetSpan({nExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.GetROSpan(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetROSpan, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetROSpan", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("n", __i.Parameter1)]), + _ => true + }, () => $"GetROSpan({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.GetROSpan(global::Mockolate.ParameterArg? n) + { + global::Mockolate.ParameterArg nArg = n ?? default; + if (nArg.IsLiteral) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetROSpan, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetROSpan", nArg.Literal!, () => $"GetROSpan({nArg})"); + } + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetROSpan, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetROSpan", nArg.ToParameterMatch(), () => $"GetROSpan({nArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.GetROSpan(global::System.Func n, string nExpression) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetROSpan, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetROSpan", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(n, nExpression), () => $"GetROSpan({nExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.GetByRef() + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetByRef, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetByRef", () => $"GetByRef()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.GetByRefReadonly() + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetByRefReadonly, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetByRefReadonly", () => $"GetByRefReadonly()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.G1() + => this.MockRegistry.VerifyMethod(this, -1, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G1<{typeof(T)}>", __i => true, () => $"G1()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.G2() + => this.MockRegistry.VerifyMethod(this, -1, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G2<{typeof(T)}>", __i => true, () => $"G2()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.G3() + => this.MockRegistry.VerifyMethod(this, -1, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G3<{typeof(T)}>", __i => true, () => $"G3()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.G4() + => this.MockRegistry.VerifyMethod(this, -1, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G4<{typeof(T)}>", __i => true, () => $"G4()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.G5() + => this.MockRegistry.VerifyMethod(this, -1, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G5<{typeof(T)}>", __i => true, () => $"G5()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.G6() + => this.MockRegistry.VerifyMethod(this, -1, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G6<{typeof(T)}>", __i => true, () => $"G6()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.G7() + => this.MockRegistry.VerifyMethod(this, -1, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G7<{typeof(T)}>", __i => true, () => $"G7()"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.G8() + => this.MockRegistry.VerifyMethod(this, -1, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G8<{typeof(T)}>", __i => true, () => $"G8()"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.Five(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Five, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.Five", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2, __i.Parameter3, __i.Parameter4, __i.Parameter5]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("a", __i.Parameter1), ("b", __i.Parameter2), ("c", __i.Parameter3), ("d", __i.Parameter4), ("e", __i.Parameter5)]), + _ => true + }, () => $"Five({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.Five(global::Mockolate.ParameterArg? a, global::Mockolate.ParameterArg? b, global::Mockolate.ParameterArg? c, global::Mockolate.ParameterArg? d, global::Mockolate.ParameterArg? e) + { + global::Mockolate.ParameterArg aArg = a ?? default; + global::Mockolate.ParameterArg bArg = b ?? default; + global::Mockolate.ParameterArg cArg = c ?? default; + global::Mockolate.ParameterArg dArg = d ?? default; + global::Mockolate.ParameterArg eArg = e ?? default; + global::Mockolate.Parameters.IParameterMatch aMatch = aArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch bMatch = bArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch cMatch = cArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch dMatch = dArg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch eMatch = eArg.ToParameterMatch(); + return this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Five, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.Five", __i => + (aMatch.Matches(__i.Parameter1)) && + (bMatch.Matches(__i.Parameter2)) && + (cMatch.Matches(__i.Parameter3)) && + (dMatch.Matches(__i.Parameter4)) && + (eMatch.Matches(__i.Parameter5)), () => $"Five({aArg}, {bArg}, {cArg}, {dArg}, {eArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.Seventeen(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Seventeen, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.Seventeen", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2, __i.Parameter3, __i.Parameter4, __i.Parameter5, __i.Parameter6, __i.Parameter7, __i.Parameter8, __i.Parameter9, __i.Parameter10, __i.Parameter11, __i.Parameter12, __i.Parameter13, __i.Parameter14, __i.Parameter15, __i.Parameter16, __i.Parameter17]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("a1", __i.Parameter1), ("a2", __i.Parameter2), ("a3", __i.Parameter3), ("a4", __i.Parameter4), ("a5", __i.Parameter5), ("a6", __i.Parameter6), ("a7", __i.Parameter7), ("a8", __i.Parameter8), ("a9", __i.Parameter9), ("a10", __i.Parameter10), ("a11", __i.Parameter11), ("a12", __i.Parameter12), ("a13", __i.Parameter13), ("a14", __i.Parameter14), ("a15", __i.Parameter15), ("a16", __i.Parameter16), ("a17", __i.Parameter17)]), + _ => true + }, () => $"Seventeen({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.Seventeen(global::Mockolate.ParameterArg? a1, global::Mockolate.ParameterArg? a2, global::Mockolate.ParameterArg? a3, global::Mockolate.ParameterArg? a4, global::Mockolate.ParameterArg? a5, global::Mockolate.ParameterArg? a6, global::Mockolate.ParameterArg? a7, global::Mockolate.ParameterArg? a8, global::Mockolate.ParameterArg? a9, global::Mockolate.ParameterArg? a10, global::Mockolate.ParameterArg? a11, global::Mockolate.ParameterArg? a12, global::Mockolate.ParameterArg? a13, global::Mockolate.ParameterArg? a14, global::Mockolate.ParameterArg? a15, global::Mockolate.ParameterArg? a16, global::Mockolate.ParameterArg? a17) + { + global::Mockolate.ParameterArg a1Arg = a1 ?? default; + global::Mockolate.ParameterArg a2Arg = a2 ?? default; + global::Mockolate.ParameterArg a3Arg = a3 ?? default; + global::Mockolate.ParameterArg a4Arg = a4 ?? default; + global::Mockolate.ParameterArg a5Arg = a5 ?? default; + global::Mockolate.ParameterArg a6Arg = a6 ?? default; + global::Mockolate.ParameterArg a7Arg = a7 ?? default; + global::Mockolate.ParameterArg a8Arg = a8 ?? default; + global::Mockolate.ParameterArg a9Arg = a9 ?? default; + global::Mockolate.ParameterArg a10Arg = a10 ?? default; + global::Mockolate.ParameterArg a11Arg = a11 ?? default; + global::Mockolate.ParameterArg a12Arg = a12 ?? default; + global::Mockolate.ParameterArg a13Arg = a13 ?? default; + global::Mockolate.ParameterArg a14Arg = a14 ?? default; + global::Mockolate.ParameterArg a15Arg = a15 ?? default; + global::Mockolate.ParameterArg a16Arg = a16 ?? default; + global::Mockolate.ParameterArg a17Arg = a17 ?? default; + global::Mockolate.Parameters.IParameterMatch a1Match = a1Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a2Match = a2Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a3Match = a3Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a4Match = a4Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a5Match = a5Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a6Match = a6Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a7Match = a7Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a8Match = a8Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a9Match = a9Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a10Match = a10Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a11Match = a11Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a12Match = a12Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a13Match = a13Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a14Match = a14Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a15Match = a15Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a16Match = a16Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a17Match = a17Arg.ToParameterMatch(); + return this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_Seventeen, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.Seventeen", __i => + (a1Match.Matches(__i.Parameter1)) && + (a2Match.Matches(__i.Parameter2)) && + (a3Match.Matches(__i.Parameter3)) && + (a4Match.Matches(__i.Parameter4)) && + (a5Match.Matches(__i.Parameter5)) && + (a6Match.Matches(__i.Parameter6)) && + (a7Match.Matches(__i.Parameter7)) && + (a8Match.Matches(__i.Parameter8)) && + (a9Match.Matches(__i.Parameter9)) && + (a10Match.Matches(__i.Parameter10)) && + (a11Match.Matches(__i.Parameter11)) && + (a12Match.Matches(__i.Parameter12)) && + (a13Match.Matches(__i.Parameter13)) && + (a14Match.Matches(__i.Parameter14)) && + (a15Match.Matches(__i.Parameter15)) && + (a16Match.Matches(__i.Parameter16)) && + (a17Match.Matches(__i.Parameter17)), () => $"Seventeen({a1Arg}, {a2Arg}, {a3Arg}, {a4Arg}, {a5Arg}, {a6Arg}, {a7Arg}, {a8Arg}, {a9Arg}, {a10Arg}, {a11Arg}, {a12Arg}, {a13Arg}, {a14Arg}, {a15Arg}, {a16Arg}, {a17Arg})"); + } + + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIComprehensiveInterface.SeventeenVoid(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_SeventeenVoid, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.SeventeenVoid", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2, __i.Parameter3, __i.Parameter4, __i.Parameter5, __i.Parameter6, __i.Parameter7, __i.Parameter8, __i.Parameter9, __i.Parameter10, __i.Parameter11, __i.Parameter12, __i.Parameter13, __i.Parameter14, __i.Parameter15, __i.Parameter16, __i.Parameter17]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("a1", __i.Parameter1), ("a2", __i.Parameter2), ("a3", __i.Parameter3), ("a4", __i.Parameter4), ("a5", __i.Parameter5), ("a6", __i.Parameter6), ("a7", __i.Parameter7), ("a8", __i.Parameter8), ("a9", __i.Parameter9), ("a10", __i.Parameter10), ("a11", __i.Parameter11), ("a12", __i.Parameter12), ("a13", __i.Parameter13), ("a14", __i.Parameter14), ("a15", __i.Parameter15), ("a16", __i.Parameter16), ("a17", __i.Parameter17)]), + _ => true + }, () => $"SeventeenVoid({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIComprehensiveInterface.SeventeenVoid(global::Mockolate.ParameterArg? a1, global::Mockolate.ParameterArg? a2, global::Mockolate.ParameterArg? a3, global::Mockolate.ParameterArg? a4, global::Mockolate.ParameterArg? a5, global::Mockolate.ParameterArg? a6, global::Mockolate.ParameterArg? a7, global::Mockolate.ParameterArg? a8, global::Mockolate.ParameterArg? a9, global::Mockolate.ParameterArg? a10, global::Mockolate.ParameterArg? a11, global::Mockolate.ParameterArg? a12, global::Mockolate.ParameterArg? a13, global::Mockolate.ParameterArg? a14, global::Mockolate.ParameterArg? a15, global::Mockolate.ParameterArg? a16, global::Mockolate.ParameterArg? a17) + { + global::Mockolate.ParameterArg a1Arg = a1 ?? default; + global::Mockolate.ParameterArg a2Arg = a2 ?? default; + global::Mockolate.ParameterArg a3Arg = a3 ?? default; + global::Mockolate.ParameterArg a4Arg = a4 ?? default; + global::Mockolate.ParameterArg a5Arg = a5 ?? default; + global::Mockolate.ParameterArg a6Arg = a6 ?? default; + global::Mockolate.ParameterArg a7Arg = a7 ?? default; + global::Mockolate.ParameterArg a8Arg = a8 ?? default; + global::Mockolate.ParameterArg a9Arg = a9 ?? default; + global::Mockolate.ParameterArg a10Arg = a10 ?? default; + global::Mockolate.ParameterArg a11Arg = a11 ?? default; + global::Mockolate.ParameterArg a12Arg = a12 ?? default; + global::Mockolate.ParameterArg a13Arg = a13 ?? default; + global::Mockolate.ParameterArg a14Arg = a14 ?? default; + global::Mockolate.ParameterArg a15Arg = a15 ?? default; + global::Mockolate.ParameterArg a16Arg = a16 ?? default; + global::Mockolate.ParameterArg a17Arg = a17 ?? default; + global::Mockolate.Parameters.IParameterMatch a1Match = a1Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a2Match = a2Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a3Match = a3Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a4Match = a4Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a5Match = a5Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a6Match = a6Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a7Match = a7Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a8Match = a8Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a9Match = a9Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a10Match = a10Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a11Match = a11Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a12Match = a12Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a13Match = a13Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a14Match = a14Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a15Match = a15Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a16Match = a16Arg.ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch a17Match = a17Arg.ToParameterMatch(); + return this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IComprehensiveInterface.MemberId_SeventeenVoid, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.SeventeenVoid", __i => + (a1Match.Matches(__i.Parameter1)) && + (a2Match.Matches(__i.Parameter2)) && + (a3Match.Matches(__i.Parameter3)) && + (a4Match.Matches(__i.Parameter4)) && + (a5Match.Matches(__i.Parameter5)) && + (a6Match.Matches(__i.Parameter6)) && + (a7Match.Matches(__i.Parameter7)) && + (a8Match.Matches(__i.Parameter8)) && + (a9Match.Matches(__i.Parameter9)) && + (a10Match.Matches(__i.Parameter10)) && + (a11Match.Matches(__i.Parameter11)) && + (a12Match.Matches(__i.Parameter12)) && + (a13Match.Matches(__i.Parameter13)) && + (a14Match.Matches(__i.Parameter14)) && + (a15Match.Matches(__i.Parameter15)) && + (a16Match.Matches(__i.Parameter16)) && + (a17Match.Matches(__i.Parameter17)), () => $"SeventeenVoid({a1Arg}, {a2Arg}, {a3Arg}, {a4Arg}, {a5Arg}, {a6Arg}, {a7Arg}, {a8Arg}, {a9Arg}, {a10Arg}, {a11Arg}, {a12Arg}, {a13Arg}, {a14Arg}, {a15Arg}, {a16Arg}, {a17Arg})"); + } + + /// + /// Verify subscriptions on the PlainEvent event PlainEvent. + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationEventResult IMockVerifyForIComprehensiveInterface.PlainEvent + { + get + { + return new global::Mockolate.Verify.VerificationEventResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_PlainEvent_Subscribe, global::Mockolate.Mock.IComprehensiveInterface.MemberId_PlainEvent_Unsubscribe, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.PlainEvent"); + } + } + + /// + /// Verify subscriptions on the TypedEvent event TypedEvent. + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationEventResult IMockVerifyForIComprehensiveInterface.TypedEvent + { + get + { + return new global::Mockolate.Verify.VerificationEventResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TypedEvent_Subscribe, global::Mockolate.Mock.IComprehensiveInterface.MemberId_TypedEvent_Unsubscribe, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TypedEvent"); + } + } + + /// + /// Verify subscriptions on the CustomEvent event CustomEvent. + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationEventResult IMockVerifyForIComprehensiveInterface.CustomEvent + { + get + { + return new global::Mockolate.Verify.VerificationEventResult(this, this.MockRegistry, global::Mockolate.Mock.IComprehensiveInterface.MemberId_CustomEvent_Subscribe, global::Mockolate.Mock.IComprehensiveInterface.MemberId_CustomEvent_Unsubscribe, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.CustomEvent"); + } + } + + #endregion IMockVerifyForIComprehensiveInterface + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class MockInScenarioForIComprehensiveInterface : global::Mockolate.Mock.IMockInScenarioForIComprehensiveInterface, global::Mockolate.Mock.IMockSetupForIComprehensiveInterface + { + private global::Mockolate.MockRegistry MockRegistry { get; } + private string _scenarioName; + + public MockInScenarioForIComprehensiveInterface(global::Mockolate.MockRegistry mockRegistry, string scenario) + { + this.MockRegistry = mockRegistry; + _scenarioName = scenario; + } + + /// + global::Mockolate.Mock.IMockSetupForIComprehensiveInterface global::Mockolate.Mock.IMockInScenarioForIComprehensiveInterface.Setup + => this; + + #region IMockSetupForIComprehensiveInterface + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.PropertySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetSet + { + get + { + var propertySetup = new global::Mockolate.Setup.PropertySetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSet"); + this.MockRegistry.SetupProperty(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSet_Get, _scenarioName, propertySetup); + return propertySetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IPropertyGetterOnlySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetOnly + { + get + { + var propertySetup = new global::Mockolate.Setup.PropertySetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetOnly"); + this.MockRegistry.SetupProperty(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetOnly_Get, _scenarioName, propertySetup); + return propertySetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IPropertySetterOnlySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.SetOnly + { + get + { + var propertySetup = new global::Mockolate.Setup.PropertySetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.SetOnly"); + this.MockRegistry.SetupProperty(global::Mockolate.Mock.IComprehensiveInterface.MemberId_SetOnly_Get, _scenarioName, propertySetup); + return propertySetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.PropertySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.NullableProp + { + get + { + var propertySetup = new global::Mockolate.Setup.PropertySetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.NullableProp"); + this.MockRegistry.SetupProperty(global::Mockolate.Mock.IComprehensiveInterface.MemberId_NullableProp_Get, _scenarioName, propertySetup); + return propertySetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.PropertySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.InitOnly + { + get + { + var propertySetup = new global::Mockolate.Setup.PropertySetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.InitOnly"); + this.MockRegistry.SetupProperty(global::Mockolate.Mock.IComprehensiveInterface.MemberId_InitOnly_Get, _scenarioName, propertySetup); + return propertySetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.EventSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.PlainEvent + { + get + { + global::Mockolate.Setup.EventSetup eventSetup = new global::Mockolate.Setup.EventSetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.PlainEvent"); + this.MockRegistry.SetupEvent(global::Mockolate.Mock.IComprehensiveInterface.MemberId_PlainEvent_Subscribe, _scenarioName, eventSetup); + return eventSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.EventSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TypedEvent + { + get + { + global::Mockolate.Setup.EventSetup eventSetup = new global::Mockolate.Setup.EventSetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TypedEvent"); + this.MockRegistry.SetupEvent(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TypedEvent_Subscribe, _scenarioName, eventSetup); + return eventSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.EventSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.CustomEvent + { + get + { + global::Mockolate.Setup.EventSetup eventSetup = new global::Mockolate.Setup.EventSetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.CustomEvent"); + this.MockRegistry.SetupEvent(global::Mockolate.Mock.IComprehensiveInterface.MemberId_CustomEvent_Subscribe, _scenarioName, eventSetup); + return eventSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[global::Mockolate.Parameters.IParameter? parameter1] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, CovariantParameterAdapter.Wrap(parameter1 ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_int_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[int parameter1] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter1)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_int_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[global::Mockolate.Parameters.IParameter? parameter1, global::Mockolate.Parameters.IParameter? parameter2, global::Mockolate.Parameters.IParameter? parameter3, global::Mockolate.Parameters.IParameter? parameter4, global::Mockolate.Parameters.IParameter? parameter5] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, CovariantParameterAdapter.Wrap(parameter1 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter2 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter3 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter4 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter5 ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_int_int_int_int_int_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[int parameter1, int parameter2, int parameter3, int parameter4, int parameter5] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter1), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter2), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter3), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter4), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter5)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_int_int_int_int_int_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[global::Mockolate.Parameters.IParameter? parameter1, global::Mockolate.Parameters.IParameter? parameter2, global::Mockolate.Parameters.IParameter? parameter3, global::Mockolate.Parameters.IParameter? parameter4, global::Mockolate.Parameters.IParameter? parameter5] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, CovariantParameterAdapter.Wrap(parameter1 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter2 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter3 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter4 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter5 ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_byte_byte_byte_byte_byte_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[byte parameter1, byte parameter2, byte parameter3, byte parameter4, byte parameter5] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter1), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter2), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter3), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter4), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter5)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_byte_byte_byte_byte_byte_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[global::Mockolate.Parameters.IParameter? parameter1, global::Mockolate.Parameters.IParameter? parameter2, global::Mockolate.Parameters.IParameter? parameter3, global::Mockolate.Parameters.IParameter? parameter4, global::Mockolate.Parameters.IParameter? parameter5] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, CovariantParameterAdapter.Wrap(parameter1 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter2 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter3 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter4 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter5 ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_short_short_short_short_short_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[short parameter1, short parameter2, short parameter3, short parameter4, short parameter5] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter1), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter2), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter3), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter4), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter5)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_short_short_short_short_short_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[global::Mockolate.Parameters.IParameter? parameter1] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, CovariantParameterAdapter.Wrap(parameter1 ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_double_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[double parameter1] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter1)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_double_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[global::Mockolate.Parameters.IParameter? parameter1] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, CovariantParameterAdapter.Wrap(parameter1 ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_char_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.this[char parameter1] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter1)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Indexer_char_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", parameters, "a", "b", "c", "tail"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IRefParameter a, global::Mockolate.Parameters.IOutParameter b, global::Mockolate.Parameters.IParameter? c, global::Mockolate.Parameters.IParameter? tail) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", (global::Mockolate.Parameters.IParameterMatch)(a), (global::Mockolate.Parameters.IParameterMatch)(b), (global::Mockolate.Parameters.IParameterMatch)(c ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(tail ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IRefParameter a, global::Mockolate.Parameters.IOutParameter b, global::Mockolate.Parameters.IParameter? c, params global::Mockolate.Parameters.IParameter[] tail) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", (global::Mockolate.Parameters.IParameterMatch)(a), (global::Mockolate.Parameters.IParameterMatch)(b), (global::Mockolate.Parameters.IParameterMatch)(c ?? global::Mockolate.It.IsNull("null")), new global::Mockolate.Parameters.ParamsArrayParameterMatch(tail)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IRefParameter a, global::Mockolate.Parameters.IOutParameter b, long c, global::Mockolate.Parameters.IParameter? tail) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", (global::Mockolate.Parameters.IParameterMatch)(a), (global::Mockolate.Parameters.IParameterMatch)(b), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(c), CovariantParameterAdapter.Wrap(tail ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IRefParameter a, global::Mockolate.Parameters.IOutParameter b, global::Mockolate.Parameters.IParameter? c, params int[] tail) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", (global::Mockolate.Parameters.IParameterMatch)(a), (global::Mockolate.Parameters.IParameterMatch)(b), (global::Mockolate.Parameters.IParameterMatch)(c ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(global::Mockolate.It.SequenceEquals(tail))); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.WithModifiers(global::Mockolate.Parameters.IRefParameter a, global::Mockolate.Parameters.IOutParameter b, long c, params int[] tail) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithModifiers", (global::Mockolate.Parameters.IParameterMatch)(a), (global::Mockolate.Parameters.IParameterMatch)(b), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(c), CovariantParameterAdapter.Wrap(global::Mockolate.It.SequenceEquals(tail))); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithModifiers, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.WithDefaults(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithDefaults", parameters, "i", "e", "d", "f", "c", "s", "st"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithDefaults, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.WithDefaults(global::Mockolate.ParameterArg? i, global::Mockolate.ParameterArg? e, global::Mockolate.ParameterArg? d, global::Mockolate.ParameterArg? f, global::Mockolate.ParameterArg? c, global::Mockolate.ParameterArg? s, global::Mockolate.ParameterArg? st) + { + global::Mockolate.ParameterArg iArg = i ?? new global::Mockolate.ParameterArg((int)(5)); + global::Mockolate.ParameterArg eArg = e ?? new global::Mockolate.ParameterArg((global::Mockolate.Tests.GeneratorCoverage.MyEnum)((global::Mockolate.Tests.GeneratorCoverage.MyEnum)1)); + global::Mockolate.ParameterArg dArg = d ?? new global::Mockolate.ParameterArg((decimal)(1.5m)); + global::Mockolate.ParameterArg fArg = f ?? new global::Mockolate.ParameterArg((float)(0.25f)); + global::Mockolate.ParameterArg cArg = c ?? new global::Mockolate.ParameterArg((char)('x')); + global::Mockolate.ParameterArg sArg = s ?? new global::Mockolate.ParameterArg((string?)(null)); + global::Mockolate.ParameterArg stArg = st ?? new global::Mockolate.ParameterArg((global::Mockolate.Tests.GeneratorCoverage.MyStruct)(default)); + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithDefaults", iArg.ToParameterMatch(), eArg.ToParameterMatch(), dArg.ToParameterMatch(), fArg.ToParameterMatch(), cArg.ToParameterMatch(), sArg.ToParameterMatch(), stArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithDefaults, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.WithCollidingNames(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithCollidingNames", parameters, "wraps", "result", "outParam1", "methodExecution", "returnValue"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithCollidingNames, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.WithCollidingNames(global::Mockolate.ParameterArg? wraps, global::Mockolate.ParameterArg? result, global::Mockolate.ParameterArg? outParam1, global::Mockolate.ParameterArg? methodExecution, global::Mockolate.ParameterArg? returnValue) + { + global::Mockolate.ParameterArg wrapsArg = wraps ?? default; + global::Mockolate.ParameterArg resultArg = result ?? default; + global::Mockolate.ParameterArg outParam1Arg = outParam1 ?? default; + global::Mockolate.ParameterArg methodExecutionArg = methodExecution ?? default; + global::Mockolate.ParameterArg returnValueArg = returnValue ?? default; + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.WithCollidingNames", wrapsArg.ToParameterMatch(), resultArg.ToParameterMatch(), outParam1Arg.ToParameterMatch(), methodExecutionArg.ToParameterMatch(), returnValueArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_WithCollidingNames, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetMaybeNull(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetMaybeNull", parameters, "s"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetMaybeNull, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetMaybeNull(global::Mockolate.ParameterArg? s) + { + global::Mockolate.ParameterArg sArg = s ?? default; + global::Mockolate.Setup.ReturnMethodSetup methodSetup; + if (sArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithLiteralValues(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetMaybeNull", sArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetMaybeNull", sArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetMaybeNull, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetMaybeNull(global::System.Func s, string sExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetMaybeNull", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(s, sExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetMaybeNull, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)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, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeObject(global::Mockolate.ParameterArg? obj) + { + global::Mockolate.ParameterArg objArg = obj ?? default; + global::Mockolate.Setup.ReturnMethodSetup methodSetup; + if (objArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithLiteralValues(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", objArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", objArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeObject(global::System.Func obj, string objExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeObject", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(obj, objExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeObject, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)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.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeTwoObjects(global::Mockolate.ParameterArg? first, global::Mockolate.ParameterArg? second) + { + global::Mockolate.ParameterArg firstArg = first ?? default; + global::Mockolate.ParameterArg secondArg = second ?? default; + global::Mockolate.Setup.ReturnMethodSetup methodSetup; + if (firstArg.IsLiteral && secondArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithLiteralValues(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", firstArg.Literal!, secondArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", firstArg.ToParameterMatch(), secondArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeTwoObjects(global::System.Func first, global::Mockolate.ParameterArg? second, string firstExpression) + { + global::Mockolate.ParameterArg secondArg = second ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(first, firstExpression), secondArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeTwoObjects(global::Mockolate.ParameterArg? first, global::System.Func second, string secondExpression) + { + global::Mockolate.ParameterArg firstArg = first ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", firstArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(second, secondExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeTwoObjects(global::System.Func first, global::System.Func second, string firstExpression, string secondExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeTwoObjects", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(first, firstExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(second, secondExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeTwoObjects, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)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.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeIntAndObject(global::Mockolate.ParameterArg? n, global::Mockolate.ParameterArg? obj) + { + global::Mockolate.ParameterArg nArg = n ?? default; + global::Mockolate.ParameterArg objArg = obj ?? default; + global::Mockolate.Setup.ReturnMethodSetup methodSetup; + if (nArg.IsLiteral && objArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithLiteralValues(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", nArg.Literal!, objArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", nArg.ToParameterMatch(), objArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeIntAndObject(global::System.Func n, global::Mockolate.ParameterArg? obj, string nExpression) + { + global::Mockolate.ParameterArg objArg = obj ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(n, nExpression), objArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeIntAndObject(global::Mockolate.ParameterArg? n, global::System.Func obj, string objExpression) + { + global::Mockolate.ParameterArg nArg = n ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", nArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(obj, objExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.TakeIntAndObject(global::System.Func n, global::System.Func obj, string nExpression, string objExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.TakeIntAndObject", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(n, nExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(obj, objExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_TakeIntAndObject, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)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; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup> global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.DoVTOf() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup>.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.DoVTOf"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_DoVTOf, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup<(int Code, string Msg)> global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetTuple() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup<(int Code, string Msg)>.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetTuple"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetTuple, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetNullable() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetNullable"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetNullable, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback, int> global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetSpan(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, int>.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSpan", parameters, "n"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSpan, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int> global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetSpan(global::Mockolate.ParameterArg? n) + { + global::Mockolate.ParameterArg nArg = n ?? default; + global::Mockolate.Setup.ReturnMethodSetup, int> methodSetup; + if (nArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, int>.WithLiteralValues(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSpan", nArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, int>.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSpan", nArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSpan, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int> global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetSpan(global::System.Func n, string nExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, int>.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetSpan", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(n, nExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetSpan, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback, int> global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetROSpan(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, int>.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetROSpan", parameters, "n"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetROSpan, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int> global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetROSpan(global::Mockolate.ParameterArg? n) + { + global::Mockolate.ParameterArg nArg = n ?? default; + global::Mockolate.Setup.ReturnMethodSetup, int> methodSetup; + if (nArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, int>.WithLiteralValues(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetROSpan", nArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, int>.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetROSpan", nArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetROSpan, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int> global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetROSpan(global::System.Func n, string nExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, int>.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetROSpan", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(n, nExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetROSpan, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetByRef() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetByRef"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetByRef, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.GetByRefReadonly() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.GetByRefReadonly"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_GetByRefReadonly, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.G1() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G1<{typeof(T)}>"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_G1_T_, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.G2() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G2<{typeof(T)}>"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_G2_T_, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.G3() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G3<{typeof(T)}>"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_G3_T_, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.G4() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G4<{typeof(T)}>"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_G4_T_, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.G5() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G5<{typeof(T)}>"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_G5_T_, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.G6() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G6<{typeof(T)}>"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_G6_T_, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.G7() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, $"global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.G7<{typeof(T)}>"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_G7_T_, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.Five(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.Five", parameters, "a", "b", "c", "d", "e"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Five, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.Five(global::Mockolate.ParameterArg? a, global::Mockolate.ParameterArg? b, global::Mockolate.ParameterArg? c, global::Mockolate.ParameterArg? d, global::Mockolate.ParameterArg? e) + { + global::Mockolate.ParameterArg aArg = a ?? default; + global::Mockolate.ParameterArg bArg = b ?? default; + global::Mockolate.ParameterArg cArg = c ?? default; + global::Mockolate.ParameterArg dArg = d ?? default; + global::Mockolate.ParameterArg eArg = e ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.Five", aArg.ToParameterMatch(), bArg.ToParameterMatch(), cArg.ToParameterMatch(), dArg.ToParameterMatch(), eArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Five, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.Seventeen(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.Seventeen", parameters, "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15", "a16", "a17"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Seventeen, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.Seventeen(global::Mockolate.ParameterArg? a1, global::Mockolate.ParameterArg? a2, global::Mockolate.ParameterArg? a3, global::Mockolate.ParameterArg? a4, global::Mockolate.ParameterArg? a5, global::Mockolate.ParameterArg? a6, global::Mockolate.ParameterArg? a7, global::Mockolate.ParameterArg? a8, global::Mockolate.ParameterArg? a9, global::Mockolate.ParameterArg? a10, global::Mockolate.ParameterArg? a11, global::Mockolate.ParameterArg? a12, global::Mockolate.ParameterArg? a13, global::Mockolate.ParameterArg? a14, global::Mockolate.ParameterArg? a15, global::Mockolate.ParameterArg? a16, global::Mockolate.ParameterArg? a17) + { + global::Mockolate.ParameterArg a1Arg = a1 ?? default; + global::Mockolate.ParameterArg a2Arg = a2 ?? default; + global::Mockolate.ParameterArg a3Arg = a3 ?? default; + global::Mockolate.ParameterArg a4Arg = a4 ?? default; + global::Mockolate.ParameterArg a5Arg = a5 ?? default; + global::Mockolate.ParameterArg a6Arg = a6 ?? default; + global::Mockolate.ParameterArg a7Arg = a7 ?? default; + global::Mockolate.ParameterArg a8Arg = a8 ?? default; + global::Mockolate.ParameterArg a9Arg = a9 ?? default; + global::Mockolate.ParameterArg a10Arg = a10 ?? default; + global::Mockolate.ParameterArg a11Arg = a11 ?? default; + global::Mockolate.ParameterArg a12Arg = a12 ?? default; + global::Mockolate.ParameterArg a13Arg = a13 ?? default; + global::Mockolate.ParameterArg a14Arg = a14 ?? default; + global::Mockolate.ParameterArg a15Arg = a15 ?? default; + global::Mockolate.ParameterArg a16Arg = a16 ?? default; + global::Mockolate.ParameterArg a17Arg = a17 ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.Seventeen", a1Arg.ToParameterMatch(), a2Arg.ToParameterMatch(), a3Arg.ToParameterMatch(), a4Arg.ToParameterMatch(), a5Arg.ToParameterMatch(), a6Arg.ToParameterMatch(), a7Arg.ToParameterMatch(), a8Arg.ToParameterMatch(), a9Arg.ToParameterMatch(), a10Arg.ToParameterMatch(), a11Arg.ToParameterMatch(), a12Arg.ToParameterMatch(), a13Arg.ToParameterMatch(), a14Arg.ToParameterMatch(), a15Arg.ToParameterMatch(), a16Arg.ToParameterMatch(), a17Arg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_Seventeen, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.SeventeenVoid(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.SeventeenVoid", parameters, "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15", "a16", "a17"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_SeventeenVoid, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIComprehensiveInterface.SeventeenVoid(global::Mockolate.ParameterArg? a1, global::Mockolate.ParameterArg? a2, global::Mockolate.ParameterArg? a3, global::Mockolate.ParameterArg? a4, global::Mockolate.ParameterArg? a5, global::Mockolate.ParameterArg? a6, global::Mockolate.ParameterArg? a7, global::Mockolate.ParameterArg? a8, global::Mockolate.ParameterArg? a9, global::Mockolate.ParameterArg? a10, global::Mockolate.ParameterArg? a11, global::Mockolate.ParameterArg? a12, global::Mockolate.ParameterArg? a13, global::Mockolate.ParameterArg? a14, global::Mockolate.ParameterArg? a15, global::Mockolate.ParameterArg? a16, global::Mockolate.ParameterArg? a17) + { + global::Mockolate.ParameterArg a1Arg = a1 ?? default; + global::Mockolate.ParameterArg a2Arg = a2 ?? default; + global::Mockolate.ParameterArg a3Arg = a3 ?? default; + global::Mockolate.ParameterArg a4Arg = a4 ?? default; + global::Mockolate.ParameterArg a5Arg = a5 ?? default; + global::Mockolate.ParameterArg a6Arg = a6 ?? default; + global::Mockolate.ParameterArg a7Arg = a7 ?? default; + global::Mockolate.ParameterArg a8Arg = a8 ?? default; + global::Mockolate.ParameterArg a9Arg = a9 ?? default; + global::Mockolate.ParameterArg a10Arg = a10 ?? default; + global::Mockolate.ParameterArg a11Arg = a11 ?? default; + global::Mockolate.ParameterArg a12Arg = a12 ?? default; + global::Mockolate.ParameterArg a13Arg = a13 ?? default; + global::Mockolate.ParameterArg a14Arg = a14 ?? default; + global::Mockolate.ParameterArg a15Arg = a15 ?? default; + global::Mockolate.ParameterArg a16Arg = a16 ?? default; + global::Mockolate.ParameterArg a17Arg = a17 ?? default; + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface.SeventeenVoid", a1Arg.ToParameterMatch(), a2Arg.ToParameterMatch(), a3Arg.ToParameterMatch(), a4Arg.ToParameterMatch(), a5Arg.ToParameterMatch(), a6Arg.ToParameterMatch(), a7Arg.ToParameterMatch(), a8Arg.ToParameterMatch(), a9Arg.ToParameterMatch(), a10Arg.ToParameterMatch(), a11Arg.ToParameterMatch(), a12Arg.ToParameterMatch(), a13Arg.ToParameterMatch(), a14Arg.ToParameterMatch(), a15Arg.ToParameterMatch(), a16Arg.ToParameterMatch(), a17Arg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IComprehensiveInterface.MemberId_SeventeenVoid, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; + } + + #endregion IMockSetupForIComprehensiveInterface + } + + /// + /// The Mockolate accessor for a mock of IComprehensiveInterface, reached through .Mock on the mocked instance. + /// + /// + /// Groups every operation that acts on the mock rather than on the mocked subject: setups, verifications, event raising, scenarios and monitoring. + /// + internal interface IMockForIComprehensiveInterface + { + /// + /// Configures how members of the mock of IComprehensiveInterface respond when invoked. + /// + /// + /// Each mocked member is available as a strongly-typed entry on this surface. Chain Returns, ReturnsAsync, Throws, ThrowsAsync or Do to control the response; chain InitializeWith/Register to initialize properties and indexers; chain multiple returns/throws to define a sequence; use .For(n), .Only(n), .Forever(), .When(predicate) to control when a callback runs.
+ /// When two setups overlap, the most recently defined one wins. + ///
+ IMockSetupForIComprehensiveInterface Setup { get; } + + /// + /// Configures how members declared on IComprehensiveInterface respond when invoked. + /// + /// + /// Static members are scoped per async/execution flow while the mock is alive; invocations from other flows are not intercepted. + /// + IMockStaticSetupForIComprehensiveInterface SetupStatic { get; } + + /// + /// Opens a named scenario scope on the mock of IComprehensiveInterface so that additional setups can be registered for that scenario. + /// + /// + /// Scenarios let you define per-state behavior. Setups registered inside the returned IMockInScenarioFor... scope only apply while the mock's current scenario matches ; switch scenarios with TransitionTo. + /// + /// Name of the scenario to enter. Any non-null string acts as a key; the mock starts in an unnamed default scenario. + /// A scoped accessor whose Setup (and SetupProtected, where applicable) register scenario-specific setups. + IMockInScenarioForIComprehensiveInterface InScenario(string scenario); + + /// + /// Opens a named scenario scope on the mock of IComprehensiveInterface and immediately invokes to register scenario-specific setups. + /// + /// + /// Equivalent to InScenario(scenario) followed by the setup callback, but returns the original IMockFor... accessor so it chains nicely at mock-creation time. + /// + /// Name of the scenario to enter. + /// Callback that receives the scenario-scoped setup surface and registers scenario-specific setups. + /// This accessor, to allow chaining. + IMockForIComprehensiveInterface InScenario(string scenario, global::System.Action setup); + + /// + /// Switches the active scenario of the mock of IComprehensiveInterface to . + /// + /// + /// After the transition, setups registered via InScenario(string) under that scenario take effect. Scenarios that have no matching setup for a given member fall back to the default (un-scoped) setups. + /// + /// Name of the scenario to transition to. + /// This accessor, to allow chaining. + IMockForIComprehensiveInterface TransitionTo(string scenario); + + /// + /// Triggers events declared on IComprehensiveInterface so that currently subscribed handlers are invoked. + /// + /// + /// One entry per event is generated; the signature matches the event's delegate. Only handlers that are subscribed at the moment of the Raise call are invoked - handlers subscribed later (or already removed) are skipped. + /// + IMockRaiseOnIComprehensiveInterface Raise { get; } + + /// + /// Asserts how often, and in which order, members of the mock of IComprehensiveInterface were invoked. + /// + /// + /// Each call to a member here returns a VerificationResult that you terminate with a count assertion: Never(), Once(), Twice(), Exactly(n), AtLeast(n)/AtLeastOnce()/AtLeastTwice(), AtMost(n)/AtMostOnce()/AtMostTwice(), Between(min, max) or Times(predicate).
+ /// Use Within(TimeSpan) / WithCancellation(CancellationToken) before the terminator to wait for expected interactions that happen on background threads.
+ /// Chain Then(...) to assert an ordered sequence of calls. A failing assertion throws a MockVerificationException. + ///
+ IMockVerifyForIComprehensiveInterface Verify { get; } + + /// + /// Asserts how often, and in which order, members declared on IComprehensiveInterface were invoked. + /// + /// + /// Same terminators and modifiers as Verify; scoped per async/execution flow in the same way as SetupStatic. + /// + IMockStaticVerifyForIComprehensiveInterface VerifyStatic { get; } + + /// + /// Verifies how often a specific method setup was matched by actual invocations. + /// + /// + /// Useful when you want to verify "this particular setup was hit N times" without re-stating the matchers. Chain the usual count terminators (Once(), AtLeastOnce(), Exactly(n), ...) on the returned result. + /// + /// The setup previously registered through Setup (typically returned from a Returns(...)/Throws(...) call). + /// A VerificationResult that counts invocations matching the given setup. + global::Mockolate.Verify.VerificationResult VerifySetup(global::Mockolate.Setup.IMethodSetup setup); + + /// + /// Checks whether every recorded interaction on this mock has been observed by at least one Verify call. + /// + /// + /// Useful in test teardown to catch unexpected interactions ("strict verification"): if any recorded call has never been matched by a verification, the method returns . + /// + /// if every recorded interaction was verified at least once; otherwise . + bool VerifyThatAllInteractionsAreVerified(); + + /// + /// Checks whether every registered setup on this mock was matched by at least one actual invocation. + /// + /// + /// Useful to catch unused setups that silently rot as the test subject evolves. + /// + /// if every registered setup was used at least once; otherwise . + bool VerifyThatAllSetupsAreUsed(); + + /// + /// Removes every recorded interaction from this mock while keeping all registered setups intact. + /// + /// + /// Handy when a single test exercises multiple logical phases and you only want to verify the interactions of the latest phase. + /// + void ClearAllInteractions(); + + /// + /// Creates a monitor whose Verify surface is scoped to interactions produced between monitor.Run() and the disposal of its IDisposable scope. + /// + /// + /// The underlying mock keeps recording all interactions as usual - only the monitor's Verify view is scoped. Useful to verify only the interactions produced by a specific block of test code without resetting the mock. + /// + /// A MockMonitor<T> that exposes Verify over the monitored interactions and a Run() method that opens the recording scope. + global::Mockolate.Monitor.MockMonitor Monitor(); + } + + /// + /// Scoped access to setups for a scenario on the mock of IComprehensiveInterface. + /// + internal interface IMockInScenarioForIComprehensiveInterface + { + /// + /// Set up the mock of IComprehensiveInterface within the scenario scope. + /// + IMockSetupForIComprehensiveInterface Setup { get; } + } + + /// + /// Set up the mock of IComprehensiveInterface. + /// + internal interface IMockSetupForIComprehensiveInterface + { + /// + /// Setup for the int property GetSet. + /// + global::Mockolate.Setup.PropertySetup GetSet { get; } + + /// + /// Setup for the int property GetOnly. + /// + global::Mockolate.Setup.IPropertyGetterOnlySetup GetOnly { get; } + + /// + /// Setup for the int property SetOnly. + /// + global::Mockolate.Setup.IPropertySetterOnlySetup SetOnly { get; } + + /// + /// Setup for the string? property NullableProp. + /// + global::Mockolate.Setup.PropertySetup NullableProp { get; } + + /// + /// Setup for the string property InitOnly. + /// + global::Mockolate.Setup.PropertySetup InitOnly { get; } + + /// + /// Setup for the event PlainEvent. + /// + global::Mockolate.Setup.EventSetup PlainEvent { get; } + + /// + /// Setup for the event TypedEvent. + /// + global::Mockolate.Setup.EventSetup TypedEvent { get; } + + /// + /// Setup for the event CustomEvent. + /// + global::Mockolate.Setup.EventSetup CustomEvent { get; } + + /// + /// Setup for the string indexer this[int] + /// + /// + /// 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::Mockolate.Setup.IndexerSetup this[global::Mockolate.Parameters.IParameter? parameter1] { get; } + + /// + /// Setup for the string indexer this[int] + /// + /// + /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IndexerSetup this[int parameter1] { get; } + + /// + /// Setup for the string indexer this[int, int, int, int, int] + /// + /// + /// 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::Mockolate.Setup.IndexerSetup this[global::Mockolate.Parameters.IParameter? parameter1, global::Mockolate.Parameters.IParameter? parameter2, global::Mockolate.Parameters.IParameter? parameter3, global::Mockolate.Parameters.IParameter? parameter4, global::Mockolate.Parameters.IParameter? parameter5] { get; } + + /// + /// Setup for the string indexer this[int, int, int, int, int] + /// + /// + /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IndexerSetup this[int parameter1, int parameter2, int parameter3, int parameter4, int parameter5] { get; } + + /// + /// Setup for the long indexer this[byte, byte, byte, byte, byte] + /// + /// + /// 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::Mockolate.Setup.IIndexerGetterOnlySetup this[global::Mockolate.Parameters.IParameter? parameter1, global::Mockolate.Parameters.IParameter? parameter2, global::Mockolate.Parameters.IParameter? parameter3, global::Mockolate.Parameters.IParameter? parameter4, global::Mockolate.Parameters.IParameter? parameter5] { get; } + + /// + /// Setup for the long indexer this[byte, byte, byte, byte, byte] + /// + /// + /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IIndexerGetterOnlySetup this[byte parameter1, byte parameter2, byte parameter3, byte parameter4, byte parameter5] { get; } + + /// + /// Setup for the long indexer this[short, short, short, short, short] + /// + /// + /// 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::Mockolate.Setup.IIndexerSetterOnlySetup this[global::Mockolate.Parameters.IParameter? parameter1, global::Mockolate.Parameters.IParameter? parameter2, global::Mockolate.Parameters.IParameter? parameter3, global::Mockolate.Parameters.IParameter? parameter4, global::Mockolate.Parameters.IParameter? parameter5] { get; } + + /// + /// Setup for the long indexer this[short, short, short, short, short] + /// + /// + /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IIndexerSetterOnlySetup this[short parameter1, short parameter2, short parameter3, short parameter4, short parameter5] { get; } + + /// + /// Setup for the string indexer this[double] + /// + /// + /// 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::Mockolate.Setup.IIndexerGetterOnlySetup this[global::Mockolate.Parameters.IParameter? parameter1] { get; } + + /// + /// Setup for the string indexer this[double] + /// + /// + /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IIndexerGetterOnlySetup this[double parameter1] { get; } + + /// + /// Setup for the string indexer this[char] + /// + /// + /// 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::Mockolate.Setup.IIndexerSetterOnlySetup this[global::Mockolate.Parameters.IParameter? parameter1] { get; } + + /// + /// Setup for the string indexer this[char] + /// + /// + /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IIndexerSetterOnlySetup this[char parameter1] { get; } + + /// + /// Setup for the method WithModifiers(ref int, out string, in long, int[]) 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.IVoidMethodSetupWithCallback WithModifiers(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Setup for the method WithModifiers(ref int, out string, in long, int[]) 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(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); + + /// + /// Setup for the method WithModifiers(ref int, out string, in long, int[]) 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(4)] + global::Mockolate.Setup.IVoidMethodSetupWithCallback WithModifiers(global::Mockolate.Parameters.IRefParameter a, global::Mockolate.Parameters.IOutParameter b, global::Mockolate.Parameters.IParameter? c, params global::Mockolate.Parameters.IParameter[] tail); + + /// + /// Setup for the method WithModifiers(ref int, out string, in long, int[]) 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(3)] + global::Mockolate.Setup.IVoidMethodSetupWithCallback WithModifiers(global::Mockolate.Parameters.IRefParameter a, global::Mockolate.Parameters.IOutParameter b, long c, global::Mockolate.Parameters.IParameter? tail); + + /// + /// Setup for the method WithModifiers(ref int, out string, in long, int[]) 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(3)] + global::Mockolate.Setup.IVoidMethodSetupWithCallback WithModifiers(global::Mockolate.Parameters.IRefParameter a, global::Mockolate.Parameters.IOutParameter b, global::Mockolate.Parameters.IParameter? c, params int[] tail); + + /// + /// Setup for the method WithModifiers(ref int, out string, in long, int[]) 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(2)] + global::Mockolate.Setup.IVoidMethodSetupWithCallback WithModifiers(global::Mockolate.Parameters.IRefParameter a, global::Mockolate.Parameters.IOutParameter b, long c, params int[] tail); + + /// + /// Setup for the method WithDefaults(int, MyEnum, decimal, float, char, string?, MyStruct) 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.IVoidMethodSetupWithCallback WithDefaults(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Setup for the method WithDefaults(int, MyEnum, decimal, float, char, string?, MyStruct) with the given , , , , , , . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer WithDefaults(global::Mockolate.ParameterArg? i = null, global::Mockolate.ParameterArg? e = null, global::Mockolate.ParameterArg? d = null, global::Mockolate.ParameterArg? f = null, global::Mockolate.ParameterArg? c = null, global::Mockolate.ParameterArg? s = null, global::Mockolate.ParameterArg? st = null); + + /// + /// Setup for the method WithCollidingNames(int, int, int, int, int) 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.IVoidMethodSetupWithCallback WithCollidingNames(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Setup for the method WithCollidingNames(int, int, int, int, int) with the given , , , , . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer WithCollidingNames(global::Mockolate.ParameterArg? wraps, global::Mockolate.ParameterArg? result, global::Mockolate.ParameterArg? outParam1, global::Mockolate.ParameterArg? methodExecution, global::Mockolate.ParameterArg? returnValue); + + /// + /// Setup for the method GetMaybeNull(string?) 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 GetMaybeNull(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Setup for the method GetMaybeNull(string?) with the given . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer GetMaybeNull(global::Mockolate.ParameterArg? s); + + /// + /// Setup for the method GetMaybeNull(string?) with the given . + /// + /// + /// This overload accepts a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer GetMaybeNull(global::System.Func s, [global::System.Runtime.CompilerServices.CallerArgumentExpression("s")] string sExpression = ""); + + /// + /// 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 accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer TakeObject(global::Mockolate.ParameterArg? obj); + + /// + /// Setup for the method TakeObject(object?) with the given . + /// + /// + /// This overload accepts a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer TakeObject(global::System.Func obj, [global::System.Runtime.CompilerServices.CallerArgumentExpression("obj")] string objExpression = ""); + + /// + /// 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 accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer TakeTwoObjects(global::Mockolate.ParameterArg? first, global::Mockolate.ParameterArg? second); + + /// + /// Setup for the method TakeTwoObjects(object?, object?) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer TakeTwoObjects(global::System.Func first, global::Mockolate.ParameterArg? second, [global::System.Runtime.CompilerServices.CallerArgumentExpression("first")] string firstExpression = ""); + + /// + /// Setup for the method TakeTwoObjects(object?, object?) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer TakeTwoObjects(global::Mockolate.ParameterArg? first, global::System.Func second, [global::System.Runtime.CompilerServices.CallerArgumentExpression("second")] string secondExpression = ""); + + /// + /// Setup for the method TakeTwoObjects(object?, object?) with the given , . + /// + /// + /// This overload accepts a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer TakeTwoObjects(global::System.Func first, global::System.Func second, [global::System.Runtime.CompilerServices.CallerArgumentExpression("first")] string firstExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("second")] string secondExpression = ""); + + /// + /// 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 accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer TakeIntAndObject(global::Mockolate.ParameterArg? n, global::Mockolate.ParameterArg? obj); + + /// + /// Setup for the method TakeIntAndObject(int, object?) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer TakeIntAndObject(global::System.Func n, global::Mockolate.ParameterArg? obj, [global::System.Runtime.CompilerServices.CallerArgumentExpression("n")] string nExpression = ""); + + /// + /// Setup for the method TakeIntAndObject(int, object?) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer TakeIntAndObject(global::Mockolate.ParameterArg? n, global::System.Func obj, [global::System.Runtime.CompilerServices.CallerArgumentExpression("obj")] string objExpression = ""); + + /// + /// Setup for the method TakeIntAndObject(int, object?) with the given , . + /// + /// + /// This overload accepts a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer TakeIntAndObject(global::System.Func n, global::System.Func obj, [global::System.Runtime.CompilerServices.CallerArgumentExpression("n")] string nExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("obj")] string objExpression = ""); + + /// + /// Setup for the method DoTask(). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetup DoTask(); + + /// + /// Setup for the method DoTaskOf(). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetup> DoTaskOf(); + + /// + /// Setup for the method DoVT(). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetup DoVT(); + + /// + /// Setup for the method DoVTOf(). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetup> DoVTOf(); + + /// + /// Setup for the method GetTuple(). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetup<(int Code, string Msg)> GetTuple(); + + /// + /// Setup for the method GetNullable(). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetup GetNullable(); + + /// + /// Setup for the method GetSpan(int) 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, int> GetSpan(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Setup for the method GetSpan(int) with the given . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int> GetSpan(global::Mockolate.ParameterArg? n); + + /// + /// Setup for the method GetSpan(int) with the given . + /// + /// + /// This overload accepts a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int> GetSpan(global::System.Func n, [global::System.Runtime.CompilerServices.CallerArgumentExpression("n")] string nExpression = ""); + + /// + /// Setup for the method GetROSpan(int) 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, int> GetROSpan(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Setup for the method GetROSpan(int) with the given . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int> GetROSpan(global::Mockolate.ParameterArg? n); + + /// + /// Setup for the method GetROSpan(int) with the given . + /// + /// + /// This overload accepts a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, int> GetROSpan(global::System.Func n, [global::System.Runtime.CompilerServices.CallerArgumentExpression("n")] string nExpression = ""); + + /// + /// Setup for the method GetByRef(). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetup GetByRef(); + + /// + /// Setup for the method GetByRefReadonly(). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetup GetByRefReadonly(); + + /// + /// Setup for the method G1<T>(). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetup G1() + where T : class; + + /// + /// Setup for the method G2<T>(). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetup G2() + where T : struct; + + /// + /// Setup for the method G3<T>(). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetup G3() + where T : new(); + + /// + /// Setup for the method G4<T>(). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetup G4() + where T : unmanaged; + + /// + /// Setup for the method G5<T>(). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetup G5() + where T : notnull; + + /// + /// Setup for the method G6<T>(). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetup G6() + where T : global::Mockolate.Tests.GeneratorCoverage.MyBase, global::System.IComparable; + + /// + /// Setup for the method G7<T>(). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetup G7() + where T : class?; + + /// + /// Setup for the method Five(int, int, int, int, int) 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 Five(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Setup for the method Five(int, int, int, int, int) with the given , , , , . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Five(global::Mockolate.ParameterArg? a, global::Mockolate.ParameterArg? b, global::Mockolate.ParameterArg? c, global::Mockolate.ParameterArg? d, global::Mockolate.ParameterArg? e); + + /// + /// Setup for the method Seventeen(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int) 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 Seventeen(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Setup for the method Seventeen(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int) with the given , , , , , , , , , , , , , , , , . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Seventeen(global::Mockolate.ParameterArg? a1, global::Mockolate.ParameterArg? a2, global::Mockolate.ParameterArg? a3, global::Mockolate.ParameterArg? a4, global::Mockolate.ParameterArg? a5, global::Mockolate.ParameterArg? a6, global::Mockolate.ParameterArg? a7, global::Mockolate.ParameterArg? a8, global::Mockolate.ParameterArg? a9, global::Mockolate.ParameterArg? a10, global::Mockolate.ParameterArg? a11, global::Mockolate.ParameterArg? a12, global::Mockolate.ParameterArg? a13, global::Mockolate.ParameterArg? a14, global::Mockolate.ParameterArg? a15, global::Mockolate.ParameterArg? a16, global::Mockolate.ParameterArg? a17); + + /// + /// Setup for the method SeventeenVoid(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int) 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.IVoidMethodSetupWithCallback SeventeenVoid(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Setup for the method SeventeenVoid(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int) with the given , , , , , , , , , , , , , , , , . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer SeventeenVoid(global::Mockolate.ParameterArg? a1, global::Mockolate.ParameterArg? a2, global::Mockolate.ParameterArg? a3, global::Mockolate.ParameterArg? a4, global::Mockolate.ParameterArg? a5, global::Mockolate.ParameterArg? a6, global::Mockolate.ParameterArg? a7, global::Mockolate.ParameterArg? a8, global::Mockolate.ParameterArg? a9, global::Mockolate.ParameterArg? a10, global::Mockolate.ParameterArg? a11, global::Mockolate.ParameterArg? a12, global::Mockolate.ParameterArg? a13, global::Mockolate.ParameterArg? a14, global::Mockolate.ParameterArg? a15, global::Mockolate.ParameterArg? a16, global::Mockolate.ParameterArg? a17); + + } + + /// + /// Set up static members for the mock of IComprehensiveInterface. + /// + internal interface IMockStaticSetupForIComprehensiveInterface + { + /// + /// Setup for the int property StaticAbstractValue. + /// + global::Mockolate.Setup.IPropertyGetterOnlySetup StaticAbstractValue { get; } + + /// + /// Setup for the method StaticAbstractMethod(). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetup StaticAbstractMethod(); + + } + + /// + /// Raise events on the mock of IComprehensiveInterface. + /// + internal interface IMockRaiseOnIComprehensiveInterface + { + /// + /// Raise the PlainEvent event. + /// + void PlainEvent(object? sender, global::System.EventArgs e); + + /// + /// Raise the TypedEvent event. + /// + void TypedEvent(object? sender, global::Mockolate.Tests.GeneratorCoverage.MyEventArgs e); + + /// + /// Raise the CustomEvent event. + /// + void CustomEvent(int x, ref int y, out string z, in long w); + + /// + /// Raise the PlainEvent event. + /// + void PlainEvent(global::Mockolate.Parameters.IDefaultEventParameters parameters); + + /// + /// Raise the TypedEvent event. + /// + void TypedEvent(global::Mockolate.Parameters.IDefaultEventParameters parameters); + + /// + /// Raise the CustomEvent event. + /// + void CustomEvent(global::Mockolate.Parameters.IDefaultEventParameters parameters); + + } + + /// + /// Verify interactions with the mock of IComprehensiveInterface. + /// + internal interface IMockVerifyForIComprehensiveInterface + { + /// + /// Verify interactions with the int property GetSet. + /// + global::Mockolate.Verify.VerificationPropertyResult GetSet { get; } + + /// + /// Verify interactions with the int property GetOnly. + /// + global::Mockolate.Verify.VerificationPropertyGetterResult GetOnly { get; } + + /// + /// Verify interactions with the int property SetOnly. + /// + global::Mockolate.Verify.VerificationPropertySetterResult SetOnly { get; } + + /// + /// Verify interactions with the string? property NullableProp. + /// + global::Mockolate.Verify.VerificationPropertyResult NullableProp { get; } + + /// + /// Verify interactions with the string property InitOnly. + /// + global::Mockolate.Verify.VerificationPropertyResult InitOnly { get; } + + /// + /// Verify interactions with the string indexer this[int]. + /// + /// + /// 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::Mockolate.Verify.VerificationIndexerResult this[global::Mockolate.Parameters.IParameter? i] { get; } + + /// + /// Verify interactions with the string indexer this[int]. + /// + /// + /// 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(0)] + global::Mockolate.Verify.VerificationIndexerResult this[int i] { get; } + + /// + /// Verify interactions with the string indexer this[int, int, int, int, int]. + /// + /// + /// 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::Mockolate.Verify.VerificationIndexerResult this[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] { get; } + + /// + /// Verify interactions with the string indexer this[int, int, int, int, int]. + /// + /// + /// 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(0)] + global::Mockolate.Verify.VerificationIndexerResult this[int a, int b, int c, int d, int e] { get; } + + /// + /// Verify interactions with the long indexer this[byte, byte, byte, byte, byte]. + /// + /// + /// 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::Mockolate.Verify.VerificationIndexerGetterResult this[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] { get; } + + /// + /// Verify interactions with the long indexer this[byte, byte, byte, byte, byte]. + /// + /// + /// 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(0)] + global::Mockolate.Verify.VerificationIndexerGetterResult this[byte a, byte b, byte c, byte d, byte e] { get; } + + /// + /// Verify interactions with the long indexer this[short, short, short, short, short]. + /// + /// + /// 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::Mockolate.Verify.VerificationIndexerSetterResult this[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] { get; } + + /// + /// Verify interactions with the long indexer this[short, short, short, short, short]. + /// + /// + /// 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(0)] + global::Mockolate.Verify.VerificationIndexerSetterResult this[short a, short b, short c, short d, short e] { get; } + + /// + /// Verify interactions with the string indexer this[double]. + /// + /// + /// 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::Mockolate.Verify.VerificationIndexerGetterResult this[global::Mockolate.Parameters.IParameter? key] { get; } + + /// + /// Verify interactions with the string indexer this[double]. + /// + /// + /// 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(0)] + global::Mockolate.Verify.VerificationIndexerGetterResult this[double key] { get; } + + /// + /// Verify interactions with the string indexer this[char]. + /// + /// + /// 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::Mockolate.Verify.VerificationIndexerSetterResult this[global::Mockolate.Parameters.IParameter? key] { get; } + + /// + /// Verify interactions with the string indexer this[char]. + /// + /// + /// 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(0)] + global::Mockolate.Verify.VerificationIndexerSetterResult this[char key] { get; } + + /// + /// Verify invocations for the method WithModifiers(ref int, out string, in long, int[]) 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 WithModifiers(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Verify invocations for the method WithModifiers(ref int, out string, in long, int[]) 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(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); + + /// + /// Verify invocations for the method WithModifiers(ref int, out string, in long, int[]) 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(4)] + global::Mockolate.Verify.VerificationResult WithModifiers(global::Mockolate.Parameters.IVerifyRefParameter a, global::Mockolate.Parameters.IVerifyOutParameter b, global::Mockolate.Parameters.IParameter? c, params global::Mockolate.Parameters.IParameter[] tail); + + /// + /// Verify invocations for the method WithModifiers(ref int, out string, in long, int[]) 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(3)] + global::Mockolate.Verify.VerificationResult WithModifiers(global::Mockolate.Parameters.IVerifyRefParameter a, global::Mockolate.Parameters.IVerifyOutParameter b, long c, global::Mockolate.Parameters.IParameter? tail); + + /// + /// Verify invocations for the method WithModifiers(ref int, out string, in long, int[]) 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(3)] + global::Mockolate.Verify.VerificationResult WithModifiers(global::Mockolate.Parameters.IVerifyRefParameter a, global::Mockolate.Parameters.IVerifyOutParameter b, global::Mockolate.Parameters.IParameter? c, params int[] tail); + + /// + /// Verify invocations for the method WithModifiers(ref int, out string, in long, int[]) 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(2)] + global::Mockolate.Verify.VerificationResult WithModifiers(global::Mockolate.Parameters.IVerifyRefParameter a, global::Mockolate.Parameters.IVerifyOutParameter b, long c, params int[] tail); + + /// + /// Verify invocations for the method WithDefaults(int, MyEnum, decimal, float, char, string?, MyStruct) 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 WithDefaults(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Verify invocations for the method WithDefaults(int, MyEnum, decimal, float, char, string?, MyStruct) with the given , , , , , , . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters WithDefaults(global::Mockolate.ParameterArg? i = null, global::Mockolate.ParameterArg? e = null, global::Mockolate.ParameterArg? d = null, global::Mockolate.ParameterArg? f = null, global::Mockolate.ParameterArg? c = null, global::Mockolate.ParameterArg? s = null, global::Mockolate.ParameterArg? st = null); + + /// + /// Verify invocations for the method WithCollidingNames(int, int, int, int, int) 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 WithCollidingNames(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Verify invocations for the method WithCollidingNames(int, int, int, int, int) with the given , , , , . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters WithCollidingNames(global::Mockolate.ParameterArg? wraps, global::Mockolate.ParameterArg? result, global::Mockolate.ParameterArg? outParam1, global::Mockolate.ParameterArg? methodExecution, global::Mockolate.ParameterArg? returnValue); + + /// + /// Verify invocations for the method GetMaybeNull(string?) 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 GetMaybeNull(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Verify invocations for the method GetMaybeNull(string?) with the given . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters GetMaybeNull(global::Mockolate.ParameterArg? s); + + /// + /// Verify invocations for the method GetMaybeNull(string?) with the given . + /// + /// + /// This overload accepts a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters GetMaybeNull(global::System.Func s, [global::System.Runtime.CompilerServices.CallerArgumentExpression("s")] string sExpression = ""); + + /// + /// 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 accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters TakeObject(global::Mockolate.ParameterArg? obj); + + /// + /// Verify invocations for the method TakeObject(object?) with the given . + /// + /// + /// This overload accepts a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters TakeObject(global::System.Func obj, [global::System.Runtime.CompilerServices.CallerArgumentExpression("obj")] string objExpression = ""); + + /// + /// 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 accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters TakeTwoObjects(global::Mockolate.ParameterArg? first, global::Mockolate.ParameterArg? second); + + /// + /// Verify invocations for the method TakeTwoObjects(object?, object?) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters TakeTwoObjects(global::System.Func first, global::Mockolate.ParameterArg? second, [global::System.Runtime.CompilerServices.CallerArgumentExpression("first")] string firstExpression = ""); + + /// + /// Verify invocations for the method TakeTwoObjects(object?, object?) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters TakeTwoObjects(global::Mockolate.ParameterArg? first, global::System.Func second, [global::System.Runtime.CompilerServices.CallerArgumentExpression("second")] string secondExpression = ""); + + /// + /// Verify invocations for the method TakeTwoObjects(object?, object?) with the given , . + /// + /// + /// This overload accepts a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters TakeTwoObjects(global::System.Func first, global::System.Func second, [global::System.Runtime.CompilerServices.CallerArgumentExpression("first")] string firstExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("second")] string secondExpression = ""); + + /// + /// 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 accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters TakeIntAndObject(global::Mockolate.ParameterArg? n, global::Mockolate.ParameterArg? obj); + + /// + /// Verify invocations for the method TakeIntAndObject(int, object?) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters TakeIntAndObject(global::System.Func n, global::Mockolate.ParameterArg? obj, [global::System.Runtime.CompilerServices.CallerArgumentExpression("n")] string nExpression = ""); + + /// + /// Verify invocations for the method TakeIntAndObject(int, object?) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters TakeIntAndObject(global::Mockolate.ParameterArg? n, global::System.Func obj, [global::System.Runtime.CompilerServices.CallerArgumentExpression("obj")] string objExpression = ""); + + /// + /// Verify invocations for the method TakeIntAndObject(int, object?) with the given , . + /// + /// + /// This overload accepts a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters TakeIntAndObject(global::System.Func n, global::System.Func obj, [global::System.Runtime.CompilerServices.CallerArgumentExpression("n")] string nExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("obj")] string objExpression = ""); + + /// + /// Verify invocations for the method DoTask(). + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters DoTask(); + + /// + /// Verify invocations for the method DoTaskOf(). + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters DoTaskOf(); + + /// + /// Verify invocations for the method DoVT(). + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters DoVT(); + + /// + /// Verify invocations for the method DoVTOf(). + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters DoVTOf(); + + /// + /// Verify invocations for the method GetTuple(). + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters GetTuple(); + + /// + /// Verify invocations for the method GetNullable(). + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters GetNullable(); + + /// + /// Verify invocations for the method GetSpan(int) 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 GetSpan(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Verify invocations for the method GetSpan(int) with the given . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters GetSpan(global::Mockolate.ParameterArg? n); + + /// + /// Verify invocations for the method GetSpan(int) with the given . + /// + /// + /// This overload accepts a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters GetSpan(global::System.Func n, [global::System.Runtime.CompilerServices.CallerArgumentExpression("n")] string nExpression = ""); + + /// + /// Verify invocations for the method GetROSpan(int) 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 GetROSpan(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Verify invocations for the method GetROSpan(int) with the given . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters GetROSpan(global::Mockolate.ParameterArg? n); + + /// + /// Verify invocations for the method GetROSpan(int) with the given . + /// + /// + /// This overload accepts a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters GetROSpan(global::System.Func n, [global::System.Runtime.CompilerServices.CallerArgumentExpression("n")] string nExpression = ""); + + /// + /// Verify invocations for the method GetByRef(). + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters GetByRef(); + + /// + /// Verify invocations for the method GetByRefReadonly(). + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters GetByRefReadonly(); + + /// + /// Verify invocations for the method G1<T>(). + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters G1() + where T : class; + + /// + /// Verify invocations for the method G2<T>(). + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters G2() + where T : struct; + + /// + /// Verify invocations for the method G3<T>(). + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters G3() + where T : new(); + + /// + /// Verify invocations for the method G4<T>(). + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters G4() + where T : unmanaged; + + /// + /// Verify invocations for the method G5<T>(). + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters G5() + where T : notnull; + + /// + /// Verify invocations for the method G6<T>(). + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters G6() + where T : global::Mockolate.Tests.GeneratorCoverage.MyBase, global::System.IComparable; + + /// + /// Verify invocations for the method G7<T>(). + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters G7() + where T : class?; + + /// + /// Verify invocations for the method G8<T>(). + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters G8() + where T : allows ref struct; + + /// + /// Verify invocations for the method Five(int, int, int, int, int) 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 Five(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Verify invocations for the method Five(int, int, int, int, int) with the given , , , , . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters Five(global::Mockolate.ParameterArg? a, global::Mockolate.ParameterArg? b, global::Mockolate.ParameterArg? c, global::Mockolate.ParameterArg? d, global::Mockolate.ParameterArg? e); + + /// + /// Verify invocations for the method Seventeen(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int) 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 Seventeen(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Verify invocations for the method Seventeen(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int) with the given , , , , , , , , , , , , , , , , . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters Seventeen(global::Mockolate.ParameterArg? a1, global::Mockolate.ParameterArg? a2, global::Mockolate.ParameterArg? a3, global::Mockolate.ParameterArg? a4, global::Mockolate.ParameterArg? a5, global::Mockolate.ParameterArg? a6, global::Mockolate.ParameterArg? a7, global::Mockolate.ParameterArg? a8, global::Mockolate.ParameterArg? a9, global::Mockolate.ParameterArg? a10, global::Mockolate.ParameterArg? a11, global::Mockolate.ParameterArg? a12, global::Mockolate.ParameterArg? a13, global::Mockolate.ParameterArg? a14, global::Mockolate.ParameterArg? a15, global::Mockolate.ParameterArg? a16, global::Mockolate.ParameterArg? a17); + + /// + /// Verify invocations for the method SeventeenVoid(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int) 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 SeventeenVoid(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Verify invocations for the method SeventeenVoid(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int) with the given , , , , , , , , , , , , , , , , . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters SeventeenVoid(global::Mockolate.ParameterArg? a1, global::Mockolate.ParameterArg? a2, global::Mockolate.ParameterArg? a3, global::Mockolate.ParameterArg? a4, global::Mockolate.ParameterArg? a5, global::Mockolate.ParameterArg? a6, global::Mockolate.ParameterArg? a7, global::Mockolate.ParameterArg? a8, global::Mockolate.ParameterArg? a9, global::Mockolate.ParameterArg? a10, global::Mockolate.ParameterArg? a11, global::Mockolate.ParameterArg? a12, global::Mockolate.ParameterArg? a13, global::Mockolate.ParameterArg? a14, global::Mockolate.ParameterArg? a15, global::Mockolate.ParameterArg? a16, global::Mockolate.ParameterArg? a17); + + /// + /// Verify subscriptions on the PlainEvent event of PlainEvent. + /// + global::Mockolate.Verify.VerificationEventResult PlainEvent { get; } + + /// + /// Verify subscriptions on the TypedEvent event of TypedEvent. + /// + global::Mockolate.Verify.VerificationEventResult TypedEvent { get; } + + /// + /// Verify subscriptions on the CustomEvent event of CustomEvent. + /// + global::Mockolate.Verify.VerificationEventResult CustomEvent { get; } + + } + + /// + /// Verify static interactions with the mock of IComprehensiveInterface. + /// + internal interface IMockStaticVerifyForIComprehensiveInterface + { + /// + /// Verify interactions with the int property StaticAbstractValue. + /// + global::Mockolate.Verify.VerificationPropertyGetterResult StaticAbstractValue { get; } + + /// + /// Verify invocations for the method StaticAbstractMethod(). + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters StaticAbstractMethod(); + + } +} +/// +/// Mock extensions for IComprehensiveInterface. +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal static partial class MockExtensionsForIComprehensiveInterface +{ + /// + extension(global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface mock) + { + /// + /// Gets the mock accessor for IComprehensiveInterface - the entry point for configuring setups, verifying interactions and raising events. + /// + /// + /// The accessor is the bridge between the strongly-typed instance of IComprehensiveInterface returned by CreateMock(...) and the underlying mock registry where setups and recorded interactions live.
+ /// Through it you can:
+ ///
+ /// Setup - configure how members respond when invoked (Returns, Throws, Do, InitializeWith, ...).
+ /// Verify - assert how often (and in which order) members were invoked.
+ /// Raise - trigger events declared on the mocked type.
+ /// SetupStatic / VerifyStatic / RaiseStatic - target members on interface mocks.
+ /// InScenario / TransitionTo - scope setups and behavior to a named scenario and switch between scenarios.
+ /// Monitor, ClearAllInteractions, VerifyThatAllInteractionsAreVerified, VerifyThatAllSetupsAreUsed - manage recorded interactions.
+ /// VerifySetup - verify how often a specific setup matched.
+ ///
+ ///
+ /// The instance is not a Mockolate-generated mock of IComprehensiveInterface. + public global::Mockolate.Mock.IMockForIComprehensiveInterface Mock + { + get + { + if (mock is global::Mockolate.Mock.IMockForIComprehensiveInterface mockInterface) + { + return mockInterface; + } + throw new global::Mockolate.Exceptions.MockException("The subject is no mock."); + } + } + + /// + /// Creates a new mock of IComprehensiveInterface with the default MockBehavior. + /// + /// + /// The returned instance is a strongly-typed mock generated at compile time - it implements IComprehensiveInterface and exposes the Mockolate surface through .Mock:
+ ///
+ /// .Mock.Setup configures how members respond (Returns, Throws, Do, InitializeWith, sequences, callbacks).
+ /// .Mock.Verify asserts how often and in which order members were invoked.
+ /// .Mock.Raise triggers events declared on the mocked type.
+ ///

+ /// With the default behavior, un-configured members return default values (empty collections / strings, completed tasks, otherwise) and base-class implementations are invoked for class mocks. Use one of the overloads that accepts a MockBehavior to customize this (for example to make un-configured calls throw or to skip the base class).
+ /// Overloads allow you to additionally pass constructor parameters (for class mocks), apply an initial setup callback before the instance is returned, or combine both. + ///
+ /// A new mock instance of IComprehensiveInterface. + public static global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface CreateMock() + => CreateMock(null, null, (object?[]?)null); + + /// + /// Creates a new mock of IComprehensiveInterface with the default MockBehavior, applying the given immediately. + /// + /// + /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. + /// + /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. + /// A new mock instance of IComprehensiveInterface. + public static global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface CreateMock(global::System.Action setup) + => CreateMock(null, setup, (object?[]?)null); + + /// + /// Creates a new mock of IComprehensiveInterface with the given . + /// + /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. + /// A new mock instance of IComprehensiveInterface. + public static global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface CreateMock(global::Mockolate.MockBehavior mockBehavior) + => CreateMock(mockBehavior, null, (object?[]?)null); + + /// + /// Creates a new mock of IComprehensiveInterface with the given , applying the given immediately. + /// + /// + /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. + /// + /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. + /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. + /// A new mock instance of IComprehensiveInterface. + public static global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface CreateMock(global::Mockolate.MockBehavior mockBehavior, global::System.Action setup) + => CreateMock(mockBehavior, setup, (object?[]?)null); + + /// + /// Creates a new mock of IComprehensiveInterface using the given , applying the given immediately, using the given . + /// + /// + /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. + /// + /// Controls how the mock responds when members are invoked without a matching setup, or for MockBehavior.Default. + /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned, or to skip. + /// Values forwarded to a matching base-class constructor, or to use the parameterless constructor. + /// A new mock instance of IComprehensiveInterface. + private static global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface CreateMock(global::Mockolate.MockBehavior? mockBehavior, global::System.Action? setup, object?[]? constructorParameters) + { + if (mockBehavior is not null) + { + IMockBehaviorAccess mockBehaviorAccess = (global::Mockolate.IMockBehaviorAccess)mockBehavior; + if (mockBehaviorAccess.TryGet?>(out var additionalSetup)) + { + if (setup is null) + { + setup = additionalSetup; + } + else + { + var originalSetup = setup; + setup = s => { additionalSetup.Invoke(s); originalSetup.Invoke(s); }; + } + } + } + + mockBehavior ??= global::Mockolate.MockBehavior.Default; + global::Mockolate.MockRegistry mockRegistry = new global::Mockolate.MockRegistry(mockBehavior, global::Mockolate.Mock.IComprehensiveInterface.MemberCount, constructorParameters); + return CreateMockInstance(mockRegistry, constructorParameters, setup); + } + + private static global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface CreateMockInstance(global::Mockolate.MockRegistry mockRegistry, object?[]? constructorParameters, global::System.Action? setup) + { + var value = new global::Mockolate.Mock.IComprehensiveInterface(mockRegistry); + if (setup is not null) + { + setup.Invoke(value); + } + return value; + } + /// + /// Creates a mock that wraps the given . + /// + /// + /// Public members on the mock forward to unless overridden by a setup; protected members still go through the base-class implementation. All forwarded interactions are recorded and can be verified the same as on a plain mock. + /// + /// The real object whose calls should be forwarded. Must not be . + /// A new mock of IComprehensiveInterface that delegates to . + public global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface Wrapping(global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface instance) + { + if (mock is global::Mockolate.IMock mockInterface) + { + global::Mockolate.MockRegistry wrappingRegistry = new global::Mockolate.MockRegistry(mockInterface.MockRegistry, instance); + wrappingRegistry = new global::Mockolate.MockRegistry(wrappingRegistry, global::Mockolate.Mock.IComprehensiveInterface.CreateFastInteractions(wrappingRegistry.Behavior)); + return CreateMockInstance(wrappingRegistry, mockInterface.MockRegistry.ConstructorParameters, null); + } + throw new global::Mockolate.Exceptions.MockException("The subject is no mock."); + } + + } + + /// + extension(global::Mockolate.MockBehavior behavior) + { + /// + /// Initializes mocks of type with the given . + /// + /// + /// The is applied to the mock before the constructor is executed. Calling Initialize again overlays additional setups on top of any previously registered ones. + /// + /// The mockable type derived from IComprehensiveInterface that this setup should apply to. + /// Callback invoked when a new mock of is created. + /// A new MockBehavior with the registered initializer. The original instance is unchanged. + public global::Mockolate.MockBehavior Initialize(global::System.Action setup) + where T : global::Mockolate.Tests.GeneratorCoverage.IComprehensiveInterface + { + var behaviorAccess = (global::Mockolate.IMockBehaviorAccess)behavior; + return behaviorAccess.Set(setup); + } + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch + { + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); + } +} + +#nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/Mock.g.cs new file mode 100644 index 00000000..3ce28555 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/Mock.g.cs @@ -0,0 +1,133 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +namespace Mockolate; + +#nullable enable +/// +/// Create new mocks by calling the static T.CreateMock() method on your type T. +/// +/// +/// You can also provide a MockBehavior parameter to customize how the mock should behave in certain scenarios.
+/// If your type is a class without a default constructor, you can provide constructor parameters by passing an object?[]? to the corresponding CreateMock(...) overload. +///
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal static partial class Mock +{ + /// + /// This interface should never be used. If it is, this is an indication that the Mockolate source generator did not run correctly or that the used type is not mockable. + /// + /// + /// The source generator creates overloads with correct return values. + /// + internal interface IMockGenerationDidNotRun {} + + /// + /// Create a new mock of with the default MockBehavior. + /// + /// Type to mock, which can be an interface or a class. + /// + /// Any interface type can be used for mocking, but for classes, only abstract and virtual members can be mocked. + /// + extension(T _) + { + /// + /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when + /// is not mockable. Calling it always throws a MockException. + /// + /// Ignored; reserved for the generator-emitted overload. + /// This method never returns - it always throws. + /// + /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. + /// If you see this fallback resolved in your IDE, the generator did not run for ; + /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. + /// + /// Always thrown: the source generator did not run or is not mockable. + public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior = null) + { + throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); + } + + /// + /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when + /// is not mockable. Calling it always throws a MockException. + /// + /// Ignored; reserved for the generator-emitted overload. + /// Ignored; reserved for the generator-emitted overload. + /// This method never returns - it always throws. + /// + /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. + /// If you see this fallback resolved in your IDE, the generator did not run for ; + /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. + /// + /// Always thrown: the source generator did not run or is not mockable. + public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior, object?[]? constructorParameters) + { + throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); + } + + /// + /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when + /// is not mockable. Calling it always throws a MockException. + /// + /// Ignored; reserved for the generator-emitted overload. + /// This method never returns - it always throws. + /// + /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. + /// If you see this fallback resolved in your IDE, the generator did not run for ; + /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. + /// + /// Always thrown: the source generator did not run or is not mockable. + public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(object?[]? constructorParameters) + { + throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); + } + } + + extension(global::Mockolate.Mock.IMockGenerationDidNotRun _) + { + /// + /// Fallback Implementing that is only resolved when the Mockolate source generator did not run or when + /// is not mockable. Calling it always throws a MockException. + /// + /// Additional interface the mock should implement. + /// This method never returns - it always throws. + /// + /// The source generator emits a concrete Implementing overload per mockable type with the same shape. + /// If you see this fallback resolved in your IDE, the generator did not run for ; + /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. + /// + /// Always thrown: the source generator did not run or is not mockable. + public global::Mockolate.Mock.IMockGenerationDidNotRun Implementing() where TInterface : class + { + throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(TInterface)}' is not mockable or the source generator did not run correctly."); + } + } + + /// + /// Adapts an IParameter (non-generic) to + /// IParameterMatch<T> so that covariant parameter + /// references (e.g. an IParameter<Derived> passed through an IParameter<Base> + /// slot) can still be invoked at setup/verify time. Only allocated when the direct + /// IParameterMatch<T> cast fails. + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch + { + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); + } +} +#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/MockBehaviorExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/MockBehaviorExtensions.g.cs new file mode 100644 index 00000000..888d2c2c --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/MockBehaviorExtensions.g.cs @@ -0,0 +1,285 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +namespace Mockolate; + +#nullable enable annotations + +/// +/// Extensions for MockBehavior. +/// +internal static partial class Mock +{ + private static readonly global::Mockolate.MockBehavior _default; + + static Mock() + { + _default = new global::Mockolate.MockBehavior(new DefaultValueGenerator()); + } + + extension(global::Mockolate.MockBehavior) + { + /// + /// The default MockBehavior - the starting point for configuring a mock. + /// + /// + /// Un-configured members return the generator-provided default value (empty strings/collections, completed + /// Tasks, otherwise), base-class + /// implementations run for class mocks, and every invocation is recorded for later verification. + /// + /// Chain SkippingBaseClass(), ThrowingWhenNotSetup(), SkippingInteractionRecording(), + /// WithDefaultValueFor<T>(...) or UseConstructorParametersFor<T>(...) to derive + /// a customized MockBehavior; because it is a , + /// each call returns a new instance and this shared default stays unchanged. + /// + public static global::Mockolate.MockBehavior Default => _default; + } + + /// + /// Defines a factory for creating default values for a specified type. + /// + public interface IDefaultValueFactory + { + /// + /// Determines whether the specified can be created by this factory. + /// + bool IsMatch(global::System.Type type); + + /// + /// Creates a new instance of the specified type. + /// + object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, object?[] parameters); + } + + /// + /// A IDefaultValueFactory that returns a specified for the given type + /// parameter . + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal class TypedDefaultValueFactory(T value) : IDefaultValueFactory + { + /// + public bool IsMatch(global::System.Type type) + => type == typeof(T); + + /// + public object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) + => value; + } + + /// + /// Provides default values for common types used in mocking scenarios. + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private class DefaultValueGenerator : IDefaultValueGenerator + { + private static readonly global::System.Collections.Concurrent.ConcurrentQueue _factories = new([ + new TypedDefaultValueFactory(""), + new CancellableTaskFactory(), + #if NET8_0_OR_GREATER + new CancellableValueTaskFactory(), + #endif + new TypedDefaultValueFactory(global::System.Threading.CancellationToken.None), + new TypedDefaultValueFactory(global::System.Array.Empty()), + ]); + + /// + public object? GenerateValue(global::System.Type type, params object?[] parameters) + { + if (TryGenerate(type, parameters, out object? value)) + { + return value; + } + + return null; + } + + /// + /// Registers a to provide default values for a specific type. + /// + public static void Register(IDefaultValueFactory defaultValueFactory) + => _factories.Enqueue(defaultValueFactory); + + /// + /// Tries to generate a default value for the specified type. + /// + protected virtual bool TryGenerate(global::System.Type type, object?[] parameters, out object? value) + { + IDefaultValueFactory? matchingFactory = global::System.Linq.Enumerable.FirstOrDefault(_factories, Predicate); + if (matchingFactory is not null) + { + value = matchingFactory.Create(type, this, parameters); + return true; + } + + value = null; + return false; + + bool Predicate(global::Mockolate.Mock.IDefaultValueFactory f) + => f.IsMatch(type); + } + + private static bool HasCanceledCancellationToken(object?[] parameters, out global::System.Threading.CancellationToken cancellationToken) + { + global::System.Threading.CancellationToken parameter = global::System.Linq.Enumerable.FirstOrDefault(global::System.Linq.Enumerable.OfType(parameters)); + if (parameter.IsCancellationRequested) + { + cancellationToken = parameter; + return true; + } + + cancellationToken = global::System.Threading.CancellationToken.None; + return false; + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class CancellableTaskFactory : IDefaultValueFactory + { + /// + public bool IsMatch(global::System.Type type) + => type == typeof(global::System.Threading.Tasks.Task); + + /// + public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) + { + if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) + { + return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); + } + + return global::System.Threading.Tasks.Task.CompletedTask; + } + } + #if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class CancellableValueTaskFactory : IDefaultValueFactory + { + /// + public bool IsMatch(global::System.Type type) + => type == typeof(global::System.Threading.Tasks.ValueTask); + + /// + public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) + { + if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) + { + return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); + } + + return global::System.Threading.Tasks.ValueTask.CompletedTask; + } + } + #endif + } +} + +/// +/// Extensions on IDefaultValueGenerator +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal static class DefaultValueGeneratorExtensions +{ + /// + /// Adds a generic Generate method for specific types. + /// + extension(IDefaultValueGenerator generator) + { + /// + /// Generates a Task of , with + /// the for context. + /// + public global::System.Threading.Tasks.Task Generate(global::System.Threading.Tasks.Task nullValue, T value, params object?[] parameters) + { + global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( + global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; + if (cancellationToken.IsCancellationRequested) + { + return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); + } + + return global::System.Threading.Tasks.Task.FromResult(value); + } + +#if NET8_0_OR_GREATER + /// + /// Generates a ValueTask of , with + /// the for context. + /// + public global::System.Threading.Tasks.ValueTask Generate(global::System.Threading.Tasks.ValueTask nullValue, T value, params object?[] parameters) + { + global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( + global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; + if (cancellationToken.IsCancellationRequested) + { + return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); + } + + return global::System.Threading.Tasks.ValueTask.FromResult(value); + } +#endif + + /// + /// Generates an empty enumerable of , with + /// the for context. + /// + public global::System.Collections.Generic.IEnumerable Generate(global::System.Collections.Generic.IEnumerable nullValue, params object?[] parameters) + => global::System.Array.Empty(); + + /// + /// Generates an empty enumerable of , with + /// the for context. + /// + public global::System.Collections.Generic.List Generate(global::System.Collections.Generic.List nullValue, params object?[] parameters) + => new global::System.Collections.Generic.List(); + + /// + /// Generates an empty array of , with + /// the for context. + /// + public T[] Generate(T[] nullValue, params object?[] parameters) + => global::System.Array.Empty(); + + /// + /// Generates an empty two-dimensional array of , with + /// the for context. + /// + public T[,] Generate(T[,] nullValue, params object?[] parameters) + => new T[,] { }; + + /// + /// Generates an empty three-dimensional array of , with + /// the for context. + /// + public T[,,] Generate(T[,,] nullValue, params object?[] parameters) + => new T[,,] { }; + + /// + /// Generates an empty four-dimensional array of , with + /// the for context. + /// + public T[,,,] Generate(T[,,,] nullValue, params object?[] parameters) + => new T[,,,] { }; + + /// + /// Generates a default value of type , with + /// the for context. + /// + public T Generate(T nullValue, params object?[] parameters) + { + if (generator.GenerateValue(typeof(T), parameters) is T value) + { + return value; + } + + return nullValue; + } + } +} + +#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ParameterArg.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ParameterArg.g.cs new file mode 100644 index 00000000..50826154 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ParameterArg.g.cs @@ -0,0 +1,133 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +#nullable enable + +namespace Mockolate +{ + /// + /// A setup or verify argument that is either an It matcher + /// (IParameter<T>) or a literal value of type . + /// + /// + /// Both case types convert implicitly, so Setup.Method(42) and Setup.Method(It.IsAny<int>()) + /// bind to the same overload. A instance stands for the literal default(T). + /// + [global::System.Runtime.CompilerServices.Union] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal readonly struct ParameterArg + { + private const byte MatcherTag = 1; + private const byte LiteralTag = 2; + + private readonly global::Mockolate.Parameters.IParameter? _matcher; + private readonly T? _literal; + private readonly byte _tag; + + /// + /// Creates the matcher case. + /// + public ParameterArg(global::Mockolate.Parameters.IParameter matcher) + { + _matcher = matcher; + _literal = default; + _tag = MatcherTag; + } + + /// + /// Creates the literal value case. + /// + public ParameterArg(T? literal) + { + _matcher = null; + _literal = literal; + _tag = LiteralTag; + } + + /// + /// The contained matcher or literal value, boxed. Part of the union pattern; the generated mocks use the + /// typed accessors instead. + /// + public object? Value => _tag switch + { + MatcherTag => _matcher, + LiteralTag => _literal, + _ => null, + }; + + /// + /// unless this is the instance. + /// + public bool HasValue => _tag != 0; + + /// + /// when the argument is a literal value (including the instance). + /// + public bool IsLiteral => _tag != MatcherTag; + + /// + /// The literal value; default(T) for the matcher case and the instance. + /// + public T? Literal => _literal; + + /// + /// Gets the matcher, when this is the matcher case. + /// + public bool TryGetValue(out global::Mockolate.Parameters.IParameter? matcher) + { + matcher = _matcher; + return _tag == MatcherTag; + } + + /// + /// Gets the literal value, when this is the literal case. + /// + public bool TryGetValue(out T? literal) + { + literal = _literal; + return _tag == LiteralTag; + } + + /// + /// The IParameterMatch<T> for this argument: the matcher itself, + /// or an equality match for the literal value. + /// + public global::Mockolate.Parameters.IParameterMatch ToParameterMatch() + { + if (_tag != MatcherTag) + { + return (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(_literal!); + } + + if (_matcher is null) + { + return (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsNull("null"); + } + + return _matcher is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantAdapter(_matcher); + } + + /// + public override string ToString() => _tag switch + { + MatcherTag => _matcher?.ToString() ?? "null", + _ => _literal?.ToString() ?? "null", + }; + + private sealed class CovariantAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch + { + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + } + } +} +#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ReturnsThrowsAsyncExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ReturnsThrowsAsyncExtensions.g.cs new file mode 100644 index 00000000..9a4ac933 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ReturnsThrowsAsyncExtensions.g.cs @@ -0,0 +1,288 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +namespace Mockolate; + +#nullable enable + +/// +/// Extensions for setting up return values and throwing exceptions for methods. +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal static class ReturnsThrowsAsyncExtensions2 +{ + /// + /// Appends to the sequence - the next matching invocation returns a completed + /// Task<TReturn> carrying this value. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5> setup, TReturn returnValue) + => setup.Returns(global::System.Threading.Tasks.Task.FromResult(returnValue)); + + /// + /// Appends a lazy async return to the sequence; is invoked on each matching + /// invocation and its result is wrapped in a completed Task<TReturn>. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5> setup, global::System.Func callback) + => setup.Returns(() => global::System.Threading.Tasks.Task.FromResult(callback())); + + /// + /// Appends a lazy async return that receives the method's arguments and produces the value wrapped in a + /// completed Task<TReturn>. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5> setup, global::System.Func callback) + => setup.Returns((v1, v2, v3, v4, v5) => global::System.Threading.Tasks.Task.FromResult(callback(v1, v2, v3, v4, v5))); + + /// + /// Appends an entry that faults the returned Task<TReturn> with + /// so awaiting it throws. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5> setup, global::System.Exception exception) + => setup.Returns(global::System.Threading.Tasks.Task.FromException(exception)); + + /// + /// Appends an entry that invokes to build the exception the returned + /// Task<TReturn> is faulted with. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5> setup, global::System.Func callback) + => setup.Returns(() => global::System.Threading.Tasks.Task.FromException(callback())); + + /// + /// Appends an entry that invokes with the method's arguments to build the + /// exception the returned Task<TReturn> is faulted with. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5> setup, global::System.Func callback) + => setup.Returns((v1, v2, v3, v4, v5) => global::System.Threading.Tasks.Task.FromException(callback(v1, v2, v3, v4, v5))); + + /// + /// Appends to the sequence - the next matching invocation returns a completed + /// Task<TReturn> carrying this value. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, TReturn returnValue) + => setup.Returns(global::System.Threading.Tasks.Task.FromResult(returnValue)); + + /// + /// Appends a lazy async return to the sequence; is invoked on each matching + /// invocation and its result is wrapped in a completed Task<TReturn>. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, global::System.Func callback) + => setup.Returns(() => global::System.Threading.Tasks.Task.FromResult(callback())); + + /// + /// Appends a lazy async return that receives the method's arguments and produces the value wrapped in a + /// completed Task<TReturn>. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, global::System.Func callback) + => setup.Returns((v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) => global::System.Threading.Tasks.Task.FromResult(callback(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17))); + + /// + /// Appends an entry that faults the returned Task<TReturn> with + /// so awaiting it throws. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, global::System.Exception exception) + => setup.Returns(global::System.Threading.Tasks.Task.FromException(exception)); + + /// + /// Appends an entry that invokes to build the exception the returned + /// Task<TReturn> is faulted with. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, global::System.Func callback) + => setup.Returns(() => global::System.Threading.Tasks.Task.FromException(callback())); + + /// + /// Appends an entry that invokes with the method's arguments to build the + /// exception the returned Task<TReturn> is faulted with. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, global::System.Func callback) + => setup.Returns((v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) => global::System.Threading.Tasks.Task.FromException(callback(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17))); + +#if NET8_0_OR_GREATER + + /// + /// Appends to the sequence - the next matching invocation returns a completed + /// ValueTask<TReturn> carrying this value. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5> setup, TReturn returnValue) + => setup.Returns(global::System.Threading.Tasks.ValueTask.FromResult(returnValue)); + + /// + /// Appends a lazy async return to the sequence; is invoked on each matching + /// invocation and its result is wrapped in a completed ValueTask<TReturn>. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5> setup, global::System.Func callback) + => setup.Returns(() => global::System.Threading.Tasks.ValueTask.FromResult(callback())); + + /// + /// Appends a lazy async return that receives the method's arguments and produces the value wrapped in a + /// completed ValueTask<TReturn>. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5> setup, global::System.Func callback) + => setup.Returns((v1, v2, v3, v4, v5) => global::System.Threading.Tasks.ValueTask.FromResult(callback(v1, v2, v3, v4, v5))); + + /// + /// Appends an entry that faults the returned ValueTask<TReturn> with + /// so awaiting it throws. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5> setup, global::System.Exception exception) + => setup.Returns(global::System.Threading.Tasks.ValueTask.FromException(exception)); + + /// + /// Appends an entry that invokes to build the exception the returned + /// ValueTask<TReturn> is faulted with. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5> setup, global::System.Func callback) + => setup.Returns(() => global::System.Threading.Tasks.ValueTask.FromException(callback())); + + /// + /// Appends an entry that invokes with the method's arguments to build the + /// exception the returned ValueTask<TReturn> is faulted with. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5> setup, global::System.Func callback) + => setup.Returns((v1, v2, v3, v4, v5) => global::System.Threading.Tasks.ValueTask.FromException(callback(v1, v2, v3, v4, v5))); + + /// + /// Appends to the sequence - the next matching invocation returns a completed + /// ValueTask<TReturn> carrying this value. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, TReturn returnValue) + => setup.Returns(global::System.Threading.Tasks.ValueTask.FromResult(returnValue)); + + /// + /// Appends a lazy async return to the sequence; is invoked on each matching + /// invocation and its result is wrapped in a completed ValueTask<TReturn>. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, global::System.Func callback) + => setup.Returns(() => global::System.Threading.Tasks.ValueTask.FromResult(callback())); + + /// + /// Appends a lazy async return that receives the method's arguments and produces the value wrapped in a + /// completed ValueTask<TReturn>. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, global::System.Func callback) + => setup.Returns((v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) => global::System.Threading.Tasks.ValueTask.FromResult(callback(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17))); + + /// + /// Appends an entry that faults the returned ValueTask<TReturn> with + /// so awaiting it throws. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, global::System.Exception exception) + => setup.Returns(global::System.Threading.Tasks.ValueTask.FromException(exception)); + + /// + /// Appends an entry that invokes to build the exception the returned + /// ValueTask<TReturn> is faulted with. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, global::System.Func callback) + => setup.Returns(() => global::System.Threading.Tasks.ValueTask.FromException(callback())); + + /// + /// Appends an entry that invokes with the method's arguments to build the + /// exception the returned ValueTask<TReturn> is faulted with. + /// + /// + /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles + /// back to the first entry unless the last one is followed by .Forever(). + /// + public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, global::System.Func callback) + => setup.Returns((v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) => global::System.Threading.Tasks.ValueTask.FromException(callback(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17))); + +#endif +} +#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpClient.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpClient.g.cs new file mode 100644 index 00000000..74974867 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpClient.g.cs @@ -0,0 +1,1823 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +#nullable enable annotations +namespace Mockolate; + +internal static partial class Mock +{ + /// + /// A mock implementation for HttpClient. + /// + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal class HttpClient : + global::System.Net.Http.HttpClient, IMockForHttpClient, IMockSetupForHttpClient, IMockProtectedSetupForHttpClient, global::Mockolate.MockExtensionsForHttpClient.IMockSetupInitializationForHttpClient, IMockVerifyForHttpClient, IMockProtectedVerifyForHttpClient, + global::Mockolate.IMock + { + internal const int MemberId_Send = 0; + internal const int MemberId_SendAsync = 1; + internal const int MemberId_Dispose = 2; + internal const int MemberCount = 3; + + /// + /// Creates a FastMockInteractions sized to MemberCount for use as the mock's interaction store. + /// Per-member buffers are not allocated up-front: the recording hot paths call GetOrCreateBuffer<TBuffer>(int, Func<FastMockInteractions, TBuffer>) so a slot is materialized only when its member is first invoked. + /// + internal static global::Mockolate.Interactions.FastMockInteractions CreateFastInteractions(global::Mockolate.MockBehavior behavior) + => new global::Mockolate.Interactions.FastMockInteractions(MemberCount, behavior.SkipInteractionRecording); + + /// + /// Builds a MockRegistry backed by a typed-buffer-sized FastMockInteractions from . + /// + private static global::Mockolate.MockRegistry MockolateCreateRegistryFromBehavior(global::Mockolate.MockBehavior behavior) + { + global::Mockolate.MockRegistry registry = new global::Mockolate.MockRegistry(behavior, MemberCount); + MockRegistryProvider.Value = registry; + return registry; + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.MockRegistry global::Mockolate.IMock.MockRegistry => this.MockRegistry; + private global::Mockolate.MockRegistry MockRegistry + { + get => field ?? MockRegistryProvider.Value; + set; + } + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + internal static readonly global::System.Threading.AsyncLocal MockRegistryProvider = new global::System.Threading.AsyncLocal(); + + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod2Buffer MockolateBuffer_Send + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.HttpClient.MemberId_Send, static fast => new global::Mockolate.Interactions.FastMethod2Buffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod2Buffer MockolateBuffer_SendAsync + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, static fast => new global::Mockolate.Interactions.FastMethod2Buffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod1Buffer MockolateBuffer_Dispose + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.HttpClient.MemberId_Dispose, static fast => new global::Mockolate.Interactions.FastMethod1Buffer(fast))); + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + IMockSetupForHttpClient IMockForHttpClient.Setup + => this; + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + IMockProtectedSetupForHttpClient IMockForHttpClient.SetupProtected + => this; + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + IMockProtectedSetupForHttpClient global::Mockolate.MockExtensionsForHttpClient.IMockSetupInitializationForHttpClient.Protected + => this; + /// + IMockInScenarioForHttpClient IMockForHttpClient.InScenario(string scenario) + => new MockInScenarioForHttpClient(this.MockRegistry, scenario); + + /// + IMockForHttpClient IMockForHttpClient.InScenario(string scenario, global::System.Action setup) + { + setup.Invoke(new MockInScenarioForHttpClient(this.MockRegistry, scenario)); + return this; + } + + /// + IMockForHttpClient IMockForHttpClient.TransitionTo(string scenario) + { + this.MockRegistry.TransitionTo(scenario); + return this; + } + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + IMockVerifyForHttpClient IMockForHttpClient.Verify + => this; + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + IMockProtectedVerifyForHttpClient IMockForHttpClient.VerifyProtected + => this; + /// + global::Mockolate.Verify.VerificationResult IMockForHttpClient.VerifySetup(global::Mockolate.Setup.IMethodSetup setup) + => this.MockRegistry.Method(this, setup); + /// + bool IMockForHttpClient.VerifyThatAllInteractionsAreVerified() + => this.MockRegistry.Interactions.GetUnverifiedInteractions().Count == 0; + /// + bool IMockForHttpClient.VerifyThatAllSetupsAreUsed() + => this.MockRegistry.GetUnusedSetups(this.MockRegistry.Interactions).Count == 0; + /// + void IMockForHttpClient.ClearAllInteractions() + => this.MockRegistry.ClearAllInteractions(); + /// + global::Mockolate.Monitor.MockMonitor IMockForHttpClient.Monitor() + => new global::Mockolate.Monitor.MockMonitor(this.MockRegistry.Interactions, interactions => new VerifyMonitorHttpClient(new global::Mockolate.MockRegistry(this.MockRegistry, interactions))); + + /// + string global::Mockolate.IMock.ToString() + => "System.Net.Http.HttpClient mock"; + + /// + public HttpClient(global::Mockolate.MockRegistry mockRegistry) + : base() + { + this.MockRegistry = mockRegistry; + } + + /// + public HttpClient(global::Mockolate.MockBehavior behavior) + : this(MockolateCreateRegistryFromBehavior(behavior)) + { + } + + /// + public HttpClient(global::Mockolate.MockRegistry mockRegistry, global::System.Net.Http.HttpMessageHandler handler) + : base(handler) + { + this.MockRegistry = mockRegistry; + } + + /// + public HttpClient(global::Mockolate.MockBehavior behavior, global::System.Net.Http.HttpMessageHandler handler) + : this(MockolateCreateRegistryFromBehavior(behavior), handler) + { + } + + /// + public HttpClient(global::Mockolate.MockRegistry mockRegistry, global::System.Net.Http.HttpMessageHandler handler, bool disposeHandler) + : base(handler, disposeHandler) + { + this.MockRegistry = mockRegistry; + } + + /// + public HttpClient(global::Mockolate.MockBehavior behavior, global::System.Net.Http.HttpMessageHandler handler, bool disposeHandler) + : this(MockolateCreateRegistryFromBehavior(behavior), handler, disposeHandler) + { + } + + #region System.Net.Http.HttpClient + + /// + [global::System.Runtime.Versioning.UnsupportedOSPlatform("android")] + [global::System.Runtime.Versioning.UnsupportedOSPlatform("browser")] + [global::System.Runtime.Versioning.UnsupportedOSPlatform("ios")] + [global::System.Runtime.Versioning.UnsupportedOSPlatform("tvos")] + public override global::System.Net.Http.HttpResponseMessage Send(global::System.Net.Http.HttpRequestMessage request, global::System.Threading.CancellationToken cancellationToken) + { + global::Mockolate.Setup.ReturnMethodSetup? methodSetup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.HttpClient.MemberId_Send); + 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(request, cancellationToken)) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::System.Net.Http.HttpMessageInvoker.Send")) + { + if (s_methodSetup.Matches(request, cancellationToken)) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + global::System.Net.Http.HttpResponseMessage wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_Send.Append("global::System.Net.Http.HttpMessageInvoker.Send", request, cancellationToken); + } + try + { + if (this.MockRegistry.Wraps is global::System.Net.Http.HttpClient wraps) + { + wrappedResult = wraps.Send(request, cancellationToken); + hasWrappedResult = true; + } + #if NETFRAMEWORK + // Persist the HttpContent, because it gets automatically disposed on .NET Framework + if (request.Content != null) + { + var stream = request.Content.ReadAsStreamAsync().ConfigureAwait(false).GetAwaiter().GetResult(); + using global::System.IO.MemoryStream ms = new(); + stream.CopyTo(ms); + byte[] bytes = ms.ToArray(); + stream.Position = 0L; + request.Properties.Add("Mockolate:HttpContent", bytes); + } + #endif + if (!(methodSetup?.SkipBaseClass(this.MockRegistry.Behavior) ?? this.MockRegistry.Behavior.SkipBaseClass) && !hasWrappedResult) + { + wrappedResult = base.Send(request, cancellationToken); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(request, cancellationToken); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::System.Net.Http.HttpMessageInvoker.Send(HttpRequestMessage, CancellationToken)' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(request, cancellationToken, out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(global::System.Net.Http.HttpResponseMessage)!, request, cancellationToken); + } + + /// + public override global::System.Threading.Tasks.Task SendAsync(global::System.Net.Http.HttpRequestMessage request, global::System.Threading.CancellationToken cancellationToken) + { + global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>? methodSetup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.HttpClient.MemberId_SendAsync); + 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, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> s_methodSetup && s_methodSetup.Matches(request, cancellationToken)) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> s_methodSetup in this.MockRegistry.GetMethodSetups, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>>("global::System.Net.Http.HttpMessageInvoker.SendAsync")) + { + if (s_methodSetup.Matches(request, cancellationToken)) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + global::System.Threading.Tasks.Task wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_SendAsync.Append("global::System.Net.Http.HttpMessageInvoker.SendAsync", request, cancellationToken); + } + try + { + if (this.MockRegistry.Wraps is global::System.Net.Http.HttpClient wraps) + { + wrappedResult = wraps.SendAsync(request, cancellationToken); + hasWrappedResult = true; + } + #if NETFRAMEWORK + // Persist the HttpContent, because it gets automatically disposed on .NET Framework + if (request.Content != null) + { + var stream = request.Content.ReadAsStreamAsync().ConfigureAwait(false).GetAwaiter().GetResult(); + using global::System.IO.MemoryStream ms = new(); + stream.CopyTo(ms); + byte[] bytes = ms.ToArray(); + stream.Position = 0L; + request.Properties.Add("Mockolate:HttpContent", bytes); + } + #endif + if (!(methodSetup?.SkipBaseClass(this.MockRegistry.Behavior) ?? this.MockRegistry.Behavior.SkipBaseClass) && !hasWrappedResult) + { + wrappedResult = base.SendAsync(request, cancellationToken); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(request, cancellationToken); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage, CancellationToken)' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(request, cancellationToken, out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(global::System.Threading.Tasks.Task)!, this.MockRegistry.Behavior.DefaultValue.Generate(default(global::System.Net.Http.HttpResponseMessage)!, request, cancellationToken), request, cancellationToken); + } + + /// + protected override void Dispose(bool disposing) + { + global::Mockolate.Setup.VoidMethodSetup? methodSetup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.HttpClient.MemberId_Dispose); + 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.VoidMethodSetup s_methodSetup && s_methodSetup.Matches(disposing)) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.VoidMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::System.Net.Http.HttpMessageInvoker.Dispose")) + { + if (s_methodSetup.Matches(disposing)) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_Dispose.Append("global::System.Net.Http.HttpMessageInvoker.Dispose", disposing); + } + try + { + if (!(methodSetup?.SkipBaseClass(this.MockRegistry.Behavior) ?? this.MockRegistry.Behavior.SkipBaseClass)) + { + base.Dispose(disposing); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(disposing); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::System.Net.Http.HttpMessageInvoker.Dispose(bool)' was invoked without prior setup."); + } + } + + #endregion System.Net.Http.HttpClient + + #region IMockSetupForHttpClient + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", parameters, "request", "cancellationToken"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + global::Mockolate.Setup.ReturnMethodSetup methodSetup; + if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.Literal!, cancellationTokenArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) + { + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", parameters, "request", "cancellationToken"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> methodSetup; + if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.Literal!, cancellationTokenArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) + { + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + #endregion IMockSetupForHttpClient + + #region IMockProtectedSetupForHttpClient + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockProtectedSetupForHttpClient.Dispose(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", parameters, "disposing"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Dispose, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpClient.Dispose(global::Mockolate.ParameterArg? disposing) + { + global::Mockolate.ParameterArg disposingArg = disposing ?? default; + global::Mockolate.Setup.VoidMethodSetup methodSetup; + if (disposingArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", disposingArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", disposingArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Dispose, methodSetup); + return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpClient.Dispose(global::System.Func disposing, string disposingExpression) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(disposing, disposingExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Dispose, methodSetup); + return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; + } + + #endregion IMockProtectedSetupForHttpClient + + #region IMockVerifyForHttpClient + + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForHttpClient.Send(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("request", __i.Parameter1), ("cancellationToken", __i.Parameter2)]), + _ => true + }, () => $"Send({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.Literal!, cancellationTokenArg.Literal!, () => $"Send({requestArg}, {cancellationTokenArg})"); + } + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch(), () => $"Send({requestArg}, {cancellationTokenArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) + { + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch(), () => $"Send({requestExpression}, {cancellationTokenArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"Send({requestArg}, {cancellationTokenExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.Send(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"Send({requestExpression}, {cancellationTokenExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForHttpClient.SendAsync(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("request", __i.Parameter1), ("cancellationToken", __i.Parameter2)]), + _ => true + }, () => $"SendAsync({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.Literal!, cancellationTokenArg.Literal!, () => $"SendAsync({requestArg}, {cancellationTokenArg})"); + } + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch(), () => $"SendAsync({requestArg}, {cancellationTokenArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) + { + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch(), () => $"SendAsync({requestExpression}, {cancellationTokenArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"SendAsync({requestArg}, {cancellationTokenExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.SendAsync(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"SendAsync({requestExpression}, {cancellationTokenExpression})"); + } + + #endregion IMockVerifyForHttpClient + + #region IMockProtectedVerifyForHttpClient + + /// + global::Mockolate.Verify.VerificationResult IMockProtectedVerifyForHttpClient.Dispose(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.HttpClient.MemberId_Dispose, "global::System.Net.Http.HttpMessageInvoker.Dispose", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("disposing", __i.Parameter1)]), + _ => true + }, () => $"Dispose({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpClient.Dispose(global::Mockolate.ParameterArg? disposing) + { + global::Mockolate.ParameterArg disposingArg = disposing ?? default; + if (disposingArg.IsLiteral) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Dispose, "global::System.Net.Http.HttpMessageInvoker.Dispose", disposingArg.Literal!, () => $"Dispose({disposingArg})"); + } + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Dispose, "global::System.Net.Http.HttpMessageInvoker.Dispose", disposingArg.ToParameterMatch(), () => $"Dispose({disposingArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpClient.Dispose(global::System.Func disposing, string disposingExpression) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Dispose, "global::System.Net.Http.HttpMessageInvoker.Dispose", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(disposing, disposingExpression), () => $"Dispose({disposingExpression})"); + } + + #endregion IMockProtectedVerifyForHttpClient + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class VerifyMonitorHttpClient(global::Mockolate.MockRegistry mockRegistry) : global::Mockolate.Mock.IMockVerifyForHttpClient + { + private global::Mockolate.MockRegistry MockRegistry { get; } = mockRegistry; + + #region IMockVerifyForHttpClient + + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForHttpClient.Send(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("request", __i.Parameter1), ("cancellationToken", __i.Parameter2)]), + _ => true + }, () => $"Send({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.Literal!, cancellationTokenArg.Literal!, () => $"Send({requestArg}, {cancellationTokenArg})"); + } + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch(), () => $"Send({requestArg}, {cancellationTokenArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) + { + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch(), () => $"Send({requestExpression}, {cancellationTokenArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"Send({requestArg}, {cancellationTokenExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.Send(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"Send({requestExpression}, {cancellationTokenExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForHttpClient.SendAsync(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("request", __i.Parameter1), ("cancellationToken", __i.Parameter2)]), + _ => true + }, () => $"SendAsync({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.Literal!, cancellationTokenArg.Literal!, () => $"SendAsync({requestArg}, {cancellationTokenArg})"); + } + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch(), () => $"SendAsync({requestArg}, {cancellationTokenArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) + { + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch(), () => $"SendAsync({requestExpression}, {cancellationTokenArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"SendAsync({requestArg}, {cancellationTokenExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.SendAsync(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"SendAsync({requestExpression}, {cancellationTokenExpression})"); + } + + #endregion IMockVerifyForHttpClient + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class MockInScenarioForHttpClient : global::Mockolate.Mock.IMockInScenarioForHttpClient, global::Mockolate.Mock.IMockSetupForHttpClient, global::Mockolate.Mock.IMockProtectedSetupForHttpClient + { + private global::Mockolate.MockRegistry MockRegistry { get; } + private string _scenarioName; + + public MockInScenarioForHttpClient(global::Mockolate.MockRegistry mockRegistry, string scenario) + { + this.MockRegistry = mockRegistry; + _scenarioName = scenario; + } + + /// + global::Mockolate.Mock.IMockSetupForHttpClient global::Mockolate.Mock.IMockInScenarioForHttpClient.Setup + => this; + + /// + global::Mockolate.Mock.IMockProtectedSetupForHttpClient global::Mockolate.Mock.IMockInScenarioForHttpClient.SetupProtected + => this; + + #region IMockSetupForHttpClient + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", parameters, "request", "cancellationToken"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + global::Mockolate.Setup.ReturnMethodSetup methodSetup; + if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.Literal!, cancellationTokenArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) + { + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", parameters, "request", "cancellationToken"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> methodSetup; + if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.Literal!, cancellationTokenArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) + { + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + #endregion IMockSetupForHttpClient + + #region IMockProtectedSetupForHttpClient + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockProtectedSetupForHttpClient.Dispose(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", parameters, "disposing"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Dispose, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpClient.Dispose(global::Mockolate.ParameterArg? disposing) + { + global::Mockolate.ParameterArg disposingArg = disposing ?? default; + global::Mockolate.Setup.VoidMethodSetup methodSetup; + if (disposingArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", disposingArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", disposingArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Dispose, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpClient.Dispose(global::System.Func disposing, string disposingExpression) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(disposing, disposingExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Dispose, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; + } + + #endregion IMockProtectedSetupForHttpClient + } + + /// + /// The Mockolate accessor for a mock of HttpClient, reached through .Mock on the mocked instance. + /// + /// + /// Groups every operation that acts on the mock rather than on the mocked subject: setups, verifications, event raising, scenarios and monitoring. + /// + internal interface IMockForHttpClient + { + /// + /// Configures how members of the mock of HttpClient respond when invoked. + /// + /// + /// Each mocked member is available as a strongly-typed entry on this surface. Chain Returns, ReturnsAsync, Throws, ThrowsAsync or Do to control the response; chain InitializeWith/Register to initialize properties and indexers; chain multiple returns/throws to define a sequence; use .For(n), .Only(n), .Forever(), .When(predicate) to control when a callback runs.
+ /// When two setups overlap, the most recently defined one wins. + ///
+ IMockSetupForHttpClient Setup { get; } + + /// + /// Configures how virtual members of the mock of HttpClient respond when invoked. + /// + /// + /// Only members declared as (or ) on the mocked class appear here. All setup chain operators (Returns, Throws, Do, sequences, .For/.Only/.Forever, ...) work identically to Setup. + /// + IMockProtectedSetupForHttpClient SetupProtected { get; } + + /// + /// Opens a named scenario scope on the mock of HttpClient so that additional setups can be registered for that scenario. + /// + /// + /// Scenarios let you define per-state behavior. Setups registered inside the returned IMockInScenarioFor... scope only apply while the mock's current scenario matches ; switch scenarios with TransitionTo. + /// + /// Name of the scenario to enter. Any non-null string acts as a key; the mock starts in an unnamed default scenario. + /// A scoped accessor whose Setup (and SetupProtected, where applicable) register scenario-specific setups. + IMockInScenarioForHttpClient InScenario(string scenario); + + /// + /// Opens a named scenario scope on the mock of HttpClient and immediately invokes to register scenario-specific setups. + /// + /// + /// Equivalent to InScenario(scenario) followed by the setup callback, but returns the original IMockFor... accessor so it chains nicely at mock-creation time. + /// + /// Name of the scenario to enter. + /// Callback that receives the scenario-scoped setup surface and registers scenario-specific setups. + /// This accessor, to allow chaining. + IMockForHttpClient InScenario(string scenario, global::System.Action setup); + + /// + /// Switches the active scenario of the mock of HttpClient to . + /// + /// + /// After the transition, setups registered via InScenario(string) under that scenario take effect. Scenarios that have no matching setup for a given member fall back to the default (un-scoped) setups. + /// + /// Name of the scenario to transition to. + /// This accessor, to allow chaining. + IMockForHttpClient TransitionTo(string scenario); + + /// + /// Asserts how often, and in which order, members of the mock of HttpClient were invoked. + /// + /// + /// Each call to a member here returns a VerificationResult that you terminate with a count assertion: Never(), Once(), Twice(), Exactly(n), AtLeast(n)/AtLeastOnce()/AtLeastTwice(), AtMost(n)/AtMostOnce()/AtMostTwice(), Between(min, max) or Times(predicate).
+ /// Use Within(TimeSpan) / WithCancellation(CancellationToken) before the terminator to wait for expected interactions that happen on background threads.
+ /// Chain Then(...) to assert an ordered sequence of calls. A failing assertion throws a MockVerificationException. + ///
+ IMockVerifyForHttpClient Verify { get; } + + /// + /// Asserts how often, and in which order, members of the mock of HttpClient were invoked. + /// + /// + /// Same terminators and modifiers as Verify (Once(), Exactly(n), Within(...), Then(...), ...); applies to members and events instead of public ones. + /// + IMockProtectedVerifyForHttpClient VerifyProtected { get; } + + /// + /// Verifies how often a specific method setup was matched by actual invocations. + /// + /// + /// Useful when you want to verify "this particular setup was hit N times" without re-stating the matchers. Chain the usual count terminators (Once(), AtLeastOnce(), Exactly(n), ...) on the returned result. + /// + /// The setup previously registered through Setup (typically returned from a Returns(...)/Throws(...) call). + /// A VerificationResult that counts invocations matching the given setup. + global::Mockolate.Verify.VerificationResult VerifySetup(global::Mockolate.Setup.IMethodSetup setup); + + /// + /// Checks whether every recorded interaction on this mock has been observed by at least one Verify call. + /// + /// + /// Useful in test teardown to catch unexpected interactions ("strict verification"): if any recorded call has never been matched by a verification, the method returns . + /// + /// if every recorded interaction was verified at least once; otherwise . + bool VerifyThatAllInteractionsAreVerified(); + + /// + /// Checks whether every registered setup on this mock was matched by at least one actual invocation. + /// + /// + /// Useful to catch unused setups that silently rot as the test subject evolves. + /// + /// if every registered setup was used at least once; otherwise . + bool VerifyThatAllSetupsAreUsed(); + + /// + /// Removes every recorded interaction from this mock while keeping all registered setups intact. + /// + /// + /// Handy when a single test exercises multiple logical phases and you only want to verify the interactions of the latest phase. + /// + void ClearAllInteractions(); + + /// + /// Creates a monitor whose Verify surface is scoped to interactions produced between monitor.Run() and the disposal of its IDisposable scope. + /// + /// + /// The underlying mock keeps recording all interactions as usual - only the monitor's Verify view is scoped. Useful to verify only the interactions produced by a specific block of test code without resetting the mock. + /// + /// A MockMonitor<T> that exposes Verify over the monitored interactions and a Run() method that opens the recording scope. + global::Mockolate.Monitor.MockMonitor Monitor(); + } + + /// + /// Scoped access to setups for a scenario on the mock of HttpClient. + /// + internal interface IMockInScenarioForHttpClient + { + /// + /// Set up the mock of HttpClient within the scenario scope. + /// + IMockSetupForHttpClient Setup { get; } + + /// + /// Set up protected members of the mock of HttpClient within the scenario scope. + /// + IMockProtectedSetupForHttpClient SetupProtected { get; } + } + + /// + /// Set up the mock of HttpClient. + /// + internal interface IMockSetupForHttpClient : global::Mockolate.Setup.IMockSetup + { + /// + /// Setup for the method Send(HttpRequestMessage, CancellationToken) 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 Send(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Setup for the method Send(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken); + + /// + /// Setup for the method Send(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = ""); + + /// + /// Setup for the method Send(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); + + /// + /// Setup for the method Send(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Send(global::System.Func request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); + + /// + /// Setup for the method SendAsync(HttpRequestMessage, CancellationToken) 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, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Setup for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken); + + /// + /// Setup for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = ""); + + /// + /// Setup for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); + + /// + /// Setup for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::System.Func request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); + + } + + /// + /// Set up protected members for the mock of HttpClient. + /// + internal interface IMockProtectedSetupForHttpClient + { + /// + /// Setup for the method Dispose(bool) 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.IVoidMethodSetupWithCallback Dispose(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Setup for the method Dispose(bool) with the given . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer Dispose(global::Mockolate.ParameterArg? disposing); + + /// + /// Setup for the method Dispose(bool) with the given . + /// + /// + /// This overload accepts a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer Dispose(global::System.Func disposing, [global::System.Runtime.CompilerServices.CallerArgumentExpression("disposing")] string disposingExpression = ""); + + } + + /// + /// Verify interactions with the mock of HttpClient. + /// + internal interface IMockVerifyForHttpClient : global::Mockolate.Verify.IMockVerify + { + /// + /// Verify invocations for the method Send(HttpRequestMessage, CancellationToken) 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 Send(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Verify invocations for the method Send(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken); + + /// + /// Verify invocations for the method Send(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = ""); + + /// + /// Verify invocations for the method Send(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); + + /// + /// Verify invocations for the method Send(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters Send(global::System.Func request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); + + /// + /// Verify invocations for the method SendAsync(HttpRequestMessage, CancellationToken) 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 SendAsync(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Verify invocations for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken); + + /// + /// Verify invocations for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = ""); + + /// + /// Verify invocations for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); + + /// + /// Verify invocations for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters SendAsync(global::System.Func request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); + + } + + /// + /// Verify protected interactions with the mock of HttpClient. + /// + internal interface IMockProtectedVerifyForHttpClient + { + /// + /// Verify invocations for the method Dispose(bool) 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 Dispose(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Verify invocations for the method Dispose(bool) with the given . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters Dispose(global::Mockolate.ParameterArg? disposing); + + /// + /// Verify invocations for the method Dispose(bool) with the given . + /// + /// + /// This overload accepts a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters Dispose(global::System.Func disposing, [global::System.Runtime.CompilerServices.CallerArgumentExpression("disposing")] string disposingExpression = ""); + + } +} +/// +/// Mock extensions for HttpClient. +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal static partial class MockExtensionsForHttpClient +{ + /// + extension(global::System.Net.Http.HttpClient mock) + { + /// + /// Gets the mock accessor for HttpClient - the entry point for configuring setups, verifying interactions and raising events. + /// + /// + /// The accessor is the bridge between the strongly-typed instance of HttpClient returned by CreateMock(...) and the underlying mock registry where setups and recorded interactions live.
+ /// Through it you can:
+ ///
+ /// Setup - configure how members respond when invoked (Returns, Throws, Do, InitializeWith, ...).
+ /// Verify - assert how often (and in which order) members were invoked.
+ /// SetupProtected / VerifyProtected / RaiseProtected - target members on class mocks.
+ /// InScenario / TransitionTo - scope setups and behavior to a named scenario and switch between scenarios.
+ /// Monitor, ClearAllInteractions, VerifyThatAllInteractionsAreVerified, VerifyThatAllSetupsAreUsed - manage recorded interactions.
+ /// VerifySetup - verify how often a specific setup matched.
+ ///
+ ///
+ /// The instance is not a Mockolate-generated mock of HttpClient. + public global::Mockolate.Mock.IMockForHttpClient Mock + { + get + { + if (mock is global::Mockolate.Mock.IMockForHttpClient mockInterface) + { + return mockInterface; + } + throw new global::Mockolate.Exceptions.MockException("The subject is no mock."); + } + } + + /// + /// Creates a new mock of HttpClient with the default MockBehavior. + /// + /// + /// The returned instance is a strongly-typed mock generated at compile time - it implements HttpClient and exposes the Mockolate surface through .Mock:
+ ///
+ /// .Mock.Setup configures how members respond (Returns, Throws, Do, InitializeWith, sequences, callbacks).
+ /// .Mock.Verify asserts how often and in which order members were invoked.
+ ///

+ /// With the default behavior, un-configured members return default values (empty collections / strings, completed tasks, otherwise) and base-class implementations are invoked for class mocks. Use one of the overloads that accepts a MockBehavior to customize this (for example to make un-configured calls throw or to skip the base class).
+ /// Overloads allow you to additionally pass constructor parameters (for class mocks), apply an initial setup callback before the instance is returned, or combine both. + ///
+ /// A new mock instance of HttpClient. + public static global::System.Net.Http.HttpClient CreateMock() + => CreateMock(null, null, (object?[]?)null); + + /// + /// Creates a new mock of HttpClient with the default MockBehavior, applying the given immediately. + /// + /// + /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. + /// + /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. + /// A new mock instance of HttpClient. + public static global::System.Net.Http.HttpClient CreateMock(global::System.Action setup) + => CreateMock(null, setup, (object?[]?)null); + + /// + /// Creates a new mock of HttpClient with the given . + /// + /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. + /// A new mock instance of HttpClient. + public static global::System.Net.Http.HttpClient CreateMock(global::Mockolate.MockBehavior mockBehavior) + => CreateMock(mockBehavior, null, (object?[]?)null); + + /// + /// Creates a new mock of HttpClient with the given , applying the given immediately. + /// + /// + /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. + /// + /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. + /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. + /// A new mock instance of HttpClient. + public static global::System.Net.Http.HttpClient CreateMock(global::Mockolate.MockBehavior mockBehavior, global::System.Action setup) + => CreateMock(mockBehavior, setup, (object?[]?)null); + + /// + /// Creates a new mock of HttpClient using the given to invoke the base-class constructor. + /// + /// Values forwarded to a matching base-class constructor. Required when no parameterless constructor exists. + /// A new mock instance of HttpClient. + public static global::System.Net.Http.HttpClient CreateMock(object?[] constructorParameters) + => CreateMock(null, null, constructorParameters); + + /// + /// Creates a new mock of HttpClient using the given and . + /// + /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. + /// Values forwarded to a matching base-class constructor. Required when no parameterless constructor exists. + /// A new mock instance of HttpClient. + public static global::System.Net.Http.HttpClient CreateMock(global::Mockolate.MockBehavior mockBehavior, object?[] constructorParameters) + => CreateMock(mockBehavior, null, constructorParameters); + + /// + /// Creates a new mock of HttpClient applying the given immediately, using the given . + /// + /// + /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. + /// + /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. + /// Values forwarded to a matching base-class constructor. Required when no parameterless constructor exists. + /// A new mock instance of HttpClient. + public static global::System.Net.Http.HttpClient CreateMock(global::System.Action setup, object?[] constructorParameters) + => CreateMock(null, setup, constructorParameters); + + /// + /// Creates a new mock of HttpClient using the given constructor parameters to invoke the HttpClient(HttpMessageHandler) constructor. + /// + /// Value forwarded to the base-class constructor. + /// A new mock instance of HttpClient. + public static global::System.Net.Http.HttpClient CreateMock(global::System.Net.Http.HttpMessageHandler handler) + => CreateMock(null, null, new object?[] { handler }); + + /// + /// Creates a new mock of HttpClient using the given and the given constructor parameters to invoke the HttpClient(HttpMessageHandler) constructor. + /// + /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. + /// Value forwarded to the base-class constructor. + /// A new mock instance of HttpClient. + public static global::System.Net.Http.HttpClient CreateMock(global::Mockolate.MockBehavior mockBehavior, global::System.Net.Http.HttpMessageHandler handler) + => CreateMock(mockBehavior, null, new object?[] { handler }); + + /// + /// Creates a new mock of HttpClient applying the given immediately, using the given constructor parameters to invoke the HttpClient(HttpMessageHandler) constructor. + /// + /// + /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. + /// + /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. + /// Value forwarded to the base-class constructor. + /// A new mock instance of HttpClient. + public static global::System.Net.Http.HttpClient CreateMock(global::System.Action setup, global::System.Net.Http.HttpMessageHandler handler) + => CreateMock(null, setup, new object?[] { handler }); + + /// + /// Creates a new mock of HttpClient using the given , applying the given immediately, using the given constructor parameters to invoke the HttpClient(HttpMessageHandler) constructor. + /// + /// + /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. + /// + /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. + /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. + /// Value forwarded to the base-class constructor. + /// A new mock instance of HttpClient. + public static global::System.Net.Http.HttpClient CreateMock(global::Mockolate.MockBehavior mockBehavior, global::System.Action setup, global::System.Net.Http.HttpMessageHandler handler) + => CreateMock(mockBehavior, setup, new object?[] { handler }); + + /// + /// Creates a new mock of HttpClient using the given constructor parameters to invoke the HttpClient(HttpMessageHandler, bool) constructor. + /// + /// Value forwarded to the base-class constructor. + /// Value forwarded to the base-class constructor. + /// A new mock instance of HttpClient. + public static global::System.Net.Http.HttpClient CreateMock(global::System.Net.Http.HttpMessageHandler handler, bool disposeHandler) + => CreateMock(null, null, new object?[] { handler, disposeHandler }); + + /// + /// Creates a new mock of HttpClient using the given and the given constructor parameters to invoke the HttpClient(HttpMessageHandler, bool) constructor. + /// + /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. + /// Value forwarded to the base-class constructor. + /// Value forwarded to the base-class constructor. + /// A new mock instance of HttpClient. + public static global::System.Net.Http.HttpClient CreateMock(global::Mockolate.MockBehavior mockBehavior, global::System.Net.Http.HttpMessageHandler handler, bool disposeHandler) + => CreateMock(mockBehavior, null, new object?[] { handler, disposeHandler }); + + /// + /// Creates a new mock of HttpClient applying the given immediately, using the given constructor parameters to invoke the HttpClient(HttpMessageHandler, bool) constructor. + /// + /// + /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. + /// + /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. + /// Value forwarded to the base-class constructor. + /// Value forwarded to the base-class constructor. + /// A new mock instance of HttpClient. + public static global::System.Net.Http.HttpClient CreateMock(global::System.Action setup, global::System.Net.Http.HttpMessageHandler handler, bool disposeHandler) + => CreateMock(null, setup, new object?[] { handler, disposeHandler }); + + /// + /// Creates a new mock of HttpClient using the given , applying the given immediately, using the given constructor parameters to invoke the HttpClient(HttpMessageHandler, bool) constructor. + /// + /// + /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. + /// + /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. + /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. + /// Value forwarded to the base-class constructor. + /// Value forwarded to the base-class constructor. + /// A new mock instance of HttpClient. + public static global::System.Net.Http.HttpClient CreateMock(global::Mockolate.MockBehavior mockBehavior, global::System.Action setup, global::System.Net.Http.HttpMessageHandler handler, bool disposeHandler) + => CreateMock(mockBehavior, setup, new object?[] { handler, disposeHandler }); + + /// + /// Creates a new mock of HttpClient using the given , applying the given immediately, using the given . + /// + /// + /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. + /// + /// Controls how the mock responds when members are invoked without a matching setup, or for MockBehavior.Default. + /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned, or to skip. + /// Values forwarded to a matching base-class constructor, or to use the parameterless constructor. + /// A new mock instance of HttpClient. + public static global::System.Net.Http.HttpClient CreateMock(global::Mockolate.MockBehavior? mockBehavior, global::System.Action? setup, object?[]? constructorParameters) + { + if (mockBehavior is not null) + { + IMockBehaviorAccess mockBehaviorAccess = (global::Mockolate.IMockBehaviorAccess)mockBehavior; + if (mockBehaviorAccess.TryGet?>(out var additionalSetup)) + { + if (setup is null) + { + setup = additionalSetup; + } + else + { + var originalSetup = setup; + setup = s => { additionalSetup.Invoke(s); originalSetup.Invoke(s); }; + } + } + if (constructorParameters is null && mockBehaviorAccess.TryGetConstructorParameters(out object?[]? parameters)) + { + constructorParameters = parameters; + } + } + + global::Mockolate.MockBehavior effectiveBehavior = mockBehavior ?? global::Mockolate.MockBehavior.Default; + global::Mockolate.MockRegistry mockRegistry = new global::Mockolate.MockRegistry(effectiveBehavior, global::Mockolate.Mock.HttpClient.CreateFastInteractions(effectiveBehavior), constructorParameters); + if (constructorParameters is null) + { + constructorParameters = [new global::Mockolate.Mock.HttpMessageHandler(mockRegistry),]; + mockRegistry = new global::Mockolate.MockRegistry(mockRegistry, constructorParameters); + } + else if (constructorParameters.Length > 0 && constructorParameters[0] is global::Mockolate.Mock.HttpMessageHandler && constructorParameters[0] is global::Mockolate.IMock httpMessageHandlerMock) + { + if (mockBehavior is not null && httpMessageHandlerMock.MockRegistry.Behavior != mockBehavior) + { + throw new global::Mockolate.Exceptions.MockException($"Mock of type 'System.Net.Http.HttpClient' cannot be created with behavior '{mockBehavior}' because it shares its mock registry with a mock of type 'System.Net.Http.HttpMessageHandler' that has behavior '{httpMessageHandlerMock.MockRegistry.Behavior}'."); + } + mockRegistry = new global::Mockolate.MockRegistry(httpMessageHandlerMock.MockRegistry, constructorParameters); + } + mockBehavior ??= global::Mockolate.MockBehavior.Default; + return CreateMockInstance(mockRegistry, constructorParameters, setup); + } + + private static global::System.Net.Http.HttpClient CreateMockInstance(global::Mockolate.MockRegistry mockRegistry, object?[]? constructorParameters, global::System.Action? setup) + { + if (constructorParameters is null || constructorParameters.Length == 0) + { + global::Mockolate.Mock.HttpClient.MockRegistryProvider.Value = mockRegistry; + global::Mockolate.MockExtensionsForHttpClient.MockSetup? setupTarget = null; + if (setup is not null) + { + setupTarget ??= new(mockRegistry); + setup.Invoke(setupTarget); + } + return new global::Mockolate.Mock.HttpClient(mockRegistry); + } + else if (constructorParameters.Length == 0) + { + global::Mockolate.Mock.HttpClient.MockRegistryProvider.Value = mockRegistry; + global::Mockolate.MockExtensionsForHttpClient.MockSetup? setupTarget = null; + if (setup is not null) + { + setupTarget ??= new(mockRegistry); + setup.Invoke(setupTarget); + } + return new global::Mockolate.Mock.HttpClient(mockRegistry); + } + else if (constructorParameters.Length == 1 + && TryCast(constructorParameters, 0, mockRegistry.Behavior, out global::System.Net.Http.HttpMessageHandler c2p1)) + { + global::Mockolate.Mock.HttpClient.MockRegistryProvider.Value = mockRegistry; + global::Mockolate.MockExtensionsForHttpClient.MockSetup? setupTarget = null; + if (setup is not null) + { + setupTarget ??= new(mockRegistry); + setup.Invoke(setupTarget); + } + return new global::Mockolate.Mock.HttpClient(mockRegistry, c2p1); + } + else if (constructorParameters.Length == 2 + && TryCast(constructorParameters, 0, mockRegistry.Behavior, out global::System.Net.Http.HttpMessageHandler c3p1) + && TryCast(constructorParameters, 1, mockRegistry.Behavior, out bool c3p2)) + { + global::Mockolate.Mock.HttpClient.MockRegistryProvider.Value = mockRegistry; + global::Mockolate.MockExtensionsForHttpClient.MockSetup? setupTarget = null; + if (setup is not null) + { + setupTarget ??= new(mockRegistry); + setup.Invoke(setupTarget); + } + return new global::Mockolate.Mock.HttpClient(mockRegistry, c3p1, c3p2); + } + else + { + throw new global::Mockolate.Exceptions.MockException($"Could not find any constructor for 'System.Net.Http.HttpClient' that matches the {constructorParameters.Length} given parameters ({string.Join(", ", constructorParameters)})."); + } + static bool TryCast(object?[] values, int index, global::Mockolate.MockBehavior behavior, out TValue result) + { + var value = values[index]; + if (value is TValue typedValue) + { + result = typedValue; + return true; + } + + result = default!; + return value is null; + } + } + /// + /// Creates a mock that wraps the given . + /// + /// + /// Public members on the mock forward to unless overridden by a setup; protected members still go through the base-class implementation. All forwarded interactions are recorded and can be verified the same as on a plain mock. + /// + /// The real object whose calls should be forwarded. Must not be . + /// A new mock of HttpClient that delegates to . + public global::System.Net.Http.HttpClient Wrapping(global::System.Net.Http.HttpClient instance) + { + if (mock is global::Mockolate.IMock mockInterface) + { + global::Mockolate.MockRegistry wrappingRegistry = new global::Mockolate.MockRegistry(mockInterface.MockRegistry, instance); + wrappingRegistry = new global::Mockolate.MockRegistry(wrappingRegistry, global::Mockolate.Mock.HttpClient.CreateFastInteractions(wrappingRegistry.Behavior)); + return CreateMockInstance(wrappingRegistry, mockInterface.MockRegistry.ConstructorParameters, null); + } + throw new global::Mockolate.Exceptions.MockException("The subject is no mock."); + } + + } + + /// + extension(global::Mockolate.MockBehavior behavior) + { + /// + /// Initializes mocks of type with the given . + /// + /// + /// The is applied to the mock before the constructor is executed. Calling Initialize again overlays additional setups on top of any previously registered ones. + /// + /// The mockable type derived from HttpClient that this setup should apply to. + /// Callback invoked when a new mock of is created. + /// A new MockBehavior with the registered initializer. The original instance is unchanged. + public global::Mockolate.MockBehavior Initialize(global::System.Action setup) + where T : global::System.Net.Http.HttpClient + { + var behaviorAccess = (global::Mockolate.IMockBehaviorAccess)behavior; + return behaviorAccess.Set(setup); + } + } + internal interface IMockSetupInitializationForHttpClient : global::Mockolate.Mock.IMockSetupForHttpClient + { + /// + /// Setup protected members + /// + global::Mockolate.Mock.IMockProtectedSetupForHttpClient Protected { get; } + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal sealed class MockSetup(global::Mockolate.MockRegistry mockRegistry) : global::Mockolate.Mock.IMockSetupForHttpClient, global::Mockolate.Mock.IMockProtectedSetupForHttpClient, IMockSetupInitializationForHttpClient + { + /// + global::Mockolate.Mock.IMockProtectedSetupForHttpClient IMockSetupInitializationForHttpClient.Protected => this; + private global::Mockolate.MockRegistry MockRegistry { get; } = mockRegistry; + + #region IMockSetupForHttpClient + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", parameters, "request", "cancellationToken"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + global::Mockolate.Setup.ReturnMethodSetup methodSetup; + if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.Literal!, cancellationTokenArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) + { + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", parameters, "request", "cancellationToken"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> methodSetup; + if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.Literal!, cancellationTokenArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) + { + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + #endregion IMockSetupForHttpClient + + #region IMockProtectedSetupForHttpClient + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockProtectedSetupForHttpClient.Dispose(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", parameters, "disposing"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Dispose, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpClient.Dispose(global::Mockolate.ParameterArg? disposing) + { + global::Mockolate.ParameterArg disposingArg = disposing ?? default; + global::Mockolate.Setup.VoidMethodSetup methodSetup; + if (disposingArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", disposingArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", disposingArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Dispose, methodSetup); + return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpClient.Dispose(global::System.Func disposing, string disposingExpression) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(disposing, disposingExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Dispose, methodSetup); + return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; + } + + #endregion IMockProtectedSetupForHttpClient + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch + { + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); + } +} + +#nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpMessageHandler.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpMessageHandler.g.cs new file mode 100644 index 00000000..c4ab9eae --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpMessageHandler.g.cs @@ -0,0 +1,1506 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +#nullable enable annotations +namespace Mockolate; + +internal static partial class Mock +{ + /// + /// A mock implementation for HttpMessageHandler. + /// + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal class HttpMessageHandler : + global::System.Net.Http.HttpMessageHandler, IMockForHttpMessageHandler, IMockSetupForHttpMessageHandler, IMockProtectedSetupForHttpMessageHandler, global::Mockolate.MockExtensionsForHttpMessageHandler.IMockSetupInitializationForHttpMessageHandler, IMockVerifyForHttpMessageHandler, IMockProtectedVerifyForHttpMessageHandler, + global::Mockolate.IMock + { + internal const int MemberId_Send = 0; + internal const int MemberId_SendAsync = 1; + internal const int MemberId_Dispose = 2; + internal const int MemberCount = 3; + + /// + /// Creates a FastMockInteractions sized to MemberCount for use as the mock's interaction store. + /// Per-member buffers are not allocated up-front: the recording hot paths call GetOrCreateBuffer<TBuffer>(int, Func<FastMockInteractions, TBuffer>) so a slot is materialized only when its member is first invoked. + /// + internal static global::Mockolate.Interactions.FastMockInteractions CreateFastInteractions(global::Mockolate.MockBehavior behavior) + => new global::Mockolate.Interactions.FastMockInteractions(MemberCount, behavior.SkipInteractionRecording); + + /// + /// Builds a MockRegistry backed by a typed-buffer-sized FastMockInteractions from . + /// + private static global::Mockolate.MockRegistry MockolateCreateRegistryFromBehavior(global::Mockolate.MockBehavior behavior) + { + global::Mockolate.MockRegistry registry = new global::Mockolate.MockRegistry(behavior, MemberCount); + MockRegistryProvider.Value = registry; + return registry; + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.MockRegistry global::Mockolate.IMock.MockRegistry => this.MockRegistry; + private global::Mockolate.MockRegistry MockRegistry + { + get => field ?? MockRegistryProvider.Value; + set; + } + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + internal static readonly global::System.Threading.AsyncLocal MockRegistryProvider = new global::System.Threading.AsyncLocal(); + + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod2Buffer MockolateBuffer_Send + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, static fast => new global::Mockolate.Interactions.FastMethod2Buffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod2Buffer MockolateBuffer_SendAsync + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, static fast => new global::Mockolate.Interactions.FastMethod2Buffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod1Buffer MockolateBuffer_Dispose + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, static fast => new global::Mockolate.Interactions.FastMethod1Buffer(fast))); + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + IMockSetupForHttpMessageHandler IMockForHttpMessageHandler.Setup + => this; + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + IMockProtectedSetupForHttpMessageHandler IMockForHttpMessageHandler.SetupProtected + => this; + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + IMockProtectedSetupForHttpMessageHandler global::Mockolate.MockExtensionsForHttpMessageHandler.IMockSetupInitializationForHttpMessageHandler.Protected + => this; + /// + IMockInScenarioForHttpMessageHandler IMockForHttpMessageHandler.InScenario(string scenario) + => new MockInScenarioForHttpMessageHandler(this.MockRegistry, scenario); + + /// + IMockForHttpMessageHandler IMockForHttpMessageHandler.InScenario(string scenario, global::System.Action setup) + { + setup.Invoke(new MockInScenarioForHttpMessageHandler(this.MockRegistry, scenario)); + return this; + } + + /// + IMockForHttpMessageHandler IMockForHttpMessageHandler.TransitionTo(string scenario) + { + this.MockRegistry.TransitionTo(scenario); + return this; + } + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + IMockVerifyForHttpMessageHandler IMockForHttpMessageHandler.Verify + => this; + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + IMockProtectedVerifyForHttpMessageHandler IMockForHttpMessageHandler.VerifyProtected + => this; + /// + global::Mockolate.Verify.VerificationResult IMockForHttpMessageHandler.VerifySetup(global::Mockolate.Setup.IMethodSetup setup) + => this.MockRegistry.Method(this, setup); + /// + bool IMockForHttpMessageHandler.VerifyThatAllInteractionsAreVerified() + => this.MockRegistry.Interactions.GetUnverifiedInteractions().Count == 0; + /// + bool IMockForHttpMessageHandler.VerifyThatAllSetupsAreUsed() + => this.MockRegistry.GetUnusedSetups(this.MockRegistry.Interactions).Count == 0; + /// + void IMockForHttpMessageHandler.ClearAllInteractions() + => this.MockRegistry.ClearAllInteractions(); + /// + global::Mockolate.Monitor.MockMonitor IMockForHttpMessageHandler.Monitor() + => new global::Mockolate.Monitor.MockMonitor(this.MockRegistry.Interactions, interactions => new VerifyMonitorHttpMessageHandler(new global::Mockolate.MockRegistry(this.MockRegistry, interactions))); + + /// + string global::Mockolate.IMock.ToString() + => "System.Net.Http.HttpMessageHandler mock"; + + /// + public HttpMessageHandler(global::Mockolate.MockRegistry mockRegistry) + : base() + { + this.MockRegistry = mockRegistry; + } + + /// + public HttpMessageHandler(global::Mockolate.MockBehavior behavior) + : this(MockolateCreateRegistryFromBehavior(behavior)) + { + } + + #region System.Net.Http.HttpMessageHandler + + /// + protected override global::System.Net.Http.HttpResponseMessage Send(global::System.Net.Http.HttpRequestMessage request, global::System.Threading.CancellationToken cancellationToken) + { + global::Mockolate.Setup.ReturnMethodSetup? methodSetup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send); + 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(request, cancellationToken)) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::System.Net.Http.HttpMessageHandler.Send")) + { + if (s_methodSetup.Matches(request, cancellationToken)) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + global::System.Net.Http.HttpResponseMessage wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_Send.Append("global::System.Net.Http.HttpMessageHandler.Send", request, cancellationToken); + } + try + { + if (!(methodSetup?.SkipBaseClass(this.MockRegistry.Behavior) ?? this.MockRegistry.Behavior.SkipBaseClass)) + { + wrappedResult = base.Send(request, cancellationToken); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(request, cancellationToken); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::System.Net.Http.HttpMessageHandler.Send(HttpRequestMessage, CancellationToken)' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(request, cancellationToken, out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(global::System.Net.Http.HttpResponseMessage)!, request, cancellationToken); + } + + /// + protected override global::System.Threading.Tasks.Task SendAsync(global::System.Net.Http.HttpRequestMessage request, global::System.Threading.CancellationToken cancellationToken) + { + global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>? methodSetup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync); + 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, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> s_methodSetup && s_methodSetup.Matches(request, cancellationToken)) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> s_methodSetup in this.MockRegistry.GetMethodSetups, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>>("global::System.Net.Http.HttpMessageHandler.SendAsync")) + { + if (s_methodSetup.Matches(request, cancellationToken)) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + global::System.Threading.Tasks.Task wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_SendAsync.Append("global::System.Net.Http.HttpMessageHandler.SendAsync", request, cancellationToken); + } + try + { + } + finally + { + methodSetup?.TriggerCallbacks(request, cancellationToken); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::System.Net.Http.HttpMessageHandler.SendAsync(HttpRequestMessage, CancellationToken)' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(request, cancellationToken, out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(global::System.Threading.Tasks.Task)!, this.MockRegistry.Behavior.DefaultValue.Generate(default(global::System.Net.Http.HttpResponseMessage)!, request, cancellationToken), request, cancellationToken); + } + + /// + protected override void Dispose(bool disposing) + { + global::Mockolate.Setup.VoidMethodSetup? methodSetup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose); + 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.VoidMethodSetup s_methodSetup && s_methodSetup.Matches(disposing)) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.VoidMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::System.Net.Http.HttpMessageHandler.Dispose")) + { + if (s_methodSetup.Matches(disposing)) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_Dispose.Append("global::System.Net.Http.HttpMessageHandler.Dispose", disposing); + } + try + { + if (!(methodSetup?.SkipBaseClass(this.MockRegistry.Behavior) ?? this.MockRegistry.Behavior.SkipBaseClass)) + { + base.Dispose(disposing); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(disposing); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::System.Net.Http.HttpMessageHandler.Dispose(bool)' was invoked without prior setup."); + } + } + + #endregion System.Net.Http.HttpMessageHandler + + #region IMockSetupForHttpMessageHandler + + #endregion IMockSetupForHttpMessageHandler + + #region IMockProtectedSetupForHttpMessageHandler + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", parameters, "request", "cancellationToken"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + global::Mockolate.Setup.ReturnMethodSetup methodSetup; + if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.Literal!, cancellationTokenArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) + { + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", parameters, "request", "cancellationToken"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> methodSetup; + if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.Literal!, cancellationTokenArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) + { + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Dispose(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", parameters, "disposing"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Dispose(global::Mockolate.ParameterArg? disposing) + { + global::Mockolate.ParameterArg disposingArg = disposing ?? default; + global::Mockolate.Setup.VoidMethodSetup methodSetup; + if (disposingArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", disposingArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", disposingArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, methodSetup); + return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Dispose(global::System.Func disposing, string disposingExpression) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(disposing, disposingExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, methodSetup); + return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; + } + + #endregion IMockProtectedSetupForHttpMessageHandler + + #region IMockVerifyForHttpMessageHandler + + #endregion IMockVerifyForHttpMessageHandler + + #region IMockProtectedVerifyForHttpMessageHandler + + /// + global::Mockolate.Verify.VerificationResult IMockProtectedVerifyForHttpMessageHandler.Send(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, "global::System.Net.Http.HttpMessageHandler.Send", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("request", __i.Parameter1), ("cancellationToken", __i.Parameter2)]), + _ => true + }, () => $"Send({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpMessageHandler.Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.Literal!, cancellationTokenArg.Literal!, () => $"Send({requestArg}, {cancellationTokenArg})"); + } + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch(), () => $"Send({requestArg}, {cancellationTokenArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpMessageHandler.Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) + { + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, "global::System.Net.Http.HttpMessageHandler.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch(), () => $"Send({requestExpression}, {cancellationTokenArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpMessageHandler.Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"Send({requestArg}, {cancellationTokenExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpMessageHandler.Send(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, "global::System.Net.Http.HttpMessageHandler.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"Send({requestExpression}, {cancellationTokenExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult IMockProtectedVerifyForHttpMessageHandler.SendAsync(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, "global::System.Net.Http.HttpMessageHandler.SendAsync", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("request", __i.Parameter1), ("cancellationToken", __i.Parameter2)]), + _ => true + }, () => $"SendAsync({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpMessageHandler.SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.Literal!, cancellationTokenArg.Literal!, () => $"SendAsync({requestArg}, {cancellationTokenArg})"); + } + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch(), () => $"SendAsync({requestArg}, {cancellationTokenArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpMessageHandler.SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) + { + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, "global::System.Net.Http.HttpMessageHandler.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch(), () => $"SendAsync({requestExpression}, {cancellationTokenArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpMessageHandler.SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"SendAsync({requestArg}, {cancellationTokenExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpMessageHandler.SendAsync(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, "global::System.Net.Http.HttpMessageHandler.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"SendAsync({requestExpression}, {cancellationTokenExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult IMockProtectedVerifyForHttpMessageHandler.Dispose(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, "global::System.Net.Http.HttpMessageHandler.Dispose", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("disposing", __i.Parameter1)]), + _ => true + }, () => $"Dispose({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpMessageHandler.Dispose(global::Mockolate.ParameterArg? disposing) + { + global::Mockolate.ParameterArg disposingArg = disposing ?? default; + if (disposingArg.IsLiteral) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, "global::System.Net.Http.HttpMessageHandler.Dispose", disposingArg.Literal!, () => $"Dispose({disposingArg})"); + } + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, "global::System.Net.Http.HttpMessageHandler.Dispose", disposingArg.ToParameterMatch(), () => $"Dispose({disposingArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpMessageHandler.Dispose(global::System.Func disposing, string disposingExpression) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, "global::System.Net.Http.HttpMessageHandler.Dispose", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(disposing, disposingExpression), () => $"Dispose({disposingExpression})"); + } + + #endregion IMockProtectedVerifyForHttpMessageHandler + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class VerifyMonitorHttpMessageHandler(global::Mockolate.MockRegistry mockRegistry) : global::Mockolate.Mock.IMockVerifyForHttpMessageHandler + { + private global::Mockolate.MockRegistry MockRegistry { get; } = mockRegistry; + + #region IMockVerifyForHttpMessageHandler + + #endregion IMockVerifyForHttpMessageHandler + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class MockInScenarioForHttpMessageHandler : global::Mockolate.Mock.IMockInScenarioForHttpMessageHandler, global::Mockolate.Mock.IMockSetupForHttpMessageHandler, global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler + { + private global::Mockolate.MockRegistry MockRegistry { get; } + private string _scenarioName; + + public MockInScenarioForHttpMessageHandler(global::Mockolate.MockRegistry mockRegistry, string scenario) + { + this.MockRegistry = mockRegistry; + _scenarioName = scenario; + } + + /// + global::Mockolate.Mock.IMockSetupForHttpMessageHandler global::Mockolate.Mock.IMockInScenarioForHttpMessageHandler.Setup + => this; + + /// + global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler global::Mockolate.Mock.IMockInScenarioForHttpMessageHandler.SetupProtected + => this; + + #region IMockSetupForHttpMessageHandler + + #endregion IMockSetupForHttpMessageHandler + + #region IMockProtectedSetupForHttpMessageHandler + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", parameters, "request", "cancellationToken"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + global::Mockolate.Setup.ReturnMethodSetup methodSetup; + if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.Literal!, cancellationTokenArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) + { + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", parameters, "request", "cancellationToken"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> methodSetup; + if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.Literal!, cancellationTokenArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) + { + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Dispose(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", parameters, "disposing"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Dispose(global::Mockolate.ParameterArg? disposing) + { + global::Mockolate.ParameterArg disposingArg = disposing ?? default; + global::Mockolate.Setup.VoidMethodSetup methodSetup; + if (disposingArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", disposingArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", disposingArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Dispose(global::System.Func disposing, string disposingExpression) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(disposing, disposingExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; + } + + #endregion IMockProtectedSetupForHttpMessageHandler + } + + /// + /// The Mockolate accessor for a mock of HttpMessageHandler, reached through .Mock on the mocked instance. + /// + /// + /// Groups every operation that acts on the mock rather than on the mocked subject: setups, verifications, event raising, scenarios and monitoring. + /// + internal interface IMockForHttpMessageHandler + { + /// + /// Configures how members of the mock of HttpMessageHandler respond when invoked. + /// + /// + /// Each mocked member is available as a strongly-typed entry on this surface. Chain Returns, ReturnsAsync, Throws, ThrowsAsync or Do to control the response; chain InitializeWith/Register to initialize properties and indexers; chain multiple returns/throws to define a sequence; use .For(n), .Only(n), .Forever(), .When(predicate) to control when a callback runs.
+ /// When two setups overlap, the most recently defined one wins. + ///
+ IMockSetupForHttpMessageHandler Setup { get; } + + /// + /// Configures how virtual members of the mock of HttpMessageHandler respond when invoked. + /// + /// + /// Only members declared as (or ) on the mocked class appear here. All setup chain operators (Returns, Throws, Do, sequences, .For/.Only/.Forever, ...) work identically to Setup. + /// + IMockProtectedSetupForHttpMessageHandler SetupProtected { get; } + + /// + /// Opens a named scenario scope on the mock of HttpMessageHandler so that additional setups can be registered for that scenario. + /// + /// + /// Scenarios let you define per-state behavior. Setups registered inside the returned IMockInScenarioFor... scope only apply while the mock's current scenario matches ; switch scenarios with TransitionTo. + /// + /// Name of the scenario to enter. Any non-null string acts as a key; the mock starts in an unnamed default scenario. + /// A scoped accessor whose Setup (and SetupProtected, where applicable) register scenario-specific setups. + IMockInScenarioForHttpMessageHandler InScenario(string scenario); + + /// + /// Opens a named scenario scope on the mock of HttpMessageHandler and immediately invokes to register scenario-specific setups. + /// + /// + /// Equivalent to InScenario(scenario) followed by the setup callback, but returns the original IMockFor... accessor so it chains nicely at mock-creation time. + /// + /// Name of the scenario to enter. + /// Callback that receives the scenario-scoped setup surface and registers scenario-specific setups. + /// This accessor, to allow chaining. + IMockForHttpMessageHandler InScenario(string scenario, global::System.Action setup); + + /// + /// Switches the active scenario of the mock of HttpMessageHandler to . + /// + /// + /// After the transition, setups registered via InScenario(string) under that scenario take effect. Scenarios that have no matching setup for a given member fall back to the default (un-scoped) setups. + /// + /// Name of the scenario to transition to. + /// This accessor, to allow chaining. + IMockForHttpMessageHandler TransitionTo(string scenario); + + /// + /// Asserts how often, and in which order, members of the mock of HttpMessageHandler were invoked. + /// + /// + /// Each call to a member here returns a VerificationResult that you terminate with a count assertion: Never(), Once(), Twice(), Exactly(n), AtLeast(n)/AtLeastOnce()/AtLeastTwice(), AtMost(n)/AtMostOnce()/AtMostTwice(), Between(min, max) or Times(predicate).
+ /// Use Within(TimeSpan) / WithCancellation(CancellationToken) before the terminator to wait for expected interactions that happen on background threads.
+ /// Chain Then(...) to assert an ordered sequence of calls. A failing assertion throws a MockVerificationException. + ///
+ IMockVerifyForHttpMessageHandler Verify { get; } + + /// + /// Asserts how often, and in which order, members of the mock of HttpMessageHandler were invoked. + /// + /// + /// Same terminators and modifiers as Verify (Once(), Exactly(n), Within(...), Then(...), ...); applies to members and events instead of public ones. + /// + IMockProtectedVerifyForHttpMessageHandler VerifyProtected { get; } + + /// + /// Verifies how often a specific method setup was matched by actual invocations. + /// + /// + /// Useful when you want to verify "this particular setup was hit N times" without re-stating the matchers. Chain the usual count terminators (Once(), AtLeastOnce(), Exactly(n), ...) on the returned result. + /// + /// The setup previously registered through Setup (typically returned from a Returns(...)/Throws(...) call). + /// A VerificationResult that counts invocations matching the given setup. + global::Mockolate.Verify.VerificationResult VerifySetup(global::Mockolate.Setup.IMethodSetup setup); + + /// + /// Checks whether every recorded interaction on this mock has been observed by at least one Verify call. + /// + /// + /// Useful in test teardown to catch unexpected interactions ("strict verification"): if any recorded call has never been matched by a verification, the method returns . + /// + /// if every recorded interaction was verified at least once; otherwise . + bool VerifyThatAllInteractionsAreVerified(); + + /// + /// Checks whether every registered setup on this mock was matched by at least one actual invocation. + /// + /// + /// Useful to catch unused setups that silently rot as the test subject evolves. + /// + /// if every registered setup was used at least once; otherwise . + bool VerifyThatAllSetupsAreUsed(); + + /// + /// Removes every recorded interaction from this mock while keeping all registered setups intact. + /// + /// + /// Handy when a single test exercises multiple logical phases and you only want to verify the interactions of the latest phase. + /// + void ClearAllInteractions(); + + /// + /// Creates a monitor whose Verify surface is scoped to interactions produced between monitor.Run() and the disposal of its IDisposable scope. + /// + /// + /// The underlying mock keeps recording all interactions as usual - only the monitor's Verify view is scoped. Useful to verify only the interactions produced by a specific block of test code without resetting the mock. + /// + /// A MockMonitor<T> that exposes Verify over the monitored interactions and a Run() method that opens the recording scope. + global::Mockolate.Monitor.MockMonitor Monitor(); + } + + /// + /// Scoped access to setups for a scenario on the mock of HttpMessageHandler. + /// + internal interface IMockInScenarioForHttpMessageHandler + { + /// + /// Set up the mock of HttpMessageHandler within the scenario scope. + /// + IMockSetupForHttpMessageHandler Setup { get; } + + /// + /// Set up protected members of the mock of HttpMessageHandler within the scenario scope. + /// + IMockProtectedSetupForHttpMessageHandler SetupProtected { get; } + } + + /// + /// Set up the mock of HttpMessageHandler. + /// + internal interface IMockSetupForHttpMessageHandler : global::Mockolate.Setup.IMockSetup + { + } + + /// + /// Set up protected members for the mock of HttpMessageHandler. + /// + internal interface IMockProtectedSetupForHttpMessageHandler + { + /// + /// Setup for the method Send(HttpRequestMessage, CancellationToken) 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 Send(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Setup for the method Send(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken); + + /// + /// Setup for the method Send(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = ""); + + /// + /// Setup for the method Send(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); + + /// + /// Setup for the method Send(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Send(global::System.Func request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); + + /// + /// Setup for the method SendAsync(HttpRequestMessage, CancellationToken) 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, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Setup for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken); + + /// + /// Setup for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = ""); + + /// + /// Setup for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); + + /// + /// Setup for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::System.Func request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); + + /// + /// Setup for the method Dispose(bool) 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.IVoidMethodSetupWithCallback Dispose(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Setup for the method Dispose(bool) with the given . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer Dispose(global::Mockolate.ParameterArg? disposing); + + /// + /// Setup for the method Dispose(bool) with the given . + /// + /// + /// This overload accepts a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer Dispose(global::System.Func disposing, [global::System.Runtime.CompilerServices.CallerArgumentExpression("disposing")] string disposingExpression = ""); + + } + + /// + /// Verify interactions with the mock of HttpMessageHandler. + /// + internal interface IMockVerifyForHttpMessageHandler : global::Mockolate.Verify.IMockVerify + { + } + + /// + /// Verify protected interactions with the mock of HttpMessageHandler. + /// + internal interface IMockProtectedVerifyForHttpMessageHandler + { + /// + /// Verify invocations for the method Send(HttpRequestMessage, CancellationToken) 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 Send(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Verify invocations for the method Send(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken); + + /// + /// Verify invocations for the method Send(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = ""); + + /// + /// Verify invocations for the method Send(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); + + /// + /// Verify invocations for the method Send(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters Send(global::System.Func request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); + + /// + /// Verify invocations for the method SendAsync(HttpRequestMessage, CancellationToken) 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 SendAsync(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Verify invocations for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken); + + /// + /// Verify invocations for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = ""); + + /// + /// Verify invocations for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); + + /// + /// Verify invocations for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . + /// + /// + /// This overload accepts a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters SendAsync(global::System.Func request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); + + /// + /// Verify invocations for the method Dispose(bool) 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 Dispose(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Verify invocations for the method Dispose(bool) with the given . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters Dispose(global::Mockolate.ParameterArg? disposing); + + /// + /// Verify invocations for the method Dispose(bool) with the given . + /// + /// + /// This overload accepts a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters Dispose(global::System.Func disposing, [global::System.Runtime.CompilerServices.CallerArgumentExpression("disposing")] string disposingExpression = ""); + + } +} +/// +/// Mock extensions for HttpMessageHandler. +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal static partial class MockExtensionsForHttpMessageHandler +{ + /// + extension(global::System.Net.Http.HttpMessageHandler mock) + { + /// + /// Gets the mock accessor for HttpMessageHandler - the entry point for configuring setups, verifying interactions and raising events. + /// + /// + /// The accessor is the bridge between the strongly-typed instance of HttpMessageHandler returned by CreateMock(...) and the underlying mock registry where setups and recorded interactions live.
+ /// Through it you can:
+ ///
+ /// Setup - configure how members respond when invoked (Returns, Throws, Do, InitializeWith, ...).
+ /// Verify - assert how often (and in which order) members were invoked.
+ /// SetupProtected / VerifyProtected / RaiseProtected - target members on class mocks.
+ /// InScenario / TransitionTo - scope setups and behavior to a named scenario and switch between scenarios.
+ /// Monitor, ClearAllInteractions, VerifyThatAllInteractionsAreVerified, VerifyThatAllSetupsAreUsed - manage recorded interactions.
+ /// VerifySetup - verify how often a specific setup matched.
+ ///
+ ///
+ /// The instance is not a Mockolate-generated mock of HttpMessageHandler. + public global::Mockolate.Mock.IMockForHttpMessageHandler Mock + { + get + { + if (mock is global::Mockolate.Mock.IMockForHttpMessageHandler mockInterface) + { + return mockInterface; + } + throw new global::Mockolate.Exceptions.MockException("The subject is no mock."); + } + } + + /// + /// Creates a new mock of HttpMessageHandler with the default MockBehavior. + /// + /// + /// The returned instance is a strongly-typed mock generated at compile time - it implements HttpMessageHandler and exposes the Mockolate surface through .Mock:
+ ///
+ /// .Mock.Setup configures how members respond (Returns, Throws, Do, InitializeWith, sequences, callbacks).
+ /// .Mock.Verify asserts how often and in which order members were invoked.
+ ///

+ /// With the default behavior, un-configured members return default values (empty collections / strings, completed tasks, otherwise) and base-class implementations are invoked for class mocks. Use one of the overloads that accepts a MockBehavior to customize this (for example to make un-configured calls throw or to skip the base class).
+ /// Overloads allow you to additionally pass constructor parameters (for class mocks), apply an initial setup callback before the instance is returned, or combine both. + ///
+ /// A new mock instance of HttpMessageHandler. + public static global::System.Net.Http.HttpMessageHandler CreateMock() + => CreateMock(null, null, (object?[]?)null); + + /// + /// Creates a new mock of HttpMessageHandler with the default MockBehavior, applying the given immediately. + /// + /// + /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. + /// + /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. + /// A new mock instance of HttpMessageHandler. + public static global::System.Net.Http.HttpMessageHandler CreateMock(global::System.Action setup) + => CreateMock(null, setup, (object?[]?)null); + + /// + /// Creates a new mock of HttpMessageHandler with the given . + /// + /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. + /// A new mock instance of HttpMessageHandler. + public static global::System.Net.Http.HttpMessageHandler CreateMock(global::Mockolate.MockBehavior mockBehavior) + => CreateMock(mockBehavior, null, (object?[]?)null); + + /// + /// Creates a new mock of HttpMessageHandler with the given , applying the given immediately. + /// + /// + /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. + /// + /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. + /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. + /// A new mock instance of HttpMessageHandler. + public static global::System.Net.Http.HttpMessageHandler CreateMock(global::Mockolate.MockBehavior mockBehavior, global::System.Action setup) + => CreateMock(mockBehavior, setup, (object?[]?)null); + + /// + /// Creates a new mock of HttpMessageHandler using the given , applying the given immediately, using the given . + /// + /// + /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. + /// + /// Controls how the mock responds when members are invoked without a matching setup, or for MockBehavior.Default. + /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned, or to skip. + /// Values forwarded to a matching base-class constructor, or to use the parameterless constructor. + /// A new mock instance of HttpMessageHandler. + private static global::System.Net.Http.HttpMessageHandler CreateMock(global::Mockolate.MockBehavior? mockBehavior, global::System.Action? setup, object?[]? constructorParameters) + { + if (mockBehavior is not null) + { + IMockBehaviorAccess mockBehaviorAccess = (global::Mockolate.IMockBehaviorAccess)mockBehavior; + if (mockBehaviorAccess.TryGet?>(out var additionalSetup)) + { + if (setup is null) + { + setup = additionalSetup; + } + else + { + var originalSetup = setup; + setup = s => { additionalSetup.Invoke(s); originalSetup.Invoke(s); }; + } + } + if (constructorParameters is null && mockBehaviorAccess.TryGetConstructorParameters(out object?[]? parameters)) + { + constructorParameters = parameters; + } + } + + mockBehavior ??= global::Mockolate.MockBehavior.Default; + global::Mockolate.MockRegistry mockRegistry = new global::Mockolate.MockRegistry(mockBehavior, global::Mockolate.Mock.HttpMessageHandler.MemberCount, constructorParameters); + return CreateMockInstance(mockRegistry, constructorParameters, setup); + } + + private static global::System.Net.Http.HttpMessageHandler CreateMockInstance(global::Mockolate.MockRegistry mockRegistry, object?[]? constructorParameters, global::System.Action? setup) + { + if (constructorParameters is null || constructorParameters.Length == 0) + { + global::Mockolate.Mock.HttpMessageHandler.MockRegistryProvider.Value = mockRegistry; + global::Mockolate.MockExtensionsForHttpMessageHandler.MockSetup? setupTarget = null; + if (setup is not null) + { + setupTarget ??= new(mockRegistry); + setup.Invoke(setupTarget); + } + return new global::Mockolate.Mock.HttpMessageHandler(mockRegistry); + } + else if (constructorParameters.Length == 0) + { + global::Mockolate.Mock.HttpMessageHandler.MockRegistryProvider.Value = mockRegistry; + global::Mockolate.MockExtensionsForHttpMessageHandler.MockSetup? setupTarget = null; + if (setup is not null) + { + setupTarget ??= new(mockRegistry); + setup.Invoke(setupTarget); + } + return new global::Mockolate.Mock.HttpMessageHandler(mockRegistry); + } + else + { + throw new global::Mockolate.Exceptions.MockException($"Could not find any constructor for 'System.Net.Http.HttpMessageHandler' that matches the {constructorParameters.Length} given parameters ({string.Join(", ", constructorParameters)})."); + } + } + /// + /// Creates a mock that wraps the given . + /// + /// + /// Public members on the mock forward to unless overridden by a setup; protected members still go through the base-class implementation. All forwarded interactions are recorded and can be verified the same as on a plain mock. + /// + /// The real object whose calls should be forwarded. Must not be . + /// A new mock of HttpMessageHandler that delegates to . + public global::System.Net.Http.HttpMessageHandler Wrapping(global::System.Net.Http.HttpMessageHandler instance) + { + if (mock is global::Mockolate.IMock mockInterface) + { + global::Mockolate.MockRegistry wrappingRegistry = new global::Mockolate.MockRegistry(mockInterface.MockRegistry, instance); + wrappingRegistry = new global::Mockolate.MockRegistry(wrappingRegistry, global::Mockolate.Mock.HttpMessageHandler.CreateFastInteractions(wrappingRegistry.Behavior)); + return CreateMockInstance(wrappingRegistry, mockInterface.MockRegistry.ConstructorParameters, null); + } + throw new global::Mockolate.Exceptions.MockException("The subject is no mock."); + } + + } + + /// + extension(global::Mockolate.MockBehavior behavior) + { + /// + /// Initializes mocks of type with the given . + /// + /// + /// The is applied to the mock before the constructor is executed. Calling Initialize again overlays additional setups on top of any previously registered ones. + /// + /// The mockable type derived from HttpMessageHandler that this setup should apply to. + /// Callback invoked when a new mock of is created. + /// A new MockBehavior with the registered initializer. The original instance is unchanged. + public global::Mockolate.MockBehavior Initialize(global::System.Action setup) + where T : global::System.Net.Http.HttpMessageHandler + { + var behaviorAccess = (global::Mockolate.IMockBehaviorAccess)behavior; + return behaviorAccess.Set(setup); + } + } + internal interface IMockSetupInitializationForHttpMessageHandler : global::Mockolate.Mock.IMockSetupForHttpMessageHandler + { + /// + /// Setup protected members + /// + global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler Protected { get; } + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal sealed class MockSetup(global::Mockolate.MockRegistry mockRegistry) : global::Mockolate.Mock.IMockSetupForHttpMessageHandler, global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler, IMockSetupInitializationForHttpMessageHandler + { + /// + global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler IMockSetupInitializationForHttpMessageHandler.Protected => this; + private global::Mockolate.MockRegistry MockRegistry { get; } = mockRegistry; + + #region IMockSetupForHttpMessageHandler + + #endregion IMockSetupForHttpMessageHandler + + #region IMockProtectedSetupForHttpMessageHandler + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", parameters, "request", "cancellationToken"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + global::Mockolate.Setup.ReturnMethodSetup methodSetup; + if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.Literal!, cancellationTokenArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) + { + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", parameters, "request", "cancellationToken"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> methodSetup; + if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.Literal!, cancellationTokenArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) + { + global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) + { + global::Mockolate.ParameterArg requestArg = request ?? default; + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, methodSetup); + return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Dispose(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", parameters, "disposing"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Dispose(global::Mockolate.ParameterArg? disposing) + { + global::Mockolate.ParameterArg disposingArg = disposing ?? default; + global::Mockolate.Setup.VoidMethodSetup methodSetup; + if (disposingArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", disposingArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", disposingArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, methodSetup); + return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Dispose(global::System.Func disposing, string disposingExpression) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(disposing, disposingExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, methodSetup); + return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; + } + + #endregion IMockProtectedSetupForHttpMessageHandler + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch + { + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); + } +} + +#nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.g.cs new file mode 100644 index 00000000..3ce28555 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.g.cs @@ -0,0 +1,133 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +namespace Mockolate; + +#nullable enable +/// +/// Create new mocks by calling the static T.CreateMock() method on your type T. +/// +/// +/// You can also provide a MockBehavior parameter to customize how the mock should behave in certain scenarios.
+/// If your type is a class without a default constructor, you can provide constructor parameters by passing an object?[]? to the corresponding CreateMock(...) overload. +///
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal static partial class Mock +{ + /// + /// This interface should never be used. If it is, this is an indication that the Mockolate source generator did not run correctly or that the used type is not mockable. + /// + /// + /// The source generator creates overloads with correct return values. + /// + internal interface IMockGenerationDidNotRun {} + + /// + /// Create a new mock of with the default MockBehavior. + /// + /// Type to mock, which can be an interface or a class. + /// + /// Any interface type can be used for mocking, but for classes, only abstract and virtual members can be mocked. + /// + extension(T _) + { + /// + /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when + /// is not mockable. Calling it always throws a MockException. + /// + /// Ignored; reserved for the generator-emitted overload. + /// This method never returns - it always throws. + /// + /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. + /// If you see this fallback resolved in your IDE, the generator did not run for ; + /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. + /// + /// Always thrown: the source generator did not run or is not mockable. + public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior = null) + { + throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); + } + + /// + /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when + /// is not mockable. Calling it always throws a MockException. + /// + /// Ignored; reserved for the generator-emitted overload. + /// Ignored; reserved for the generator-emitted overload. + /// This method never returns - it always throws. + /// + /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. + /// If you see this fallback resolved in your IDE, the generator did not run for ; + /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. + /// + /// Always thrown: the source generator did not run or is not mockable. + public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior, object?[]? constructorParameters) + { + throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); + } + + /// + /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when + /// is not mockable. Calling it always throws a MockException. + /// + /// Ignored; reserved for the generator-emitted overload. + /// This method never returns - it always throws. + /// + /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. + /// If you see this fallback resolved in your IDE, the generator did not run for ; + /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. + /// + /// Always thrown: the source generator did not run or is not mockable. + public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(object?[]? constructorParameters) + { + throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); + } + } + + extension(global::Mockolate.Mock.IMockGenerationDidNotRun _) + { + /// + /// Fallback Implementing that is only resolved when the Mockolate source generator did not run or when + /// is not mockable. Calling it always throws a MockException. + /// + /// Additional interface the mock should implement. + /// This method never returns - it always throws. + /// + /// The source generator emits a concrete Implementing overload per mockable type with the same shape. + /// If you see this fallback resolved in your IDE, the generator did not run for ; + /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. + /// + /// Always thrown: the source generator did not run or is not mockable. + public global::Mockolate.Mock.IMockGenerationDidNotRun Implementing() where TInterface : class + { + throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(TInterface)}' is not mockable or the source generator did not run correctly."); + } + } + + /// + /// Adapts an IParameter (non-generic) to + /// IParameterMatch<T> so that covariant parameter + /// references (e.g. an IParameter<Derived> passed through an IParameter<Base> + /// slot) can still be invoked at setup/verify time. Only allocated when the direct + /// IParameterMatch<T> cast fails. + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch + { + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); + } +} +#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/MockBehaviorExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/MockBehaviorExtensions.g.cs new file mode 100644 index 00000000..3e895b59 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/MockBehaviorExtensions.g.cs @@ -0,0 +1,301 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +namespace Mockolate; + +#nullable enable annotations + +/// +/// Extensions for MockBehavior. +/// +internal static partial class Mock +{ + private static readonly global::Mockolate.MockBehavior _default; + + static Mock() + { + _default = new global::Mockolate.MockBehavior(new DefaultValueGenerator()); + } + + extension(global::Mockolate.MockBehavior) + { + /// + /// The default MockBehavior - the starting point for configuring a mock. + /// + /// + /// Un-configured members return the generator-provided default value (empty strings/collections, completed + /// Tasks, otherwise), base-class + /// implementations run for class mocks, and every invocation is recorded for later verification. + /// + /// Chain SkippingBaseClass(), ThrowingWhenNotSetup(), SkippingInteractionRecording(), + /// WithDefaultValueFor<T>(...) or UseConstructorParametersFor<T>(...) to derive + /// a customized MockBehavior; because it is a , + /// each call returns a new instance and this shared default stays unchanged. + /// + public static global::Mockolate.MockBehavior Default => _default; + } + + /// + /// Defines a factory for creating default values for a specified type. + /// + public interface IDefaultValueFactory + { + /// + /// Determines whether the specified can be created by this factory. + /// + bool IsMatch(global::System.Type type); + + /// + /// Creates a new instance of the specified type. + /// + object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, object?[] parameters); + } + + /// + /// A IDefaultValueFactory that returns a specified for the given type + /// parameter . + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal class TypedDefaultValueFactory(T value) : IDefaultValueFactory + { + /// + public bool IsMatch(global::System.Type type) + => type == typeof(T); + + /// + public object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) + => value; + } + /// + /// A IDefaultValueFactory that returns an empty HttpResponseMessage with the specified + /// . + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class HttpResponseMessageFactory(global::System.Net.HttpStatusCode statusCode) : IDefaultValueFactory + { + /// + public bool IsMatch(global::System.Type type) + => type == typeof(global::System.Net.Http.HttpResponseMessage); + + /// + public object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) + => new global::System.Net.Http.HttpResponseMessage(statusCode) { Content = new global::System.Net.Http.StringContent(string.Empty) }; + } + + /// + /// Provides default values for common types used in mocking scenarios. + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private class DefaultValueGenerator : IDefaultValueGenerator + { + private static readonly global::System.Collections.Concurrent.ConcurrentQueue _factories = new([ + new TypedDefaultValueFactory(""), + new HttpResponseMessageFactory(global::System.Net.HttpStatusCode.NotImplemented), + new CancellableTaskFactory(), + #if NET8_0_OR_GREATER + new CancellableValueTaskFactory(), + #endif + new TypedDefaultValueFactory(global::System.Threading.CancellationToken.None), + new TypedDefaultValueFactory(global::System.Array.Empty()), + ]); + + /// + public object? GenerateValue(global::System.Type type, params object?[] parameters) + { + if (TryGenerate(type, parameters, out object? value)) + { + return value; + } + + return null; + } + + /// + /// Registers a to provide default values for a specific type. + /// + public static void Register(IDefaultValueFactory defaultValueFactory) + => _factories.Enqueue(defaultValueFactory); + + /// + /// Tries to generate a default value for the specified type. + /// + protected virtual bool TryGenerate(global::System.Type type, object?[] parameters, out object? value) + { + IDefaultValueFactory? matchingFactory = global::System.Linq.Enumerable.FirstOrDefault(_factories, Predicate); + if (matchingFactory is not null) + { + value = matchingFactory.Create(type, this, parameters); + return true; + } + + value = null; + return false; + + bool Predicate(global::Mockolate.Mock.IDefaultValueFactory f) + => f.IsMatch(type); + } + + private static bool HasCanceledCancellationToken(object?[] parameters, out global::System.Threading.CancellationToken cancellationToken) + { + global::System.Threading.CancellationToken parameter = global::System.Linq.Enumerable.FirstOrDefault(global::System.Linq.Enumerable.OfType(parameters)); + if (parameter.IsCancellationRequested) + { + cancellationToken = parameter; + return true; + } + + cancellationToken = global::System.Threading.CancellationToken.None; + return false; + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class CancellableTaskFactory : IDefaultValueFactory + { + /// + public bool IsMatch(global::System.Type type) + => type == typeof(global::System.Threading.Tasks.Task); + + /// + public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) + { + if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) + { + return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); + } + + return global::System.Threading.Tasks.Task.CompletedTask; + } + } + #if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class CancellableValueTaskFactory : IDefaultValueFactory + { + /// + public bool IsMatch(global::System.Type type) + => type == typeof(global::System.Threading.Tasks.ValueTask); + + /// + public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) + { + if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) + { + return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); + } + + return global::System.Threading.Tasks.ValueTask.CompletedTask; + } + } + #endif + } +} + +/// +/// Extensions on IDefaultValueGenerator +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal static class DefaultValueGeneratorExtensions +{ + /// + /// Adds a generic Generate method for specific types. + /// + extension(IDefaultValueGenerator generator) + { + /// + /// Generates a Task of , with + /// the for context. + /// + public global::System.Threading.Tasks.Task Generate(global::System.Threading.Tasks.Task nullValue, T value, params object?[] parameters) + { + global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( + global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; + if (cancellationToken.IsCancellationRequested) + { + return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); + } + + return global::System.Threading.Tasks.Task.FromResult(value); + } + +#if NET8_0_OR_GREATER + /// + /// Generates a ValueTask of , with + /// the for context. + /// + public global::System.Threading.Tasks.ValueTask Generate(global::System.Threading.Tasks.ValueTask nullValue, T value, params object?[] parameters) + { + global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( + global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; + if (cancellationToken.IsCancellationRequested) + { + return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); + } + + return global::System.Threading.Tasks.ValueTask.FromResult(value); + } +#endif + + /// + /// Generates an empty enumerable of , with + /// the for context. + /// + public global::System.Collections.Generic.IEnumerable Generate(global::System.Collections.Generic.IEnumerable nullValue, params object?[] parameters) + => global::System.Array.Empty(); + + /// + /// Generates an empty enumerable of , with + /// the for context. + /// + public global::System.Collections.Generic.List Generate(global::System.Collections.Generic.List nullValue, params object?[] parameters) + => new global::System.Collections.Generic.List(); + + /// + /// Generates an empty array of , with + /// the for context. + /// + public T[] Generate(T[] nullValue, params object?[] parameters) + => global::System.Array.Empty(); + + /// + /// Generates an empty two-dimensional array of , with + /// the for context. + /// + public T[,] Generate(T[,] nullValue, params object?[] parameters) + => new T[,] { }; + + /// + /// Generates an empty three-dimensional array of , with + /// the for context. + /// + public T[,,] Generate(T[,,] nullValue, params object?[] parameters) + => new T[,,] { }; + + /// + /// Generates an empty four-dimensional array of , with + /// the for context. + /// + public T[,,,] Generate(T[,,,] nullValue, params object?[] parameters) + => new T[,,,] { }; + + /// + /// Generates a default value of type , with + /// the for context. + /// + public T Generate(T nullValue, params object?[] parameters) + { + if (generator.GenerateValue(typeof(T), parameters) is T value) + { + return value; + } + + return nullValue; + } + } +} + +#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/ParameterArg.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/ParameterArg.g.cs new file mode 100644 index 00000000..50826154 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/ParameterArg.g.cs @@ -0,0 +1,133 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +#nullable enable + +namespace Mockolate +{ + /// + /// A setup or verify argument that is either an It matcher + /// (IParameter<T>) or a literal value of type . + /// + /// + /// Both case types convert implicitly, so Setup.Method(42) and Setup.Method(It.IsAny<int>()) + /// bind to the same overload. A instance stands for the literal default(T). + /// + [global::System.Runtime.CompilerServices.Union] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal readonly struct ParameterArg + { + private const byte MatcherTag = 1; + private const byte LiteralTag = 2; + + private readonly global::Mockolate.Parameters.IParameter? _matcher; + private readonly T? _literal; + private readonly byte _tag; + + /// + /// Creates the matcher case. + /// + public ParameterArg(global::Mockolate.Parameters.IParameter matcher) + { + _matcher = matcher; + _literal = default; + _tag = MatcherTag; + } + + /// + /// Creates the literal value case. + /// + public ParameterArg(T? literal) + { + _matcher = null; + _literal = literal; + _tag = LiteralTag; + } + + /// + /// The contained matcher or literal value, boxed. Part of the union pattern; the generated mocks use the + /// typed accessors instead. + /// + public object? Value => _tag switch + { + MatcherTag => _matcher, + LiteralTag => _literal, + _ => null, + }; + + /// + /// unless this is the instance. + /// + public bool HasValue => _tag != 0; + + /// + /// when the argument is a literal value (including the instance). + /// + public bool IsLiteral => _tag != MatcherTag; + + /// + /// The literal value; default(T) for the matcher case and the instance. + /// + public T? Literal => _literal; + + /// + /// Gets the matcher, when this is the matcher case. + /// + public bool TryGetValue(out global::Mockolate.Parameters.IParameter? matcher) + { + matcher = _matcher; + return _tag == MatcherTag; + } + + /// + /// Gets the literal value, when this is the literal case. + /// + public bool TryGetValue(out T? literal) + { + literal = _literal; + return _tag == LiteralTag; + } + + /// + /// The IParameterMatch<T> for this argument: the matcher itself, + /// or an equality match for the literal value. + /// + public global::Mockolate.Parameters.IParameterMatch ToParameterMatch() + { + if (_tag != MatcherTag) + { + return (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(_literal!); + } + + if (_matcher is null) + { + return (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsNull("null"); + } + + return _matcher is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantAdapter(_matcher); + } + + /// + public override string ToString() => _tag switch + { + MatcherTag => _matcher?.ToString() ?? "null", + _ => _literal?.ToString() ?? "null", + }; + + private sealed class CovariantAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch + { + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + } + } +} +#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.IKeywordEdgeCases.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.IKeywordEdgeCases.g.cs new file mode 100644 index 00000000..d8e59526 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.IKeywordEdgeCases.g.cs @@ -0,0 +1,1541 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +#nullable enable annotations +namespace Mockolate; + +internal static partial class Mock +{ + /// + /// A mock implementation for IKeywordEdgeCases. + /// + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal class IKeywordEdgeCases : + global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases, IMockForIKeywordEdgeCases, IMockSetupForIKeywordEdgeCases, IMockRaiseOnIKeywordEdgeCases, IMockVerifyForIKeywordEdgeCases, + global::Mockolate.IMock + { + internal const int MemberId__class_Get = 0; + internal const int MemberId__class_Set = 1; + internal const int MemberId__event_Subscribe = 2; + internal const int MemberId__event_Unsubscribe = 3; + internal const int MemberId_Indexer_int_string_Get = 4; + internal const int MemberId_Indexer_int_string_Set = 5; + internal const int MemberId__return = 6; + internal const int MemberId__if = 7; + internal const int MemberId__void__class_ = 8; + internal const int MemberCount = 9; + internal static readonly global::Mockolate.Interactions.PropertyGetterAccess PropertyAccess__class_Get = new global::Mockolate.Interactions.PropertyGetterAccess("global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@class"); + + /// + /// Creates a FastMockInteractions sized to MemberCount for use as the mock's interaction store. + /// Per-member buffers are not allocated up-front: the recording hot paths call GetOrCreateBuffer<TBuffer>(int, Func<FastMockInteractions, TBuffer>) so a slot is materialized only when its member is first invoked. + /// + internal static global::Mockolate.Interactions.FastMockInteractions CreateFastInteractions(global::Mockolate.MockBehavior behavior) + => new global::Mockolate.Interactions.FastMockInteractions(MemberCount, behavior.SkipInteractionRecording); + + /// + /// Builds a MockRegistry backed by a typed-buffer-sized FastMockInteractions from . + /// + private static global::Mockolate.MockRegistry MockolateCreateRegistryFromBehavior(global::Mockolate.MockBehavior behavior) + { + global::Mockolate.MockRegistry registry = new global::Mockolate.MockRegistry(behavior, MemberCount); + return registry; + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.MockRegistry global::Mockolate.IMock.MockRegistry => this.MockRegistry; + private global::Mockolate.MockRegistry MockRegistry { get; } + + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastIndexerGetterBuffer MockolateBuffer_Indexer_int_string_Get + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, static fast => new global::Mockolate.Interactions.FastIndexerGetterBuffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastIndexerSetterBuffer MockolateBuffer_Indexer_int_string_Set + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Set, static fast => new global::Mockolate.Interactions.FastIndexerSetterBuffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod0Buffer MockolateBuffer__return + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__return, static fast => new global::Mockolate.Interactions.FastMethod0Buffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastMethod1Buffer MockolateBuffer__if + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__if, static fast => new global::Mockolate.Interactions.FastMethod1Buffer(fast))); + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + IMockSetupForIKeywordEdgeCases IMockForIKeywordEdgeCases.Setup + => this; + /// + IMockInScenarioForIKeywordEdgeCases IMockForIKeywordEdgeCases.InScenario(string scenario) + => new MockInScenarioForIKeywordEdgeCases(this.MockRegistry, scenario); + + /// + IMockForIKeywordEdgeCases IMockForIKeywordEdgeCases.InScenario(string scenario, global::System.Action setup) + { + setup.Invoke(new MockInScenarioForIKeywordEdgeCases(this.MockRegistry, scenario)); + return this; + } + + /// + IMockForIKeywordEdgeCases IMockForIKeywordEdgeCases.TransitionTo(string scenario) + { + this.MockRegistry.TransitionTo(scenario); + return this; + } + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + IMockRaiseOnIKeywordEdgeCases IMockForIKeywordEdgeCases.Raise + => this; + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + IMockVerifyForIKeywordEdgeCases IMockForIKeywordEdgeCases.Verify + => this; + /// + global::Mockolate.Verify.VerificationResult IMockForIKeywordEdgeCases.VerifySetup(global::Mockolate.Setup.IMethodSetup setup) + => this.MockRegistry.Method(this, setup); + /// + bool IMockForIKeywordEdgeCases.VerifyThatAllInteractionsAreVerified() + => this.MockRegistry.Interactions.GetUnverifiedInteractions().Count == 0; + /// + bool IMockForIKeywordEdgeCases.VerifyThatAllSetupsAreUsed() + => this.MockRegistry.GetUnusedSetups(this.MockRegistry.Interactions).Count == 0; + /// + void IMockForIKeywordEdgeCases.ClearAllInteractions() + => this.MockRegistry.ClearAllInteractions(); + /// + global::Mockolate.Monitor.MockMonitor IMockForIKeywordEdgeCases.Monitor() + => new global::Mockolate.Monitor.MockMonitor(this.MockRegistry.Interactions, interactions => new VerifyMonitorIKeywordEdgeCases(new global::Mockolate.MockRegistry(this.MockRegistry, interactions))); + + /// + string global::Mockolate.IMock.ToString() + => "Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases mock"; + + /// + public IKeywordEdgeCases(global::Mockolate.MockRegistry mockRegistry) + { + this.MockRegistry = mockRegistry; + } + + /// + public IKeywordEdgeCases(global::Mockolate.MockBehavior behavior) + : this(MockolateCreateRegistryFromBehavior(behavior)) + { + } + + #region Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases + + private global::System.EventHandler? _mockolateEvent_global__Mockolate_Tests_GeneratorCoverage_IKeywordEdgeCases_event; + /// + public event global::System.EventHandler @event + { + add + { + if (value is not null) + { + this.MockRegistry.AddEvent(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__event_Subscribe, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@event", value.Target, value.Method); + } + this._mockolateEvent_global__Mockolate_Tests_GeneratorCoverage_IKeywordEdgeCases_event += value; + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases wraps) + { + wraps.@event += value; + } + } + remove + { + if (value is not null) + { + this.MockRegistry.RemoveEvent(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__event_Unsubscribe, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@event", value.Target, value.Method); + } + this._mockolateEvent_global__Mockolate_Tests_GeneratorCoverage_IKeywordEdgeCases_event -= value; + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases wraps) + { + wraps.@event -= value; + } + } + } + + /// + public int @class + { + get + { + return this.MockRegistry.GetPropertyFast(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__class_Get, global::Mockolate.Mock.IKeywordEdgeCases.PropertyAccess__class_Get, static b => b.DefaultValue.Generate(default(int)!), this.MockRegistry.Wraps is not global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases wraps ? null : () => wraps.@class); + } + } + + /// + public string this[int @params, string @void] + { + get + { + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_Indexer_int_string_Get.Append(@params, @void); + } + global::Mockolate.Setup.IndexerSetup? setup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.IndexerSetup[]? snapshot_setup = this.MockRegistry.GetIndexerSetupSnapshot(global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get); + if (snapshot_setup is not null) + { + for (int i_setup = snapshot_setup.Length - 1; i_setup >= 0; i_setup--) + { + if (snapshot_setup[i_setup] is global::Mockolate.Setup.IndexerSetup s_setup && s_setup.Matches(@params, @void)) + { + setup = s_setup; + break; + } + } + } + } + global::Mockolate.Interactions.IndexerGetterAccess access = new(@params, @void); + setup ??= this.MockRegistry.GetIndexerSetup>(access); + if (this.MockRegistry.Wraps is not global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases wraps) + { + return setup is null + ? this.MockRegistry.GetIndexerFallback(access, 0) + : this.MockRegistry.ApplyIndexerSetup(access, setup, 0); + } + string baseResult = wraps[@params, @void]; + return this.MockRegistry.ApplyIndexerGetter(access, setup, baseResult, 0); + } + set + { + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_Indexer_int_string_Set.Append(@params, @void, value); + } + global::Mockolate.Setup.IndexerSetup? setup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.IndexerSetup[]? snapshot_setup = this.MockRegistry.GetIndexerSetupSnapshot(global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get); + if (snapshot_setup is not null) + { + for (int i_setup = snapshot_setup.Length - 1; i_setup >= 0; i_setup--) + { + if (snapshot_setup[i_setup] is global::Mockolate.Setup.IndexerSetup s_setup && s_setup.Matches(@params, @void, value)) + { + setup = s_setup; + break; + } + } + } + } + global::Mockolate.Interactions.IndexerSetterAccess access = new(@params, @void, value); + setup ??= this.MockRegistry.GetIndexerSetup>(access); + this.MockRegistry.ApplyIndexerSetter(access, setup, value, 0); + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases wraps) + { + wraps[@params, @void] = value; + } + } + } + + /// + public string @return() + { + global::Mockolate.Setup.ReturnMethodSetup? methodSetup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__return); + 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()) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@return")) + { + if (s_methodSetup.Matches()) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + string wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer__return.Append("global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@return"); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases wraps) + { + wrappedResult = wraps.@return(); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@return()' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(string)!); + } + + /// + public void @if(int @params) + { + global::Mockolate.Setup.VoidMethodSetup? methodSetup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__if); + 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.VoidMethodSetup s_methodSetup && s_methodSetup.Matches(@params)) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.VoidMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@if")) + { + if (s_methodSetup.Matches(@params)) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer__if.Append("global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@if", @params); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases wraps) + { + wraps.@if(@params); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(@params); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@if(int)' was invoked without prior setup."); + } + } + + /// + public int @void<@class>(int @ref) + { + global::Mockolate.Setup.ReturnMethodSetup? methodSetup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__void__class_); + string name_methodSetup = $"global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@void<{typeof(@class)}>"; + 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.Name == name_methodSetup && s_methodSetup.Matches(@ref)) + { + methodSetup = s_methodSetup; + break; + } + } + } + } + if (methodSetup is null) + { + foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>($"global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@void<{typeof(@class)}>")) + { + if (s_methodSetup.Matches(@ref)) + { + methodSetup = s_methodSetup; + break; + } + } + } + bool hasWrappedResult = false; + int wrappedResult = default!; + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockRegistry.RegisterInteraction(new global::Mockolate.Interactions.MethodInvocation($"global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@void<{typeof(@class)}>", @ref)); + } + try + { + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases wraps) + { + wrappedResult = wraps.@void<@class>(@ref); + hasWrappedResult = true; + } + } + finally + { + methodSetup?.TriggerCallbacks(@ref); + } + if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) + { + throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@void<@class>(int)' was invoked without prior setup."); + } + if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) + { + return wrappedResult; + } + return methodSetup?.TryGetReturnValue(@ref, out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(int)!, @ref); + } + + #endregion Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases + + #region IMockSetupForIKeywordEdgeCases + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IPropertyGetterOnlySetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.@class + { + get + { + var propertySetup = new global::Mockolate.Setup.PropertySetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@class"); + this.MockRegistry.SetupProperty(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__class_Get, propertySetup); + return propertySetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.EventSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.@event + { + get + { + global::Mockolate.Setup.EventSetup eventSetup = new global::Mockolate.Setup.EventSetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@event"); + this.MockRegistry.SetupEvent(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__event_Subscribe, eventSetup); + return eventSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[global::Mockolate.Parameters.IParameter? parameter1, global::Mockolate.Parameters.IParameter? parameter2] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, CovariantParameterAdapter.Wrap(parameter1 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter2 ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[int parameter1, global::Mockolate.Parameters.IParameter? parameter2] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter1), CovariantParameterAdapter.Wrap(parameter2 ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[global::Mockolate.Parameters.IParameter? parameter1, string parameter2] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, CovariantParameterAdapter.Wrap(parameter1 ?? global::Mockolate.It.IsNull("null")), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter2)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[int parameter1, string parameter2] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter1), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter2)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, indexerSetup); + return indexerSetup; + } + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.@return() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@return"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__return, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.@if(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@if", parameters, "@params"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__if, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.@if(global::Mockolate.ParameterArg? @params) + { + global::Mockolate.ParameterArg @paramsArg = @params ?? default; + global::Mockolate.Setup.VoidMethodSetup methodSetup; + if (@paramsArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithLiteralValues(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@if", @paramsArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@if", @paramsArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__if, methodSetup); + return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.@if(global::System.Func @params, string @paramsExpression) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@if", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(@params, @paramsExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__if, methodSetup); + return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.@void<@class>(global::Mockolate.Parameters.IParameters parameters) + where @class : default + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, $"global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@void<{typeof(@class)}>", parameters, "@ref"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__void__class_, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.@void<@class>(global::Mockolate.Parameters.IParameter? @ref) + where @class : default + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, $"global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@void<{typeof(@class)}>", CovariantParameterAdapter.Wrap(@ref ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__void__class_, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.@void<@class>(int @ref) + where @class : default + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithLiteralValues(MockRegistry, $"global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@void<{typeof(@class)}>", @ref); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__void__class_, methodSetup); + return methodSetup; + } + + #endregion IMockSetupForIKeywordEdgeCases + + #region IMockRaiseOnIKeywordEdgeCases + + /// + void IMockRaiseOnIKeywordEdgeCases.@event(object? sender, global::System.EventArgs e) + { + this._mockolateEvent_global__Mockolate_Tests_GeneratorCoverage_IKeywordEdgeCases_event?.Invoke(sender, e); + } + + /// + void IMockRaiseOnIKeywordEdgeCases.@event(global::Mockolate.Parameters.IDefaultEventParameters parameters) + { + global::Mockolate.MockBehavior mockBehavior = this.MockRegistry.Behavior; + this._mockolateEvent_global__Mockolate_Tests_GeneratorCoverage_IKeywordEdgeCases_event?.Invoke(mockBehavior.DefaultValue.Generate(default(object)), mockBehavior.DefaultValue.Generate(default(global::System.EventArgs))); + } + + #endregion IMockRaiseOnIKeywordEdgeCases + + #region IMockVerifyForIKeywordEdgeCases + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationPropertyGetterResult IMockVerifyForIKeywordEdgeCases.@class + { + get + { + return new global::Mockolate.Verify.VerificationPropertyGetterResult(this, this.MockRegistry, global::Mockolate.Mock.IKeywordEdgeCases.MemberId__class_Get, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@class"); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[global::Mockolate.Parameters.IParameter? @params, global::Mockolate.Parameters.IParameter? @void] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Set, + CovariantParameterAdapter.Wrap(@params ?? global::Mockolate.It.IsNull("null")), + CovariantParameterAdapter.Wrap(@void ?? global::Mockolate.It.IsNull("null")), + () => global::System.String.Format("[{0}, {1}]", (object?)@params ?? "null", (object?)@void ?? "null")); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[int @params, global::Mockolate.Parameters.IParameter? @void] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Set, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(@params, "@params"), + CovariantParameterAdapter.Wrap(@void ?? global::Mockolate.It.IsNull("null")), + () => global::System.String.Format("[{0}, {1}]", (object?)@params, (object?)@void ?? "null")); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[global::Mockolate.Parameters.IParameter? @params, string @void] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Set, + CovariantParameterAdapter.Wrap(@params ?? global::Mockolate.It.IsNull("null")), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(@void, "@void"), + () => global::System.String.Format("[{0}, {1}]", (object?)@params ?? "null", (object?)@void)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[int @params, string @void] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Set, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(@params, "@params"), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(@void, "@void"), + () => global::System.String.Format("[{0}, {1}]", (object?)@params, (object?)@void)); + } + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIKeywordEdgeCases.@return() + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IKeywordEdgeCases.MemberId__return, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@return", () => $"@return()"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIKeywordEdgeCases.@if(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IKeywordEdgeCases.MemberId__if, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@if", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("@params", __i.Parameter1)]), + _ => true + }, () => $"@if({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIKeywordEdgeCases.@if(global::Mockolate.ParameterArg? @params) + { + global::Mockolate.ParameterArg @paramsArg = @params ?? default; + if (@paramsArg.IsLiteral) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IKeywordEdgeCases.MemberId__if, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@if", @paramsArg.Literal!, () => $"@if({@paramsArg})"); + } + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IKeywordEdgeCases.MemberId__if, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@if", @paramsArg.ToParameterMatch(), () => $"@if({@paramsArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIKeywordEdgeCases.@if(global::System.Func @params, string @paramsExpression) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IKeywordEdgeCases.MemberId__if, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@if", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(@params, @paramsExpression), () => $"@if({@paramsExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIKeywordEdgeCases.@void<@class>(global::Mockolate.Parameters.IParameters parameters) + where @class : default + => this.MockRegistry.VerifyMethod>(this, -1, $"global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@void<{typeof(@class)}>", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("@ref", __i.Parameter1)]), + _ => true + }, () => $"@void<@class>({parameters})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIKeywordEdgeCases.@void<@class>(global::Mockolate.Parameters.IParameter? @ref) + where @class : default + => this.MockRegistry.VerifyMethod>(this, -1, $"global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@void<{typeof(@class)}>", __i => + (@ref is not null ? CovariantParameterAdapter.Wrap(@ref).Matches(__i.Parameter1) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter1, default(int))), () => $"@void<@class>({@ref})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIKeywordEdgeCases.@void<@class>(int @ref) + where @class : default + => this.MockRegistry.VerifyMethod>(this, -1, $"global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@void<{typeof(@class)}>", __i => + (global::System.Collections.Generic.EqualityComparer.Default.Equals(@ref, __i.Parameter1)), () => $"@void<@class>({@ref})"); + /// + /// Verify subscriptions on the @event event @event. + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationEventResult IMockVerifyForIKeywordEdgeCases.@event + { + get + { + return new global::Mockolate.Verify.VerificationEventResult(this, this.MockRegistry, global::Mockolate.Mock.IKeywordEdgeCases.MemberId__event_Subscribe, global::Mockolate.Mock.IKeywordEdgeCases.MemberId__event_Unsubscribe, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@event"); + } + } + + #endregion IMockVerifyForIKeywordEdgeCases + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class VerifyMonitorIKeywordEdgeCases(global::Mockolate.MockRegistry mockRegistry) : global::Mockolate.Mock.IMockVerifyForIKeywordEdgeCases + { + private global::Mockolate.MockRegistry MockRegistry { get; } = mockRegistry; + + #region IMockVerifyForIKeywordEdgeCases + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationPropertyGetterResult IMockVerifyForIKeywordEdgeCases.@class + { + get + { + return new global::Mockolate.Verify.VerificationPropertyGetterResult(this, this.MockRegistry, global::Mockolate.Mock.IKeywordEdgeCases.MemberId__class_Get, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@class"); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[global::Mockolate.Parameters.IParameter? @params, global::Mockolate.Parameters.IParameter? @void] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Set, + CovariantParameterAdapter.Wrap(@params ?? global::Mockolate.It.IsNull("null")), + CovariantParameterAdapter.Wrap(@void ?? global::Mockolate.It.IsNull("null")), + () => global::System.String.Format("[{0}, {1}]", (object?)@params ?? "null", (object?)@void ?? "null")); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[int @params, global::Mockolate.Parameters.IParameter? @void] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Set, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(@params, "@params"), + CovariantParameterAdapter.Wrap(@void ?? global::Mockolate.It.IsNull("null")), + () => global::System.String.Format("[{0}, {1}]", (object?)@params, (object?)@void ?? "null")); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[global::Mockolate.Parameters.IParameter? @params, string @void] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Set, + CovariantParameterAdapter.Wrap(@params ?? global::Mockolate.It.IsNull("null")), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(@void, "@void"), + () => global::System.String.Format("[{0}, {1}]", (object?)@params ?? "null", (object?)@void)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[int @params, string @void] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Set, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(@params, "@params"), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(@void, "@void"), + () => global::System.String.Format("[{0}, {1}]", (object?)@params, (object?)@void)); + } + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIKeywordEdgeCases.@return() + => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IKeywordEdgeCases.MemberId__return, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@return", () => $"@return()"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIKeywordEdgeCases.@if(global::Mockolate.Parameters.IParameters parameters) + => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.IKeywordEdgeCases.MemberId__if, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@if", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("@params", __i.Parameter1)]), + _ => true + }, () => $"@if({parameters})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIKeywordEdgeCases.@if(global::Mockolate.ParameterArg? @params) + { + global::Mockolate.ParameterArg @paramsArg = @params ?? default; + if (@paramsArg.IsLiteral) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IKeywordEdgeCases.MemberId__if, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@if", @paramsArg.Literal!, () => $"@if({@paramsArg})"); + } + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IKeywordEdgeCases.MemberId__if, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@if", @paramsArg.ToParameterMatch(), () => $"@if({@paramsArg})"); + } + + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIKeywordEdgeCases.@if(global::System.Func @params, string @paramsExpression) + { + return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.IKeywordEdgeCases.MemberId__if, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@if", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(@params, @paramsExpression), () => $"@if({@paramsExpression})"); + } + + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIKeywordEdgeCases.@void<@class>(global::Mockolate.Parameters.IParameters parameters) + where @class : default + => this.MockRegistry.VerifyMethod>(this, -1, $"global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@void<{typeof(@class)}>", __i => parameters switch + { + global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1]), + global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("@ref", __i.Parameter1)]), + _ => true + }, () => $"@void<@class>({parameters})"); + /// + global::Mockolate.Verify.VerificationResult IMockVerifyForIKeywordEdgeCases.@void<@class>(global::Mockolate.Parameters.IParameter? @ref) + where @class : default + => this.MockRegistry.VerifyMethod>(this, -1, $"global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@void<{typeof(@class)}>", __i => + (@ref is not null ? CovariantParameterAdapter.Wrap(@ref).Matches(__i.Parameter1) : global::System.Collections.Generic.EqualityComparer.Default.Equals(__i.Parameter1, default(int))), () => $"@void<@class>({@ref})"); + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForIKeywordEdgeCases.@void<@class>(int @ref) + where @class : default + => this.MockRegistry.VerifyMethod>(this, -1, $"global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@void<{typeof(@class)}>", __i => + (global::System.Collections.Generic.EqualityComparer.Default.Equals(@ref, __i.Parameter1)), () => $"@void<@class>({@ref})"); + /// + /// Verify subscriptions on the @event event @event. + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationEventResult IMockVerifyForIKeywordEdgeCases.@event + { + get + { + return new global::Mockolate.Verify.VerificationEventResult(this, this.MockRegistry, global::Mockolate.Mock.IKeywordEdgeCases.MemberId__event_Subscribe, global::Mockolate.Mock.IKeywordEdgeCases.MemberId__event_Unsubscribe, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@event"); + } + } + + #endregion IMockVerifyForIKeywordEdgeCases + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class MockInScenarioForIKeywordEdgeCases : global::Mockolate.Mock.IMockInScenarioForIKeywordEdgeCases, global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases + { + private global::Mockolate.MockRegistry MockRegistry { get; } + private string _scenarioName; + + public MockInScenarioForIKeywordEdgeCases(global::Mockolate.MockRegistry mockRegistry, string scenario) + { + this.MockRegistry = mockRegistry; + _scenarioName = scenario; + } + + /// + global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases global::Mockolate.Mock.IMockInScenarioForIKeywordEdgeCases.Setup + => this; + + #region IMockSetupForIKeywordEdgeCases + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IPropertyGetterOnlySetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.@class + { + get + { + var propertySetup = new global::Mockolate.Setup.PropertySetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@class"); + this.MockRegistry.SetupProperty(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__class_Get, _scenarioName, propertySetup); + return propertySetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.EventSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.@event + { + get + { + global::Mockolate.Setup.EventSetup eventSetup = new global::Mockolate.Setup.EventSetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@event"); + this.MockRegistry.SetupEvent(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__event_Subscribe, _scenarioName, eventSetup); + return eventSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[global::Mockolate.Parameters.IParameter? parameter1, global::Mockolate.Parameters.IParameter? parameter2] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, CovariantParameterAdapter.Wrap(parameter1 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter2 ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[int parameter1, global::Mockolate.Parameters.IParameter? parameter2] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter1), CovariantParameterAdapter.Wrap(parameter2 ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[global::Mockolate.Parameters.IParameter? parameter1, string parameter2] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, CovariantParameterAdapter.Wrap(parameter1 ?? global::Mockolate.It.IsNull("null")), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter2)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[int parameter1, string parameter2] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter1), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter2)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.@return() + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@return"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__return, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.@if(global::Mockolate.Parameters.IParameters parameters) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameters(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@if", parameters, "@params"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__if, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.@if(global::Mockolate.ParameterArg? @params) + { + global::Mockolate.ParameterArg @paramsArg = @params ?? default; + global::Mockolate.Setup.VoidMethodSetup methodSetup; + if (@paramsArg.IsLiteral) + { + methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithLiteralValues(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@if", @paramsArg.Literal!); + } + else + { + methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@if", @paramsArg.ToParameterMatch()); + } + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__if, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.@if(global::System.Func @params, string @paramsExpression) + { + var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@if", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(@params, @paramsExpression)); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__if, _scenarioName, methodSetup); + return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.@void<@class>(global::Mockolate.Parameters.IParameters parameters) + where @class : default + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, $"global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@void<{typeof(@class)}>", parameters, "@ref"); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__void__class_, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.@void<@class>(global::Mockolate.Parameters.IParameter? @ref) + where @class : default + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, $"global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@void<{typeof(@class)}>", CovariantParameterAdapter.Wrap(@ref ?? global::Mockolate.It.IsNull("null"))); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__void__class_, _scenarioName, methodSetup); + return methodSetup; + } + + /// + global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.@void<@class>(int @ref) + where @class : default + { + var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithLiteralValues(MockRegistry, $"global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases.@void<{typeof(@class)}>", @ref); + this.MockRegistry.SetupMethod(global::Mockolate.Mock.IKeywordEdgeCases.MemberId__void__class_, _scenarioName, methodSetup); + return methodSetup; + } + + #endregion IMockSetupForIKeywordEdgeCases + } + + /// + /// The Mockolate accessor for a mock of IKeywordEdgeCases, reached through .Mock on the mocked instance. + /// + /// + /// Groups every operation that acts on the mock rather than on the mocked subject: setups, verifications, event raising, scenarios and monitoring. + /// + internal interface IMockForIKeywordEdgeCases + { + /// + /// Configures how members of the mock of IKeywordEdgeCases respond when invoked. + /// + /// + /// Each mocked member is available as a strongly-typed entry on this surface. Chain Returns, ReturnsAsync, Throws, ThrowsAsync or Do to control the response; chain InitializeWith/Register to initialize properties and indexers; chain multiple returns/throws to define a sequence; use .For(n), .Only(n), .Forever(), .When(predicate) to control when a callback runs.
+ /// When two setups overlap, the most recently defined one wins. + ///
+ IMockSetupForIKeywordEdgeCases Setup { get; } + + /// + /// Opens a named scenario scope on the mock of IKeywordEdgeCases so that additional setups can be registered for that scenario. + /// + /// + /// Scenarios let you define per-state behavior. Setups registered inside the returned IMockInScenarioFor... scope only apply while the mock's current scenario matches ; switch scenarios with TransitionTo. + /// + /// Name of the scenario to enter. Any non-null string acts as a key; the mock starts in an unnamed default scenario. + /// A scoped accessor whose Setup (and SetupProtected, where applicable) register scenario-specific setups. + IMockInScenarioForIKeywordEdgeCases InScenario(string scenario); + + /// + /// Opens a named scenario scope on the mock of IKeywordEdgeCases and immediately invokes to register scenario-specific setups. + /// + /// + /// Equivalent to InScenario(scenario) followed by the setup callback, but returns the original IMockFor... accessor so it chains nicely at mock-creation time. + /// + /// Name of the scenario to enter. + /// Callback that receives the scenario-scoped setup surface and registers scenario-specific setups. + /// This accessor, to allow chaining. + IMockForIKeywordEdgeCases InScenario(string scenario, global::System.Action setup); + + /// + /// Switches the active scenario of the mock of IKeywordEdgeCases to . + /// + /// + /// After the transition, setups registered via InScenario(string) under that scenario take effect. Scenarios that have no matching setup for a given member fall back to the default (un-scoped) setups. + /// + /// Name of the scenario to transition to. + /// This accessor, to allow chaining. + IMockForIKeywordEdgeCases TransitionTo(string scenario); + + /// + /// Triggers events declared on IKeywordEdgeCases so that currently subscribed handlers are invoked. + /// + /// + /// One entry per event is generated; the signature matches the event's delegate. Only handlers that are subscribed at the moment of the Raise call are invoked - handlers subscribed later (or already removed) are skipped. + /// + IMockRaiseOnIKeywordEdgeCases Raise { get; } + + /// + /// Asserts how often, and in which order, members of the mock of IKeywordEdgeCases were invoked. + /// + /// + /// Each call to a member here returns a VerificationResult that you terminate with a count assertion: Never(), Once(), Twice(), Exactly(n), AtLeast(n)/AtLeastOnce()/AtLeastTwice(), AtMost(n)/AtMostOnce()/AtMostTwice(), Between(min, max) or Times(predicate).
+ /// Use Within(TimeSpan) / WithCancellation(CancellationToken) before the terminator to wait for expected interactions that happen on background threads.
+ /// Chain Then(...) to assert an ordered sequence of calls. A failing assertion throws a MockVerificationException. + ///
+ IMockVerifyForIKeywordEdgeCases Verify { get; } + + /// + /// Verifies how often a specific method setup was matched by actual invocations. + /// + /// + /// Useful when you want to verify "this particular setup was hit N times" without re-stating the matchers. Chain the usual count terminators (Once(), AtLeastOnce(), Exactly(n), ...) on the returned result. + /// + /// The setup previously registered through Setup (typically returned from a Returns(...)/Throws(...) call). + /// A VerificationResult that counts invocations matching the given setup. + global::Mockolate.Verify.VerificationResult VerifySetup(global::Mockolate.Setup.IMethodSetup setup); + + /// + /// Checks whether every recorded interaction on this mock has been observed by at least one Verify call. + /// + /// + /// Useful in test teardown to catch unexpected interactions ("strict verification"): if any recorded call has never been matched by a verification, the method returns . + /// + /// if every recorded interaction was verified at least once; otherwise . + bool VerifyThatAllInteractionsAreVerified(); + + /// + /// Checks whether every registered setup on this mock was matched by at least one actual invocation. + /// + /// + /// Useful to catch unused setups that silently rot as the test subject evolves. + /// + /// if every registered setup was used at least once; otherwise . + bool VerifyThatAllSetupsAreUsed(); + + /// + /// Removes every recorded interaction from this mock while keeping all registered setups intact. + /// + /// + /// Handy when a single test exercises multiple logical phases and you only want to verify the interactions of the latest phase. + /// + void ClearAllInteractions(); + + /// + /// Creates a monitor whose Verify surface is scoped to interactions produced between monitor.Run() and the disposal of its IDisposable scope. + /// + /// + /// The underlying mock keeps recording all interactions as usual - only the monitor's Verify view is scoped. Useful to verify only the interactions produced by a specific block of test code without resetting the mock. + /// + /// A MockMonitor<T> that exposes Verify over the monitored interactions and a Run() method that opens the recording scope. + global::Mockolate.Monitor.MockMonitor Monitor(); + } + + /// + /// Scoped access to setups for a scenario on the mock of IKeywordEdgeCases. + /// + internal interface IMockInScenarioForIKeywordEdgeCases + { + /// + /// Set up the mock of IKeywordEdgeCases within the scenario scope. + /// + IMockSetupForIKeywordEdgeCases Setup { get; } + } + + /// + /// Set up the mock of IKeywordEdgeCases. + /// + internal interface IMockSetupForIKeywordEdgeCases : global::Mockolate.Setup.IMockSetup + { + /// + /// Setup for the int property @class. + /// + global::Mockolate.Setup.IPropertyGetterOnlySetup @class { get; } + + /// + /// Setup for the event @event. + /// + global::Mockolate.Setup.EventSetup @event { get; } + + /// + /// Setup for the string indexer this[int, string] + /// + /// + /// 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::Mockolate.Setup.IndexerSetup this[global::Mockolate.Parameters.IParameter? parameter1, global::Mockolate.Parameters.IParameter? parameter2] { get; } + + /// + /// Setup for the string indexer this[int, string] + /// + /// + /// 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.IndexerSetup this[int parameter1, global::Mockolate.Parameters.IParameter? parameter2] { get; } + + /// + /// Setup for the string indexer this[int, string] + /// + /// + /// 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.IndexerSetup this[global::Mockolate.Parameters.IParameter? parameter1, string parameter2] { get; } + + /// + /// Setup for the string indexer this[int, string] + /// + /// + /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IndexerSetup this[int parameter1, string parameter2] { get; } + + /// + /// Setup for the method @return(). + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IReturnMethodSetup @return(); + + /// + /// Setup for the method @if(int) 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.IVoidMethodSetupWithCallback @if(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Setup for the method @if(int) with the given . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer @if(global::Mockolate.ParameterArg? @params); + + /// + /// Setup for the method @if(int) with the given . + /// + /// + /// This overload accepts a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer @if(global::System.Func @params, [global::System.Runtime.CompilerServices.CallerArgumentExpression("params")] string @paramsExpression = ""); + + /// + /// Setup for the method @void<@class>(int) 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 @void<@class>(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Setup for the method @void<@class>(int) 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 @void<@class>(global::Mockolate.Parameters.IParameter? @ref); + + /// + /// Setup for the method @void<@class>(int) with the given . + /// + /// + /// 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); + + } + + /// + /// Raise events on the mock of IKeywordEdgeCases. + /// + internal interface IMockRaiseOnIKeywordEdgeCases + { + /// + /// Raise the @event event. + /// + void @event(object? sender, global::System.EventArgs e); + + /// + /// Raise the @event event. + /// + void @event(global::Mockolate.Parameters.IDefaultEventParameters parameters); + + } + + /// + /// Verify interactions with the mock of IKeywordEdgeCases. + /// + internal interface IMockVerifyForIKeywordEdgeCases : global::Mockolate.Verify.IMockVerify + { + /// + /// Verify interactions with the int property @class. + /// + global::Mockolate.Verify.VerificationPropertyGetterResult @class { get; } + + /// + /// Verify interactions with the string indexer this[int, string]. + /// + /// + /// 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::Mockolate.Verify.VerificationIndexerResult this[global::Mockolate.Parameters.IParameter? @params, global::Mockolate.Parameters.IParameter? @void] { get; } + + /// + /// Verify interactions with the string indexer this[int, string]. + /// + /// + /// 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.VerificationIndexerResult this[int @params, global::Mockolate.Parameters.IParameter? @void] { get; } + + /// + /// Verify interactions with the string indexer this[int, string]. + /// + /// + /// 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.VerificationIndexerResult this[global::Mockolate.Parameters.IParameter? @params, string @void] { get; } + + /// + /// Verify interactions with the string indexer this[int, string]. + /// + /// + /// 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(0)] + global::Mockolate.Verify.VerificationIndexerResult this[int @params, string @void] { get; } + + /// + /// Verify invocations for the method @return(). + /// + global::Mockolate.Verify.VerificationResult.IgnoreParameters @return(); + + /// + /// Verify invocations for the method @if(int) 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 @if(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Verify invocations for the method @if(int) with the given . + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters @if(global::Mockolate.ParameterArg? @params); + + /// + /// Verify invocations for the method @if(int) with the given . + /// + /// + /// This overload accepts a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters @if(global::System.Func @params, [global::System.Runtime.CompilerServices.CallerArgumentExpression("params")] string @paramsExpression = ""); + + /// + /// Verify invocations for the method @void<@class>(int) 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 @void<@class>(global::Mockolate.Parameters.IParameters parameters); + + /// + /// Verify invocations for the method @void<@class>(int) 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 @void<@class>(global::Mockolate.Parameters.IParameter? @ref); + + /// + /// Verify invocations for the method @void<@class>(int) 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::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Verify.VerificationResult.IgnoreParameters @void<@class>(int @ref); + + /// + /// Verify subscriptions on the @event event of @event. + /// + global::Mockolate.Verify.VerificationEventResult @event { get; } + + } +} +/// +/// Mock extensions for IKeywordEdgeCases. +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal static partial class MockExtensionsForIKeywordEdgeCases +{ + /// + extension(global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases mock) + { + /// + /// Gets the mock accessor for IKeywordEdgeCases - the entry point for configuring setups, verifying interactions and raising events. + /// + /// + /// The accessor is the bridge between the strongly-typed instance of IKeywordEdgeCases returned by CreateMock(...) and the underlying mock registry where setups and recorded interactions live.
+ /// Through it you can:
+ ///
+ /// Setup - configure how members respond when invoked (Returns, Throws, Do, InitializeWith, ...).
+ /// Verify - assert how often (and in which order) members were invoked.
+ /// Raise - trigger events declared on the mocked type.
+ /// InScenario / TransitionTo - scope setups and behavior to a named scenario and switch between scenarios.
+ /// Monitor, ClearAllInteractions, VerifyThatAllInteractionsAreVerified, VerifyThatAllSetupsAreUsed - manage recorded interactions.
+ /// VerifySetup - verify how often a specific setup matched.
+ ///
+ ///
+ /// The instance is not a Mockolate-generated mock of IKeywordEdgeCases. + public global::Mockolate.Mock.IMockForIKeywordEdgeCases Mock + { + get + { + if (mock is global::Mockolate.Mock.IMockForIKeywordEdgeCases mockInterface) + { + return mockInterface; + } + throw new global::Mockolate.Exceptions.MockException("The subject is no mock."); + } + } + + /// + /// Creates a new mock of IKeywordEdgeCases with the default MockBehavior. + /// + /// + /// The returned instance is a strongly-typed mock generated at compile time - it implements IKeywordEdgeCases and exposes the Mockolate surface through .Mock:
+ ///
+ /// .Mock.Setup configures how members respond (Returns, Throws, Do, InitializeWith, sequences, callbacks).
+ /// .Mock.Verify asserts how often and in which order members were invoked.
+ /// .Mock.Raise triggers events declared on the mocked type.
+ ///

+ /// With the default behavior, un-configured members return default values (empty collections / strings, completed tasks, otherwise) and base-class implementations are invoked for class mocks. Use one of the overloads that accepts a MockBehavior to customize this (for example to make un-configured calls throw or to skip the base class).
+ /// Overloads allow you to additionally pass constructor parameters (for class mocks), apply an initial setup callback before the instance is returned, or combine both. + ///
+ /// A new mock instance of IKeywordEdgeCases. + public static global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases CreateMock() + => CreateMock(null, null, (object?[]?)null); + + /// + /// Creates a new mock of IKeywordEdgeCases with the default MockBehavior, applying the given immediately. + /// + /// + /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. + /// + /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. + /// A new mock instance of IKeywordEdgeCases. + public static global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases CreateMock(global::System.Action setup) + => CreateMock(null, setup, (object?[]?)null); + + /// + /// Creates a new mock of IKeywordEdgeCases with the given . + /// + /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. + /// A new mock instance of IKeywordEdgeCases. + public static global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases CreateMock(global::Mockolate.MockBehavior mockBehavior) + => CreateMock(mockBehavior, null, (object?[]?)null); + + /// + /// Creates a new mock of IKeywordEdgeCases with the given , applying the given immediately. + /// + /// + /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. + /// + /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. + /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. + /// A new mock instance of IKeywordEdgeCases. + public static global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases CreateMock(global::Mockolate.MockBehavior mockBehavior, global::System.Action setup) + => CreateMock(mockBehavior, setup, (object?[]?)null); + + /// + /// Creates a new mock of IKeywordEdgeCases using the given , applying the given immediately, using the given . + /// + /// + /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. + /// + /// Controls how the mock responds when members are invoked without a matching setup, or for MockBehavior.Default. + /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned, or to skip. + /// Values forwarded to a matching base-class constructor, or to use the parameterless constructor. + /// A new mock instance of IKeywordEdgeCases. + private static global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases CreateMock(global::Mockolate.MockBehavior? mockBehavior, global::System.Action? setup, object?[]? constructorParameters) + { + if (mockBehavior is not null) + { + IMockBehaviorAccess mockBehaviorAccess = (global::Mockolate.IMockBehaviorAccess)mockBehavior; + if (mockBehaviorAccess.TryGet?>(out var additionalSetup)) + { + if (setup is null) + { + setup = additionalSetup; + } + else + { + var originalSetup = setup; + setup = s => { additionalSetup.Invoke(s); originalSetup.Invoke(s); }; + } + } + } + + mockBehavior ??= global::Mockolate.MockBehavior.Default; + global::Mockolate.MockRegistry mockRegistry = new global::Mockolate.MockRegistry(mockBehavior, global::Mockolate.Mock.IKeywordEdgeCases.MemberCount, constructorParameters); + return CreateMockInstance(mockRegistry, constructorParameters, setup); + } + + private static global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases CreateMockInstance(global::Mockolate.MockRegistry mockRegistry, object?[]? constructorParameters, global::System.Action? setup) + { + var value = new global::Mockolate.Mock.IKeywordEdgeCases(mockRegistry); + if (setup is not null) + { + setup.Invoke(value); + } + return value; + } + /// + /// Creates a mock that wraps the given . + /// + /// + /// Public members on the mock forward to unless overridden by a setup; protected members still go through the base-class implementation. All forwarded interactions are recorded and can be verified the same as on a plain mock. + /// + /// The real object whose calls should be forwarded. Must not be . + /// A new mock of IKeywordEdgeCases that delegates to . + public global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases Wrapping(global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases instance) + { + if (mock is global::Mockolate.IMock mockInterface) + { + global::Mockolate.MockRegistry wrappingRegistry = new global::Mockolate.MockRegistry(mockInterface.MockRegistry, instance); + wrappingRegistry = new global::Mockolate.MockRegistry(wrappingRegistry, global::Mockolate.Mock.IKeywordEdgeCases.CreateFastInteractions(wrappingRegistry.Behavior)); + return CreateMockInstance(wrappingRegistry, mockInterface.MockRegistry.ConstructorParameters, null); + } + throw new global::Mockolate.Exceptions.MockException("The subject is no mock."); + } + + } + + /// + extension(global::Mockolate.MockBehavior behavior) + { + /// + /// Initializes mocks of type with the given . + /// + /// + /// The is applied to the mock before the constructor is executed. Calling Initialize again overlays additional setups on top of any previously registered ones. + /// + /// The mockable type derived from IKeywordEdgeCases that this setup should apply to. + /// Callback invoked when a new mock of is created. + /// A new MockBehavior with the registered initializer. The original instance is unchanged. + public global::Mockolate.MockBehavior Initialize(global::System.Action setup) + where T : global::Mockolate.Tests.GeneratorCoverage.IKeywordEdgeCases + { + var behaviorAccess = (global::Mockolate.IMockBehaviorAccess)behavior; + return behaviorAccess.Set(setup); + } + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch + { + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); + } +} + +#nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.g.cs new file mode 100644 index 00000000..3ce28555 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.g.cs @@ -0,0 +1,133 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +namespace Mockolate; + +#nullable enable +/// +/// Create new mocks by calling the static T.CreateMock() method on your type T. +/// +/// +/// You can also provide a MockBehavior parameter to customize how the mock should behave in certain scenarios.
+/// If your type is a class without a default constructor, you can provide constructor parameters by passing an object?[]? to the corresponding CreateMock(...) overload. +///
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal static partial class Mock +{ + /// + /// This interface should never be used. If it is, this is an indication that the Mockolate source generator did not run correctly or that the used type is not mockable. + /// + /// + /// The source generator creates overloads with correct return values. + /// + internal interface IMockGenerationDidNotRun {} + + /// + /// Create a new mock of with the default MockBehavior. + /// + /// Type to mock, which can be an interface or a class. + /// + /// Any interface type can be used for mocking, but for classes, only abstract and virtual members can be mocked. + /// + extension(T _) + { + /// + /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when + /// is not mockable. Calling it always throws a MockException. + /// + /// Ignored; reserved for the generator-emitted overload. + /// This method never returns - it always throws. + /// + /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. + /// If you see this fallback resolved in your IDE, the generator did not run for ; + /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. + /// + /// Always thrown: the source generator did not run or is not mockable. + public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior = null) + { + throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); + } + + /// + /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when + /// is not mockable. Calling it always throws a MockException. + /// + /// Ignored; reserved for the generator-emitted overload. + /// Ignored; reserved for the generator-emitted overload. + /// This method never returns - it always throws. + /// + /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. + /// If you see this fallback resolved in your IDE, the generator did not run for ; + /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. + /// + /// Always thrown: the source generator did not run or is not mockable. + public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior, object?[]? constructorParameters) + { + throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); + } + + /// + /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when + /// is not mockable. Calling it always throws a MockException. + /// + /// Ignored; reserved for the generator-emitted overload. + /// This method never returns - it always throws. + /// + /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. + /// If you see this fallback resolved in your IDE, the generator did not run for ; + /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. + /// + /// Always thrown: the source generator did not run or is not mockable. + public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(object?[]? constructorParameters) + { + throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); + } + } + + extension(global::Mockolate.Mock.IMockGenerationDidNotRun _) + { + /// + /// Fallback Implementing that is only resolved when the Mockolate source generator did not run or when + /// is not mockable. Calling it always throws a MockException. + /// + /// Additional interface the mock should implement. + /// This method never returns - it always throws. + /// + /// The source generator emits a concrete Implementing overload per mockable type with the same shape. + /// If you see this fallback resolved in your IDE, the generator did not run for ; + /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. + /// + /// Always thrown: the source generator did not run or is not mockable. + public global::Mockolate.Mock.IMockGenerationDidNotRun Implementing() where TInterface : class + { + throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(TInterface)}' is not mockable or the source generator did not run correctly."); + } + } + + /// + /// Adapts an IParameter (non-generic) to + /// IParameterMatch<T> so that covariant parameter + /// references (e.g. an IParameter<Derived> passed through an IParameter<Base> + /// slot) can still be invoked at setup/verify time. Only allocated when the direct + /// IParameterMatch<T> cast fails. + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch + { + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); + } +} +#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/MockBehaviorExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/MockBehaviorExtensions.g.cs new file mode 100644 index 00000000..888d2c2c --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/MockBehaviorExtensions.g.cs @@ -0,0 +1,285 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +namespace Mockolate; + +#nullable enable annotations + +/// +/// Extensions for MockBehavior. +/// +internal static partial class Mock +{ + private static readonly global::Mockolate.MockBehavior _default; + + static Mock() + { + _default = new global::Mockolate.MockBehavior(new DefaultValueGenerator()); + } + + extension(global::Mockolate.MockBehavior) + { + /// + /// The default MockBehavior - the starting point for configuring a mock. + /// + /// + /// Un-configured members return the generator-provided default value (empty strings/collections, completed + /// Tasks, otherwise), base-class + /// implementations run for class mocks, and every invocation is recorded for later verification. + /// + /// Chain SkippingBaseClass(), ThrowingWhenNotSetup(), SkippingInteractionRecording(), + /// WithDefaultValueFor<T>(...) or UseConstructorParametersFor<T>(...) to derive + /// a customized MockBehavior; because it is a , + /// each call returns a new instance and this shared default stays unchanged. + /// + public static global::Mockolate.MockBehavior Default => _default; + } + + /// + /// Defines a factory for creating default values for a specified type. + /// + public interface IDefaultValueFactory + { + /// + /// Determines whether the specified can be created by this factory. + /// + bool IsMatch(global::System.Type type); + + /// + /// Creates a new instance of the specified type. + /// + object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, object?[] parameters); + } + + /// + /// A IDefaultValueFactory that returns a specified for the given type + /// parameter . + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal class TypedDefaultValueFactory(T value) : IDefaultValueFactory + { + /// + public bool IsMatch(global::System.Type type) + => type == typeof(T); + + /// + public object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) + => value; + } + + /// + /// Provides default values for common types used in mocking scenarios. + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private class DefaultValueGenerator : IDefaultValueGenerator + { + private static readonly global::System.Collections.Concurrent.ConcurrentQueue _factories = new([ + new TypedDefaultValueFactory(""), + new CancellableTaskFactory(), + #if NET8_0_OR_GREATER + new CancellableValueTaskFactory(), + #endif + new TypedDefaultValueFactory(global::System.Threading.CancellationToken.None), + new TypedDefaultValueFactory(global::System.Array.Empty()), + ]); + + /// + public object? GenerateValue(global::System.Type type, params object?[] parameters) + { + if (TryGenerate(type, parameters, out object? value)) + { + return value; + } + + return null; + } + + /// + /// Registers a to provide default values for a specific type. + /// + public static void Register(IDefaultValueFactory defaultValueFactory) + => _factories.Enqueue(defaultValueFactory); + + /// + /// Tries to generate a default value for the specified type. + /// + protected virtual bool TryGenerate(global::System.Type type, object?[] parameters, out object? value) + { + IDefaultValueFactory? matchingFactory = global::System.Linq.Enumerable.FirstOrDefault(_factories, Predicate); + if (matchingFactory is not null) + { + value = matchingFactory.Create(type, this, parameters); + return true; + } + + value = null; + return false; + + bool Predicate(global::Mockolate.Mock.IDefaultValueFactory f) + => f.IsMatch(type); + } + + private static bool HasCanceledCancellationToken(object?[] parameters, out global::System.Threading.CancellationToken cancellationToken) + { + global::System.Threading.CancellationToken parameter = global::System.Linq.Enumerable.FirstOrDefault(global::System.Linq.Enumerable.OfType(parameters)); + if (parameter.IsCancellationRequested) + { + cancellationToken = parameter; + return true; + } + + cancellationToken = global::System.Threading.CancellationToken.None; + return false; + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class CancellableTaskFactory : IDefaultValueFactory + { + /// + public bool IsMatch(global::System.Type type) + => type == typeof(global::System.Threading.Tasks.Task); + + /// + public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) + { + if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) + { + return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); + } + + return global::System.Threading.Tasks.Task.CompletedTask; + } + } + #if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class CancellableValueTaskFactory : IDefaultValueFactory + { + /// + public bool IsMatch(global::System.Type type) + => type == typeof(global::System.Threading.Tasks.ValueTask); + + /// + public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) + { + if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) + { + return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); + } + + return global::System.Threading.Tasks.ValueTask.CompletedTask; + } + } + #endif + } +} + +/// +/// Extensions on IDefaultValueGenerator +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal static class DefaultValueGeneratorExtensions +{ + /// + /// Adds a generic Generate method for specific types. + /// + extension(IDefaultValueGenerator generator) + { + /// + /// Generates a Task of , with + /// the for context. + /// + public global::System.Threading.Tasks.Task Generate(global::System.Threading.Tasks.Task nullValue, T value, params object?[] parameters) + { + global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( + global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; + if (cancellationToken.IsCancellationRequested) + { + return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); + } + + return global::System.Threading.Tasks.Task.FromResult(value); + } + +#if NET8_0_OR_GREATER + /// + /// Generates a ValueTask of , with + /// the for context. + /// + public global::System.Threading.Tasks.ValueTask Generate(global::System.Threading.Tasks.ValueTask nullValue, T value, params object?[] parameters) + { + global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( + global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; + if (cancellationToken.IsCancellationRequested) + { + return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); + } + + return global::System.Threading.Tasks.ValueTask.FromResult(value); + } +#endif + + /// + /// Generates an empty enumerable of , with + /// the for context. + /// + public global::System.Collections.Generic.IEnumerable Generate(global::System.Collections.Generic.IEnumerable nullValue, params object?[] parameters) + => global::System.Array.Empty(); + + /// + /// Generates an empty enumerable of , with + /// the for context. + /// + public global::System.Collections.Generic.List Generate(global::System.Collections.Generic.List nullValue, params object?[] parameters) + => new global::System.Collections.Generic.List(); + + /// + /// Generates an empty array of , with + /// the for context. + /// + public T[] Generate(T[] nullValue, params object?[] parameters) + => global::System.Array.Empty(); + + /// + /// Generates an empty two-dimensional array of , with + /// the for context. + /// + public T[,] Generate(T[,] nullValue, params object?[] parameters) + => new T[,] { }; + + /// + /// Generates an empty three-dimensional array of , with + /// the for context. + /// + public T[,,] Generate(T[,,] nullValue, params object?[] parameters) + => new T[,,] { }; + + /// + /// Generates an empty four-dimensional array of , with + /// the for context. + /// + public T[,,,] Generate(T[,,,] nullValue, params object?[] parameters) + => new T[,,,] { }; + + /// + /// Generates a default value of type , with + /// the for context. + /// + public T Generate(T nullValue, params object?[] parameters) + { + if (generator.GenerateValue(typeof(T), parameters) is T value) + { + return value; + } + + return nullValue; + } + } +} + +#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/ParameterArg.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/ParameterArg.g.cs new file mode 100644 index 00000000..50826154 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/ParameterArg.g.cs @@ -0,0 +1,133 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +#nullable enable + +namespace Mockolate +{ + /// + /// A setup or verify argument that is either an It matcher + /// (IParameter<T>) or a literal value of type . + /// + /// + /// Both case types convert implicitly, so Setup.Method(42) and Setup.Method(It.IsAny<int>()) + /// bind to the same overload. A instance stands for the literal default(T). + /// + [global::System.Runtime.CompilerServices.Union] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal readonly struct ParameterArg + { + private const byte MatcherTag = 1; + private const byte LiteralTag = 2; + + private readonly global::Mockolate.Parameters.IParameter? _matcher; + private readonly T? _literal; + private readonly byte _tag; + + /// + /// Creates the matcher case. + /// + public ParameterArg(global::Mockolate.Parameters.IParameter matcher) + { + _matcher = matcher; + _literal = default; + _tag = MatcherTag; + } + + /// + /// Creates the literal value case. + /// + public ParameterArg(T? literal) + { + _matcher = null; + _literal = literal; + _tag = LiteralTag; + } + + /// + /// The contained matcher or literal value, boxed. Part of the union pattern; the generated mocks use the + /// typed accessors instead. + /// + public object? Value => _tag switch + { + MatcherTag => _matcher, + LiteralTag => _literal, + _ => null, + }; + + /// + /// unless this is the instance. + /// + public bool HasValue => _tag != 0; + + /// + /// when the argument is a literal value (including the instance). + /// + public bool IsLiteral => _tag != MatcherTag; + + /// + /// The literal value; default(T) for the matcher case and the instance. + /// + public T? Literal => _literal; + + /// + /// Gets the matcher, when this is the matcher case. + /// + public bool TryGetValue(out global::Mockolate.Parameters.IParameter? matcher) + { + matcher = _matcher; + return _tag == MatcherTag; + } + + /// + /// Gets the literal value, when this is the literal case. + /// + public bool TryGetValue(out T? literal) + { + literal = _literal; + return _tag == LiteralTag; + } + + /// + /// The IParameterMatch<T> for this argument: the matcher itself, + /// or an equality match for the literal value. + /// + public global::Mockolate.Parameters.IParameterMatch ToParameterMatch() + { + if (_tag != MatcherTag) + { + return (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(_literal!); + } + + if (_matcher is null) + { + return (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsNull("null"); + } + + return _matcher is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantAdapter(_matcher); + } + + /// + public override string ToString() => _tag switch + { + MatcherTag => _matcher?.ToString() ?? "null", + _ => _literal?.ToString() ?? "null", + }; + + private sealed class CovariantAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch + { + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + } + } +} +#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotTests.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotTests.cs index b6297d62..2c88b4d4 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotTests.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotTests.cs @@ -3,6 +3,7 @@ using System.Net; using System.Net.Http; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; namespace Mockolate.SourceGenerators.Tests.Snapshot; @@ -100,6 +101,41 @@ await That(SnapshotStorage.StripConfigSpecificLines(generated[fileName])) IStaticAbstractMembers sut = IStaticAbstractMembers.CreateMock(); """, []), + new( + "ComprehensiveDelegate_CanBeCreated_Unions", + ["ComprehensiveDelegate.cs",], + """ + ComprehensiveDelegate sut = ComprehensiveDelegate.CreateMock(); + """, + [], + UnionMode: true), + new( + "ComprehensiveInterface_CanBeCreated_Unions", + [ + "ComprehensiveDelegate.cs", "IComprehensiveInterface.cs", + "MyBase.cs", "MyEnum.cs", "MyEventArgs.cs", "MyStruct.cs", + ], + """ + IComprehensiveInterface sut = IComprehensiveInterface.CreateMock(); + """, + [], + UnionMode: true), + new( + "HttpClient_CanBeCreated_Unions", + [], + """ + System.Net.Http.HttpClient sut = System.Net.Http.HttpClient.CreateMock(); + """, + [typeof(HttpClient), typeof(HttpStatusCode),], + UnionMode: true), + new( + "KeywordEdgeCases_CanBeCreated_Unions", + ["IKeywordEdgeCases.cs",], + """ + IKeywordEdgeCases sut = IKeywordEdgeCases.CreateMock(); + """, + [], + UnionMode: true), ]; public static TheoryData ScenarioNames @@ -138,10 +174,24 @@ public static void Main(string[] args) """; sources.Add(program); + // Classic scenarios are pinned to C# 14 so that they keep describing the classic overload set once the + // compiler ships C# 15 and union support is detected automatically. Union scenarios opt in through the + // MockolateUnionParameters property, because the pinned test Roslyn predates C# 15 (see UnionParameterArgTests). + if (scenario.UnionMode) + { + return Generator.Run( + sources.ToArray(), + ["NET9_0_OR_GREATER", "NET10_0_OR_GREATER", "NET11_0_OR_GREATER",], + LanguageVersion.Preview, + new Dictionary { ["build_property.MockolateUnionParameters"] = "true", }, + scenario.AssemblyTypes); + } + return Generator.Run( sources.ToArray(), - DocumentationMode.Parse, ["NET9_0_OR_GREATER", "NET10_0_OR_GREATER",], + LanguageVersion.CSharp14, + null, scenario.AssemblyTypes); } diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/SnapshotScenario.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/SnapshotScenario.cs index 72952b58..c577a5e2 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/SnapshotScenario.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/SnapshotScenario.cs @@ -4,4 +4,5 @@ internal sealed record SnapshotScenario( string Name, string[] CoverageFiles, string MainBody, - Type[] AssemblyTypes); \ No newline at end of file + Type[] AssemblyTypes, + bool UnionMode = false); diff --git a/Tests/Mockolate.SourceGenerators.Tests/TestHelpers/Generator.cs b/Tests/Mockolate.SourceGenerators.Tests/TestHelpers/Generator.cs index b4fa523c..e3582c13 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/TestHelpers/Generator.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/TestHelpers/Generator.cs @@ -64,6 +64,11 @@ public static GeneratorResult Run([StringSyntax("c#-test")] string source, Langu IReadOnlyDictionary? globalOptions) => RunCore([source,], DocumentationMode.Parse, [], [], [], languageVersion, globalOptions); + public static GeneratorResult Run(string[] sources, string[] preprocessorSymbols, LanguageVersion languageVersion, + IReadOnlyDictionary? globalOptions, params Type[] assemblyTypes) + => RunCore(sources, DocumentationMode.Parse, preprocessorSymbols, [], assemblyTypes, languageVersion, + globalOptions); + private static GeneratorResult RunCore(string[] sources, DocumentationMode documentationMode, string[] preprocessorSymbols, MetadataReference[] externalReferences, Type[] assemblyTypes, LanguageVersion languageVersion = LanguageVersion.Latest, diff --git a/Tests/Mockolate.SourceGenerators.Tests/UnionOverloadTests.cs b/Tests/Mockolate.SourceGenerators.Tests/UnionOverloadTests.cs new file mode 100644 index 00000000..44a1905b --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/UnionOverloadTests.cs @@ -0,0 +1,210 @@ +using System.Collections.Generic; +using System.Linq; +using Microsoft.CodeAnalysis.CSharp; + +namespace Mockolate.SourceGenerators.Tests; + +// The generated code is compiled against the pinned minimum Roslyn, which predates unions; these tests therefore +// check the emitted overload shapes, while the call-site behaviour lives in Mockolate.Tests on net11.0. +public sealed class UnionOverloadTests +{ + private const string MockFile = "Mock.IMyService.g.cs"; + + private static readonly Dictionary UnionsEnabled = new() + { + ["build_property.MockolateUnionParameters"] = "true", + }; + + private const string Source = """ + #nullable enable + using System; + using Mockolate; + + namespace MyCode + { + public class Program + { + public static void Main(string[] args) + { + _ = IMyService.CreateMock(); + } + } + + public interface IMyService + { + bool Plain(int value, string text); + void Register(Func callback); + int Five(int a, int b, int c, int d, int e); + void WithParams(int first, params int[] rest); + T Generic(T value); + void WithRef(ref int value, string text); + void WithDefaults(int i = 5, string? s = null); + bool TakeObject(object? obj); + int Overloaded(int value); + int Overloaded(string? value); + int Mixed(int value); + int Mixed(T value); + } + } + """; + + private static GeneratorResult RunInUnionMode() + => Generator.Run([Source,], ["NET11_0_OR_GREATER",], LanguageVersion.Preview, UnionsEnabled); + + private static string GenerateMockInUnionMode() + => RunInUnionMode().Sources[MockFile].Replace("\r\n", "\n"); + + [Fact] + public async Task GeneratedCode_ShouldCompile() + { + GeneratorResult result = RunInUnionMode(); + + await That(result.Diagnostics).IsEmpty(); + } + + [Fact] + public async Task TwoParameters_ShouldEmitOneOverloadPerUnionOrPredicateAssignment() + { + string mock = GenerateMockInUnionMode(); + + await That(mock) + .Contains( + "[global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)]\n\t\tglobal::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Plain(global::Mockolate.ParameterArg? value, global::Mockolate.ParameterArg? text);") + .And + .Contains( + "[global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)]\n\t\tglobal::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Plain(global::System.Func value, global::Mockolate.ParameterArg? text, [global::System.Runtime.CompilerServices.CallerArgumentExpression(\"value\")] string valueExpression = \"\");") + .And + .Contains( + "[global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)]\n\t\tglobal::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Plain(global::Mockolate.ParameterArg? value, global::System.Func text, [global::System.Runtime.CompilerServices.CallerArgumentExpression(\"text\")] string textExpression = \"\");") + .And + .Contains( + "[global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)]\n\t\tglobal::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Plain(global::System.Func value, global::System.Func text, [global::System.Runtime.CompilerServices.CallerArgumentExpression(\"value\")] string valueExpression = \"\", [global::System.Runtime.CompilerServices.CallerArgumentExpression(\"text\")] string textExpression = \"\");") + .And + .Contains("Plain(global::Mockolate.Parameters.IParameters parameters);").And + .DoesNotContain("Plain(global::Mockolate.Parameters.IParameter? value").And + .DoesNotContain("IReturnMethodSetupParameterIgnorer Plain(int value, string text)"); + } + + [Fact] + public async Task SetupImplementation_ShouldUseLiteralFastPathWhenAllArgumentsAreLiterals() + { + string mock = GenerateMockInUnionMode(); + + await That(mock) + .Contains("global::Mockolate.ParameterArg valueArg = value ?? default;").And + .Contains("if (valueArg.IsLiteral && textArg.IsLiteral)").And + .Contains(".WithLiteralValues(MockRegistry, \"global::MyCode.IMyService.Plain\", valueArg.Literal!, textArg.Literal!);").And + .Contains(".WithParameterCollection(MockRegistry, \"global::MyCode.IMyService.Plain\", valueArg.ToParameterMatch(), textArg.ToParameterMatch());").And + .Contains("(global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(value, valueExpression)"); + } + + [Fact] + public async Task Verify_ShouldMirrorTheSetupOverloads() + { + string mock = GenerateMockInUnionMode(); + + await That(mock) + .Contains("global::Mockolate.Verify.VerificationResult.IgnoreParameters Plain(global::Mockolate.ParameterArg? value, global::Mockolate.ParameterArg? text);").And + .Contains("global::Mockolate.Verify.VerificationResult.IgnoreParameters Plain(global::System.Func value, global::Mockolate.ParameterArg? text, [global::System.Runtime.CompilerServices.CallerArgumentExpression(\"value\")] string valueExpression = \"\");").And + .Contains("() => $\"Plain({valueExpression}, {textArg})\""); + } + + [Fact] + public async Task DelegateTypedParameter_ShouldOfferTheRawDelegateInsteadOfAPredicate() + { + string mock = GenerateMockInUnionMode(); + + await That(mock) + .Contains("Register(global::Mockolate.ParameterArg>? callback);").And + .Contains("Register(global::System.Func callback);").And + .DoesNotContain("Register(global::System.Func, bool>"); + } + + [Fact] + public async Task AboveFourParameters_ShouldEmitOnlyTheAllUnionOverload() + { + string mock = GenerateMockInUnionMode(); + + await That(mock) + .Contains("Five(global::Mockolate.ParameterArg? a, global::Mockolate.ParameterArg? b, global::Mockolate.ParameterArg? c, global::Mockolate.ParameterArg? d, global::Mockolate.ParameterArg? e);").And + .DoesNotContain("Five(global::System.Func").And + .DoesNotContain("Five(global::Mockolate.Parameters.IParameter? a"); + } + + [Fact] + public async Task ParamsGenericAndOverloadedMethods_ShouldKeepTheClassicOverloads() + { + string mock = GenerateMockInUnionMode(); + + await That(mock) + .Contains("WithParams(global::Mockolate.Parameters.IParameter? first, global::Mockolate.Parameters.IParameter? rest);").And + .Contains("WithParams(int first, params int[] rest);").And + .DoesNotContain("WithParams(global::Mockolate.ParameterArg?").And + .Contains("Generic(global::Mockolate.Parameters.IParameter? value);").And + .DoesNotContain("Generic(global::Mockolate.ParameterArg?").And + .Contains("Overloaded(global::Mockolate.Parameters.IParameter? value);").And + .Contains("Overloaded(int value);").And + .Contains("Overloaded(global::Mockolate.Parameters.IParameter? value);").And + .Contains("Overloaded(string? value);").And + .DoesNotContain("Overloaded(global::Mockolate.ParameterArg<").And + .Contains("Mixed(global::Mockolate.Parameters.IParameter? value);").And + .Contains("Mixed(int value);").And + .DoesNotContain("Mixed(global::Mockolate.ParameterArg<"); + } + + [Fact] + public async Task IParametersOverload_ShouldKeepItsPriorityAboveTheUnionOverloads() + { + string mock = GenerateMockInUnionMode(); + + await That(mock) + .Contains( + "[global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue - 1)]\n\t\tglobal::Mockolate.Setup.IReturnMethodSetupWithCallback TakeObject(global::Mockolate.Parameters.IParameters parameters);"); + } + + [Fact] + public async Task RefParameter_ShouldStayAMatcherSlot() + { + string mock = GenerateMockInUnionMode(); + + await That(mock) + .Contains("WithRef(global::Mockolate.Parameters.IRefParameter value, global::Mockolate.ParameterArg? text);").And + .Contains("WithRef(global::Mockolate.Parameters.IRefParameter value, global::System.Func text, [global::System.Runtime.CompilerServices.CallerArgumentExpression(\"text\")] string textExpression = \"\");"); + } + + [Fact] + public async Task OptionalParameters_ShouldFallBackToTheDeclaredDefault() + { + string mock = GenerateMockInUnionMode(); + + await That(mock) + .Contains("WithDefaults(global::Mockolate.ParameterArg? i = null, global::Mockolate.ParameterArg? s = null);").And + .Contains("global::Mockolate.ParameterArg iArg = i ?? new global::Mockolate.ParameterArg((int)(5));").And + .Contains("global::Mockolate.ParameterArg sArg = s ?? new global::Mockolate.ParameterArg((string?)(null));").And + .Contains("global::Mockolate.ParameterArg valueArg = value ?? default;"); + } + + [Fact] + public async Task ObjectParameter_ShouldNotOutrankTheIParametersOverload() + { + string mock = GenerateMockInUnionMode(); + + await That(mock) + .Contains( + "[global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)]\n\t\tglobal::Mockolate.Setup.IReturnMethodSetupParameterIgnorer TakeObject(global::Mockolate.ParameterArg? obj);") + ; + } + + [Fact] + public async Task WithoutUnionSupport_ShouldEmitTheClassicOverloads() + { + GeneratorResult result = Generator.Run([Source,], [], LanguageVersion.CSharp14, null); + string mock = result.Sources[MockFile]; + + await That(mock) + .Contains("Plain(global::Mockolate.Parameters.IParameter? value, global::Mockolate.Parameters.IParameter? text);").And + .Contains("Plain(int value, string text);").And + .DoesNotContain("ParameterArg"); + await That(result.Sources.Keys).DoesNotContain("ParameterArg.g.cs"); + } +} diff --git a/Tests/Mockolate.SourceGenerators.Tests/UnionParameterArgTests.cs b/Tests/Mockolate.SourceGenerators.Tests/UnionParameterArgTests.cs index 0b5cdb92..28e00ebc 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/UnionParameterArgTests.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/UnionParameterArgTests.cs @@ -96,7 +96,7 @@ public async Task WhenTheFrameworkDeclaresUnionAttribute_ShouldNotEmitThePolyfil [InlineData(false)] public async Task ParameterArgSource_ShouldContainThePolyfillOnlyWhenRequested(bool emitPolyfill) { - string source = Sources.Sources.ParameterArg(emitPolyfill); + string source = Sources.Sources.ParameterArg(emitPolyfill, false, false); await That(source.Contains(PolyfillDeclaration)).IsEqualTo(emitPolyfill); await That(source).Contains("internal readonly struct ParameterArg"); diff --git a/Tests/Mockolate.Tests/UnionSetupTests.cs b/Tests/Mockolate.Tests/UnionSetupTests.cs new file mode 100644 index 00000000..6586ae4a --- /dev/null +++ b/Tests/Mockolate.Tests/UnionSetupTests.cs @@ -0,0 +1,268 @@ +#if NET11_0_OR_GREATER +using Mockolate.Exceptions; +using Mockolate.Verify; + +namespace Mockolate.Tests; + +// On this target the generator emits the union-typed setup and verify overloads (C# preview with +// MockolateUnionParameters enabled): one ParameterArg? or Func slot per parameter. +public sealed class UnionSetupTests +{ + [Fact] + public async Task Setup_WithPredicate_ShouldMatchOnlyWhenThePredicateHolds() + { + IUnionService sut = IUnionService.CreateMock(); + sut.Mock.Setup.Compute(x => x > 0, "a").Returns(1); + + int positive = sut.Compute(5, "a"); + int negative = sut.Compute(-1, "a"); + + await That(positive).IsEqualTo(1); + await That(negative).IsEqualTo(0); + } + + [Fact] + public async Task Setup_WithLiteralAndMatcher_ShouldBothBind() + { + IUnionService sut = IUnionService.CreateMock(); + sut.Mock.Setup.Compute(5, It.IsAny()).Returns(2); + + int matching = sut.Compute(5, "z"); + int other = sut.Compute(6, "z"); + + await That(matching).IsEqualTo(2); + await That(other).IsEqualTo(0); + } + + [Fact] + public async Task Setup_WithNull_ShouldMatchTheNullLiteral() + { + IUnionService sut = IUnionService.CreateMock(); + sut.Mock.Setup.Describe(null).Returns("none"); + + string forNull = sut.Describe(null); + string forValue = sut.Describe("x"); + + await That(forNull).IsEqualTo("none"); + await That(forValue).IsNotEqualTo("none"); + } + + [Fact] + public async Task Setup_WithDefault_ShouldMatchTheDefaultValue() + { + IUnionService sut = IUnionService.CreateMock(); + sut.Mock.Setup.Compute(default, "a").Returns(3); + + int forZero = sut.Compute(0, "a"); + int forOne = sut.Compute(1, "a"); + + await That(forZero).IsEqualTo(3); + await That(forOne).IsEqualTo(0); + } + + [Fact] + public async Task Setup_WithDelegateTypedParameter_ShouldTreatLambdasAsValues() + { + IUnionService sut = IUnionService.CreateMock(); + Func callback = x => x > 0; + sut.Mock.Setup.Register(callback); + + sut.Register(callback); + + await That(sut.Mock.Verify.Register(callback)).Once(); + await That(sut.Mock.Verify.Register(x => x > 0)).Never(); + await That(sut.Mock.Verify.Register(It.IsAny>())).Once(); + } + + [Fact] + public async Task Setup_WithFourMixedArguments_ShouldMatchAll() + { + IUnionService sut = IUnionService.CreateMock(); + sut.Mock.Setup.Sum(1, It.IsAny(), x => x > 2, 4).Returns(10); + + int matching = sut.Sum(1, 2, 3, 4); + int failingPredicate = sut.Sum(1, 2, 2, 4); + int failingLiteral = sut.Sum(1, 2, 3, 5); + + await That(matching).IsEqualTo(10); + await That(failingPredicate).IsEqualTo(0); + await That(failingLiteral).IsEqualTo(0); + } + + [Fact] + public async Task Setup_AnyParameters_ShouldBeAvailableOnMatcherSetups() + { + IUnionService sut = IUnionService.CreateMock(); + sut.Mock.Setup.Compute(It.Is(1), "a").AnyParameters().Returns(7); + + int result = sut.Compute(9, "zz"); + + await That(result).IsEqualTo(7); + } + + [Fact] + public async Task Setup_OmittedOptionalParameter_ShouldUseTheDeclaredDefault() + { + IUnionService sut = IUnionService.CreateMock(); + sut.Mock.Setup.WithDefault().Returns(3); + + int forDefault = sut.WithDefault(); + int forOther = sut.WithDefault(6); + + await That(forDefault).IsEqualTo(3); + await That(forOther).IsEqualTo(0); + } + + [Fact] + public async Task Setup_ObjectParameter_ShouldTreatMatchersAsMatchers() + { + IUnionService sut = IUnionService.CreateMock(); + sut.Mock.Setup.Take(It.IsAny()).Returns(true); + + bool forString = sut.Take("x"); + bool forInt = sut.Take(1); + + await That(forString).IsTrue(); + await That(forInt).IsFalse(); + } + + [Fact] + public async Task Verify_WithLiteralMatcherAndPredicate_ShouldCount() + { + IUnionService sut = IUnionService.CreateMock(); + sut.Compute(5, "a"); + sut.Compute(6, "bb"); + + await That(sut.Mock.Verify.Compute(5, "a")).Once(); + await That(sut.Mock.Verify.Compute(It.IsAny(), s => s.Length == 2)).Once(); + await That(sut.Mock.Verify.Compute(x => x > 4, It.IsAny())).Twice(); + await That(sut.Mock.Verify.Compute(x => x > 10, It.IsAny())).Never(); + } + + [Fact] + public async Task Verify_WithPredicate_FailureMessage_ShouldContainThePredicateText() + { + IUnionService sut = IUnionService.CreateMock(); + sut.Compute(5, "a"); + + void Act() + => sut.Mock.Verify.Compute(x => x > 10, "a").Once(); + + await That(Act).Throws() + .WithMessage("*Compute(x => x > 10, a)*").AsWildcard(); + } + + [Fact] + public async Task Setup_ObjectParameter_ShouldTreatADelegateVariableAsValueAndALambdaAsPredicate() + { + IUnionService sut = IUnionService.CreateMock(); + Func predicate = o => o is int; + sut.Mock.Setup.Take(predicate).Returns(true); + + bool forInt = sut.Take(1); + bool forTheDelegateItself = sut.Take(predicate); + + await That(forInt).IsFalse(); + await That(forTheDelegateItself).IsTrue(); + + IUnionService other = IUnionService.CreateMock(); + other.Mock.Setup.Take(o => o is int).Returns(true); + + await That(other.Take(1)).IsTrue(); + await That(other.Take("x")).IsFalse(); + } + + [Fact] + public async Task Setup_WithOutParameter_ShouldCombineAMatcherSlotWithAPredicate() + { + IUnionService sut = IUnionService.CreateMock(); + sut.Mock.Setup.TryParse(s => s.Length > 0, It.IsOut(() => 42)).Returns(true); + + bool nonEmpty = sut.TryParse("a", out int parsed); + bool empty = sut.TryParse("", out int _); + + await That(nonEmpty).IsTrue(); + await That(parsed).IsEqualTo(42); + await That(empty).IsFalse(); + await That(sut.Mock.Verify.TryParse("a", It.IsOut())).Once(); + await That(sut.Mock.Verify.TryParse(s => s.Length == 0, It.IsOut())).Once(); + } + + [Fact] + public async Task Verify_AnyParameters_ShouldIgnoreTheUnionArguments() + { + IUnionService sut = IUnionService.CreateMock(); + sut.Compute(1, "a"); + sut.Compute(2, "b"); + + await That(sut.Mock.Verify.Compute(x => x > 100, "zzz").AnyParameters()).Exactly(2); + } + + [Fact] + public async Task Setup_InScenario_ShouldOnlyApplyInThatScenario() + { + IUnionService sut = IUnionService.CreateMock(); + sut.Mock.InScenario("a").Setup.Compute(x => x > 0, "a").Returns(9); + + int beforeTransition = sut.Compute(5, "a"); + sut.Mock.TransitionTo("a"); + int inScenario = sut.Compute(5, "a"); + + await That(beforeTransition).IsEqualTo(0); + await That(inScenario).IsEqualTo(9); + } + + [Fact] + public async Task OverloadedMethods_ShouldKeepTheClassicBindings() + { + IOverloadedService sut = IOverloadedService.CreateMock(); + sut.Mock.Setup.M(null).Returns(1); + sut.Mock.Setup.N(5).Returns(2); + sut.Mock.Setup.Foo(5).Returns(3); + + await That(sut.M((string?)null)).IsEqualTo(1); + await That(sut.N(5)).IsEqualTo(2); + await That(sut.N(5L)).IsEqualTo(0); + await That(sut.Foo(5)).IsEqualTo(3); + await That(sut.Foo(5)).IsEqualTo(0); + } + + [Fact] + public async Task DelegateMock_ShouldOfferPredicates() + { + UnionDelegate sut = UnionDelegate.CreateMock(); + sut.Mock.Setup(x => x > 0, "a").Returns(1); + + int positive = sut(5, "a"); + int negative = sut(-1, "a"); + + await That(positive).IsEqualTo(1); + await That(negative).IsEqualTo(0); + await That(sut.Mock.Verify(x => x != 0, It.IsAny())).Twice(); + await That(sut.Mock.Verify(5, "a")).Once(); + } + + public delegate int UnionDelegate(int x, string y); + + public interface IUnionService + { + int Compute(int value, string text); + string Describe(string? s); + void Register(Func callback); + int Sum(int a, int b, int c, int d); + int WithDefault(int i = 5); + bool Take(object? o); + bool TryParse(string s, out int result); + } + + public interface IOverloadedService + { + int M(int v); + int M(string? v); + int N(int v); + int N(long v); + int Foo(int v); + int Foo(T v); + } +} +#endif From 14b27244a36cde140b8549332734525333b3f795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Fri, 4 Sep 2026 21:17:46 +0200 Subject: [PATCH 04/14] feat: union-typed setup and verify indexers Extends union mode to indexers: every indexer that is the only one of its key count on the type and has value-capable keys gets one Setup and one Verify indexer per assignment of its keys to ParameterArg? or Func, with the same slot rules as methods (delegate-typed keys offer the raw delegate and dispatch as literal values, Span keys keep their matcher slot, ref-struct and params keys keep the classic set). Indexers of the same arity keep the classic set, because two indexers with convertible key types (this[int]/this[long]) would make Setup[5] ambiguous; indexers of different arity never compete. Indexers have no IParameters overload, so the all-union indexer takes the classic all-matcher priority (int.MaxValue) and predicate combinations rank by their union slot count. Keys always dispatch through ToParameterMatch() because IndexerSetup has no literal fast path; the typed verify path is used up to four keys, the IndexerGetterAccess/IndexerSetterAccess predicate above that. Without union support the output is unchanged. Tests: a new IUnionIndexers coverage interface with one indexer per key count (getter/setter, getter-only, setter-only, delegate-typed key, five keys) and its union snapshot, generator assertions for the two-key indexer overloads, the delegate-typed key and same-arity indexers falling back to the classic set, and net11.0 behavioural tests for indexer setup and verify with predicates, literals and matchers, the setter verification, the failure message and overloaded indexers. --- .../Sources/Sources.MockClass.Unions.cs | 422 ++- .../Sources/Sources.MockClass.cs | 42 + .../Mock.IKeywordEdgeCases.g.cs | 128 +- .../IndexerSetups.g.cs | 1055 ++++++ .../Mock.IUnionIndexers.g.cs | 2892 +++++++++++++++++ .../Mock.g.cs | 133 + .../MockBehaviorExtensions.g.cs | 285 ++ .../ParameterArg.g.cs | 133 + .../Snapshot/MockGenerationSnapshotTests.cs | 8 + .../UnionOverloadTests.cs | 75 + .../GeneratorCoverage/IUnionIndexers.cs | 15 + Tests/Mockolate.Tests/UnionSetupTests.cs | 61 + 12 files changed, 5151 insertions(+), 98 deletions(-) create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/IndexerSetups.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/Mock.IUnionIndexers.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/Mock.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/MockBehaviorExtensions.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/ParameterArg.g.cs create mode 100644 Tests/Mockolate.Tests/GeneratorCoverage/IUnionIndexers.cs diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.Unions.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.Unions.cs index 8ca2c4e2..229d6f5d 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.Unions.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.Unions.cs @@ -163,8 +163,10 @@ private static void AppendUnionSummary(StringBuilder sb, Class @class, Method me } private static void AppendUnionOverloadRemark(StringBuilder sb, Method method, UnionSlot[] slots) + => AppendUnionOverloadRemark(sb, method.Parameters.AsArray().Select(p => p.Name).ToArray(), slots); + + private static void AppendUnionOverloadRemark(StringBuilder sb, string[] parameterNames, UnionSlot[] slots) { - MethodParameter[] parameters = method.Parameters.AsArray(); List parts = []; AddPart(UnionSlot.Union, "an matcher or a direct value for {0}"); AddPart(UnionSlot.Predicate, "a predicate for {0}"); @@ -176,9 +178,9 @@ private static void AppendUnionOverloadRemark(StringBuilder sb, Method method, U void AddPart(UnionSlot slot, string format) { - string[] names = parameters + string[] names = parameterNames .Where((_, i) => slots[i] == slot) - .Select(p => $"") + .Select(name => $"") .ToArray(); if (names.Length > 0) { @@ -228,6 +230,8 @@ private static void AppendUnionParameters(StringBuilder sb, Method method, Union bool[] hasTrailingDefault = isDefinition ? ComputeTrailingDefaults(method.Parameters.AsSpan(), breaksDefaults) : new bool[parameters.Length]; + string[] names = parameters.Select(p => p.Name).ToArray(); + string[] expressionNames = parameters.Select(p => UnionExpressionParameterName(method, p)).ToArray(); for (int i = 0; i < parameters.Length; i++) { if (i > 0) @@ -235,41 +239,53 @@ private static void AppendUnionParameters(StringBuilder sb, Method method, Union sb.Append(", "); } - MethodParameter parameter = parameters[i]; - switch (slots[i]) - { - case UnionSlot.Union: - sb.Append("global::Mockolate.ParameterArg<").Append(parameter.ToNullableType()).Append(">? ") - .Append(parameter.Name); - break; - case UnionSlot.Predicate: - sb.Append("global::System.Func<").Append(parameter.ToNullableType()).Append(", bool> ") - .Append(parameter.Name); - break; - case UnionSlot.RawDelegate: - sb.Append(parameter.ToNullableType()).Append(' ').Append(parameter.Name); - break; - default: - if (isVerify) - { - sb.AppendVerifyParameter(parameter); - } - else - { - sb.Append(parameter.ToParameter()); - } - - sb.Append(' ').Append(parameter.Name); - break; - } - + AppendUnionSlotParameter(sb, parameters[i], names[i], slots[i], isVerify); if (hasTrailingDefault[i]) { sb.Append(" = null"); } } - for (int i = 0; i < parameters.Length; i++) + AppendUnionExpressionParameters(sb, names, expressionNames, slots, isDefinition); + } + + private static void AppendUnionSlotParameter(StringBuilder sb, MethodParameter parameter, string name, + UnionSlot slot, bool isVerify) + { + switch (slot) + { + case UnionSlot.Union: + sb.Append("global::Mockolate.ParameterArg<").Append(parameter.ToNullableType()).Append(">? ").Append(name); + break; + case UnionSlot.Predicate: + sb.Append("global::System.Func<").Append(parameter.ToNullableType()).Append(", bool> ").Append(name); + break; + case UnionSlot.RawDelegate: + sb.Append(parameter.ToNullableType()).Append(' ').Append(name); + break; + default: + if (isVerify) + { + sb.AppendVerifyParameter(parameter); + } + else + { + sb.Append(parameter.ToParameter()); + } + + sb.Append(' ').Append(name); + break; + } + } + + /// + /// One trailing string per predicate slot carrying the caller's argument text; the definition adds the + /// [CallerArgumentExpression] and the default, the explicit implementation just the parameter. + /// + private static void AppendUnionExpressionParameters(StringBuilder sb, string[] names, string[] expressionNames, + UnionSlot[] slots, bool isDefinition) + { + for (int i = 0; i < names.Length; i++) { if (slots[i] != UnionSlot.Predicate) { @@ -281,10 +297,10 @@ private static void AppendUnionParameters(StringBuilder sb, Method method, Union { // Parameter names are stored escaped (`@params`); the attribute needs the bare identifier. sb.Append("[global::System.Runtime.CompilerServices.CallerArgumentExpression(\"") - .Append(parameters[i].Name.TrimStart('@')).Append("\")] "); + .Append(names[i].TrimStart('@')).Append("\")] "); } - sb.Append("string ").Append(UnionExpressionParameterName(method, parameters[i])); + sb.Append("string ").Append(expressionNames[i]); if (isDefinition) { sb.Append(" = \"\""); @@ -629,4 +645,342 @@ private static void AppendUnionMethodVerifyImplementation(StringBuilder sb, Meth private static string UnionMatchLocalName(Method method, MethodParameter parameter) => CreateUniqueParameterName(method.Parameters, $"{parameter.Name}Match"); + + #region Indexers + + /// + /// Whether the indexer gets the union-mode key overloads. Only an indexer that is the sole one of its key count + /// qualifies (, see ): two same-arity + /// indexers with convertible key types (this[int]/this[long]) would make Setup[5] ambiguous + /// because a union conversion loses to the numeric conversion, while indexers of different arity never compete. + /// Ref-struct keys have no value overloads at all and a params key cannot survive inside a union type. + /// + private static bool UseUnionIndexer(Property indexer, bool hasUniqueKeyCount, bool useUnionOverloads) + => useUnionOverloads && + hasUniqueKeyCount && + indexer.IndexerParameters is { } parameters && + !parameters.Any(p => p.NeedsRefStructPipeline() || p.IsParams) && + parameters.Any(p => p.CanUseNullableParameterOverload()); + + private static bool HasUniqueIndexerKeyCount(Class @class, Property indexer) + { + int keyCount = indexer.IndexerParameters!.Value.Count; + return @class.AllProperties().Count(p => + p.IsIndexer && p.ExplicitImplementation is null && p.IndexerParameters?.Count == keyCount) == 1; + } + + // Indexers have no IParameters overload, so the all-union indexer simply takes the top priority the classic + // all-matcher indexer has; combinations with predicates rank by their union/fixed slot count. + private static string UnionIndexerPriority(UnionSlot[] slots) + { + int unionCount = slots.Count(s => s is UnionSlot.Union or UnionSlot.Fixed); + return unionCount == slots.Length ? "int.MaxValue" : unionCount.ToString(); + } + + private static string[] UnionIndexerSetupNames(Property indexer) + => Enumerable.Range(1, indexer.IndexerParameters!.Value.Count).Select(i => $"parameter{i}").ToArray(); + + private static string[] UnionIndexerVerifyNames(Property indexer) + => indexer.IndexerParameters!.Value.AsArray().Select(p => p.Name).ToArray(); + + private static string[] UnionIndexerExpressionNames(Property indexer, string[] names) + => names.Select(name => CreateUniqueParameterName(indexer.IndexerParameters!.Value, $"{name}Expression")) + .ToArray(); + + private static void AppendUnionIndexerParameters(StringBuilder sb, Property indexer, string[] names, + string[] expressionNames, UnionSlot[] slots, bool isDefinition, bool isVerify) + { + MethodParameter[] parameters = indexer.IndexerParameters!.Value.AsArray(); + for (int i = 0; i < parameters.Length; i++) + { + if (i > 0) + { + sb.Append(", "); + } + + AppendUnionSlotParameter(sb, parameters[i], names[i], slots[i], isVerify); + } + + AppendUnionExpressionParameters(sb, names, expressionNames, slots, isDefinition); + } + + /// + /// The IParameterMatch<T> for one indexer key. Indexers have no literal fast path, so a union slot + /// always goes through ToParameterMatch(); an omitted or key is the literal + /// default(T). + /// + private static void AppendUnionIndexerKeyMatch(StringBuilder sb, MethodParameter parameter, string name, + string expressionName, UnionSlot slot) + { + switch (slot) + { + case UnionSlot.Union: + sb.Append('(').Append(name).Append(" ?? default).ToParameterMatch()"); + break; + case UnionSlot.Predicate: + sb.Append("(global::Mockolate.Parameters.IParameterMatch<").Append(parameter.ToTypeOrWrapper()) + .Append(">)global::Mockolate.It.Satisfies<").Append(parameter.ToNullableType()).Append(">(") + .Append(name).Append(", ").Append(expressionName).Append(')'); + break; + case UnionSlot.RawDelegate: + AppendNamedValueParameter(sb, parameter, name); + break; + default: + sb.Append("CovariantParameterAdapter<").Append(parameter.ToTypeOrWrapper()).Append(">.Wrap(") + .Append(name).Append(')'); + break; + } + } + + private static void AppendUnionIndexerSetupDefinition(StringBuilder sb, Property indexer, UnionSlot[] slots) + { + string[] names = UnionIndexerSetupNames(indexer); + sb.AppendXmlSummary( + $"Setup for the {indexer.Type.Fullname.EscapeForXmlDoc()} indexer p.RefKind.GetString() + p.Type.Fullname.EscapeForXmlDoc()))}]\" />"); + AppendUnionOverloadRemark(sb, names, slots); + sb.Append("\t\t[global::System.Runtime.CompilerServices.OverloadResolutionPriority(") + .Append(UnionIndexerPriority(slots)).Append(")]").AppendLine(); + sb.Append("\t\t").Append(GetIndexerSetupType(indexer)).AppendTypeOrWrapper(indexer.Type); + foreach (MethodParameter parameter in indexer.IndexerParameters!) + { + sb.Append(", ").AppendTypeOrWrapper(parameter.Type); + } + + sb.Append("> this["); + AppendUnionIndexerParameters(sb, indexer, names, UnionIndexerExpressionNames(indexer, names), slots, + isDefinition: true, isVerify: false); + sb.Append("] { get; }").AppendLine(); + sb.AppendLine(); + } + +#pragma warning disable S107 // Methods should not have too many parameters + private static void AppendUnionIndexerSetupImplementation(StringBuilder sb, Property indexer, + string mockRegistryName, string setupName, MemberIdTable memberIds, string memberIdPrefix, + UnionSlot[] slots, string? scopeExpression = null) +#pragma warning restore S107 + { + MethodParameter[] parameters = indexer.IndexerParameters!.Value.AsArray(); + string[] names = UnionIndexerSetupNames(indexer); + string[] expressionNames = UnionIndexerExpressionNames(indexer, names); + string scopePrefix = scopeExpression is null ? "" : scopeExpression + ", "; + sb.Append("\t\t/// ").AppendLine(); + sb.Append( + "\t\t[global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)]") + .AppendLine(); + sb.Append("\t\t").Append(GetIndexerSetupType(indexer)).AppendTypeOrWrapper(indexer.Type); + foreach (MethodParameter parameter in parameters) + { + sb.Append(", ").AppendTypeOrWrapper(parameter.Type); + } + + sb.Append("> global::Mockolate.Mock.").Append(setupName).Append(".this["); + AppendUnionIndexerParameters(sb, indexer, names, expressionNames, slots, isDefinition: false, + isVerify: false); + sb.Append("]").AppendLine(); + sb.Append("\t\t{").AppendLine(); + sb.Append("\t\t\tget").AppendLine(); + sb.Append("\t\t\t{").AppendLine(); + sb.Append("\t\t\t\tvar indexerSetup = new global::Mockolate.Setup.IndexerSetup<") + .AppendTypeOrWrapper(indexer.Type); + foreach (MethodParameter parameter in parameters) + { + sb.Append(", ").AppendTypeOrWrapper(parameter.Type); + } + + sb.Append(">(").Append(mockRegistryName); + for (int i = 0; i < parameters.Length; i++) + { + sb.Append(", "); + AppendUnionIndexerKeyMatch(sb, parameters[i], names[i], expressionNames[i], slots[i]); + } + + sb.Append(");").AppendLine(); + sb.Append("\t\t\t\tthis.").Append(mockRegistryName).Append(".SetupIndexer(") + .Append(memberIdPrefix).Append(memberIds.GetIndexerGetIdentifier(indexer)).Append(", ") + .Append(scopePrefix).Append("indexerSetup);").AppendLine(); + sb.Append("\t\t\t\treturn indexerSetup;").AppendLine(); + sb.Append("\t\t\t}").AppendLine(); + sb.Append("\t\t}").AppendLine(); + sb.AppendLine(); + } + + private static void AppendUnionIndexerVerifyDefinition(StringBuilder sb, Property indexer, string verifyName, + UnionSlot[] slots) + { + string[] names = UnionIndexerVerifyNames(indexer); + sb.AppendXmlSummary( + $"Verify interactions with the {indexer.Type.Fullname.EscapeForXmlDoc()} indexer p.RefKind.GetString() + p.Type.Fullname.EscapeForXmlDoc()))}]\" />."); + AppendUnionOverloadRemark(sb, names, slots); + sb.Append("\t\t[global::System.Runtime.CompilerServices.OverloadResolutionPriority(") + .Append(UnionIndexerPriority(slots)).Append(")]").AppendLine(); + sb.Append("\t\t"); + AppendIndexerVerifyType(sb, indexer, verifyName); + sb.Append(" this["); + AppendUnionIndexerParameters(sb, indexer, names, UnionIndexerExpressionNames(indexer, names), slots, + isDefinition: true, isVerify: true); + sb.Append("] { get; }").AppendLine(); + sb.AppendLine(); + } + +#pragma warning disable S107 // Methods should not have too many parameters + private static void AppendUnionIndexerVerifyImplementation(StringBuilder sb, Property indexer, + string mockRegistryName, string verifyName, MemberIdTable memberIds, string memberIdPrefix, + bool useFastBuffers, UnionSlot[] slots) +#pragma warning restore S107 + { + MethodParameter[] parameters = indexer.IndexerParameters!.Value.AsArray(); + string[] names = UnionIndexerVerifyNames(indexer); + string[] expressionNames = UnionIndexerExpressionNames(indexer, names); + bool useFastForIndexer = useFastBuffers && IsFastBufferEligibleIndexer(indexer); + string indexerGetMemberId = useFastForIndexer + ? memberIdPrefix + memberIds.GetIndexerGetIdentifier(indexer) + : "-1"; + string indexerSetMemberId = useFastForIndexer + ? memberIdPrefix + memberIds.GetIndexerSetIdentifier(indexer) + : "-1"; + PropertyAccessors interceptedAccessors = GetInterceptedAccessors(indexer); + + sb.Append("\t\t/// ").AppendLine(); + sb.Append( + "\t\t[global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)]") + .AppendLine(); + sb.Append("\t\t"); + AppendIndexerVerifyType(sb, indexer, verifyName); + sb.Append(' ').Append(verifyName).Append(".this["); + AppendUnionIndexerParameters(sb, indexer, names, expressionNames, slots, isDefinition: false, + isVerify: true); + sb.Append("]").AppendLine(); + sb.Append("\t\t{").AppendLine(); + sb.Append("\t\t\tget").AppendLine(); + sb.Append("\t\t\t{").AppendLine(); + if (parameters.Length <= 4) + { + // Typed path: one IParameterMatch per key, exactly like the classic matcher indexer. + string typedVerifyType = interceptedAccessors switch + { + PropertyAccessors.GetOnly => "VerificationIndexerGetterResult", + PropertyAccessors.SetOnly => "VerificationIndexerSetterResult", + _ => "VerificationIndexerResult", + }; + string verifyMemberIds = interceptedAccessors switch + { + PropertyAccessors.GetOnly => indexerGetMemberId, + PropertyAccessors.SetOnly => indexerSetMemberId, + _ => $"{indexerGetMemberId}, {indexerSetMemberId}", + }; + sb.Append("\t\t\t\treturn new global::Mockolate.Verify.").Append(typedVerifyType).Append('<') + .Append(verifyName); + foreach (MethodParameter parameter in parameters) + { + sb.Append(", ").AppendTypeOrWrapper(parameter.Type); + } + + if (interceptedAccessors != PropertyAccessors.GetOnly) + { + sb.Append(", ").AppendTypeOrWrapper(indexer.Type); + } + + sb.Append(">(this, this.").Append(mockRegistryName) + .Append(", ").Append(verifyMemberIds).Append(",").AppendLine(); + for (int i = 0; i < parameters.Length; i++) + { + sb.Append("\t\t\t\t\t"); + AppendUnionIndexerKeyMatch(sb, parameters[i], names[i], expressionNames[i], slots[i]); + sb.Append(',').AppendLine(); + } + } + else + { + switch (interceptedAccessors) + { + case PropertyAccessors.GetOnly: + sb.Append("\t\t\t\treturn new global::Mockolate.Verify.VerificationIndexerGetterResult<") + .Append(verifyName); + foreach (MethodParameter parameter in parameters) + { + sb.Append(", ").AppendTypeOrWrapper(parameter.Type); + } + + sb.Append(">(this, this.").Append(mockRegistryName) + .Append(", ").Append(indexerGetMemberId).Append(",").AppendLine(); + break; + case PropertyAccessors.SetOnly: + sb.Append("\t\t\t\treturn new global::Mockolate.Verify.VerificationIndexerSetterResult<") + .Append(verifyName); + foreach (MethodParameter parameter in parameters) + { + sb.Append(", ").AppendTypeOrWrapper(parameter.Type); + } + + sb.Append(", ").AppendTypeOrWrapper(indexer.Type).Append(">(this, this.").Append(mockRegistryName) + .Append(", ").Append(indexerSetMemberId).Append(",").AppendLine(); + break; + default: + sb.Append("\t\t\t\treturn new global::Mockolate.Verify.VerificationIndexerResult<").Append(verifyName) + .Append(", ").AppendTypeOrWrapper(indexer.Type).Append(">(this, this.").Append(mockRegistryName) + .Append(", ").Append(indexerGetMemberId).Append(", ").Append(indexerSetMemberId).Append(",").AppendLine(); + break; + } + + if (interceptedAccessors != PropertyAccessors.SetOnly) + { + sb.Append("\t\t\t\t\tinteraction => interaction is global::Mockolate.Interactions.IndexerGetterAccess<") + .Append(string.Join(", ", parameters.Select(p => p.ToTypeOrWrapper()))).Append("> g"); + AppendUnionIndexerKeyMatches(sb, parameters, names, expressionNames, slots, "g"); + sb.Append(",").AppendLine(); + } + + if (interceptedAccessors != PropertyAccessors.GetOnly) + { + sb.Append( + "\t\t\t\t\t(interaction, value) => interaction is global::Mockolate.Interactions.IndexerSetterAccess<"); + foreach (MethodParameter parameter in parameters) + { + sb.AppendTypeOrWrapper(parameter.Type).Append(", "); + } + + sb.AppendTypeOrWrapper(indexer.Type).Append("> s"); + AppendUnionIndexerKeyMatches(sb, parameters, names, expressionNames, slots, "s"); + sb.Append(" && value.Matches(s.TypedValue),").AppendLine(); + } + } + + sb.Append("\t\t\t\t\t() => global::System.String.Format(\"[") + .Append(string.Join(", ", Enumerable.Range(0, parameters.Length).Select(k => $"{{{k}}}"))) + .Append("]\""); + for (int i = 0; i < parameters.Length; i++) + { + sb.Append(", "); + switch (slots[i]) + { + case UnionSlot.Union: + sb.Append("(object?)(").Append(names[i]).Append(" ?? default)"); + break; + case UnionSlot.Predicate: + sb.Append("(object?)").Append(expressionNames[i]); + break; + default: + sb.Append("(object?)").Append(names[i]).Append(" ?? \"null\""); + break; + } + } + + sb.Append("));").AppendLine(); + sb.Append("\t\t\t}").AppendLine(); + sb.Append("\t\t}").AppendLine(); + sb.AppendLine(); + } + + private static void AppendUnionIndexerKeyMatches(StringBuilder sb, MethodParameter[] parameters, string[] names, + string[] expressionNames, UnionSlot[] slots, string interactionVar) + { + for (int i = 0; i < parameters.Length; i++) + { + sb.Append(" && "); + AppendUnionIndexerKeyMatch(sb, parameters[i], names[i], expressionNames[i], slots[i]); + sb.Append(".Matches(").Append(interactionVar).Append(".Parameter").Append(i + 1).Append(')'); + } + } + + #endregion Indexers } diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs index cc7bcb08..596598d3 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs @@ -3300,6 +3300,16 @@ private static void DefineSetupInterface(StringBuilder sb, Class @class, MemberT indexer.MemberType == memberType; foreach (Property indexer in @class.AllProperties().Where(indexerPredicate)) { + if (UseUnionIndexer(indexer, HasUniqueIndexerKeyCount(@class, indexer), useUnionOverloads)) + { + foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(indexer.IndexerParameters!.Value)) + { + AppendUnionIndexerSetupDefinition(sb, indexer, slots); + } + + continue; + } + AppendIndexerSetupDefinition(sb, indexer, hasOverloadResolutionPriority: hasOverloadResolutionPriority); if (indexer.IndexerParameters!.Value.Count <= MaxExplicitParameters) { @@ -3771,6 +3781,17 @@ private static void ImplementSetupInterface(StringBuilder sb, Class @class, stri indexer.MemberType == memberType; foreach (Property indexer in @class.AllProperties().Where(indexerPredicate)) { + if (UseUnionIndexer(indexer, HasUniqueIndexerKeyCount(@class, indexer), useUnionOverloads)) + { + foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(indexer.IndexerParameters!.Value)) + { + AppendUnionIndexerSetupImplementation(sb, indexer, mockRegistryName, setupName, memberIds, + memberIdPrefix, slots, scopeExpression); + } + + continue; + } + AppendIndexerSetupImplementation(sb, indexer, mockRegistryName, setupName, memberIds, memberIdPrefix, scopeExpression: scopeExpression); if (indexer.IndexerParameters!.Value.Count <= MaxExplicitParameters) @@ -5216,6 +5237,16 @@ private static void DefineVerifyInterface(StringBuilder sb, Class @class, string indexer.MemberType == memberType; foreach (Property indexer in @class.AllProperties().Where(indexerPredicate)) { + if (UseUnionIndexer(indexer, HasUniqueIndexerKeyCount(@class, indexer), useUnionOverloads)) + { + foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(indexer.IndexerParameters!.Value)) + { + AppendUnionIndexerVerifyDefinition(sb, indexer, verifyName, slots); + } + + continue; + } + AppendIndexerVerifyDefinition(sb, indexer, verifyName, hasOverloadResolutionPriority: hasOverloadResolutionPriority); if (indexer.IndexerParameters!.Value.Count <= MaxExplicitParameters) @@ -5513,6 +5544,17 @@ private static void ImplementVerifyInterface(StringBuilder sb, Class @class, str indexer.MemberType == memberType; foreach (Property indexer in @class.AllProperties().Where(indexerPredicate)) { + if (UseUnionIndexer(indexer, HasUniqueIndexerKeyCount(@class, indexer), useUnionOverloads)) + { + foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(indexer.IndexerParameters!.Value)) + { + AppendUnionIndexerVerifyImplementation(sb, indexer, mockRegistryName, verifyName, memberIds, + memberIdPrefix, useFastBuffers, slots); + } + + continue; + } + AppendIndexerVerifyImplementation(sb, indexer, mockRegistryName, verifyName, memberIds, memberIdPrefix, useFastBuffers); if (indexer.IndexerParameters!.Value.Count <= MaxExplicitParameters) diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.IKeywordEdgeCases.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.IKeywordEdgeCases.g.cs index d8e59526..627f4bdf 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.IKeywordEdgeCases.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.IKeywordEdgeCases.g.cs @@ -439,11 +439,11 @@ public int @void<@class>(int @ref) /// [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[global::Mockolate.Parameters.IParameter? parameter1, global::Mockolate.Parameters.IParameter? parameter2] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[global::Mockolate.ParameterArg? parameter1, global::Mockolate.ParameterArg? parameter2] { get { - var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, CovariantParameterAdapter.Wrap(parameter1 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter2 ?? global::Mockolate.It.IsNull("null"))); + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (parameter2 ?? default).ToParameterMatch()); this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, indexerSetup); return indexerSetup; } @@ -451,11 +451,11 @@ public int @void<@class>(int @ref) /// [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[int parameter1, global::Mockolate.Parameters.IParameter? parameter2] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, string parameter1Expression] { get { - var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter1), CovariantParameterAdapter.Wrap(parameter2 ?? global::Mockolate.It.IsNull("null"))); + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter1, parameter1Expression), (parameter2 ?? default).ToParameterMatch()); this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, indexerSetup); return indexerSetup; } @@ -463,11 +463,11 @@ public int @void<@class>(int @ref) /// [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[global::Mockolate.Parameters.IParameter? parameter1, string parameter2] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[global::Mockolate.ParameterArg? parameter1, global::System.Func parameter2, string parameter2Expression] { get { - var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, CovariantParameterAdapter.Wrap(parameter1 ?? global::Mockolate.It.IsNull("null")), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter2)); + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression)); this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, indexerSetup); return indexerSetup; } @@ -475,11 +475,11 @@ public int @void<@class>(int @ref) /// [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[int parameter1, string parameter2] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[global::System.Func parameter1, global::System.Func parameter2, string parameter1Expression, string parameter2Expression] { get { - var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter1), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter2)); + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter1, parameter1Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression)); this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, indexerSetup); return indexerSetup; } @@ -586,53 +586,53 @@ void IMockRaiseOnIKeywordEdgeCases.@event(global::Mockolate.Parameters.IDefaultE /// [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[global::Mockolate.Parameters.IParameter? @params, global::Mockolate.Parameters.IParameter? @void] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[global::Mockolate.ParameterArg? @params, global::Mockolate.ParameterArg? @void] { get { return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Set, - CovariantParameterAdapter.Wrap(@params ?? global::Mockolate.It.IsNull("null")), - CovariantParameterAdapter.Wrap(@void ?? global::Mockolate.It.IsNull("null")), - () => global::System.String.Format("[{0}, {1}]", (object?)@params ?? "null", (object?)@void ?? "null")); + (@params ?? default).ToParameterMatch(), + (@void ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}]", (object?)(@params ?? default), (object?)(@void ?? default))); } } /// [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[int @params, global::Mockolate.Parameters.IParameter? @void] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[global::System.Func @params, global::Mockolate.ParameterArg? @void, string @paramsExpression] { get { return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Set, - (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(@params, "@params"), - CovariantParameterAdapter.Wrap(@void ?? global::Mockolate.It.IsNull("null")), - () => global::System.String.Format("[{0}, {1}]", (object?)@params, (object?)@void ?? "null")); + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(@params, @paramsExpression), + (@void ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}]", (object?)@paramsExpression, (object?)(@void ?? default))); } } /// [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[global::Mockolate.Parameters.IParameter? @params, string @void] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[global::Mockolate.ParameterArg? @params, global::System.Func @void, string @voidExpression] { get { return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Set, - CovariantParameterAdapter.Wrap(@params ?? global::Mockolate.It.IsNull("null")), - (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(@void, "@void"), - () => global::System.String.Format("[{0}, {1}]", (object?)@params ?? "null", (object?)@void)); + (@params ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(@void, @voidExpression), + () => global::System.String.Format("[{0}, {1}]", (object?)(@params ?? default), (object?)@voidExpression)); } } /// [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[int @params, string @void] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[global::System.Func @params, global::System.Func @void, string @paramsExpression, string @voidExpression] { get { return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Set, - (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(@params, "@params"), - (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(@void, "@void"), - () => global::System.String.Format("[{0}, {1}]", (object?)@params, (object?)@void)); + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(@params, @paramsExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(@void, @voidExpression), + () => global::System.String.Format("[{0}, {1}]", (object?)@paramsExpression, (object?)@voidExpression)); } } @@ -717,53 +717,53 @@ private sealed class VerifyMonitorIKeywordEdgeCases(global::Mockolate.MockRegist /// [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[global::Mockolate.Parameters.IParameter? @params, global::Mockolate.Parameters.IParameter? @void] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[global::Mockolate.ParameterArg? @params, global::Mockolate.ParameterArg? @void] { get { return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Set, - CovariantParameterAdapter.Wrap(@params ?? global::Mockolate.It.IsNull("null")), - CovariantParameterAdapter.Wrap(@void ?? global::Mockolate.It.IsNull("null")), - () => global::System.String.Format("[{0}, {1}]", (object?)@params ?? "null", (object?)@void ?? "null")); + (@params ?? default).ToParameterMatch(), + (@void ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}]", (object?)(@params ?? default), (object?)(@void ?? default))); } } /// [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[int @params, global::Mockolate.Parameters.IParameter? @void] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[global::System.Func @params, global::Mockolate.ParameterArg? @void, string @paramsExpression] { get { return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Set, - (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(@params, "@params"), - CovariantParameterAdapter.Wrap(@void ?? global::Mockolate.It.IsNull("null")), - () => global::System.String.Format("[{0}, {1}]", (object?)@params, (object?)@void ?? "null")); + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(@params, @paramsExpression), + (@void ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}]", (object?)@paramsExpression, (object?)(@void ?? default))); } } /// [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[global::Mockolate.Parameters.IParameter? @params, string @void] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[global::Mockolate.ParameterArg? @params, global::System.Func @void, string @voidExpression] { get { return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Set, - CovariantParameterAdapter.Wrap(@params ?? global::Mockolate.It.IsNull("null")), - (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(@void, "@void"), - () => global::System.String.Format("[{0}, {1}]", (object?)@params ?? "null", (object?)@void)); + (@params ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(@void, @voidExpression), + () => global::System.String.Format("[{0}, {1}]", (object?)(@params ?? default), (object?)@voidExpression)); } } /// [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[int @params, string @void] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIKeywordEdgeCases.this[global::System.Func @params, global::System.Func @void, string @paramsExpression, string @voidExpression] { get { return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Set, - (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(@params, "@params"), - (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Is(@void, "@void"), - () => global::System.String.Format("[{0}, {1}]", (object?)@params, (object?)@void)); + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(@params, @paramsExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(@void, @voidExpression), + () => global::System.String.Format("[{0}, {1}]", (object?)@paramsExpression, (object?)@voidExpression)); } } @@ -873,11 +873,11 @@ public MockInScenarioForIKeywordEdgeCases(global::Mockolate.MockRegistry mockReg /// [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[global::Mockolate.Parameters.IParameter? parameter1, global::Mockolate.Parameters.IParameter? parameter2] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[global::Mockolate.ParameterArg? parameter1, global::Mockolate.ParameterArg? parameter2] { get { - var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, CovariantParameterAdapter.Wrap(parameter1 ?? global::Mockolate.It.IsNull("null")), CovariantParameterAdapter.Wrap(parameter2 ?? global::Mockolate.It.IsNull("null"))); + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (parameter2 ?? default).ToParameterMatch()); this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, _scenarioName, indexerSetup); return indexerSetup; } @@ -885,11 +885,11 @@ public MockInScenarioForIKeywordEdgeCases(global::Mockolate.MockRegistry mockReg /// [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[int parameter1, global::Mockolate.Parameters.IParameter? parameter2] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, string parameter1Expression] { get { - var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter1), CovariantParameterAdapter.Wrap(parameter2 ?? global::Mockolate.It.IsNull("null"))); + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter1, parameter1Expression), (parameter2 ?? default).ToParameterMatch()); this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, _scenarioName, indexerSetup); return indexerSetup; } @@ -897,11 +897,11 @@ public MockInScenarioForIKeywordEdgeCases(global::Mockolate.MockRegistry mockReg /// [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[global::Mockolate.Parameters.IParameter? parameter1, string parameter2] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[global::Mockolate.ParameterArg? parameter1, global::System.Func parameter2, string parameter2Expression] { get { - var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, CovariantParameterAdapter.Wrap(parameter1 ?? global::Mockolate.It.IsNull("null")), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter2)); + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression)); this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, _scenarioName, indexerSetup); return indexerSetup; } @@ -909,11 +909,11 @@ public MockInScenarioForIKeywordEdgeCases(global::Mockolate.MockRegistry mockReg /// [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[int parameter1, string parameter2] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIKeywordEdgeCases.this[global::System.Func parameter1, global::System.Func parameter2, string parameter1Expression, string parameter2Expression] { get { - var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter1), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(parameter2)); + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter1, parameter1Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression)); this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IKeywordEdgeCases.MemberId_Indexer_int_string_Get, _scenarioName, indexerSetup); return indexerSetup; } @@ -1132,37 +1132,37 @@ internal interface IMockSetupForIKeywordEdgeCases : global::Mockolate.Setup.IMoc /// Setup for the string indexer this[int, string] /// /// - /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. /// [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] - global::Mockolate.Setup.IndexerSetup this[global::Mockolate.Parameters.IParameter? parameter1, global::Mockolate.Parameters.IParameter? parameter2] { get; } + global::Mockolate.Setup.IndexerSetup this[global::Mockolate.ParameterArg? parameter1, global::Mockolate.ParameterArg? parameter2] { get; } /// /// Setup for the string indexer this[int, string] /// /// - /// This overload accepts a direct value for (equivalent to It.Is<T>(value)) and an It matcher for . + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. /// [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] - global::Mockolate.Setup.IndexerSetup this[int parameter1, global::Mockolate.Parameters.IParameter? parameter2] { get; } + global::Mockolate.Setup.IndexerSetup this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter1")] string parameter1Expression = ""] { get; } /// /// Setup for the string indexer this[int, string] /// /// - /// This overload accepts a direct value for (equivalent to It.Is<T>(value)) and an It matcher for . + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. /// [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] - global::Mockolate.Setup.IndexerSetup this[global::Mockolate.Parameters.IParameter? parameter1, string parameter2] { get; } + global::Mockolate.Setup.IndexerSetup this[global::Mockolate.ParameterArg? parameter1, global::System.Func parameter2, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter2")] string parameter2Expression = ""] { get; } /// /// Setup for the string indexer this[int, string] /// /// - /// This overload accepts direct values for every parameter; each is treated as It.Is<T>(value). + /// This overload accepts a predicate for , . A or argument stands for the literal default value. /// [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] - global::Mockolate.Setup.IndexerSetup this[int parameter1, string parameter2] { get; } + global::Mockolate.Setup.IndexerSetup this[global::System.Func parameter1, global::System.Func parameter2, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter1")] string parameter1Expression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter2")] string parameter2Expression = ""] { get; } /// /// Setup for the method @return(). @@ -1257,37 +1257,37 @@ internal interface IMockVerifyForIKeywordEdgeCases : global::Mockolate.Verify.IM /// Verify interactions with the string indexer this[int, string]. /// /// - /// This overload takes It argument matchers (e.g. It.IsAny<T>(), It.Is<T>(value)) for every parameter. + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. /// [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] - global::Mockolate.Verify.VerificationIndexerResult this[global::Mockolate.Parameters.IParameter? @params, global::Mockolate.Parameters.IParameter? @void] { get; } + global::Mockolate.Verify.VerificationIndexerResult this[global::Mockolate.ParameterArg? @params, global::Mockolate.ParameterArg? @void] { get; } /// /// Verify interactions with the string indexer this[int, string]. /// /// - /// This overload accepts a direct value for (equivalent to It.Is<T>(value)) and an It matcher for . + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. /// [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] - global::Mockolate.Verify.VerificationIndexerResult this[int @params, global::Mockolate.Parameters.IParameter? @void] { get; } + global::Mockolate.Verify.VerificationIndexerResult this[global::System.Func @params, global::Mockolate.ParameterArg? @void, [global::System.Runtime.CompilerServices.CallerArgumentExpression("params")] string @paramsExpression = ""] { get; } /// /// Verify interactions with the string indexer this[int, string]. /// /// - /// This overload accepts a direct value for (equivalent to It.Is<T>(value)) and an It matcher for . + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. /// [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] - global::Mockolate.Verify.VerificationIndexerResult this[global::Mockolate.Parameters.IParameter? @params, string @void] { get; } + global::Mockolate.Verify.VerificationIndexerResult this[global::Mockolate.ParameterArg? @params, global::System.Func @void, [global::System.Runtime.CompilerServices.CallerArgumentExpression("void")] string @voidExpression = ""] { get; } /// /// Verify interactions with the string indexer this[int, string]. /// /// - /// This overload accepts direct values for every parameter and returns a VerificationResult<TVerify>.IgnoreParameters whose VerificationResult<TVerify>.AnyParameters() drops per-parameter matching entirely. + /// This overload accepts a predicate for , . A or argument stands for the literal default value. /// [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] - global::Mockolate.Verify.VerificationIndexerResult this[int @params, string @void] { get; } + global::Mockolate.Verify.VerificationIndexerResult this[global::System.Func @params, global::System.Func @void, [global::System.Runtime.CompilerServices.CallerArgumentExpression("params")] string @paramsExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("void")] string @voidExpression = ""] { get; } /// /// Verify invocations for the method @return(). diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/IndexerSetups.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/IndexerSetups.g.cs new file mode 100644 index 00000000..e2e703fc --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/IndexerSetups.g.cs @@ -0,0 +1,1055 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +#nullable enable + +namespace Mockolate.Setup +{ + /// + /// Sets up a indexer getter for , , , and . + /// + internal interface IIndexerGetterSetup + { + /// + /// Registers a to be invoked whenever the indexer's getter is accessed. + /// + IIndexerGetterSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Transitions the scenario to the given whenever the indexer is read. + /// + IIndexerGetterSetupParallelCallbackBuilder TransitionTo(string scenario); + } + + /// + /// Sets up a indexer getter for , , , and with callback support for the parameters. + /// + internal interface IIndexerGetterSetupWithCallback : global::Mockolate.Setup.IIndexerGetterSetup + { + /// + /// Registers a to be invoked whenever the indexer's getter is accessed. + /// + /// + /// The callback receives the parameters of the indexer. + /// + IIndexerGetterSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Registers a to be invoked whenever the indexer's getter is accessed. + /// + /// + /// The callback receives the parameters of the indexer and the value of the indexer as last parameter. + /// + IIndexerGetterSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Registers a to be invoked whenever the indexer's getter is accessed. + /// + /// + /// The callback receives an incrementing access counter as first parameter, the parameters of the indexer and the value of the indexer as last parameter. + /// + IIndexerGetterSetupCallbackBuilder Do(global::System.Action callback); + } + + /// + /// Sets up a indexer setter for , , , and . + /// + internal interface IIndexerSetterSetup + { + /// + /// Registers a to be invoked whenever the indexer's setter is accessed. + /// + IIndexerSetterSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Registers a to be invoked whenever the indexer's setter is accessed. + /// + /// + /// The callback receives the value the indexer is set to as single parameter. + /// + IIndexerSetterSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Transitions the scenario to the given whenever the indexer is written to. + /// + IIndexerSetterSetupParallelCallbackBuilder TransitionTo(string scenario); + } + + /// + /// Sets up a indexer setter for , , , and with callback support for the parameters. + /// + internal interface IIndexerSetterSetupWithCallback : global::Mockolate.Setup.IIndexerSetterSetup + { + /// + /// Registers a to be invoked whenever the indexer's setter is accessed. + /// + /// + /// The callback receives the parameters of the indexer and the value the indexer is set to as last parameter. + /// + IIndexerSetterSetupCallbackBuilder Do(global::System.Action callback); + + /// + /// Registers a to be invoked whenever the indexer's setter is accessed. + /// + /// + /// The callback receives an incrementing access counter as first parameter, the parameters of the indexer and the value the indexer is set to as last parameter. + /// + IIndexerSetterSetupCallbackBuilder Do(global::System.Action callback); + } + + /// + /// Sets up a indexer for , , , and . + /// + internal interface IIndexerSetup + { + /// + /// Sets up callbacks on the getter. + /// + IIndexerGetterSetupWithCallback OnGet { get; } + + /// + /// Sets up callbacks on the setter. + /// + IIndexerSetterSetupWithCallback OnSet { get; } + + /// + /// Overrides SkipBaseClass for this indexer only. + /// + /// + /// If not specified, use SkipBaseClass. + /// + global::Mockolate.Setup.IIndexerSetup SkippingBaseClass(bool skipBaseClass = true); + + /// + /// Initializes the indexer with the given . + /// + global::Mockolate.Setup.IIndexerSetup InitializeWith(TValue value); + + /// + /// Registers the for this indexer. + /// + IIndexerSetupReturnBuilder Returns(TValue returnValue); + + /// + /// Registers a to setup the return value for this indexer. + /// + IIndexerSetupReturnBuilder Returns(global::System.Func callback); + + /// + /// Registers an to throw when the indexer is read. + /// + IIndexerSetupReturnBuilder Throws() + where TException : global::System.Exception, new(); + + /// + /// Registers an to throw when the indexer is read. + /// + IIndexerSetupReturnBuilder Throws(global::System.Exception exception); + + /// + /// Registers a that will calculate the exception to throw when the indexer is read. + /// + IIndexerSetupReturnBuilder Throws(global::System.Func callback); + } + + /// + /// Sets up a indexer for , , , and with callback support for the parameters. + /// + internal interface IIndexerSetupWithCallback : global::Mockolate.Setup.IIndexerSetup + { + /// + /// Initializes the indexer according to the given . + /// + global::Mockolate.Setup.IIndexerSetup InitializeWith(global::System.Func valueGenerator); + + /// + /// Registers a to setup the return value for this indexer. + /// + /// + /// The callback receives the parameters of the indexer. + /// + IIndexerSetupReturnBuilder Returns(global::System.Func callback); + + /// + /// Registers a to setup the return value for this indexer. + /// + /// + /// The callback receives the parameters of the indexer and the value of the indexer as last parameter. + /// + IIndexerSetupReturnBuilder Returns(global::System.Func callback); + + /// + /// Registers a that will calculate the exception to throw when the indexer is read. + /// + /// + /// The callback receives the parameters of the indexer. + /// + IIndexerSetupReturnBuilder Throws(global::System.Func callback); + + /// + /// Registers a that will calculate the exception to throw when the indexer is read. + /// + /// + /// The callback receives the parameters of the indexer and the value of the indexer as last parameter. + /// + IIndexerSetupReturnBuilder Throws(global::System.Func callback); + } + + /// + /// Sets up a getter callback for a indexer for , , , and . + /// + internal interface IIndexerGetterSetupCallbackBuilder : IIndexerGetterSetupParallelCallbackBuilder + { + /// + /// Runs the callback in parallel to the other callbacks. + /// + IIndexerGetterSetupParallelCallbackBuilder InParallel(); + } + + /// + /// Sets up a parallel getter callback for a indexer for , , , and . + /// + internal interface IIndexerGetterSetupParallelCallbackBuilder : IIndexerGetterSetupCallbackWhenBuilder + { + /// + /// Limits the callback to only execute for indexer accesses where the predicate returns true. + /// + /// + /// Provides a zero-based counter indicating how many times the indexer has been accessed so far. + /// + IIndexerGetterSetupCallbackWhenBuilder When(global::System.Func predicate); + } + + /// + /// Sets up a when getter callback for a indexer for , , , and . + /// + internal interface IIndexerGetterSetupCallbackWhenBuilder : global::Mockolate.Setup.IIndexerSetupWithCallback + { + /// + /// Repeats the callback for the given number of . + /// + /// + /// The number of times is only counted for actual executions (IIndexerGetterSetupParallelCallbackBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). + /// + IIndexerGetterSetupCallbackWhenBuilder For(int times); + + /// + /// Deactivates the callback after the given number of . + /// + /// + /// The number of times is only counted for actual executions (IIndexerGetterSetupParallelCallbackBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IIndexerSetup Only(int times); + } + + /// + /// Sets up a setter callback for a indexer for , , , and . + /// + internal interface IIndexerSetterSetupCallbackBuilder : IIndexerSetterSetupParallelCallbackBuilder + { + /// + /// Runs the callback in parallel to the other callbacks. + /// + IIndexerSetterSetupParallelCallbackBuilder InParallel(); + } + + /// + /// Sets up a parallel setter callback for a indexer for , , , and . + /// + internal interface IIndexerSetterSetupParallelCallbackBuilder : IIndexerSetterSetupCallbackWhenBuilder + { + /// + /// Limits the callback to only execute for indexer accesses where the predicate returns true. + /// + /// + /// Provides a zero-based counter indicating how many times the indexer has been accessed so far. + /// + IIndexerSetterSetupCallbackWhenBuilder When(global::System.Func predicate); + } + + /// + /// Sets up a when setter callback for a indexer for , , , and . + /// + internal interface IIndexerSetterSetupCallbackWhenBuilder : global::Mockolate.Setup.IIndexerSetupWithCallback + { + /// + /// Repeats the callback for the given number of . + /// + /// + /// The number of times is only counted for actual executions (IIndexerSetterSetupParallelCallbackBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). + /// + IIndexerSetterSetupCallbackWhenBuilder For(int times); + + /// + /// Deactivates the callback after the given number of . + /// + /// + /// The number of times is only counted for actual executions (IIndexerSetterSetupParallelCallbackBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IIndexerSetup Only(int times); + } + + /// + /// Sets up a return/throw callback for a indexer for , , , and . + /// + internal interface IIndexerSetupReturnBuilder : IIndexerSetupReturnWhenBuilder + { + /// + /// Limits the return/throw callback to only execute for indexer accesses where the predicate returns true. + /// + /// + /// Provides a zero-based counter indicating how many times the indexer has been accessed so far. + /// + IIndexerSetupReturnWhenBuilder When(global::System.Func predicate); + } + + /// + /// Sets up a when return/throw callback for a indexer for , , , and . + /// + internal interface IIndexerSetupReturnWhenBuilder : global::Mockolate.Setup.IIndexerSetupWithCallback + { + /// + /// Repeats the return/throw callback for the given number of . + /// + /// + /// The number of times is only counted for actual executions (IIndexerSetupReturnBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). + /// + IIndexerSetupReturnWhenBuilder For(int times); + + /// + /// Deactivates the return/throw after the given number of . + /// + /// + /// The number of times is only counted for actual executions (IIndexerSetupReturnBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). + /// + global::Mockolate.Setup.IIndexerSetup Only(int times); + } + + /// + /// Sets up a indexer for , , , and . + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal class IndexerSetup(global::Mockolate.MockRegistry mockRegistry, global::Mockolate.Parameters.IParameterMatch parameter1, global::Mockolate.Parameters.IParameterMatch parameter2, global::Mockolate.Parameters.IParameterMatch parameter3, global::Mockolate.Parameters.IParameterMatch parameter4, global::Mockolate.Parameters.IParameterMatch parameter5) : global::Mockolate.Setup.IndexerSetup(mockRegistry), + global::Mockolate.Setup.IIndexerSetupWithCallback, + global::Mockolate.Setup.IIndexerGetterSetupCallbackBuilder, + global::Mockolate.Setup.IIndexerSetterSetupCallbackBuilder, + global::Mockolate.Setup.IIndexerSetupReturnBuilder, + global::Mockolate.Setup.IIndexerGetterSetupWithCallback, + global::Mockolate.Setup.IIndexerSetterSetupWithCallback + { + private Callbacks>? _getterCallbacks; + private Callbacks>? _setterCallbacks; + private Callbacks>? _returnCallbacks; + private bool? _skipBaseClass; + private global::System.Func? _initialization; + + /// + public global::Mockolate.Setup.IIndexerSetup SkippingBaseClass(bool skipBaseClass = true) + { + _skipBaseClass = skipBaseClass; + return this; + } + + /// + public global::Mockolate.Setup.IIndexerSetupWithCallback InitializeWith(TValue value) + { + if (_initialization is not null) + { + throw new global::Mockolate.Exceptions.MockException("The indexer is already initialized. You cannot initialize it twice."); + } + + _initialization = (_, _, _, _, _) => value; + return this; + } + + global::Mockolate.Setup.IIndexerSetup global::Mockolate.Setup.IIndexerSetup.InitializeWith(TValue value) + => InitializeWith(value); + + /// + public global::Mockolate.Setup.IIndexerSetup InitializeWith(global::System.Func valueGenerator) + { + if (_initialization is not null) + { + throw new global::Mockolate.Exceptions.MockException("The indexer is already initialized. You cannot initialize it twice."); + } + + _initialization = valueGenerator; + return this; + } + + /// + public IIndexerGetterSetupWithCallback OnGet + => this; + + /// + IIndexerGetterSetupCallbackBuilder IIndexerGetterSetup.Do(global::System.Action callback) + { + Callback>? currentCallback = new((_, _, _, _, _, _, _) => callback()); + _getterCallbacks = _getterCallbacks.Register(currentCallback); + return this; + } + + /// + IIndexerGetterSetupCallbackBuilder IIndexerGetterSetupWithCallback.Do(global::System.Action callback) + { + Callback>? currentCallback = new((_, p1, p2, p3, p4, p5, _) => callback(p1, p2, p3, p4, p5)); + _getterCallbacks = _getterCallbacks.Register(currentCallback); + return this; + } + + /// + IIndexerGetterSetupCallbackBuilder IIndexerGetterSetupWithCallback.Do(global::System.Action callback) + { + Callback>? currentCallback = new((_, p1, p2, p3, p4, p5, v) => callback(p1, p2, p3, p4, p5, v)); + _getterCallbacks = _getterCallbacks.Register(currentCallback); + return this; + } + + /// + IIndexerGetterSetupCallbackBuilder IIndexerGetterSetupWithCallback.Do(global::System.Action callback) + { + Callback>? currentCallback = new(callback); + _getterCallbacks = _getterCallbacks.Register(currentCallback); + return this; + } + + IIndexerGetterSetupParallelCallbackBuilder IIndexerGetterSetup.TransitionTo(string scenario) + { + Callback>? currentCallback = new((_, _, _, _, _, _, _) => TransitionScenario(scenario)); + currentCallback.InParallel(); + _getterCallbacks = _getterCallbacks.Register(currentCallback); + return this; + } + + /// + public IIndexerSetterSetupWithCallback OnSet + => this; + + /// + IIndexerSetterSetupCallbackBuilder IIndexerSetterSetup.Do(global::System.Action callback) + { + Callback>? currentCallback = new((_, _, _, _, _, _, _) => callback()); + _setterCallbacks = _setterCallbacks.Register(currentCallback); + return this; + } + + /// + IIndexerSetterSetupCallbackBuilder IIndexerSetterSetup.Do(global::System.Action callback) + { + Callback>? currentCallback = new((_, _, _, _, _, _, v) => callback(v)); + _setterCallbacks = _setterCallbacks.Register(currentCallback); + return this; + } + + /// + IIndexerSetterSetupCallbackBuilder IIndexerSetterSetupWithCallback.Do(global::System.Action callback) + { + Callback>? currentCallback = new((_, p1, p2, p3, p4, p5, v) => callback(p1, p2, p3, p4, p5, v)); + _setterCallbacks = _setterCallbacks.Register(currentCallback); + return this; + } + + /// + IIndexerSetterSetupCallbackBuilder IIndexerSetterSetupWithCallback.Do(global::System.Action callback) + { + Callback>? currentCallback = new(callback); + _setterCallbacks = _setterCallbacks.Register(currentCallback); + return this; + } + + IIndexerSetterSetupParallelCallbackBuilder IIndexerSetterSetup.TransitionTo(string scenario) + { + Callback>? currentCallback = new((_, _, _, _, _, _, _) => TransitionScenario(scenario)); + currentCallback.InParallel(); + _setterCallbacks = _setterCallbacks.Register(currentCallback); + return this; + } + + /// + public IIndexerSetupReturnBuilder Returns(TValue returnValue) + { + var currentCallback = new Callback>((_, _, _, _, _, _, _) => returnValue); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + public IIndexerSetupReturnBuilder Returns(global::System.Func callback) + { + var currentCallback = new Callback>((_, _, _, _, _, _, _) => callback()); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + public IIndexerSetupReturnBuilder Returns(global::System.Func callback) + { + var currentCallback = new Callback>((_, p1, p2, p3, p4, p5, _) => callback(p1, p2, p3, p4, p5)); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + public IIndexerSetupReturnBuilder Returns(global::System.Func callback) + { + var currentCallback = new Callback>((_, v, p1, p2, p3, p4, p5) => callback(v, p1, p2, p3, p4, p5)); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + public IIndexerSetupReturnBuilder Throws() + where TException : global::System.Exception, new() + { + var currentCallback = new Callback>((_, _, _, _, _, _, _) => throw new TException()); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + public IIndexerSetupReturnBuilder Throws(global::System.Exception exception) + { + var currentCallback = new Callback>((_, _, _, _, _, _, _) => throw exception); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + public IIndexerSetupReturnBuilder Throws(global::System.Func callback) + { + var currentCallback = new Callback>((_, _, _, _, _, _, _) => throw callback()); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + public IIndexerSetupReturnBuilder Throws(global::System.Func callback) + { + var currentCallback = new Callback>((_, p1, p2, p3, p4, p5, _) => throw callback(p1, p2, p3, p4, p5)); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + public IIndexerSetupReturnBuilder Throws(global::System.Func callback) + { + var currentCallback = new Callback>((_, p1, p2, p3, p4, p5, v) => throw callback(p1, p2, p3, p4, p5, v)); + _returnCallbacks = _returnCallbacks.Register(currentCallback); + return this; + } + + /// + IIndexerGetterSetupCallbackWhenBuilder IIndexerGetterSetupParallelCallbackBuilder.When(global::System.Func predicate) + { + _getterCallbacks?.Active?.When(predicate); + return this; + } + + /// + IIndexerGetterSetupParallelCallbackBuilder IIndexerGetterSetupCallbackBuilder.InParallel() + { + _getterCallbacks?.Active?.InParallel(); + return this; + } + + /// + IIndexerGetterSetupCallbackWhenBuilder IIndexerGetterSetupCallbackWhenBuilder.For(int times) + { + _getterCallbacks?.Active?.For(times); + return this; + } + + /// + global::Mockolate.Setup.IIndexerSetup IIndexerGetterSetupCallbackWhenBuilder.Only(int times) + { + _getterCallbacks?.Active?.Only(times); + return this; + } + + /// + IIndexerSetterSetupCallbackWhenBuilder IIndexerSetterSetupParallelCallbackBuilder.When(global::System.Func predicate) + { + _setterCallbacks?.Active?.When(predicate); + return this; + } + + /// + IIndexerSetterSetupParallelCallbackBuilder IIndexerSetterSetupCallbackBuilder.InParallel() + { + _setterCallbacks?.Active?.InParallel(); + return this; + } + + /// + IIndexerSetterSetupCallbackWhenBuilder IIndexerSetterSetupCallbackWhenBuilder.For(int times) + { + _setterCallbacks?.Active?.For(times); + return this; + } + + /// + global::Mockolate.Setup.IIndexerSetup IIndexerSetterSetupCallbackWhenBuilder.Only(int times) + { + _setterCallbacks?.Active?.Only(times); + return this; + } + + /// + IIndexerSetupReturnWhenBuilder IIndexerSetupReturnBuilder.When(global::System.Func predicate) + { + _returnCallbacks?.Active?.When(predicate); + return this; + } + + /// + IIndexerSetupReturnWhenBuilder IIndexerSetupReturnWhenBuilder.For(int times) + { + _returnCallbacks?.Active?.For(times); + return this; + } + + /// + global::Mockolate.Setup.IIndexerSetup IIndexerSetupReturnWhenBuilder.Only(int times) + { + _returnCallbacks?.Active?.Only(times); + return this; + } + + /// + /// Check if the setup matches the specified parameter values. + /// + public virtual bool Matches(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5) + { + if (!parameter1.Matches(p1) || !parameter2.Matches(p2) || !parameter3.Matches(p3) || !parameter4.Matches(p4) || !parameter5.Matches(p5)) + { + return false; + } + + parameter1.InvokeCallbacks(p1); + parameter2.InvokeCallbacks(p2); + parameter3.InvokeCallbacks(p3); + parameter4.InvokeCallbacks(p4); + parameter5.InvokeCallbacks(p5); + return true; + } + + /// + /// Check if the setup matches the specified parameter values. + /// + public virtual bool Matches(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, TValue value) + => Matches(p1, p2, p3, p4, p5); + + /// + protected override bool MatchesAccess(global::Mockolate.Interactions.IndexerAccess access) + { + if (access is global::Mockolate.Interactions.IndexerGetterAccess getter) + { + return Matches(getter.Parameter1, getter.Parameter2, getter.Parameter3, getter.Parameter4, getter.Parameter5); + } + + if (access is global::Mockolate.Interactions.IndexerSetterAccess setter) + { + return Matches(setter.Parameter1, setter.Parameter2, setter.Parameter3, setter.Parameter4, setter.Parameter5, setter.TypedValue); + } + + return false; + } + + /// + public override bool? SkipBaseClass() + => _skipBaseClass; + + /// + public override TResult GetResult(global::Mockolate.Interactions.IndexerAccess access, global::Mockolate.MockBehavior behavior, TResult baseValue) + { + if (!TryExtractParameters(access, out T1 p1, out T2 p2, out T3 p3, out T4 p4, out T5 p5)) + { + return baseValue; + } + + TValue currentValue = TryCast(baseValue, out TValue casted, behavior) ? casted : default!; + currentValue = ExecuteGetterCallbacks(p1, p2, p3, p4, p5, currentValue); + currentValue = ExecuteReturnCallbacks(p1, p2, p3, p4, p5, currentValue); + access.StoreValue(currentValue); + return TryCast(currentValue, out TResult result, behavior) ? result : baseValue; + } + + /// + public override TResult GetResult(global::Mockolate.Interactions.IndexerAccess access, global::Mockolate.MockBehavior behavior) + { + if (!TryExtractParameters(access, out T1 p1, out T2 p2, out T3 p3, out T4 p4, out T5 p5)) + { + return behavior.DefaultValue.Generate(default(TResult)!); + } + + TValue currentValue; + if (access.TryFindStoredValue(out TValue existing)) + { + currentValue = existing; + } + else if (_initialization is not null) + { + currentValue = _initialization.Invoke(p1, p2, p3, p4, p5); + } + else + { + currentValue = TryCast(behavior.DefaultValue.Generate(default(TValue)!), out TValue casted, behavior) ? casted : default!; + } + + currentValue = ExecuteGetterCallbacks(p1, p2, p3, p4, p5, currentValue); + currentValue = ExecuteReturnCallbacks(p1, p2, p3, p4, p5, currentValue); + access.StoreValue(currentValue); + return TryCast(currentValue, out TResult result, behavior) ? result : behavior.DefaultValue.Generate(default(TResult)!); + } + + /// + public override TResult GetResult(global::Mockolate.Interactions.IndexerAccess access, global::Mockolate.MockBehavior behavior, global::System.Func defaultValueGenerator) + { + if (!TryExtractParameters(access, out T1 p1, out T2 p2, out T3 p3, out T4 p4, out T5 p5)) + { + return defaultValueGenerator(); + } + + TValue currentValue; + if (access.TryFindStoredValue(out TValue existing)) + { + currentValue = existing; + } + else if (_initialization is not null) + { + currentValue = _initialization.Invoke(p1, p2, p3, p4, p5); + } + else + { + currentValue = TryCast(defaultValueGenerator(), out TValue casted, behavior) ? casted : default!; + } + + currentValue = ExecuteGetterCallbacks(p1, p2, p3, p4, p5, currentValue); + currentValue = ExecuteReturnCallbacks(p1, p2, p3, p4, p5, currentValue); + access.StoreValue(currentValue); + return TryCast(currentValue, out TResult result, behavior) ? result : defaultValueGenerator(); + } + + /// + public override void SetResult(global::Mockolate.Interactions.IndexerAccess access, global::Mockolate.MockBehavior behavior, TResult value) + { + access.StoreValue(value); + if (!TryExtractParameters(access, out T1 p1, out T2 p2, out T3 p3, out T4 p4, out T5 p5)) + { + return; + } + + if (!TryCast(value, out TValue resultValue, behavior)) + { + return; + } + + if (_setterCallbacks is not null) + { + bool wasInvoked = false; + int currentSetterCallbacksIndex = _setterCallbacks.CurrentIndex; + for (int i = 0; i < _setterCallbacks.Count; i++) + { + Callback> setterCallback = + _setterCallbacks[(currentSetterCallbacksIndex + i) % _setterCallbacks.Count]; + if (setterCallback.Invoke(wasInvoked, ref _setterCallbacks.CurrentIndex, (p1, p2, p3, p4, p5, resultValue), + static (count, @delegate, state) => @delegate(count, state.p1, state.p2, state.p3, state.p4, state.p5, state.resultValue))) + { + wasInvoked = true; + } + } + } + } + + private TValue ExecuteGetterCallbacks(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, TValue currentValue) + { + if (_getterCallbacks is not null) + { + bool wasInvoked = false; + int currentGetterCallbacksIndex = _getterCallbacks.CurrentIndex; + for (int i = 0; i < _getterCallbacks.Count; i++) + { + Callback> getterCallback = + _getterCallbacks[(currentGetterCallbacksIndex + i) % _getterCallbacks.Count]; + if (getterCallback.Invoke(wasInvoked, ref _getterCallbacks.CurrentIndex, (p1, p2, p3, p4, p5, currentValue), + static (count, @delegate, state) => @delegate(count, state.p1, state.p2, state.p3, state.p4, state.p5, state.currentValue))) + { + wasInvoked = true; + } + } + } + + return currentValue; + } + + private TValue ExecuteReturnCallbacks(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, TValue currentValue) + { + if (_returnCallbacks is not null) + { + foreach (Callback> _ in _returnCallbacks) + { + Callback> returnCallback = + _returnCallbacks[_returnCallbacks.CurrentIndex % _returnCallbacks.Count]; + if (returnCallback.Invoke(ref _returnCallbacks.CurrentIndex, (p1, p2, p3, p4, p5, currentValue), + static (count, @delegate, state) => @delegate(count, state.p1, state.p2, state.p3, state.p4, state.p5, state.currentValue), + out TValue? newValue)) + { + return newValue!; + } + } + } + + return currentValue; + } + + private static bool TryExtractParameters(global::Mockolate.Interactions.IndexerAccess access, out T1 p1, out T2 p2, out T3 p3, out T4 p4, out T5 p5) + { + if (access is global::Mockolate.Interactions.IndexerGetterAccess getter) + { + p1 = getter.Parameter1; + p2 = getter.Parameter2; + p3 = getter.Parameter3; + p4 = getter.Parameter4; + p5 = getter.Parameter5; + return true; + } + + if (access is global::Mockolate.Interactions.IndexerSetterAccess setter) + { + p1 = setter.Parameter1; + p2 = setter.Parameter2; + p3 = setter.Parameter3; + p4 = setter.Parameter4; + p5 = setter.Parameter5; + return true; + } + + p1 = default!; + p2 = default!; + p3 = default!; + p4 = default!; + p5 = default!; + return false; + } + + /// + public override string ToString() + => $"{FormatType(typeof(TValue))} this[{parameter1}, {parameter2}, {parameter3}, {parameter4}, {parameter5}]"; + + } + +} + +namespace Mockolate +{ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal static class IndexerSetupExtensions + { + + /// + /// Extensions for indexer getter callback setups with 5 parameters. + /// + extension(Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder setup) + { + /// + /// Executes the callback only once. + /// + public global::Mockolate.Setup.IIndexerSetup OnlyOnce() + => setup.Only(1); + } + + /// + /// Extensions for indexer setter callback setups with 5 parameters. + /// + extension(Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder setup) + { + /// + /// Executes the callback only once. + /// + public global::Mockolate.Setup.IIndexerSetup OnlyOnce() + => setup.Only(1); + } + + /// + /// Extensions for indexer setups with 5 parameters. + /// + extension(Mockolate.Setup.IIndexerSetupReturnWhenBuilder setup) + { + /// + /// Returns/throws forever. + /// + public void Forever() + { + setup.For(int.MaxValue); + } + + /// + /// Uses the return value only once. + /// + public global::Mockolate.Setup.IIndexerSetup OnlyOnce() + => setup.Only(1); + } + } +} +namespace Mockolate.Interactions +{ + /// + /// An access of an indexer getter with 5 typed parameters. + /// + [global::System.Diagnostics.DebuggerDisplay("{ToString()}")] + internal class IndexerGetterAccess(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5) + : global::Mockolate.Interactions.IndexerAccess + { + /// + /// The value of parameter 1. + /// + public T1 Parameter1 { get; } = parameter1; + /// + /// The value of parameter 2. + /// + public T2 Parameter2 { get; } = parameter2; + /// + /// The value of parameter 3. + /// + public T3 Parameter3 { get; } = parameter3; + /// + /// The value of parameter 4. + /// + public T4 Parameter4 { get; } = parameter4; + /// + /// The value of parameter 5. + /// + public T5 Parameter5 { get; } = parameter5; + /// + public override int ParameterCount => 5; + /// + public override object? GetParameterValueAt(int index) + => index switch + { + 0 => Parameter1, + 1 => Parameter2, + 2 => Parameter3, + 3 => Parameter4, + 4 => Parameter5, + _ => null, + }; + /// + protected override global::Mockolate.Setup.IndexerValueStorage? TraverseStorage(global::Mockolate.Setup.IndexerValueStorage? storage, bool createMissing) + { + global::Mockolate.Setup.IndexerValueStorage? s = storage; + if (s is null) + { + return null; + } + s = createMissing ? s.GetOrAddChildDispatch(Parameter1) : s.GetChildDispatch(Parameter1); + if (s is null) + { + return null; + } + s = createMissing ? s.GetOrAddChildDispatch(Parameter2) : s.GetChildDispatch(Parameter2); + if (s is null) + { + return null; + } + s = createMissing ? s.GetOrAddChildDispatch(Parameter3) : s.GetChildDispatch(Parameter3); + if (s is null) + { + return null; + } + s = createMissing ? s.GetOrAddChildDispatch(Parameter4) : s.GetChildDispatch(Parameter4); + if (s is null) + { + return null; + } + return createMissing ? s.GetOrAddChildDispatch(Parameter5) : s.GetChildDispatch(Parameter5); + } + /// + public override string ToString() + => $"get indexer [{Parameter1?.ToString() ?? "null"}, {Parameter2?.ToString() ?? "null"}, {Parameter3?.ToString() ?? "null"}, {Parameter4?.ToString() ?? "null"}, {Parameter5?.ToString() ?? "null"}]"; + } + /// + /// An access of an indexer setter with 5 typed parameters. + /// + [global::System.Diagnostics.DebuggerDisplay("{ToString()}")] + internal class IndexerSetterAccess(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, TValue value) + : global::Mockolate.Interactions.IndexerAccess + { + /// + /// The value of parameter 1. + /// + public T1 Parameter1 { get; } = parameter1; + /// + /// The value of parameter 2. + /// + public T2 Parameter2 { get; } = parameter2; + /// + /// The value of parameter 3. + /// + public T3 Parameter3 { get; } = parameter3; + /// + /// The value of parameter 4. + /// + public T4 Parameter4 { get; } = parameter4; + /// + /// The value of parameter 5. + /// + public T5 Parameter5 { get; } = parameter5; + /// + /// The typed value the indexer was being set to. + /// + public TValue TypedValue { get; } = value; + /// + public override int ParameterCount => 5; + /// + public override object? GetParameterValueAt(int index) + => index switch + { + 0 => Parameter1, + 1 => Parameter2, + 2 => Parameter3, + 3 => Parameter4, + 4 => Parameter5, + _ => null, + }; + /// + protected override global::Mockolate.Setup.IndexerValueStorage? TraverseStorage(global::Mockolate.Setup.IndexerValueStorage? storage, bool createMissing) + { + global::Mockolate.Setup.IndexerValueStorage? s = storage; + if (s is null) + { + return null; + } + s = createMissing ? s.GetOrAddChildDispatch(Parameter1) : s.GetChildDispatch(Parameter1); + if (s is null) + { + return null; + } + s = createMissing ? s.GetOrAddChildDispatch(Parameter2) : s.GetChildDispatch(Parameter2); + if (s is null) + { + return null; + } + s = createMissing ? s.GetOrAddChildDispatch(Parameter3) : s.GetChildDispatch(Parameter3); + if (s is null) + { + return null; + } + s = createMissing ? s.GetOrAddChildDispatch(Parameter4) : s.GetChildDispatch(Parameter4); + if (s is null) + { + return null; + } + return createMissing ? s.GetOrAddChildDispatch(Parameter5) : s.GetChildDispatch(Parameter5); + } + /// + public override string ToString() + => $"set indexer [{Parameter1?.ToString() ?? "null"}, {Parameter2?.ToString() ?? "null"}, {Parameter3?.ToString() ?? "null"}, {Parameter4?.ToString() ?? "null"}, {Parameter5?.ToString() ?? "null"}] to {TypedValue?.ToString() ?? "null"}"; + } +} + +#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/Mock.IUnionIndexers.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/Mock.IUnionIndexers.g.cs new file mode 100644 index 00000000..5dfd94ba --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/Mock.IUnionIndexers.g.cs @@ -0,0 +1,2892 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +#nullable enable annotations +namespace Mockolate; + +internal static partial class Mock +{ + /// + /// A mock implementation for IUnionIndexers. + /// + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal class IUnionIndexers : + global::Mockolate.Tests.GeneratorCoverage.IUnionIndexers, IMockForIUnionIndexers, IMockSetupForIUnionIndexers, IMockVerifyForIUnionIndexers, + global::Mockolate.IMock + { + internal const int MemberId_Indexer_int_Get = 0; + internal const int MemberId_Indexer_int_Set = 1; + internal const int MemberId_Indexer_byte_byte_Get = 2; + internal const int MemberId_Indexer_byte_byte_Set = 3; + internal const int MemberId_Indexer_short_short_short_Get = 4; + internal const int MemberId_Indexer_short_short_short_Set = 5; + internal const int MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get = 6; + internal const int MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Set = 7; + internal const int MemberId_Indexer_int_int_int_int_int_Get = 8; + internal const int MemberId_Indexer_int_int_int_int_int_Set = 9; + internal const int MemberCount = 10; + + /// + /// Creates a FastMockInteractions sized to MemberCount for use as the mock's interaction store. + /// Per-member buffers are not allocated up-front: the recording hot paths call GetOrCreateBuffer<TBuffer>(int, Func<FastMockInteractions, TBuffer>) so a slot is materialized only when its member is first invoked. + /// + internal static global::Mockolate.Interactions.FastMockInteractions CreateFastInteractions(global::Mockolate.MockBehavior behavior) + => new global::Mockolate.Interactions.FastMockInteractions(MemberCount, behavior.SkipInteractionRecording); + + /// + /// Builds a MockRegistry backed by a typed-buffer-sized FastMockInteractions from . + /// + private static global::Mockolate.MockRegistry MockolateCreateRegistryFromBehavior(global::Mockolate.MockBehavior behavior) + { + global::Mockolate.MockRegistry registry = new global::Mockolate.MockRegistry(behavior, MemberCount); + return registry; + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.MockRegistry global::Mockolate.IMock.MockRegistry => this.MockRegistry; + private global::Mockolate.MockRegistry MockRegistry { get; } + + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastIndexerGetterBuffer MockolateBuffer_Indexer_int_Get + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_int_Get, static fast => new global::Mockolate.Interactions.FastIndexerGetterBuffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastIndexerSetterBuffer MockolateBuffer_Indexer_int_Set + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_int_Set, static fast => new global::Mockolate.Interactions.FastIndexerSetterBuffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastIndexerGetterBuffer MockolateBuffer_Indexer_byte_byte_Get + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_byte_byte_Get, static fast => new global::Mockolate.Interactions.FastIndexerGetterBuffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastIndexerSetterBuffer MockolateBuffer_Indexer_byte_byte_Set + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_byte_byte_Set, static fast => new global::Mockolate.Interactions.FastIndexerSetterBuffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastIndexerGetterBuffer MockolateBuffer_Indexer_short_short_short_Get + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Get, static fast => new global::Mockolate.Interactions.FastIndexerGetterBuffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastIndexerSetterBuffer MockolateBuffer_Indexer_short_short_short_Set + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Set, static fast => new global::Mockolate.Interactions.FastIndexerSetterBuffer(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastIndexerGetterBuffer, int, string, bool> MockolateBuffer_Indexer_global__System_Func_int__bool__int_string_bool_Get + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer, int, string, bool>>(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, static fast => new global::Mockolate.Interactions.FastIndexerGetterBuffer, int, string, bool>(fast))); + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + private global::Mockolate.Interactions.FastIndexerSetterBuffer, int, string, bool, string> MockolateBuffer_Indexer_global__System_Func_int__bool__int_string_bool_Set + => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer, int, string, bool, string>>(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Set, static fast => new global::Mockolate.Interactions.FastIndexerSetterBuffer, int, string, bool, string>(fast))); + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + IMockSetupForIUnionIndexers IMockForIUnionIndexers.Setup + => this; + /// + IMockInScenarioForIUnionIndexers IMockForIUnionIndexers.InScenario(string scenario) + => new MockInScenarioForIUnionIndexers(this.MockRegistry, scenario); + + /// + IMockForIUnionIndexers IMockForIUnionIndexers.InScenario(string scenario, global::System.Action setup) + { + setup.Invoke(new MockInScenarioForIUnionIndexers(this.MockRegistry, scenario)); + return this; + } + + /// + IMockForIUnionIndexers IMockForIUnionIndexers.TransitionTo(string scenario) + { + this.MockRegistry.TransitionTo(scenario); + return this; + } + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + IMockVerifyForIUnionIndexers IMockForIUnionIndexers.Verify + => this; + /// + global::Mockolate.Verify.VerificationResult IMockForIUnionIndexers.VerifySetup(global::Mockolate.Setup.IMethodSetup setup) + => this.MockRegistry.Method(this, setup); + /// + bool IMockForIUnionIndexers.VerifyThatAllInteractionsAreVerified() + => this.MockRegistry.Interactions.GetUnverifiedInteractions().Count == 0; + /// + bool IMockForIUnionIndexers.VerifyThatAllSetupsAreUsed() + => this.MockRegistry.GetUnusedSetups(this.MockRegistry.Interactions).Count == 0; + /// + void IMockForIUnionIndexers.ClearAllInteractions() + => this.MockRegistry.ClearAllInteractions(); + /// + global::Mockolate.Monitor.MockMonitor IMockForIUnionIndexers.Monitor() + => new global::Mockolate.Monitor.MockMonitor(this.MockRegistry.Interactions, interactions => new VerifyMonitorIUnionIndexers(new global::Mockolate.MockRegistry(this.MockRegistry, interactions))); + + /// + string global::Mockolate.IMock.ToString() + => "Mockolate.Tests.GeneratorCoverage.IUnionIndexers mock"; + + /// + public IUnionIndexers(global::Mockolate.MockRegistry mockRegistry) + { + this.MockRegistry = mockRegistry; + } + + /// + public IUnionIndexers(global::Mockolate.MockBehavior behavior) + : this(MockolateCreateRegistryFromBehavior(behavior)) + { + } + + #region Mockolate.Tests.GeneratorCoverage.IUnionIndexers + + /// + public string this[int key] + { + get + { + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_Indexer_int_Get.Append(key); + } + global::Mockolate.Setup.IndexerSetup? setup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.IndexerSetup[]? snapshot_setup = this.MockRegistry.GetIndexerSetupSnapshot(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_int_Get); + if (snapshot_setup is not null) + { + for (int i_setup = snapshot_setup.Length - 1; i_setup >= 0; i_setup--) + { + if (snapshot_setup[i_setup] is global::Mockolate.Setup.IndexerSetup s_setup && s_setup.Matches(key)) + { + setup = s_setup; + break; + } + } + } + } + global::Mockolate.Interactions.IndexerGetterAccess access = new(key); + setup ??= this.MockRegistry.GetIndexerSetup>(access); + if (this.MockRegistry.Wraps is not global::Mockolate.Tests.GeneratorCoverage.IUnionIndexers wraps) + { + return setup is null + ? this.MockRegistry.GetIndexerFallback(access, 0) + : this.MockRegistry.ApplyIndexerSetup(access, setup, 0); + } + string baseResult = wraps[key]; + return this.MockRegistry.ApplyIndexerGetter(access, setup, baseResult, 0); + } + set + { + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_Indexer_int_Set.Append(key, value); + } + global::Mockolate.Setup.IndexerSetup? setup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.IndexerSetup[]? snapshot_setup = this.MockRegistry.GetIndexerSetupSnapshot(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_int_Get); + if (snapshot_setup is not null) + { + for (int i_setup = snapshot_setup.Length - 1; i_setup >= 0; i_setup--) + { + if (snapshot_setup[i_setup] is global::Mockolate.Setup.IndexerSetup s_setup && s_setup.Matches(key, value)) + { + setup = s_setup; + break; + } + } + } + } + global::Mockolate.Interactions.IndexerSetterAccess access = new(key, value); + setup ??= this.MockRegistry.GetIndexerSetup>(access); + this.MockRegistry.ApplyIndexerSetter(access, setup, value, 0); + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IUnionIndexers wraps) + { + wraps[key] = value; + } + } + } + + /// + public long this[byte a, byte b] + { + get + { + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_Indexer_byte_byte_Get.Append(a, b); + } + global::Mockolate.Setup.IndexerSetup? setup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.IndexerSetup[]? snapshot_setup = this.MockRegistry.GetIndexerSetupSnapshot(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_byte_byte_Get); + if (snapshot_setup is not null) + { + for (int i_setup = snapshot_setup.Length - 1; i_setup >= 0; i_setup--) + { + if (snapshot_setup[i_setup] is global::Mockolate.Setup.IndexerSetup s_setup && s_setup.Matches(a, b)) + { + setup = s_setup; + break; + } + } + } + } + global::Mockolate.Interactions.IndexerGetterAccess access = new(a, b); + setup ??= this.MockRegistry.GetIndexerSetup>(access); + if (this.MockRegistry.Wraps is not global::Mockolate.Tests.GeneratorCoverage.IUnionIndexers wraps) + { + return setup is null + ? this.MockRegistry.GetIndexerFallback(access, 1) + : this.MockRegistry.ApplyIndexerSetup(access, setup, 1); + } + long baseResult = wraps[a, b]; + return this.MockRegistry.ApplyIndexerGetter(access, setup, baseResult, 1); + } + } + + /// + public long this[short a, short b, short c] + { + set + { + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_Indexer_short_short_short_Set.Append(a, b, c, value); + } + global::Mockolate.Setup.IndexerSetup? setup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.IndexerSetup[]? snapshot_setup = this.MockRegistry.GetIndexerSetupSnapshot(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Get); + if (snapshot_setup is not null) + { + for (int i_setup = snapshot_setup.Length - 1; i_setup >= 0; i_setup--) + { + if (snapshot_setup[i_setup] is global::Mockolate.Setup.IndexerSetup s_setup && s_setup.Matches(a, b, c, value)) + { + setup = s_setup; + break; + } + } + } + } + global::Mockolate.Interactions.IndexerSetterAccess access = new(a, b, c, value); + setup ??= this.MockRegistry.GetIndexerSetup>(access); + this.MockRegistry.ApplyIndexerSetter(access, setup, value, 2); + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IUnionIndexers wraps) + { + wraps[a, b, c] = value; + } + } + } + + /// + public string this[global::System.Func selector, int key, string name, bool flag] + { + get + { + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockolateBuffer_Indexer_global__System_Func_int__bool__int_string_bool_Get.Append(selector, key, name, flag); + } + global::Mockolate.Setup.IndexerSetup, int, string, bool>? setup = null; + if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) + { + global::Mockolate.Setup.IndexerSetup[]? snapshot_setup = this.MockRegistry.GetIndexerSetupSnapshot(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get); + if (snapshot_setup is not null) + { + for (int i_setup = snapshot_setup.Length - 1; i_setup >= 0; i_setup--) + { + if (snapshot_setup[i_setup] is global::Mockolate.Setup.IndexerSetup, int, string, bool> s_setup && s_setup.Matches(selector, key, name, flag)) + { + setup = s_setup; + break; + } + } + } + } + global::Mockolate.Interactions.IndexerGetterAccess, int, string, bool> access = new(selector, key, name, flag); + setup ??= this.MockRegistry.GetIndexerSetup, int, string, bool>>(access); + if (this.MockRegistry.Wraps is not global::Mockolate.Tests.GeneratorCoverage.IUnionIndexers wraps) + { + return setup is null + ? this.MockRegistry.GetIndexerFallback(access, 3) + : this.MockRegistry.ApplyIndexerSetup(access, setup, 3); + } + string baseResult = wraps[selector, key, name, flag]; + return this.MockRegistry.ApplyIndexerGetter(access, setup, baseResult, 3); + } + } + + /// + public string this[int a, int b, int c, int d, int e] + { + get + { + global::Mockolate.Interactions.IndexerGetterAccess access = new(a, b, c, d, e); + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockRegistry.RegisterInteraction(access); + } + global::Mockolate.Setup.IndexerSetup? setup = this.MockRegistry.GetIndexerSetup>(access); + if (this.MockRegistry.Wraps is not global::Mockolate.Tests.GeneratorCoverage.IUnionIndexers wraps) + { + return setup is null + ? this.MockRegistry.GetIndexerFallback(access, 4) + : this.MockRegistry.ApplyIndexerSetup(access, setup, 4); + } + string baseResult = wraps[a, b, c, d, e]; + return this.MockRegistry.ApplyIndexerGetter(access, setup, baseResult, 4); + } + set + { + global::Mockolate.Interactions.IndexerSetterAccess access = new(a, b, c, d, e, value); + if (this.MockRegistry.Behavior.SkipInteractionRecording == false) + { + this.MockRegistry.RegisterInteraction(access); + } + global::Mockolate.Setup.IndexerSetup? setup = this.MockRegistry.GetIndexerSetup>(access); + this.MockRegistry.ApplyIndexerSetter(access, setup, value, 4); + if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.IUnionIndexers wraps) + { + wraps[a, b, c, d, e] = value; + } + } + } + + #endregion Mockolate.Tests.GeneratorCoverage.IUnionIndexers + + #region IMockSetupForIUnionIndexers + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg? parameter1] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (parameter1 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_int_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, string parameter1Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter1, parameter1Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_int_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg? parameter1, global::Mockolate.ParameterArg? parameter2] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (parameter2 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_byte_byte_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, string parameter1Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter1, parameter1Expression), (parameter2 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_byte_byte_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg? parameter1, global::System.Func parameter2, string parameter2Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_byte_byte_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::System.Func parameter2, string parameter1Expression, string parameter2Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter1, parameter1Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_byte_byte_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg? parameter1, global::Mockolate.ParameterArg? parameter2, global::Mockolate.ParameterArg? parameter3] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (parameter2 ?? default).ToParameterMatch(), (parameter3 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, global::Mockolate.ParameterArg? parameter3, string parameter1Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter1, parameter1Expression), (parameter2 ?? default).ToParameterMatch(), (parameter3 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg? parameter1, global::System.Func parameter2, global::Mockolate.ParameterArg? parameter3, string parameter2Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (parameter3 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::System.Func parameter2, global::Mockolate.ParameterArg? parameter3, string parameter1Expression, string parameter2Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter1, parameter1Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (parameter3 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg? parameter1, global::Mockolate.ParameterArg? parameter2, global::System.Func parameter3, string parameter3Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (parameter2 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, global::System.Func parameter3, string parameter1Expression, string parameter3Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter1, parameter1Expression), (parameter2 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg? parameter1, global::System.Func parameter2, global::System.Func parameter3, string parameter2Expression, string parameter3Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::System.Func parameter2, global::System.Func parameter3, string parameter1Expression, string parameter2Expression, string parameter3Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter1, parameter1Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg>? parameter1, global::Mockolate.ParameterArg? parameter2, global::Mockolate.ParameterArg? parameter3, global::Mockolate.ParameterArg? parameter4] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (parameter2 ?? default).ToParameterMatch(), (parameter3 ?? default).ToParameterMatch(), (parameter4 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, global::Mockolate.ParameterArg? parameter3, global::Mockolate.ParameterArg? parameter4] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(parameter1), (parameter2 ?? default).ToParameterMatch(), (parameter3 ?? default).ToParameterMatch(), (parameter4 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg>? parameter1, global::System.Func parameter2, global::Mockolate.ParameterArg? parameter3, global::Mockolate.ParameterArg? parameter4, string parameter2Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (parameter3 ?? default).ToParameterMatch(), (parameter4 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::System.Func parameter2, global::Mockolate.ParameterArg? parameter3, global::Mockolate.ParameterArg? parameter4, string parameter2Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(parameter1), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (parameter3 ?? default).ToParameterMatch(), (parameter4 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg>? parameter1, global::Mockolate.ParameterArg? parameter2, global::System.Func parameter3, global::Mockolate.ParameterArg? parameter4, string parameter3Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (parameter2 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression), (parameter4 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, global::System.Func parameter3, global::Mockolate.ParameterArg? parameter4, string parameter3Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(parameter1), (parameter2 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression), (parameter4 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg>? parameter1, global::System.Func parameter2, global::System.Func parameter3, global::Mockolate.ParameterArg? parameter4, string parameter2Expression, string parameter3Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression), (parameter4 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::System.Func parameter2, global::System.Func parameter3, global::Mockolate.ParameterArg? parameter4, string parameter2Expression, string parameter3Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(parameter1), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression), (parameter4 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg>? parameter1, global::Mockolate.ParameterArg? parameter2, global::Mockolate.ParameterArg? parameter3, global::System.Func parameter4, string parameter4Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (parameter2 ?? default).ToParameterMatch(), (parameter3 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter4, parameter4Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, global::Mockolate.ParameterArg? parameter3, global::System.Func parameter4, string parameter4Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(parameter1), (parameter2 ?? default).ToParameterMatch(), (parameter3 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter4, parameter4Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg>? parameter1, global::System.Func parameter2, global::Mockolate.ParameterArg? parameter3, global::System.Func parameter4, string parameter2Expression, string parameter4Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (parameter3 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter4, parameter4Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::System.Func parameter2, global::Mockolate.ParameterArg? parameter3, global::System.Func parameter4, string parameter2Expression, string parameter4Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(parameter1), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (parameter3 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter4, parameter4Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg>? parameter1, global::Mockolate.ParameterArg? parameter2, global::System.Func parameter3, global::System.Func parameter4, string parameter3Expression, string parameter4Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (parameter2 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter4, parameter4Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, global::System.Func parameter3, global::System.Func parameter4, string parameter3Expression, string parameter4Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(parameter1), (parameter2 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter4, parameter4Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg>? parameter1, global::System.Func parameter2, global::System.Func parameter3, global::System.Func parameter4, string parameter2Expression, string parameter3Expression, string parameter4Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter4, parameter4Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::System.Func parameter2, global::System.Func parameter3, global::System.Func parameter4, string parameter2Expression, string parameter3Expression, string parameter4Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(parameter1), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter4, parameter4Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg? parameter1, global::Mockolate.ParameterArg? parameter2, global::Mockolate.ParameterArg? parameter3, global::Mockolate.ParameterArg? parameter4, global::Mockolate.ParameterArg? parameter5] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (parameter2 ?? default).ToParameterMatch(), (parameter3 ?? default).ToParameterMatch(), (parameter4 ?? default).ToParameterMatch(), (parameter5 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_int_int_int_int_int_Get, indexerSetup); + return indexerSetup; + } + } + + #endregion IMockSetupForIUnionIndexers + + #region IMockVerifyForIUnionIndexers + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg? key] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_int_Get, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_int_Set, + (key ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}]", (object?)(key ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIUnionIndexers.this[global::System.Func key, string keyExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_int_Get, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_int_Set, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(key, keyExpression), + () => global::System.String.Format("[{0}]", (object?)keyExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg? a, global::Mockolate.ParameterArg? b] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_byte_byte_Get, + (a ?? default).ToParameterMatch(), + (b ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}]", (object?)(a ?? default), (object?)(b ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult IMockVerifyForIUnionIndexers.this[global::System.Func a, global::Mockolate.ParameterArg? b, string aExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_byte_byte_Get, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(a, aExpression), + (b ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}]", (object?)aExpression, (object?)(b ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg? a, global::System.Func b, string bExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_byte_byte_Get, + (a ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(b, bExpression), + () => global::System.String.Format("[{0}, {1}]", (object?)(a ?? default), (object?)bExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult IMockVerifyForIUnionIndexers.this[global::System.Func a, global::System.Func b, string aExpression, string bExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_byte_byte_Get, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(a, aExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(b, bExpression), + () => global::System.String.Format("[{0}, {1}]", (object?)aExpression, (object?)bExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg? a, global::Mockolate.ParameterArg? b, global::Mockolate.ParameterArg? c] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Set, + (a ?? default).ToParameterMatch(), + (b ?? default).ToParameterMatch(), + (c ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}]", (object?)(a ?? default), (object?)(b ?? default), (object?)(c ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIUnionIndexers.this[global::System.Func a, global::Mockolate.ParameterArg? b, global::Mockolate.ParameterArg? c, string aExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Set, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(a, aExpression), + (b ?? default).ToParameterMatch(), + (c ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}]", (object?)aExpression, (object?)(b ?? default), (object?)(c ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg? a, global::System.Func b, global::Mockolate.ParameterArg? c, string bExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Set, + (a ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(b, bExpression), + (c ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}]", (object?)(a ?? default), (object?)bExpression, (object?)(c ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIUnionIndexers.this[global::System.Func a, global::System.Func b, global::Mockolate.ParameterArg? c, string aExpression, string bExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Set, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(a, aExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(b, bExpression), + (c ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}]", (object?)aExpression, (object?)bExpression, (object?)(c ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg? a, global::Mockolate.ParameterArg? b, global::System.Func c, string cExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Set, + (a ?? default).ToParameterMatch(), + (b ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(c, cExpression), + () => global::System.String.Format("[{0}, {1}, {2}]", (object?)(a ?? default), (object?)(b ?? default), (object?)cExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIUnionIndexers.this[global::System.Func a, global::Mockolate.ParameterArg? b, global::System.Func c, string aExpression, string cExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Set, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(a, aExpression), + (b ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(c, cExpression), + () => global::System.String.Format("[{0}, {1}, {2}]", (object?)aExpression, (object?)(b ?? default), (object?)cExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg? a, global::System.Func b, global::System.Func c, string bExpression, string cExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Set, + (a ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(b, bExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(c, cExpression), + () => global::System.String.Format("[{0}, {1}, {2}]", (object?)(a ?? default), (object?)bExpression, (object?)cExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIUnionIndexers.this[global::System.Func a, global::System.Func b, global::System.Func c, string aExpression, string bExpression, string cExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Set, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(a, aExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(b, bExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(c, cExpression), + () => global::System.String.Format("[{0}, {1}, {2}]", (object?)aExpression, (object?)bExpression, (object?)cExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg>? selector, global::Mockolate.ParameterArg? key, global::Mockolate.ParameterArg? name, global::Mockolate.ParameterArg? flag] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (selector ?? default).ToParameterMatch(), + (key ?? default).ToParameterMatch(), + (name ?? default).ToParameterMatch(), + (flag ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)(selector ?? default), (object?)(key ?? default), (object?)(name ?? default), (object?)(flag ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::System.Func selector, global::Mockolate.ParameterArg? key, global::Mockolate.ParameterArg? name, global::Mockolate.ParameterArg? flag] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(selector), + (key ?? default).ToParameterMatch(), + (name ?? default).ToParameterMatch(), + (flag ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)selector ?? "null", (object?)(key ?? default), (object?)(name ?? default), (object?)(flag ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg>? selector, global::System.Func key, global::Mockolate.ParameterArg? name, global::Mockolate.ParameterArg? flag, string keyExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (selector ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(key, keyExpression), + (name ?? default).ToParameterMatch(), + (flag ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)(selector ?? default), (object?)keyExpression, (object?)(name ?? default), (object?)(flag ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::System.Func selector, global::System.Func key, global::Mockolate.ParameterArg? name, global::Mockolate.ParameterArg? flag, string keyExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(selector), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(key, keyExpression), + (name ?? default).ToParameterMatch(), + (flag ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)selector ?? "null", (object?)keyExpression, (object?)(name ?? default), (object?)(flag ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg>? selector, global::Mockolate.ParameterArg? key, global::System.Func name, global::Mockolate.ParameterArg? flag, string nameExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (selector ?? default).ToParameterMatch(), + (key ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(name, nameExpression), + (flag ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)(selector ?? default), (object?)(key ?? default), (object?)nameExpression, (object?)(flag ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::System.Func selector, global::Mockolate.ParameterArg? key, global::System.Func name, global::Mockolate.ParameterArg? flag, string nameExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(selector), + (key ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(name, nameExpression), + (flag ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)selector ?? "null", (object?)(key ?? default), (object?)nameExpression, (object?)(flag ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg>? selector, global::System.Func key, global::System.Func name, global::Mockolate.ParameterArg? flag, string keyExpression, string nameExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (selector ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(key, keyExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(name, nameExpression), + (flag ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)(selector ?? default), (object?)keyExpression, (object?)nameExpression, (object?)(flag ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::System.Func selector, global::System.Func key, global::System.Func name, global::Mockolate.ParameterArg? flag, string keyExpression, string nameExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(selector), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(key, keyExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(name, nameExpression), + (flag ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)selector ?? "null", (object?)keyExpression, (object?)nameExpression, (object?)(flag ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg>? selector, global::Mockolate.ParameterArg? key, global::Mockolate.ParameterArg? name, global::System.Func flag, string flagExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (selector ?? default).ToParameterMatch(), + (key ?? default).ToParameterMatch(), + (name ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(flag, flagExpression), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)(selector ?? default), (object?)(key ?? default), (object?)(name ?? default), (object?)flagExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::System.Func selector, global::Mockolate.ParameterArg? key, global::Mockolate.ParameterArg? name, global::System.Func flag, string flagExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(selector), + (key ?? default).ToParameterMatch(), + (name ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(flag, flagExpression), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)selector ?? "null", (object?)(key ?? default), (object?)(name ?? default), (object?)flagExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg>? selector, global::System.Func key, global::Mockolate.ParameterArg? name, global::System.Func flag, string keyExpression, string flagExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (selector ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(key, keyExpression), + (name ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(flag, flagExpression), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)(selector ?? default), (object?)keyExpression, (object?)(name ?? default), (object?)flagExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::System.Func selector, global::System.Func key, global::Mockolate.ParameterArg? name, global::System.Func flag, string keyExpression, string flagExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(selector), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(key, keyExpression), + (name ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(flag, flagExpression), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)selector ?? "null", (object?)keyExpression, (object?)(name ?? default), (object?)flagExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg>? selector, global::Mockolate.ParameterArg? key, global::System.Func name, global::System.Func flag, string nameExpression, string flagExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (selector ?? default).ToParameterMatch(), + (key ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(name, nameExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(flag, flagExpression), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)(selector ?? default), (object?)(key ?? default), (object?)nameExpression, (object?)flagExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::System.Func selector, global::Mockolate.ParameterArg? key, global::System.Func name, global::System.Func flag, string nameExpression, string flagExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(selector), + (key ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(name, nameExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(flag, flagExpression), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)selector ?? "null", (object?)(key ?? default), (object?)nameExpression, (object?)flagExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg>? selector, global::System.Func key, global::System.Func name, global::System.Func flag, string keyExpression, string nameExpression, string flagExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (selector ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(key, keyExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(name, nameExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(flag, flagExpression), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)(selector ?? default), (object?)keyExpression, (object?)nameExpression, (object?)flagExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::System.Func selector, global::System.Func key, global::System.Func name, global::System.Func flag, string keyExpression, string nameExpression, string flagExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(selector), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(key, keyExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(name, nameExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(flag, flagExpression), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)selector ?? "null", (object?)keyExpression, (object?)nameExpression, (object?)flagExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg? a, global::Mockolate.ParameterArg? b, global::Mockolate.ParameterArg? c, global::Mockolate.ParameterArg? d, global::Mockolate.ParameterArg? e] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, -1, -1, + interaction => interaction is global::Mockolate.Interactions.IndexerGetterAccess g && (a ?? default).ToParameterMatch().Matches(g.Parameter1) && (b ?? default).ToParameterMatch().Matches(g.Parameter2) && (c ?? default).ToParameterMatch().Matches(g.Parameter3) && (d ?? default).ToParameterMatch().Matches(g.Parameter4) && (e ?? default).ToParameterMatch().Matches(g.Parameter5), + (interaction, value) => interaction is global::Mockolate.Interactions.IndexerSetterAccess s && (a ?? default).ToParameterMatch().Matches(s.Parameter1) && (b ?? default).ToParameterMatch().Matches(s.Parameter2) && (c ?? default).ToParameterMatch().Matches(s.Parameter3) && (d ?? default).ToParameterMatch().Matches(s.Parameter4) && (e ?? default).ToParameterMatch().Matches(s.Parameter5) && value.Matches(s.TypedValue), + () => global::System.String.Format("[{0}, {1}, {2}, {3}, {4}]", (object?)(a ?? default), (object?)(b ?? default), (object?)(c ?? default), (object?)(d ?? default), (object?)(e ?? default))); + } + } + + #endregion IMockVerifyForIUnionIndexers + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class VerifyMonitorIUnionIndexers(global::Mockolate.MockRegistry mockRegistry) : global::Mockolate.Mock.IMockVerifyForIUnionIndexers + { + private global::Mockolate.MockRegistry MockRegistry { get; } = mockRegistry; + + #region IMockVerifyForIUnionIndexers + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg? key] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_int_Get, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_int_Set, + (key ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}]", (object?)(key ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIUnionIndexers.this[global::System.Func key, string keyExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_int_Get, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_int_Set, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(key, keyExpression), + () => global::System.String.Format("[{0}]", (object?)keyExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg? a, global::Mockolate.ParameterArg? b] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_byte_byte_Get, + (a ?? default).ToParameterMatch(), + (b ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}]", (object?)(a ?? default), (object?)(b ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult IMockVerifyForIUnionIndexers.this[global::System.Func a, global::Mockolate.ParameterArg? b, string aExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_byte_byte_Get, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(a, aExpression), + (b ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}]", (object?)aExpression, (object?)(b ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg? a, global::System.Func b, string bExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_byte_byte_Get, + (a ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(b, bExpression), + () => global::System.String.Format("[{0}, {1}]", (object?)(a ?? default), (object?)bExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult IMockVerifyForIUnionIndexers.this[global::System.Func a, global::System.Func b, string aExpression, string bExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_byte_byte_Get, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(a, aExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(b, bExpression), + () => global::System.String.Format("[{0}, {1}]", (object?)aExpression, (object?)bExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg? a, global::Mockolate.ParameterArg? b, global::Mockolate.ParameterArg? c] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Set, + (a ?? default).ToParameterMatch(), + (b ?? default).ToParameterMatch(), + (c ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}]", (object?)(a ?? default), (object?)(b ?? default), (object?)(c ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIUnionIndexers.this[global::System.Func a, global::Mockolate.ParameterArg? b, global::Mockolate.ParameterArg? c, string aExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Set, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(a, aExpression), + (b ?? default).ToParameterMatch(), + (c ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}]", (object?)aExpression, (object?)(b ?? default), (object?)(c ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg? a, global::System.Func b, global::Mockolate.ParameterArg? c, string bExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Set, + (a ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(b, bExpression), + (c ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}]", (object?)(a ?? default), (object?)bExpression, (object?)(c ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIUnionIndexers.this[global::System.Func a, global::System.Func b, global::Mockolate.ParameterArg? c, string aExpression, string bExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Set, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(a, aExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(b, bExpression), + (c ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}]", (object?)aExpression, (object?)bExpression, (object?)(c ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg? a, global::Mockolate.ParameterArg? b, global::System.Func c, string cExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Set, + (a ?? default).ToParameterMatch(), + (b ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(c, cExpression), + () => global::System.String.Format("[{0}, {1}, {2}]", (object?)(a ?? default), (object?)(b ?? default), (object?)cExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIUnionIndexers.this[global::System.Func a, global::Mockolate.ParameterArg? b, global::System.Func c, string aExpression, string cExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Set, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(a, aExpression), + (b ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(c, cExpression), + () => global::System.String.Format("[{0}, {1}, {2}]", (object?)aExpression, (object?)(b ?? default), (object?)cExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg? a, global::System.Func b, global::System.Func c, string bExpression, string cExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Set, + (a ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(b, bExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(c, cExpression), + () => global::System.String.Format("[{0}, {1}, {2}]", (object?)(a ?? default), (object?)bExpression, (object?)cExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerSetterResult IMockVerifyForIUnionIndexers.this[global::System.Func a, global::System.Func b, global::System.Func c, string aExpression, string bExpression, string cExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerSetterResult(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Set, + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(a, aExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(b, bExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(c, cExpression), + () => global::System.String.Format("[{0}, {1}, {2}]", (object?)aExpression, (object?)bExpression, (object?)cExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg>? selector, global::Mockolate.ParameterArg? key, global::Mockolate.ParameterArg? name, global::Mockolate.ParameterArg? flag] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (selector ?? default).ToParameterMatch(), + (key ?? default).ToParameterMatch(), + (name ?? default).ToParameterMatch(), + (flag ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)(selector ?? default), (object?)(key ?? default), (object?)(name ?? default), (object?)(flag ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::System.Func selector, global::Mockolate.ParameterArg? key, global::Mockolate.ParameterArg? name, global::Mockolate.ParameterArg? flag] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(selector), + (key ?? default).ToParameterMatch(), + (name ?? default).ToParameterMatch(), + (flag ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)selector ?? "null", (object?)(key ?? default), (object?)(name ?? default), (object?)(flag ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg>? selector, global::System.Func key, global::Mockolate.ParameterArg? name, global::Mockolate.ParameterArg? flag, string keyExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (selector ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(key, keyExpression), + (name ?? default).ToParameterMatch(), + (flag ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)(selector ?? default), (object?)keyExpression, (object?)(name ?? default), (object?)(flag ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::System.Func selector, global::System.Func key, global::Mockolate.ParameterArg? name, global::Mockolate.ParameterArg? flag, string keyExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(selector), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(key, keyExpression), + (name ?? default).ToParameterMatch(), + (flag ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)selector ?? "null", (object?)keyExpression, (object?)(name ?? default), (object?)(flag ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg>? selector, global::Mockolate.ParameterArg? key, global::System.Func name, global::Mockolate.ParameterArg? flag, string nameExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (selector ?? default).ToParameterMatch(), + (key ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(name, nameExpression), + (flag ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)(selector ?? default), (object?)(key ?? default), (object?)nameExpression, (object?)(flag ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::System.Func selector, global::Mockolate.ParameterArg? key, global::System.Func name, global::Mockolate.ParameterArg? flag, string nameExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(selector), + (key ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(name, nameExpression), + (flag ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)selector ?? "null", (object?)(key ?? default), (object?)nameExpression, (object?)(flag ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg>? selector, global::System.Func key, global::System.Func name, global::Mockolate.ParameterArg? flag, string keyExpression, string nameExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (selector ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(key, keyExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(name, nameExpression), + (flag ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)(selector ?? default), (object?)keyExpression, (object?)nameExpression, (object?)(flag ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::System.Func selector, global::System.Func key, global::System.Func name, global::Mockolate.ParameterArg? flag, string keyExpression, string nameExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(selector), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(key, keyExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(name, nameExpression), + (flag ?? default).ToParameterMatch(), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)selector ?? "null", (object?)keyExpression, (object?)nameExpression, (object?)(flag ?? default))); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg>? selector, global::Mockolate.ParameterArg? key, global::Mockolate.ParameterArg? name, global::System.Func flag, string flagExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (selector ?? default).ToParameterMatch(), + (key ?? default).ToParameterMatch(), + (name ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(flag, flagExpression), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)(selector ?? default), (object?)(key ?? default), (object?)(name ?? default), (object?)flagExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::System.Func selector, global::Mockolate.ParameterArg? key, global::Mockolate.ParameterArg? name, global::System.Func flag, string flagExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(selector), + (key ?? default).ToParameterMatch(), + (name ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(flag, flagExpression), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)selector ?? "null", (object?)(key ?? default), (object?)(name ?? default), (object?)flagExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg>? selector, global::System.Func key, global::Mockolate.ParameterArg? name, global::System.Func flag, string keyExpression, string flagExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (selector ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(key, keyExpression), + (name ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(flag, flagExpression), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)(selector ?? default), (object?)keyExpression, (object?)(name ?? default), (object?)flagExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::System.Func selector, global::System.Func key, global::Mockolate.ParameterArg? name, global::System.Func flag, string keyExpression, string flagExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(selector), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(key, keyExpression), + (name ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(flag, flagExpression), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)selector ?? "null", (object?)keyExpression, (object?)(name ?? default), (object?)flagExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg>? selector, global::Mockolate.ParameterArg? key, global::System.Func name, global::System.Func flag, string nameExpression, string flagExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (selector ?? default).ToParameterMatch(), + (key ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(name, nameExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(flag, flagExpression), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)(selector ?? default), (object?)(key ?? default), (object?)nameExpression, (object?)flagExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::System.Func selector, global::Mockolate.ParameterArg? key, global::System.Func name, global::System.Func flag, string nameExpression, string flagExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(selector), + (key ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(name, nameExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(flag, flagExpression), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)selector ?? "null", (object?)(key ?? default), (object?)nameExpression, (object?)flagExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg>? selector, global::System.Func key, global::System.Func name, global::System.Func flag, string keyExpression, string nameExpression, string flagExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (selector ?? default).ToParameterMatch(), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(key, keyExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(name, nameExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(flag, flagExpression), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)(selector ?? default), (object?)keyExpression, (object?)nameExpression, (object?)flagExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> IMockVerifyForIUnionIndexers.this[global::System.Func selector, global::System.Func key, global::System.Func name, global::System.Func flag, string keyExpression, string nameExpression, string flagExpression] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool>(this, this.MockRegistry, global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, + (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(selector), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(key, keyExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(name, nameExpression), + (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(flag, flagExpression), + () => global::System.String.Format("[{0}, {1}, {2}, {3}]", (object?)selector ?? "null", (object?)keyExpression, (object?)nameExpression, (object?)flagExpression)); + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Verify.VerificationIndexerResult IMockVerifyForIUnionIndexers.this[global::Mockolate.ParameterArg? a, global::Mockolate.ParameterArg? b, global::Mockolate.ParameterArg? c, global::Mockolate.ParameterArg? d, global::Mockolate.ParameterArg? e] + { + get + { + return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, -1, -1, + interaction => interaction is global::Mockolate.Interactions.IndexerGetterAccess g && (a ?? default).ToParameterMatch().Matches(g.Parameter1) && (b ?? default).ToParameterMatch().Matches(g.Parameter2) && (c ?? default).ToParameterMatch().Matches(g.Parameter3) && (d ?? default).ToParameterMatch().Matches(g.Parameter4) && (e ?? default).ToParameterMatch().Matches(g.Parameter5), + (interaction, value) => interaction is global::Mockolate.Interactions.IndexerSetterAccess s && (a ?? default).ToParameterMatch().Matches(s.Parameter1) && (b ?? default).ToParameterMatch().Matches(s.Parameter2) && (c ?? default).ToParameterMatch().Matches(s.Parameter3) && (d ?? default).ToParameterMatch().Matches(s.Parameter4) && (e ?? default).ToParameterMatch().Matches(s.Parameter5) && value.Matches(s.TypedValue), + () => global::System.String.Format("[{0}, {1}, {2}, {3}, {4}]", (object?)(a ?? default), (object?)(b ?? default), (object?)(c ?? default), (object?)(d ?? default), (object?)(e ?? default))); + } + } + + #endregion IMockVerifyForIUnionIndexers + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class MockInScenarioForIUnionIndexers : global::Mockolate.Mock.IMockInScenarioForIUnionIndexers, global::Mockolate.Mock.IMockSetupForIUnionIndexers + { + private global::Mockolate.MockRegistry MockRegistry { get; } + private string _scenarioName; + + public MockInScenarioForIUnionIndexers(global::Mockolate.MockRegistry mockRegistry, string scenario) + { + this.MockRegistry = mockRegistry; + _scenarioName = scenario; + } + + /// + global::Mockolate.Mock.IMockSetupForIUnionIndexers global::Mockolate.Mock.IMockInScenarioForIUnionIndexers.Setup + => this; + + #region IMockSetupForIUnionIndexers + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg? parameter1] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (parameter1 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_int_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, string parameter1Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter1, parameter1Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_int_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg? parameter1, global::Mockolate.ParameterArg? parameter2] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (parameter2 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_byte_byte_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, string parameter1Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter1, parameter1Expression), (parameter2 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_byte_byte_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg? parameter1, global::System.Func parameter2, string parameter2Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_byte_byte_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::System.Func parameter2, string parameter1Expression, string parameter2Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter1, parameter1Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_byte_byte_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg? parameter1, global::Mockolate.ParameterArg? parameter2, global::Mockolate.ParameterArg? parameter3] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (parameter2 ?? default).ToParameterMatch(), (parameter3 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, global::Mockolate.ParameterArg? parameter3, string parameter1Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter1, parameter1Expression), (parameter2 ?? default).ToParameterMatch(), (parameter3 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg? parameter1, global::System.Func parameter2, global::Mockolate.ParameterArg? parameter3, string parameter2Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (parameter3 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::System.Func parameter2, global::Mockolate.ParameterArg? parameter3, string parameter1Expression, string parameter2Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter1, parameter1Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (parameter3 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg? parameter1, global::Mockolate.ParameterArg? parameter2, global::System.Func parameter3, string parameter3Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (parameter2 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, global::System.Func parameter3, string parameter1Expression, string parameter3Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter1, parameter1Expression), (parameter2 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg? parameter1, global::System.Func parameter2, global::System.Func parameter3, string parameter2Expression, string parameter3Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerSetterOnlySetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::System.Func parameter2, global::System.Func parameter3, string parameter1Expression, string parameter2Expression, string parameter3Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter1, parameter1Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_short_short_short_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg>? parameter1, global::Mockolate.ParameterArg? parameter2, global::Mockolate.ParameterArg? parameter3, global::Mockolate.ParameterArg? parameter4] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (parameter2 ?? default).ToParameterMatch(), (parameter3 ?? default).ToParameterMatch(), (parameter4 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, global::Mockolate.ParameterArg? parameter3, global::Mockolate.ParameterArg? parameter4] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(parameter1), (parameter2 ?? default).ToParameterMatch(), (parameter3 ?? default).ToParameterMatch(), (parameter4 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg>? parameter1, global::System.Func parameter2, global::Mockolate.ParameterArg? parameter3, global::Mockolate.ParameterArg? parameter4, string parameter2Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (parameter3 ?? default).ToParameterMatch(), (parameter4 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::System.Func parameter2, global::Mockolate.ParameterArg? parameter3, global::Mockolate.ParameterArg? parameter4, string parameter2Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(parameter1), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (parameter3 ?? default).ToParameterMatch(), (parameter4 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg>? parameter1, global::Mockolate.ParameterArg? parameter2, global::System.Func parameter3, global::Mockolate.ParameterArg? parameter4, string parameter3Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (parameter2 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression), (parameter4 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, global::System.Func parameter3, global::Mockolate.ParameterArg? parameter4, string parameter3Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(parameter1), (parameter2 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression), (parameter4 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg>? parameter1, global::System.Func parameter2, global::System.Func parameter3, global::Mockolate.ParameterArg? parameter4, string parameter2Expression, string parameter3Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression), (parameter4 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::System.Func parameter2, global::System.Func parameter3, global::Mockolate.ParameterArg? parameter4, string parameter2Expression, string parameter3Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(parameter1), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression), (parameter4 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg>? parameter1, global::Mockolate.ParameterArg? parameter2, global::Mockolate.ParameterArg? parameter3, global::System.Func parameter4, string parameter4Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (parameter2 ?? default).ToParameterMatch(), (parameter3 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter4, parameter4Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, global::Mockolate.ParameterArg? parameter3, global::System.Func parameter4, string parameter4Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(parameter1), (parameter2 ?? default).ToParameterMatch(), (parameter3 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter4, parameter4Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg>? parameter1, global::System.Func parameter2, global::Mockolate.ParameterArg? parameter3, global::System.Func parameter4, string parameter2Expression, string parameter4Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (parameter3 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter4, parameter4Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::System.Func parameter2, global::Mockolate.ParameterArg? parameter3, global::System.Func parameter4, string parameter2Expression, string parameter4Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(parameter1), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (parameter3 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter4, parameter4Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg>? parameter1, global::Mockolate.ParameterArg? parameter2, global::System.Func parameter3, global::System.Func parameter4, string parameter3Expression, string parameter4Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (parameter2 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter4, parameter4Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, global::System.Func parameter3, global::System.Func parameter4, string parameter3Expression, string parameter4Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(parameter1), (parameter2 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter4, parameter4Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg>? parameter1, global::System.Func parameter2, global::System.Func parameter3, global::System.Func parameter4, string parameter2Expression, string parameter3Expression, string parameter4Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter4, parameter4Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::System.Func parameter1, global::System.Func parameter2, global::System.Func parameter3, global::System.Func parameter4, string parameter2Expression, string parameter3Expression, string parameter4Expression] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup, int, string, bool>(MockRegistry, (global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(parameter1), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter2, parameter2Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter3, parameter3Expression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter4, parameter4Expression)); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_global__System_Func_int__bool__int_string_bool_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + /// + [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] + global::Mockolate.Setup.IndexerSetup global::Mockolate.Mock.IMockSetupForIUnionIndexers.this[global::Mockolate.ParameterArg? parameter1, global::Mockolate.ParameterArg? parameter2, global::Mockolate.ParameterArg? parameter3, global::Mockolate.ParameterArg? parameter4, global::Mockolate.ParameterArg? parameter5] + { + get + { + var indexerSetup = new global::Mockolate.Setup.IndexerSetup(MockRegistry, (parameter1 ?? default).ToParameterMatch(), (parameter2 ?? default).ToParameterMatch(), (parameter3 ?? default).ToParameterMatch(), (parameter4 ?? default).ToParameterMatch(), (parameter5 ?? default).ToParameterMatch()); + this.MockRegistry.SetupIndexer(global::Mockolate.Mock.IUnionIndexers.MemberId_Indexer_int_int_int_int_int_Get, _scenarioName, indexerSetup); + return indexerSetup; + } + } + + #endregion IMockSetupForIUnionIndexers + } + + /// + /// The Mockolate accessor for a mock of IUnionIndexers, reached through .Mock on the mocked instance. + /// + /// + /// Groups every operation that acts on the mock rather than on the mocked subject: setups, verifications, event raising, scenarios and monitoring. + /// + internal interface IMockForIUnionIndexers + { + /// + /// Configures how members of the mock of IUnionIndexers respond when invoked. + /// + /// + /// Each mocked member is available as a strongly-typed entry on this surface. Chain Returns, ReturnsAsync, Throws, ThrowsAsync or Do to control the response; chain InitializeWith/Register to initialize properties and indexers; chain multiple returns/throws to define a sequence; use .For(n), .Only(n), .Forever(), .When(predicate) to control when a callback runs.
+ /// When two setups overlap, the most recently defined one wins. + ///
+ IMockSetupForIUnionIndexers Setup { get; } + + /// + /// Opens a named scenario scope on the mock of IUnionIndexers so that additional setups can be registered for that scenario. + /// + /// + /// Scenarios let you define per-state behavior. Setups registered inside the returned IMockInScenarioFor... scope only apply while the mock's current scenario matches ; switch scenarios with TransitionTo. + /// + /// Name of the scenario to enter. Any non-null string acts as a key; the mock starts in an unnamed default scenario. + /// A scoped accessor whose Setup (and SetupProtected, where applicable) register scenario-specific setups. + IMockInScenarioForIUnionIndexers InScenario(string scenario); + + /// + /// Opens a named scenario scope on the mock of IUnionIndexers and immediately invokes to register scenario-specific setups. + /// + /// + /// Equivalent to InScenario(scenario) followed by the setup callback, but returns the original IMockFor... accessor so it chains nicely at mock-creation time. + /// + /// Name of the scenario to enter. + /// Callback that receives the scenario-scoped setup surface and registers scenario-specific setups. + /// This accessor, to allow chaining. + IMockForIUnionIndexers InScenario(string scenario, global::System.Action setup); + + /// + /// Switches the active scenario of the mock of IUnionIndexers to . + /// + /// + /// After the transition, setups registered via InScenario(string) under that scenario take effect. Scenarios that have no matching setup for a given member fall back to the default (un-scoped) setups. + /// + /// Name of the scenario to transition to. + /// This accessor, to allow chaining. + IMockForIUnionIndexers TransitionTo(string scenario); + + /// + /// Asserts how often, and in which order, members of the mock of IUnionIndexers were invoked. + /// + /// + /// Each call to a member here returns a VerificationResult that you terminate with a count assertion: Never(), Once(), Twice(), Exactly(n), AtLeast(n)/AtLeastOnce()/AtLeastTwice(), AtMost(n)/AtMostOnce()/AtMostTwice(), Between(min, max) or Times(predicate).
+ /// Use Within(TimeSpan) / WithCancellation(CancellationToken) before the terminator to wait for expected interactions that happen on background threads.
+ /// Chain Then(...) to assert an ordered sequence of calls. A failing assertion throws a MockVerificationException. + ///
+ IMockVerifyForIUnionIndexers Verify { get; } + + /// + /// Verifies how often a specific method setup was matched by actual invocations. + /// + /// + /// Useful when you want to verify "this particular setup was hit N times" without re-stating the matchers. Chain the usual count terminators (Once(), AtLeastOnce(), Exactly(n), ...) on the returned result. + /// + /// The setup previously registered through Setup (typically returned from a Returns(...)/Throws(...) call). + /// A VerificationResult that counts invocations matching the given setup. + global::Mockolate.Verify.VerificationResult VerifySetup(global::Mockolate.Setup.IMethodSetup setup); + + /// + /// Checks whether every recorded interaction on this mock has been observed by at least one Verify call. + /// + /// + /// Useful in test teardown to catch unexpected interactions ("strict verification"): if any recorded call has never been matched by a verification, the method returns . + /// + /// if every recorded interaction was verified at least once; otherwise . + bool VerifyThatAllInteractionsAreVerified(); + + /// + /// Checks whether every registered setup on this mock was matched by at least one actual invocation. + /// + /// + /// Useful to catch unused setups that silently rot as the test subject evolves. + /// + /// if every registered setup was used at least once; otherwise . + bool VerifyThatAllSetupsAreUsed(); + + /// + /// Removes every recorded interaction from this mock while keeping all registered setups intact. + /// + /// + /// Handy when a single test exercises multiple logical phases and you only want to verify the interactions of the latest phase. + /// + void ClearAllInteractions(); + + /// + /// Creates a monitor whose Verify surface is scoped to interactions produced between monitor.Run() and the disposal of its IDisposable scope. + /// + /// + /// The underlying mock keeps recording all interactions as usual - only the monitor's Verify view is scoped. Useful to verify only the interactions produced by a specific block of test code without resetting the mock. + /// + /// A MockMonitor<T> that exposes Verify over the monitored interactions and a Run() method that opens the recording scope. + global::Mockolate.Monitor.MockMonitor Monitor(); + } + + /// + /// Scoped access to setups for a scenario on the mock of IUnionIndexers. + /// + internal interface IMockInScenarioForIUnionIndexers + { + /// + /// Set up the mock of IUnionIndexers within the scenario scope. + /// + IMockSetupForIUnionIndexers Setup { get; } + } + + /// + /// Set up the mock of IUnionIndexers. + /// + internal interface IMockSetupForIUnionIndexers : global::Mockolate.Setup.IMockSetup + { + /// + /// Setup for the string indexer this[int] + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IndexerSetup this[global::Mockolate.ParameterArg? parameter1] { get; } + + /// + /// Setup for the string indexer this[int] + /// + /// + /// This overload accepts a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IndexerSetup this[global::System.Func parameter1, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter1")] string parameter1Expression = ""] { get; } + + /// + /// Setup for the long indexer this[byte, byte] + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IIndexerGetterOnlySetup this[global::Mockolate.ParameterArg? parameter1, global::Mockolate.ParameterArg? parameter2] { get; } + + /// + /// Setup for the long indexer this[byte, byte] + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IIndexerGetterOnlySetup this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter1")] string parameter1Expression = ""] { get; } + + /// + /// Setup for the long indexer this[byte, byte] + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IIndexerGetterOnlySetup this[global::Mockolate.ParameterArg? parameter1, global::System.Func parameter2, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter2")] string parameter2Expression = ""] { get; } + + /// + /// Setup for the long indexer this[byte, byte] + /// + /// + /// This overload accepts a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IIndexerGetterOnlySetup this[global::System.Func parameter1, global::System.Func parameter2, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter1")] string parameter1Expression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter2")] string parameter2Expression = ""] { get; } + + /// + /// Setup for the long indexer this[short, short, short] + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IIndexerSetterOnlySetup this[global::Mockolate.ParameterArg? parameter1, global::Mockolate.ParameterArg? parameter2, global::Mockolate.ParameterArg? parameter3] { get; } + + /// + /// Setup for the long indexer this[short, short, short] + /// + /// + /// This overload accepts an It matcher or a direct value for , and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Setup.IIndexerSetterOnlySetup this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, global::Mockolate.ParameterArg? parameter3, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter1")] string parameter1Expression = ""] { get; } + + /// + /// Setup for the long indexer this[short, short, short] + /// + /// + /// This overload accepts an It matcher or a direct value for , and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Setup.IIndexerSetterOnlySetup this[global::Mockolate.ParameterArg? parameter1, global::System.Func parameter2, global::Mockolate.ParameterArg? parameter3, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter2")] string parameter2Expression = ""] { get; } + + /// + /// Setup for the long indexer this[short, short, short] + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IIndexerSetterOnlySetup this[global::System.Func parameter1, global::System.Func parameter2, global::Mockolate.ParameterArg? parameter3, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter1")] string parameter1Expression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter2")] string parameter2Expression = ""] { get; } + + /// + /// Setup for the long indexer this[short, short, short] + /// + /// + /// This overload accepts an It matcher or a direct value for , and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Setup.IIndexerSetterOnlySetup this[global::Mockolate.ParameterArg? parameter1, global::Mockolate.ParameterArg? parameter2, global::System.Func parameter3, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter3")] string parameter3Expression = ""] { get; } + + /// + /// Setup for the long indexer this[short, short, short] + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IIndexerSetterOnlySetup this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, global::System.Func parameter3, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter1")] string parameter1Expression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter3")] string parameter3Expression = ""] { get; } + + /// + /// Setup for the long indexer this[short, short, short] + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IIndexerSetterOnlySetup this[global::Mockolate.ParameterArg? parameter1, global::System.Func parameter2, global::System.Func parameter3, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter2")] string parameter2Expression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter3")] string parameter3Expression = ""] { get; } + + /// + /// Setup for the long indexer this[short, short, short] + /// + /// + /// This overload accepts a predicate for , , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IIndexerSetterOnlySetup this[global::System.Func parameter1, global::System.Func parameter2, global::System.Func parameter3, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter1")] string parameter1Expression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter2")] string parameter2Expression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter3")] string parameter3Expression = ""] { get; } + + /// + /// Setup for the string indexer Func<int, bool>, int, string, bool] + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> this[global::Mockolate.ParameterArg>? parameter1, global::Mockolate.ParameterArg? parameter2, global::Mockolate.ParameterArg? parameter3, global::Mockolate.ParameterArg? parameter4] { get; } + + /// + /// Setup for the string indexer Func<int, bool>, int, string, bool] + /// + /// + /// This overload accepts an It matcher or a direct value for , , and a delegate value for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(3)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, global::Mockolate.ParameterArg? parameter3, global::Mockolate.ParameterArg? parameter4] { get; } + + /// + /// Setup for the string indexer Func<int, bool>, int, string, bool] + /// + /// + /// This overload accepts an It matcher or a direct value for , , and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(3)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> this[global::Mockolate.ParameterArg>? parameter1, global::System.Func parameter2, global::Mockolate.ParameterArg? parameter3, global::Mockolate.ParameterArg? parameter4, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter2")] string parameter2Expression = ""] { get; } + + /// + /// Setup for the string indexer Func<int, bool>, int, string, bool] + /// + /// + /// This overload accepts an It matcher or a direct value for , and a predicate for and a delegate value for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> this[global::System.Func parameter1, global::System.Func parameter2, global::Mockolate.ParameterArg? parameter3, global::Mockolate.ParameterArg? parameter4, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter2")] string parameter2Expression = ""] { get; } + + /// + /// Setup for the string indexer Func<int, bool>, int, string, bool] + /// + /// + /// This overload accepts an It matcher or a direct value for , , and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(3)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> this[global::Mockolate.ParameterArg>? parameter1, global::Mockolate.ParameterArg? parameter2, global::System.Func parameter3, global::Mockolate.ParameterArg? parameter4, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter3")] string parameter3Expression = ""] { get; } + + /// + /// Setup for the string indexer Func<int, bool>, int, string, bool] + /// + /// + /// This overload accepts an It matcher or a direct value for , and a predicate for and a delegate value for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, global::System.Func parameter3, global::Mockolate.ParameterArg? parameter4, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter3")] string parameter3Expression = ""] { get; } + + /// + /// Setup for the string indexer Func<int, bool>, int, string, bool] + /// + /// + /// This overload accepts an It matcher or a direct value for , and a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> this[global::Mockolate.ParameterArg>? parameter1, global::System.Func parameter2, global::System.Func parameter3, global::Mockolate.ParameterArg? parameter4, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter2")] string parameter2Expression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter3")] string parameter3Expression = ""] { get; } + + /// + /// Setup for the string indexer Func<int, bool>, int, string, bool] + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for , and a delegate value for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> this[global::System.Func parameter1, global::System.Func parameter2, global::System.Func parameter3, global::Mockolate.ParameterArg? parameter4, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter2")] string parameter2Expression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter3")] string parameter3Expression = ""] { get; } + + /// + /// Setup for the string indexer Func<int, bool>, int, string, bool] + /// + /// + /// This overload accepts an It matcher or a direct value for , , and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(3)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> this[global::Mockolate.ParameterArg>? parameter1, global::Mockolate.ParameterArg? parameter2, global::Mockolate.ParameterArg? parameter3, global::System.Func parameter4, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter4")] string parameter4Expression = ""] { get; } + + /// + /// Setup for the string indexer Func<int, bool>, int, string, bool] + /// + /// + /// This overload accepts an It matcher or a direct value for , and a predicate for and a delegate value for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, global::Mockolate.ParameterArg? parameter3, global::System.Func parameter4, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter4")] string parameter4Expression = ""] { get; } + + /// + /// Setup for the string indexer Func<int, bool>, int, string, bool] + /// + /// + /// This overload accepts an It matcher or a direct value for , and a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> this[global::Mockolate.ParameterArg>? parameter1, global::System.Func parameter2, global::Mockolate.ParameterArg? parameter3, global::System.Func parameter4, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter2")] string parameter2Expression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter4")] string parameter4Expression = ""] { get; } + + /// + /// Setup for the string indexer Func<int, bool>, int, string, bool] + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for , and a delegate value for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> this[global::System.Func parameter1, global::System.Func parameter2, global::Mockolate.ParameterArg? parameter3, global::System.Func parameter4, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter2")] string parameter2Expression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter4")] string parameter4Expression = ""] { get; } + + /// + /// Setup for the string indexer Func<int, bool>, int, string, bool] + /// + /// + /// This overload accepts an It matcher or a direct value for , and a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> this[global::Mockolate.ParameterArg>? parameter1, global::Mockolate.ParameterArg? parameter2, global::System.Func parameter3, global::System.Func parameter4, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter3")] string parameter3Expression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter4")] string parameter4Expression = ""] { get; } + + /// + /// Setup for the string indexer Func<int, bool>, int, string, bool] + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for , and a delegate value for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, global::System.Func parameter3, global::System.Func parameter4, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter3")] string parameter3Expression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter4")] string parameter4Expression = ""] { get; } + + /// + /// Setup for the string indexer Func<int, bool>, int, string, bool] + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for , , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> this[global::Mockolate.ParameterArg>? parameter1, global::System.Func parameter2, global::System.Func parameter3, global::System.Func parameter4, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter2")] string parameter2Expression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter3")] string parameter3Expression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter4")] string parameter4Expression = ""] { get; } + + /// + /// Setup for the string indexer Func<int, bool>, int, string, bool] + /// + /// + /// This overload accepts a predicate for , , and a delegate value for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Setup.IIndexerGetterOnlySetup, int, string, bool> this[global::System.Func parameter1, global::System.Func parameter2, global::System.Func parameter3, global::System.Func parameter4, [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter2")] string parameter2Expression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter3")] string parameter3Expression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("parameter4")] string parameter4Expression = ""] { get; } + + /// + /// Setup for the string indexer this[int, int, int, int, int] + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Setup.IndexerSetup this[global::Mockolate.ParameterArg? parameter1, global::Mockolate.ParameterArg? parameter2, global::Mockolate.ParameterArg? parameter3, global::Mockolate.ParameterArg? parameter4, global::Mockolate.ParameterArg? parameter5] { get; } + + } + + /// + /// Verify interactions with the mock of IUnionIndexers. + /// + internal interface IMockVerifyForIUnionIndexers : global::Mockolate.Verify.IMockVerify + { + /// + /// Verify interactions with the string indexer this[int]. + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Verify.VerificationIndexerResult this[global::Mockolate.ParameterArg? key] { get; } + + /// + /// Verify interactions with the string indexer this[int]. + /// + /// + /// This overload accepts a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Verify.VerificationIndexerResult this[global::System.Func key, [global::System.Runtime.CompilerServices.CallerArgumentExpression("key")] string keyExpression = ""] { get; } + + /// + /// Verify interactions with the long indexer this[byte, byte]. + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Verify.VerificationIndexerGetterResult this[global::Mockolate.ParameterArg? a, global::Mockolate.ParameterArg? b] { get; } + + /// + /// Verify interactions with the long indexer this[byte, byte]. + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationIndexerGetterResult this[global::System.Func a, global::Mockolate.ParameterArg? b, [global::System.Runtime.CompilerServices.CallerArgumentExpression("a")] string aExpression = ""] { get; } + + /// + /// Verify interactions with the long indexer this[byte, byte]. + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationIndexerGetterResult this[global::Mockolate.ParameterArg? a, global::System.Func b, [global::System.Runtime.CompilerServices.CallerArgumentExpression("b")] string bExpression = ""] { get; } + + /// + /// Verify interactions with the long indexer this[byte, byte]. + /// + /// + /// This overload accepts a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Verify.VerificationIndexerGetterResult this[global::System.Func a, global::System.Func b, [global::System.Runtime.CompilerServices.CallerArgumentExpression("a")] string aExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("b")] string bExpression = ""] { get; } + + /// + /// Verify interactions with the long indexer this[short, short, short]. + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Verify.VerificationIndexerSetterResult this[global::Mockolate.ParameterArg? a, global::Mockolate.ParameterArg? b, global::Mockolate.ParameterArg? c] { get; } + + /// + /// Verify interactions with the long indexer this[short, short, short]. + /// + /// + /// This overload accepts an It matcher or a direct value for , and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Verify.VerificationIndexerSetterResult this[global::System.Func a, global::Mockolate.ParameterArg? b, global::Mockolate.ParameterArg? c, [global::System.Runtime.CompilerServices.CallerArgumentExpression("a")] string aExpression = ""] { get; } + + /// + /// Verify interactions with the long indexer this[short, short, short]. + /// + /// + /// This overload accepts an It matcher or a direct value for , and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Verify.VerificationIndexerSetterResult this[global::Mockolate.ParameterArg? a, global::System.Func b, global::Mockolate.ParameterArg? c, [global::System.Runtime.CompilerServices.CallerArgumentExpression("b")] string bExpression = ""] { get; } + + /// + /// Verify interactions with the long indexer this[short, short, short]. + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationIndexerSetterResult this[global::System.Func a, global::System.Func b, global::Mockolate.ParameterArg? c, [global::System.Runtime.CompilerServices.CallerArgumentExpression("a")] string aExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("b")] string bExpression = ""] { get; } + + /// + /// Verify interactions with the long indexer this[short, short, short]. + /// + /// + /// This overload accepts an It matcher or a direct value for , and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Verify.VerificationIndexerSetterResult this[global::Mockolate.ParameterArg? a, global::Mockolate.ParameterArg? b, global::System.Func c, [global::System.Runtime.CompilerServices.CallerArgumentExpression("c")] string cExpression = ""] { get; } + + /// + /// Verify interactions with the long indexer this[short, short, short]. + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationIndexerSetterResult this[global::System.Func a, global::Mockolate.ParameterArg? b, global::System.Func c, [global::System.Runtime.CompilerServices.CallerArgumentExpression("a")] string aExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("c")] string cExpression = ""] { get; } + + /// + /// Verify interactions with the long indexer this[short, short, short]. + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationIndexerSetterResult this[global::Mockolate.ParameterArg? a, global::System.Func b, global::System.Func c, [global::System.Runtime.CompilerServices.CallerArgumentExpression("b")] string bExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("c")] string cExpression = ""] { get; } + + /// + /// Verify interactions with the long indexer this[short, short, short]. + /// + /// + /// This overload accepts a predicate for , , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Verify.VerificationIndexerSetterResult this[global::System.Func a, global::System.Func b, global::System.Func c, [global::System.Runtime.CompilerServices.CallerArgumentExpression("a")] string aExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("b")] string bExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("c")] string cExpression = ""] { get; } + + /// + /// Verify interactions with the string indexer Func<int, bool>, int, string, bool]. + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> this[global::Mockolate.ParameterArg>? selector, global::Mockolate.ParameterArg? key, global::Mockolate.ParameterArg? name, global::Mockolate.ParameterArg? flag] { get; } + + /// + /// Verify interactions with the string indexer Func<int, bool>, int, string, bool]. + /// + /// + /// This overload accepts an It matcher or a direct value for , , and a delegate value for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(3)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> this[global::System.Func selector, global::Mockolate.ParameterArg? key, global::Mockolate.ParameterArg? name, global::Mockolate.ParameterArg? flag] { get; } + + /// + /// Verify interactions with the string indexer Func<int, bool>, int, string, bool]. + /// + /// + /// This overload accepts an It matcher or a direct value for , , and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(3)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> this[global::Mockolate.ParameterArg>? selector, global::System.Func key, global::Mockolate.ParameterArg? name, global::Mockolate.ParameterArg? flag, [global::System.Runtime.CompilerServices.CallerArgumentExpression("key")] string keyExpression = ""] { get; } + + /// + /// Verify interactions with the string indexer Func<int, bool>, int, string, bool]. + /// + /// + /// This overload accepts an It matcher or a direct value for , and a predicate for and a delegate value for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> this[global::System.Func selector, global::System.Func key, global::Mockolate.ParameterArg? name, global::Mockolate.ParameterArg? flag, [global::System.Runtime.CompilerServices.CallerArgumentExpression("key")] string keyExpression = ""] { get; } + + /// + /// Verify interactions with the string indexer Func<int, bool>, int, string, bool]. + /// + /// + /// This overload accepts an It matcher or a direct value for , , and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(3)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> this[global::Mockolate.ParameterArg>? selector, global::Mockolate.ParameterArg? key, global::System.Func name, global::Mockolate.ParameterArg? flag, [global::System.Runtime.CompilerServices.CallerArgumentExpression("name")] string nameExpression = ""] { get; } + + /// + /// Verify interactions with the string indexer Func<int, bool>, int, string, bool]. + /// + /// + /// This overload accepts an It matcher or a direct value for , and a predicate for and a delegate value for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> this[global::System.Func selector, global::Mockolate.ParameterArg? key, global::System.Func name, global::Mockolate.ParameterArg? flag, [global::System.Runtime.CompilerServices.CallerArgumentExpression("name")] string nameExpression = ""] { get; } + + /// + /// Verify interactions with the string indexer Func<int, bool>, int, string, bool]. + /// + /// + /// This overload accepts an It matcher or a direct value for , and a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> this[global::Mockolate.ParameterArg>? selector, global::System.Func key, global::System.Func name, global::Mockolate.ParameterArg? flag, [global::System.Runtime.CompilerServices.CallerArgumentExpression("key")] string keyExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("name")] string nameExpression = ""] { get; } + + /// + /// Verify interactions with the string indexer Func<int, bool>, int, string, bool]. + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for , and a delegate value for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> this[global::System.Func selector, global::System.Func key, global::System.Func name, global::Mockolate.ParameterArg? flag, [global::System.Runtime.CompilerServices.CallerArgumentExpression("key")] string keyExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("name")] string nameExpression = ""] { get; } + + /// + /// Verify interactions with the string indexer Func<int, bool>, int, string, bool]. + /// + /// + /// This overload accepts an It matcher or a direct value for , , and a predicate for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(3)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> this[global::Mockolate.ParameterArg>? selector, global::Mockolate.ParameterArg? key, global::Mockolate.ParameterArg? name, global::System.Func flag, [global::System.Runtime.CompilerServices.CallerArgumentExpression("flag")] string flagExpression = ""] { get; } + + /// + /// Verify interactions with the string indexer Func<int, bool>, int, string, bool]. + /// + /// + /// This overload accepts an It matcher or a direct value for , and a predicate for and a delegate value for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> this[global::System.Func selector, global::Mockolate.ParameterArg? key, global::Mockolate.ParameterArg? name, global::System.Func flag, [global::System.Runtime.CompilerServices.CallerArgumentExpression("flag")] string flagExpression = ""] { get; } + + /// + /// Verify interactions with the string indexer Func<int, bool>, int, string, bool]. + /// + /// + /// This overload accepts an It matcher or a direct value for , and a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> this[global::Mockolate.ParameterArg>? selector, global::System.Func key, global::Mockolate.ParameterArg? name, global::System.Func flag, [global::System.Runtime.CompilerServices.CallerArgumentExpression("key")] string keyExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("flag")] string flagExpression = ""] { get; } + + /// + /// Verify interactions with the string indexer Func<int, bool>, int, string, bool]. + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for , and a delegate value for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> this[global::System.Func selector, global::System.Func key, global::Mockolate.ParameterArg? name, global::System.Func flag, [global::System.Runtime.CompilerServices.CallerArgumentExpression("key")] string keyExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("flag")] string flagExpression = ""] { get; } + + /// + /// Verify interactions with the string indexer Func<int, bool>, int, string, bool]. + /// + /// + /// This overload accepts an It matcher or a direct value for , and a predicate for , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(2)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> this[global::Mockolate.ParameterArg>? selector, global::Mockolate.ParameterArg? key, global::System.Func name, global::System.Func flag, [global::System.Runtime.CompilerServices.CallerArgumentExpression("name")] string nameExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("flag")] string flagExpression = ""] { get; } + + /// + /// Verify interactions with the string indexer Func<int, bool>, int, string, bool]. + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for , and a delegate value for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> this[global::System.Func selector, global::Mockolate.ParameterArg? key, global::System.Func name, global::System.Func flag, [global::System.Runtime.CompilerServices.CallerArgumentExpression("name")] string nameExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("flag")] string flagExpression = ""] { get; } + + /// + /// Verify interactions with the string indexer Func<int, bool>, int, string, bool]. + /// + /// + /// This overload accepts an It matcher or a direct value for and a predicate for , , . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> this[global::Mockolate.ParameterArg>? selector, global::System.Func key, global::System.Func name, global::System.Func flag, [global::System.Runtime.CompilerServices.CallerArgumentExpression("key")] string keyExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("name")] string nameExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("flag")] string flagExpression = ""] { get; } + + /// + /// Verify interactions with the string indexer Func<int, bool>, int, string, bool]. + /// + /// + /// This overload accepts a predicate for , , and a delegate value for . A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] + global::Mockolate.Verify.VerificationIndexerGetterResult, int, string, bool> this[global::System.Func selector, global::System.Func key, global::System.Func name, global::System.Func flag, [global::System.Runtime.CompilerServices.CallerArgumentExpression("key")] string keyExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("name")] string nameExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("flag")] string flagExpression = ""] { get; } + + /// + /// Verify interactions with the string indexer this[int, int, int, int, int]. + /// + /// + /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. + /// + [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] + global::Mockolate.Verify.VerificationIndexerResult this[global::Mockolate.ParameterArg? a, global::Mockolate.ParameterArg? b, global::Mockolate.ParameterArg? c, global::Mockolate.ParameterArg? d, global::Mockolate.ParameterArg? e] { get; } + + } +} +/// +/// Mock extensions for IUnionIndexers. +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal static partial class MockExtensionsForIUnionIndexers +{ + /// + extension(global::Mockolate.Tests.GeneratorCoverage.IUnionIndexers mock) + { + /// + /// Gets the mock accessor for IUnionIndexers - the entry point for configuring setups, verifying interactions and raising events. + /// + /// + /// The accessor is the bridge between the strongly-typed instance of IUnionIndexers returned by CreateMock(...) and the underlying mock registry where setups and recorded interactions live.
+ /// Through it you can:
+ ///
+ /// Setup - configure how members respond when invoked (Returns, Throws, Do, InitializeWith, ...).
+ /// Verify - assert how often (and in which order) members were invoked.
+ /// InScenario / TransitionTo - scope setups and behavior to a named scenario and switch between scenarios.
+ /// Monitor, ClearAllInteractions, VerifyThatAllInteractionsAreVerified, VerifyThatAllSetupsAreUsed - manage recorded interactions.
+ /// VerifySetup - verify how often a specific setup matched.
+ ///
+ ///
+ /// The instance is not a Mockolate-generated mock of IUnionIndexers. + public global::Mockolate.Mock.IMockForIUnionIndexers Mock + { + get + { + if (mock is global::Mockolate.Mock.IMockForIUnionIndexers mockInterface) + { + return mockInterface; + } + throw new global::Mockolate.Exceptions.MockException("The subject is no mock."); + } + } + + /// + /// Creates a new mock of IUnionIndexers with the default MockBehavior. + /// + /// + /// The returned instance is a strongly-typed mock generated at compile time - it implements IUnionIndexers and exposes the Mockolate surface through .Mock:
+ ///
+ /// .Mock.Setup configures how members respond (Returns, Throws, Do, InitializeWith, sequences, callbacks).
+ /// .Mock.Verify asserts how often and in which order members were invoked.
+ ///

+ /// With the default behavior, un-configured members return default values (empty collections / strings, completed tasks, otherwise) and base-class implementations are invoked for class mocks. Use one of the overloads that accepts a MockBehavior to customize this (for example to make un-configured calls throw or to skip the base class).
+ /// Overloads allow you to additionally pass constructor parameters (for class mocks), apply an initial setup callback before the instance is returned, or combine both. + ///
+ /// A new mock instance of IUnionIndexers. + public static global::Mockolate.Tests.GeneratorCoverage.IUnionIndexers CreateMock() + => CreateMock(null, null, (object?[]?)null); + + /// + /// Creates a new mock of IUnionIndexers with the default MockBehavior, applying the given immediately. + /// + /// + /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. + /// + /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. + /// A new mock instance of IUnionIndexers. + public static global::Mockolate.Tests.GeneratorCoverage.IUnionIndexers CreateMock(global::System.Action setup) + => CreateMock(null, setup, (object?[]?)null); + + /// + /// Creates a new mock of IUnionIndexers with the given . + /// + /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. + /// A new mock instance of IUnionIndexers. + public static global::Mockolate.Tests.GeneratorCoverage.IUnionIndexers CreateMock(global::Mockolate.MockBehavior mockBehavior) + => CreateMock(mockBehavior, null, (object?[]?)null); + + /// + /// Creates a new mock of IUnionIndexers with the given , applying the given immediately. + /// + /// + /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. + /// + /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. + /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. + /// A new mock instance of IUnionIndexers. + public static global::Mockolate.Tests.GeneratorCoverage.IUnionIndexers CreateMock(global::Mockolate.MockBehavior mockBehavior, global::System.Action setup) + => CreateMock(mockBehavior, setup, (object?[]?)null); + + /// + /// Creates a new mock of IUnionIndexers using the given , applying the given immediately, using the given . + /// + /// + /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. + /// + /// Controls how the mock responds when members are invoked without a matching setup, or for MockBehavior.Default. + /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned, or to skip. + /// Values forwarded to a matching base-class constructor, or to use the parameterless constructor. + /// A new mock instance of IUnionIndexers. + private static global::Mockolate.Tests.GeneratorCoverage.IUnionIndexers CreateMock(global::Mockolate.MockBehavior? mockBehavior, global::System.Action? setup, object?[]? constructorParameters) + { + if (mockBehavior is not null) + { + IMockBehaviorAccess mockBehaviorAccess = (global::Mockolate.IMockBehaviorAccess)mockBehavior; + if (mockBehaviorAccess.TryGet?>(out var additionalSetup)) + { + if (setup is null) + { + setup = additionalSetup; + } + else + { + var originalSetup = setup; + setup = s => { additionalSetup.Invoke(s); originalSetup.Invoke(s); }; + } + } + } + + mockBehavior ??= global::Mockolate.MockBehavior.Default; + global::Mockolate.MockRegistry mockRegistry = new global::Mockolate.MockRegistry(mockBehavior, global::Mockolate.Mock.IUnionIndexers.MemberCount, constructorParameters); + return CreateMockInstance(mockRegistry, constructorParameters, setup); + } + + private static global::Mockolate.Tests.GeneratorCoverage.IUnionIndexers CreateMockInstance(global::Mockolate.MockRegistry mockRegistry, object?[]? constructorParameters, global::System.Action? setup) + { + var value = new global::Mockolate.Mock.IUnionIndexers(mockRegistry); + if (setup is not null) + { + setup.Invoke(value); + } + return value; + } + /// + /// Creates a mock that wraps the given . + /// + /// + /// Public members on the mock forward to unless overridden by a setup; protected members still go through the base-class implementation. All forwarded interactions are recorded and can be verified the same as on a plain mock. + /// + /// The real object whose calls should be forwarded. Must not be . + /// A new mock of IUnionIndexers that delegates to . + public global::Mockolate.Tests.GeneratorCoverage.IUnionIndexers Wrapping(global::Mockolate.Tests.GeneratorCoverage.IUnionIndexers instance) + { + if (mock is global::Mockolate.IMock mockInterface) + { + global::Mockolate.MockRegistry wrappingRegistry = new global::Mockolate.MockRegistry(mockInterface.MockRegistry, instance); + wrappingRegistry = new global::Mockolate.MockRegistry(wrappingRegistry, global::Mockolate.Mock.IUnionIndexers.CreateFastInteractions(wrappingRegistry.Behavior)); + return CreateMockInstance(wrappingRegistry, mockInterface.MockRegistry.ConstructorParameters, null); + } + throw new global::Mockolate.Exceptions.MockException("The subject is no mock."); + } + + } + + /// + extension(global::Mockolate.MockBehavior behavior) + { + /// + /// Initializes mocks of type with the given . + /// + /// + /// The is applied to the mock before the constructor is executed. Calling Initialize again overlays additional setups on top of any previously registered ones. + /// + /// The mockable type derived from IUnionIndexers that this setup should apply to. + /// Callback invoked when a new mock of is created. + /// A new MockBehavior with the registered initializer. The original instance is unchanged. + public global::Mockolate.MockBehavior Initialize(global::System.Action setup) + where T : global::Mockolate.Tests.GeneratorCoverage.IUnionIndexers + { + var behaviorAccess = (global::Mockolate.IMockBehaviorAccess)behavior; + return behaviorAccess.Set(setup); + } + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch + { + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); + } +} + +#nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/Mock.g.cs new file mode 100644 index 00000000..3ce28555 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/Mock.g.cs @@ -0,0 +1,133 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +namespace Mockolate; + +#nullable enable +/// +/// Create new mocks by calling the static T.CreateMock() method on your type T. +/// +/// +/// You can also provide a MockBehavior parameter to customize how the mock should behave in certain scenarios.
+/// If your type is a class without a default constructor, you can provide constructor parameters by passing an object?[]? to the corresponding CreateMock(...) overload. +///
+[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal static partial class Mock +{ + /// + /// This interface should never be used. If it is, this is an indication that the Mockolate source generator did not run correctly or that the used type is not mockable. + /// + /// + /// The source generator creates overloads with correct return values. + /// + internal interface IMockGenerationDidNotRun {} + + /// + /// Create a new mock of with the default MockBehavior. + /// + /// Type to mock, which can be an interface or a class. + /// + /// Any interface type can be used for mocking, but for classes, only abstract and virtual members can be mocked. + /// + extension(T _) + { + /// + /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when + /// is not mockable. Calling it always throws a MockException. + /// + /// Ignored; reserved for the generator-emitted overload. + /// This method never returns - it always throws. + /// + /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. + /// If you see this fallback resolved in your IDE, the generator did not run for ; + /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. + /// + /// Always thrown: the source generator did not run or is not mockable. + public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior = null) + { + throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); + } + + /// + /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when + /// is not mockable. Calling it always throws a MockException. + /// + /// Ignored; reserved for the generator-emitted overload. + /// Ignored; reserved for the generator-emitted overload. + /// This method never returns - it always throws. + /// + /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. + /// If you see this fallback resolved in your IDE, the generator did not run for ; + /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. + /// + /// Always thrown: the source generator did not run or is not mockable. + public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior, object?[]? constructorParameters) + { + throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); + } + + /// + /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when + /// is not mockable. Calling it always throws a MockException. + /// + /// Ignored; reserved for the generator-emitted overload. + /// This method never returns - it always throws. + /// + /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. + /// If you see this fallback resolved in your IDE, the generator did not run for ; + /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. + /// + /// Always thrown: the source generator did not run or is not mockable. + public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(object?[]? constructorParameters) + { + throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); + } + } + + extension(global::Mockolate.Mock.IMockGenerationDidNotRun _) + { + /// + /// Fallback Implementing that is only resolved when the Mockolate source generator did not run or when + /// is not mockable. Calling it always throws a MockException. + /// + /// Additional interface the mock should implement. + /// This method never returns - it always throws. + /// + /// The source generator emits a concrete Implementing overload per mockable type with the same shape. + /// If you see this fallback resolved in your IDE, the generator did not run for ; + /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. + /// + /// Always thrown: the source generator did not run or is not mockable. + public global::Mockolate.Mock.IMockGenerationDidNotRun Implementing() where TInterface : class + { + throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(TInterface)}' is not mockable or the source generator did not run correctly."); + } + } + + /// + /// Adapts an IParameter (non-generic) to + /// IParameterMatch<T> so that covariant parameter + /// references (e.g. an IParameter<Derived> passed through an IParameter<Base> + /// slot) can still be invoked at setup/verify time. Only allocated when the direct + /// IParameterMatch<T> cast fails. + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch + { + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); + } +} +#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/MockBehaviorExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/MockBehaviorExtensions.g.cs new file mode 100644 index 00000000..888d2c2c --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/MockBehaviorExtensions.g.cs @@ -0,0 +1,285 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +namespace Mockolate; + +#nullable enable annotations + +/// +/// Extensions for MockBehavior. +/// +internal static partial class Mock +{ + private static readonly global::Mockolate.MockBehavior _default; + + static Mock() + { + _default = new global::Mockolate.MockBehavior(new DefaultValueGenerator()); + } + + extension(global::Mockolate.MockBehavior) + { + /// + /// The default MockBehavior - the starting point for configuring a mock. + /// + /// + /// Un-configured members return the generator-provided default value (empty strings/collections, completed + /// Tasks, otherwise), base-class + /// implementations run for class mocks, and every invocation is recorded for later verification. + /// + /// Chain SkippingBaseClass(), ThrowingWhenNotSetup(), SkippingInteractionRecording(), + /// WithDefaultValueFor<T>(...) or UseConstructorParametersFor<T>(...) to derive + /// a customized MockBehavior; because it is a , + /// each call returns a new instance and this shared default stays unchanged. + /// + public static global::Mockolate.MockBehavior Default => _default; + } + + /// + /// Defines a factory for creating default values for a specified type. + /// + public interface IDefaultValueFactory + { + /// + /// Determines whether the specified can be created by this factory. + /// + bool IsMatch(global::System.Type type); + + /// + /// Creates a new instance of the specified type. + /// + object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, object?[] parameters); + } + + /// + /// A IDefaultValueFactory that returns a specified for the given type + /// parameter . + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal class TypedDefaultValueFactory(T value) : IDefaultValueFactory + { + /// + public bool IsMatch(global::System.Type type) + => type == typeof(T); + + /// + public object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) + => value; + } + + /// + /// Provides default values for common types used in mocking scenarios. + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private class DefaultValueGenerator : IDefaultValueGenerator + { + private static readonly global::System.Collections.Concurrent.ConcurrentQueue _factories = new([ + new TypedDefaultValueFactory(""), + new CancellableTaskFactory(), + #if NET8_0_OR_GREATER + new CancellableValueTaskFactory(), + #endif + new TypedDefaultValueFactory(global::System.Threading.CancellationToken.None), + new TypedDefaultValueFactory(global::System.Array.Empty()), + ]); + + /// + public object? GenerateValue(global::System.Type type, params object?[] parameters) + { + if (TryGenerate(type, parameters, out object? value)) + { + return value; + } + + return null; + } + + /// + /// Registers a to provide default values for a specific type. + /// + public static void Register(IDefaultValueFactory defaultValueFactory) + => _factories.Enqueue(defaultValueFactory); + + /// + /// Tries to generate a default value for the specified type. + /// + protected virtual bool TryGenerate(global::System.Type type, object?[] parameters, out object? value) + { + IDefaultValueFactory? matchingFactory = global::System.Linq.Enumerable.FirstOrDefault(_factories, Predicate); + if (matchingFactory is not null) + { + value = matchingFactory.Create(type, this, parameters); + return true; + } + + value = null; + return false; + + bool Predicate(global::Mockolate.Mock.IDefaultValueFactory f) + => f.IsMatch(type); + } + + private static bool HasCanceledCancellationToken(object?[] parameters, out global::System.Threading.CancellationToken cancellationToken) + { + global::System.Threading.CancellationToken parameter = global::System.Linq.Enumerable.FirstOrDefault(global::System.Linq.Enumerable.OfType(parameters)); + if (parameter.IsCancellationRequested) + { + cancellationToken = parameter; + return true; + } + + cancellationToken = global::System.Threading.CancellationToken.None; + return false; + } + + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class CancellableTaskFactory : IDefaultValueFactory + { + /// + public bool IsMatch(global::System.Type type) + => type == typeof(global::System.Threading.Tasks.Task); + + /// + public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) + { + if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) + { + return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); + } + + return global::System.Threading.Tasks.Task.CompletedTask; + } + } + #if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + private sealed class CancellableValueTaskFactory : IDefaultValueFactory + { + /// + public bool IsMatch(global::System.Type type) + => type == typeof(global::System.Threading.Tasks.ValueTask); + + /// + public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) + { + if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) + { + return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); + } + + return global::System.Threading.Tasks.ValueTask.CompletedTask; + } + } + #endif + } +} + +/// +/// Extensions on IDefaultValueGenerator +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal static class DefaultValueGeneratorExtensions +{ + /// + /// Adds a generic Generate method for specific types. + /// + extension(IDefaultValueGenerator generator) + { + /// + /// Generates a Task of , with + /// the for context. + /// + public global::System.Threading.Tasks.Task Generate(global::System.Threading.Tasks.Task nullValue, T value, params object?[] parameters) + { + global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( + global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; + if (cancellationToken.IsCancellationRequested) + { + return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); + } + + return global::System.Threading.Tasks.Task.FromResult(value); + } + +#if NET8_0_OR_GREATER + /// + /// Generates a ValueTask of , with + /// the for context. + /// + public global::System.Threading.Tasks.ValueTask Generate(global::System.Threading.Tasks.ValueTask nullValue, T value, params object?[] parameters) + { + global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( + global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; + if (cancellationToken.IsCancellationRequested) + { + return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); + } + + return global::System.Threading.Tasks.ValueTask.FromResult(value); + } +#endif + + /// + /// Generates an empty enumerable of , with + /// the for context. + /// + public global::System.Collections.Generic.IEnumerable Generate(global::System.Collections.Generic.IEnumerable nullValue, params object?[] parameters) + => global::System.Array.Empty(); + + /// + /// Generates an empty enumerable of , with + /// the for context. + /// + public global::System.Collections.Generic.List Generate(global::System.Collections.Generic.List nullValue, params object?[] parameters) + => new global::System.Collections.Generic.List(); + + /// + /// Generates an empty array of , with + /// the for context. + /// + public T[] Generate(T[] nullValue, params object?[] parameters) + => global::System.Array.Empty(); + + /// + /// Generates an empty two-dimensional array of , with + /// the for context. + /// + public T[,] Generate(T[,] nullValue, params object?[] parameters) + => new T[,] { }; + + /// + /// Generates an empty three-dimensional array of , with + /// the for context. + /// + public T[,,] Generate(T[,,] nullValue, params object?[] parameters) + => new T[,,] { }; + + /// + /// Generates an empty four-dimensional array of , with + /// the for context. + /// + public T[,,,] Generate(T[,,,] nullValue, params object?[] parameters) + => new T[,,,] { }; + + /// + /// Generates a default value of type , with + /// the for context. + /// + public T Generate(T nullValue, params object?[] parameters) + { + if (generator.GenerateValue(typeof(T), parameters) is T value) + { + return value; + } + + return nullValue; + } + } +} + +#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/ParameterArg.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/ParameterArg.g.cs new file mode 100644 index 00000000..50826154 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/ParameterArg.g.cs @@ -0,0 +1,133 @@ +//---------------------- +// +// This code was generated by the Mockolate source generator. +// +// Changes to this file may cause incorrect behavior and +// will be lost if the code is regenerated! +// +//---------------------- + +#nullable enable + +namespace Mockolate +{ + /// + /// A setup or verify argument that is either an It matcher + /// (IParameter<T>) or a literal value of type . + /// + /// + /// Both case types convert implicitly, so Setup.Method(42) and Setup.Method(It.IsAny<int>()) + /// bind to the same overload. A instance stands for the literal default(T). + /// + [global::System.Runtime.CompilerServices.Union] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal readonly struct ParameterArg + { + private const byte MatcherTag = 1; + private const byte LiteralTag = 2; + + private readonly global::Mockolate.Parameters.IParameter? _matcher; + private readonly T? _literal; + private readonly byte _tag; + + /// + /// Creates the matcher case. + /// + public ParameterArg(global::Mockolate.Parameters.IParameter matcher) + { + _matcher = matcher; + _literal = default; + _tag = MatcherTag; + } + + /// + /// Creates the literal value case. + /// + public ParameterArg(T? literal) + { + _matcher = null; + _literal = literal; + _tag = LiteralTag; + } + + /// + /// The contained matcher or literal value, boxed. Part of the union pattern; the generated mocks use the + /// typed accessors instead. + /// + public object? Value => _tag switch + { + MatcherTag => _matcher, + LiteralTag => _literal, + _ => null, + }; + + /// + /// unless this is the instance. + /// + public bool HasValue => _tag != 0; + + /// + /// when the argument is a literal value (including the instance). + /// + public bool IsLiteral => _tag != MatcherTag; + + /// + /// The literal value; default(T) for the matcher case and the instance. + /// + public T? Literal => _literal; + + /// + /// Gets the matcher, when this is the matcher case. + /// + public bool TryGetValue(out global::Mockolate.Parameters.IParameter? matcher) + { + matcher = _matcher; + return _tag == MatcherTag; + } + + /// + /// Gets the literal value, when this is the literal case. + /// + public bool TryGetValue(out T? literal) + { + literal = _literal; + return _tag == LiteralTag; + } + + /// + /// The IParameterMatch<T> for this argument: the matcher itself, + /// or an equality match for the literal value. + /// + public global::Mockolate.Parameters.IParameterMatch ToParameterMatch() + { + if (_tag != MatcherTag) + { + return (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(_literal!); + } + + if (_matcher is null) + { + return (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsNull("null"); + } + + return _matcher is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantAdapter(_matcher); + } + + /// + public override string ToString() => _tag switch + { + MatcherTag => _matcher?.ToString() ?? "null", + _ => _literal?.ToString() ?? "null", + }; + + private sealed class CovariantAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch + { + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + } + } +} +#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotTests.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotTests.cs index 2c88b4d4..f6525585 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotTests.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotTests.cs @@ -136,6 +136,14 @@ await That(SnapshotStorage.StripConfigSpecificLines(generated[fileName])) """, [], UnionMode: true), + new( + "UnionIndexers_CanBeCreated_Unions", + ["IUnionIndexers.cs",], + """ + IUnionIndexers sut = IUnionIndexers.CreateMock(); + """, + [], + UnionMode: true), ]; public static TheoryData ScenarioNames diff --git a/Tests/Mockolate.SourceGenerators.Tests/UnionOverloadTests.cs b/Tests/Mockolate.SourceGenerators.Tests/UnionOverloadTests.cs index 44a1905b..ce2ed8b3 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/UnionOverloadTests.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/UnionOverloadTests.cs @@ -44,6 +44,8 @@ public interface IMyService int Overloaded(string? value); int Mixed(int value); int Mixed(T value); + string this[int key, string name] { get; set; } + string this[Func selector] { get; } } } """; @@ -152,6 +154,79 @@ await That(mock) .DoesNotContain("Mixed(global::Mockolate.ParameterArg<"); } + [Fact] + public async Task Indexer_ShouldEmitOneOverloadPerUnionOrPredicateAssignment() + { + string mock = GenerateMockInUnionMode(); + + await That(mock) + .Contains( + "[global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)]\n\t\tglobal::Mockolate.Setup.IndexerSetup this[global::Mockolate.ParameterArg? parameter1, global::Mockolate.ParameterArg? parameter2] { get; }") + .And + .Contains( + "[global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)]\n\t\tglobal::Mockolate.Setup.IndexerSetup this[global::System.Func parameter1, global::Mockolate.ParameterArg? parameter2, [global::System.Runtime.CompilerServices.CallerArgumentExpression(\"parameter1\")] string parameter1Expression = \"\"] { get; }") + .And + .Contains("(parameter1 ?? default).ToParameterMatch(), (parameter2 ?? default).ToParameterMatch());").And + .Contains("(global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(parameter1, parameter1Expression)").And + .Contains("global::Mockolate.Verify.VerificationIndexerResult this[global::Mockolate.ParameterArg? key, global::Mockolate.ParameterArg? name] { get; }").And + .Contains("global::Mockolate.Verify.VerificationIndexerResult this[global::Mockolate.ParameterArg? key, global::System.Func name, [global::System.Runtime.CompilerServices.CallerArgumentExpression(\"name\")] string nameExpression = \"\"] { get; }").And + .Contains("(object?)(key ?? default), (object?)nameExpression));").And + .DoesNotContain("this[global::Mockolate.Parameters.IParameter? parameter1").And + .DoesNotContain("this[int parameter1, string parameter2]"); + } + + [Fact] + public async Task Indexer_WithDelegateTypedKey_ShouldOfferTheRawDelegateAsLiteral() + { + string mock = GenerateMockInUnionMode(); + + await That(mock) + .Contains("this[global::Mockolate.ParameterArg>? parameter1] { get; }").And + .Contains("this[global::System.Func parameter1] { get; }").And + .Contains("(global::Mockolate.Parameters.IParameterMatch>)global::Mockolate.It.IsValue>(parameter1)").And + .DoesNotContain("this[global::System.Func, bool>"); + } + + [Fact] + public async Task Indexers_WithTheSameKeyCount_ShouldKeepTheClassicOverloads() + { + const string source = """ + #nullable enable + using Mockolate; + + namespace MyCode + { + public class Program + { + public static void Main(string[] args) + { + _ = IOverloadedIndexers.CreateMock(); + } + } + + public interface IOverloadedIndexers + { + string this[int i] { get; } + string this[long l] { get; } + string this[int a, int b] { get; } + } + } + """; + + GeneratorResult result = Generator.Run([source,], ["NET11_0_OR_GREATER",], LanguageVersion.Preview, + UnionsEnabled); + string mock = result.Sources["Mock.IOverloadedIndexers.g.cs"]; + + await That(result.Diagnostics).IsEmpty(); + await That(mock) + .Contains("this[global::Mockolate.Parameters.IParameter? parameter1] { get; }").And + .Contains("this[int parameter1] { get; }").And + .Contains("this[global::Mockolate.Parameters.IParameter? parameter1] { get; }").And + .DoesNotContain("this[global::Mockolate.ParameterArg? parameter1]").And + .DoesNotContain("this[global::Mockolate.ParameterArg? parameter1]").And + .Contains("this[global::Mockolate.ParameterArg? parameter1, global::Mockolate.ParameterArg? parameter2] { get; }"); + } + [Fact] public async Task IParametersOverload_ShouldKeepItsPriorityAboveTheUnionOverloads() { diff --git a/Tests/Mockolate.Tests/GeneratorCoverage/IUnionIndexers.cs b/Tests/Mockolate.Tests/GeneratorCoverage/IUnionIndexers.cs new file mode 100644 index 00000000..720cbdb7 --- /dev/null +++ b/Tests/Mockolate.Tests/GeneratorCoverage/IUnionIndexers.cs @@ -0,0 +1,15 @@ +namespace Mockolate.Tests.GeneratorCoverage; + +/// +/// Indexer shapes for the union-mode snapshot: one indexer per key count so that every one of them qualifies for +/// union-typed keys (a getter/setter pair, a getter-only and a setter-only indexer, a delegate-typed key, and a +/// five-key indexer that exercises the predicate-based verify path). +/// +public interface IUnionIndexers +{ + string this[int key] { get; set; } + long this[byte a, byte b] { get; } + long this[short a, short b, short c] { set; } + string this[System.Func selector, int key, string name, bool flag] { get; } + string this[int a, int b, int c, int d, int e] { get; set; } +} diff --git a/Tests/Mockolate.Tests/UnionSetupTests.cs b/Tests/Mockolate.Tests/UnionSetupTests.cs index 6586ae4a..abed4f81 100644 --- a/Tests/Mockolate.Tests/UnionSetupTests.cs +++ b/Tests/Mockolate.Tests/UnionSetupTests.cs @@ -242,8 +242,68 @@ public async Task DelegateMock_ShouldOfferPredicates() await That(sut.Mock.Verify(5, "a")).Once(); } + [Fact] + public async Task Indexer_Setup_WithPredicateLiteralAndMatcher_ShouldMatch() + { + IUnionService sut = IUnionService.CreateMock(); + sut.Mock.Setup[x => x > 0, "a"].Returns("positive"); + sut.Mock.Setup[0, It.IsAny()].Returns("zero"); + + await That(sut[5, "a"]).IsEqualTo("positive"); + await That(sut[-1, "a"]).IsNotEqualTo("positive"); + await That(sut[0, "whatever"]).IsEqualTo("zero"); + } + + [Fact] + public async Task Indexer_Verify_WithPredicateLiteralAndMatcher_ShouldCount() + { + IUnionService sut = IUnionService.CreateMock(); + _ = sut[5, "a"]; + _ = sut[6, "bb"]; + sut[7, "c"] = "v"; + + await That(sut.Mock.Verify[x => x > 0, It.IsAny()].Got()).Twice(); + await That(sut.Mock.Verify[5, "a"].Got()).Once(); + await That(sut.Mock.Verify[It.IsAny(), s => s.Length == 2].Got()).Once(); + await That(sut.Mock.Verify[x => x > 10, "a"].Got()).Never(); + await That(sut.Mock.Verify[7, s => s == "c"].Set(It.IsAny())).Once(); + } + + [Fact] + public async Task Indexer_Verify_FailureMessage_ShouldContainThePredicateText() + { + IUnionService sut = IUnionService.CreateMock(); + _ = sut[5, "a"]; + + void Act() + => sut.Mock.Verify[x => x > 10, "a"].Got().Once(); + + await That(Act).Throws() + .WithMessage("*[x => x > 10, a]*").AsWildcard(); + } + + [Fact] + public async Task OverloadedIndexers_ShouldKeepTheClassicBindings() + { + IOverloadedIndexerService sut = IOverloadedIndexerService.CreateMock(); + sut.Mock.Setup[5].Returns("int"); + sut.Mock.Setup[5, "a"].Returns("two"); + + await That(sut[5]).IsEqualTo("int"); + await That(sut[5L]).IsNotEqualTo("int"); + await That(sut[5, "a"]).IsEqualTo("two"); + await That(sut.Mock.Verify[5].Got()).Once(); + } + public delegate int UnionDelegate(int x, string y); + public interface IOverloadedIndexerService + { + string this[int i] { get; } + string this[long l] { get; } + string this[int a, string b] { get; } + } + public interface IUnionService { int Compute(int value, string text); @@ -253,6 +313,7 @@ public interface IUnionService int WithDefault(int i = 5); bool Take(object? o); bool TryParse(string s, out int result); + string this[int key, string name] { get; set; } } public interface IOverloadedService From 7dece927aaefb64d60ba536339b0180694a7a3e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Sat, 5 Sep 2026 07:44:46 +0200 Subject: [PATCH 05/14] fix: report unused verifications that return IgnoreParameters UseVerificationAnalyzer only recognised a return type named VerificationResult, so verifications returning the nested VerificationResult.IgnoreParameters were never reported when left unused. That shape is returned by the classic all-value overload (Verify.Method(42)), by the parameterless overload (Verify.Method()) and, since union mode, by every union-typed verify overload, which had silently disabled Mockolate0001 for that surface. The analyzer now unwraps the nested type; the code fixer needs no change because the count assertions are extension members on VerificationResult. Classic-mode consumers with an unused Verify.Method(42) or Verify.Method() statement get Mockolate0001 from now on, which is what the rule is for (such a statement asserts nothing). --- .../UseVerificationAnalyzer.cs | 22 +++++++--- .../UseVerificationAnalyzerTests.cs | 43 +++++++++++++++++++ 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/Source/Mockolate.Analyzers/UseVerificationAnalyzer.cs b/Source/Mockolate.Analyzers/UseVerificationAnalyzer.cs index cad5d066..6b7b68b4 100644 --- a/Source/Mockolate.Analyzers/UseVerificationAnalyzer.cs +++ b/Source/Mockolate.Analyzers/UseVerificationAnalyzer.cs @@ -31,18 +31,28 @@ private static void AnalyzeOperation(OperationAnalysisContext context) if (context.Operation is IInvocationOperation invocationOperation) { ITypeSymbol? returnType = invocationOperation.Type; - if (returnType is INamedTypeSymbol namedReturnType && - namedReturnType.ContainingNamespace?.ContainingNamespace?.ContainingNamespace?.IsGlobalNamespace == - true && - namedReturnType.ContainingNamespace.ContainingNamespace.Name == "Mockolate" && - namedReturnType.ContainingNamespace.Name == "Verify" && - namedReturnType.Name == "VerificationResult") + if (returnType is INamedTypeSymbol namedReturnType && IsVerificationResult(namedReturnType)) { CheckIsUsed(context, invocationOperation); } } } + /// + /// Matches Mockolate.Verify.VerificationResult<T> and its nested IgnoreParameters, which the + /// value and the union-typed verify overloads return. + /// + private static bool IsVerificationResult(INamedTypeSymbol type) + { + INamedTypeSymbol candidate = type is { Name: "IgnoreParameters", ContainingType: { } containingType, } + ? containingType + : type; + return candidate.Name == "VerificationResult" && + candidate.ContainingNamespace?.Name == "Verify" && + candidate.ContainingNamespace.ContainingNamespace?.Name == "Mockolate" && + candidate.ContainingNamespace.ContainingNamespace.ContainingNamespace?.IsGlobalNamespace == true; + } + private static void CheckIsUsed(OperationAnalysisContext context, IInvocationOperation invocationOperation) { if (IsOperationUsed(invocationOperation)) diff --git a/Tests/Mockolate.Analyzers.Tests/UseVerificationAnalyzerTests.cs b/Tests/Mockolate.Analyzers.Tests/UseVerificationAnalyzerTests.cs index de634c27..3fba9e54 100644 --- a/Tests/Mockolate.Analyzers.Tests/UseVerificationAnalyzerTests.cs +++ b/Tests/Mockolate.Analyzers.Tests/UseVerificationAnalyzerTests.cs @@ -6,6 +6,49 @@ namespace Mockolate.Analyzers.Tests; public class UseVerificationAnalyzerTests { + [Fact] + public async Task WhenIgnoreParametersResultIsNotUsed_ShouldBeFlagged() => await Verifier + .VerifyAnalyzerAsync( + """ + using Mockolate; + using Mockolate.Verify; + + public class MyClass + { + public void MyTest() + { + {|#0:VerifySomething()|}; + } + + public static VerificationResult>>.IgnoreParameters VerifySomething() + => null!; + } + """, + Verifier.Diagnostic(Rules.UseVerificationRule) + .WithLocation(0) + ); + + [Fact] + public async Task WhenIgnoreParametersResultIsUsed_ShouldNotBeFlagged() => await Verifier + .VerifyAnalyzerAsync( + """ + using Mockolate; + using Mockolate.Verify; + + public class MyClass + { + public void MyTest() + { + VerificationResult>>.IgnoreParameters result = VerifySomething(); + _ = result; + } + + public static VerificationResult>>.IgnoreParameters VerifySomething() + => null!; + } + """ + ); + [Fact] public async Task WhenAssigned_ShouldNotBeFlagged() => await Verifier .VerifyAnalyzerAsync( From aa4b7c826dcfeab1162203b16c105a7649c688be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Sat, 5 Sep 2026 07:44:46 +0200 Subject: [PATCH 06/14] docs: describe union parameters and add the union benchmark project - A "Union Parameters (C# 15)" section in the parameter matching page: how union mode is enabled, predicates without It.Satisfies, the null/default fallback to the declared default, which parameters keep a matcher slot and which members keep the classic overloads, and the MockolateUnionAttributePolyfills switch. Short notes on the methods and indexers pages, a README feature bullet with a link, and a CLAUDE.md note on the generator's union mode. - Benchmarks/Mockolate.Benchmarks.Unions compiles the CompleteMethod workflow and a setup-only variant in union mode (literal, matcher, predicate) with the same job as the classic Mockolate.Benchmarks, for a job-for-job comparison. Union mode is a compilation-wide switch, so it cannot share a project with the classic benchmarks; it is part of the solution build but not of the CI benchmark matrix, so CI compiles it and never runs it. Measured setup-only: literal 91 ns / 584 B (same allocation as the classic value path, so ParameterArg does not box), matcher 98 ns / 592 B, predicate 88 ns / 632 B. --- .../BenchmarksBase.cs | 26 +++++++++ .../IMyMethodInterface.cs | 6 ++ .../Mockolate.Benchmarks.Unions.csproj | 24 ++++++++ .../Mockolate.Benchmarks.Unions/Program.cs | 3 + .../UnionParameterBenchmarks.cs | 58 +++++++++++++++++++ .../UnionSetupBenchmarks.cs | 33 +++++++++++ CLAUDE.md | 1 + Docs/pages/setup/02-methods.md | 3 +- Docs/pages/setup/03-indexers.md | 13 +++++ Docs/pages/setup/04-parameter-matching.md | 37 ++++++++++++ Mockolate.slnx | 1 + README.md | 2 +- 12 files changed, 205 insertions(+), 2 deletions(-) create mode 100644 Benchmarks/Mockolate.Benchmarks.Unions/BenchmarksBase.cs create mode 100644 Benchmarks/Mockolate.Benchmarks.Unions/IMyMethodInterface.cs create mode 100644 Benchmarks/Mockolate.Benchmarks.Unions/Mockolate.Benchmarks.Unions.csproj create mode 100644 Benchmarks/Mockolate.Benchmarks.Unions/Program.cs create mode 100644 Benchmarks/Mockolate.Benchmarks.Unions/UnionParameterBenchmarks.cs create mode 100644 Benchmarks/Mockolate.Benchmarks.Unions/UnionSetupBenchmarks.cs diff --git a/Benchmarks/Mockolate.Benchmarks.Unions/BenchmarksBase.cs b/Benchmarks/Mockolate.Benchmarks.Unions/BenchmarksBase.cs new file mode 100644 index 00000000..94282d6b --- /dev/null +++ b/Benchmarks/Mockolate.Benchmarks.Unions/BenchmarksBase.cs @@ -0,0 +1,26 @@ +using BenchmarkDotNet.Attributes; +using BenchmarkDotNet.Configs; +using BenchmarkDotNet.Jobs; +using BenchmarkDotNet.Toolchains.InProcess.Emit; + +namespace Mockolate.Benchmarks.Unions; + +/// +/// Same job as the classic Mockolate.Benchmarks, so the union-mode numbers compare job for job. +/// +[Config(typeof(Config))] +[MarkdownExporterAttribute.GitHub] +[MemoryDiagnoser] +public abstract class BenchmarksBase +{ + private sealed class Config : ManualConfig + { + public Config() + { + AddJob(Job.MediumRun + .WithLaunchCount(1) + .WithToolchain(InProcessEmitToolchain.Instance) + .WithId("InProcess")); + } + } +} diff --git a/Benchmarks/Mockolate.Benchmarks.Unions/IMyMethodInterface.cs b/Benchmarks/Mockolate.Benchmarks.Unions/IMyMethodInterface.cs new file mode 100644 index 00000000..8a55e620 --- /dev/null +++ b/Benchmarks/Mockolate.Benchmarks.Unions/IMyMethodInterface.cs @@ -0,0 +1,6 @@ +namespace Mockolate.Benchmarks.Unions; + +public interface IMyMethodInterface +{ + bool MyFunc(int value); +} diff --git a/Benchmarks/Mockolate.Benchmarks.Unions/Mockolate.Benchmarks.Unions.csproj b/Benchmarks/Mockolate.Benchmarks.Unions/Mockolate.Benchmarks.Unions.csproj new file mode 100644 index 00000000..351c9152 --- /dev/null +++ b/Benchmarks/Mockolate.Benchmarks.Unions/Mockolate.Benchmarks.Unions.csproj @@ -0,0 +1,24 @@ + + + + + + + Exe + net11.0 + preview + true + enable + enable + false + false + False + + + + + + + + + diff --git a/Benchmarks/Mockolate.Benchmarks.Unions/Program.cs b/Benchmarks/Mockolate.Benchmarks.Unions/Program.cs new file mode 100644 index 00000000..c9a04672 --- /dev/null +++ b/Benchmarks/Mockolate.Benchmarks.Unions/Program.cs @@ -0,0 +1,3 @@ +using BenchmarkDotNet.Running; + +BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); diff --git a/Benchmarks/Mockolate.Benchmarks.Unions/UnionParameterBenchmarks.cs b/Benchmarks/Mockolate.Benchmarks.Unions/UnionParameterBenchmarks.cs new file mode 100644 index 00000000..54b453de --- /dev/null +++ b/Benchmarks/Mockolate.Benchmarks.Unions/UnionParameterBenchmarks.cs @@ -0,0 +1,58 @@ +using BenchmarkDotNet.Attributes; +using Mockolate.Verify; + +namespace Mockolate.Benchmarks.Unions; + +#pragma warning disable CA1822 // Mark members as static +/// +/// The CompleteMethodBenchmarks.Method_Mockolate workflow (create, set up one method, invoke +/// times, verify) on the union-typed surface, with a literal value, an It matcher and a predicate as the +/// argument. Compare against Mockolate.Benchmarks, which compiles the same workflow in classic mode. +/// +public class UnionParameterBenchmarks : BenchmarksBase +{ + [Params(1, 10)] public int N { get; set; } + + [Benchmark(Baseline = true)] + public void Value() + { + IMyMethodInterface sut = IMyMethodInterface.CreateMock(); + sut.Mock.Setup.MyFunc(42).Returns(true); + + for (int i = 0; i < N; i++) + { + sut.MyFunc(42); + } + + sut.Mock.Verify.MyFunc(42).Exactly(N); + } + + [Benchmark] + public void Matcher() + { + IMyMethodInterface sut = IMyMethodInterface.CreateMock(); + sut.Mock.Setup.MyFunc(It.IsAny()).Returns(true); + + for (int i = 0; i < N; i++) + { + sut.MyFunc(42); + } + + sut.Mock.Verify.MyFunc(It.IsAny()).Exactly(N); + } + + [Benchmark] + public void Predicate() + { + IMyMethodInterface sut = IMyMethodInterface.CreateMock(); + sut.Mock.Setup.MyFunc(x => x > 0).Returns(true); + + for (int i = 0; i < N; i++) + { + sut.MyFunc(42); + } + + sut.Mock.Verify.MyFunc(x => x > 0).Exactly(N); + } +} +#pragma warning restore CA1822 // Mark members as static diff --git a/Benchmarks/Mockolate.Benchmarks.Unions/UnionSetupBenchmarks.cs b/Benchmarks/Mockolate.Benchmarks.Unions/UnionSetupBenchmarks.cs new file mode 100644 index 00000000..ba8b2852 --- /dev/null +++ b/Benchmarks/Mockolate.Benchmarks.Unions/UnionSetupBenchmarks.cs @@ -0,0 +1,33 @@ +using BenchmarkDotNet.Attributes; + +namespace Mockolate.Benchmarks.Unions; + +#pragma warning disable CA1822 // Mark members as static +/// +/// Isolates the argument conversion and setup dispatch of the union-typed surface: creates a mock and registers one +/// setup with a literal value, an It matcher or a predicate. +/// +public class UnionSetupBenchmarks : BenchmarksBase +{ + [Benchmark(Baseline = true)] + public void Value() + { + IMyMethodInterface sut = IMyMethodInterface.CreateMock(); + sut.Mock.Setup.MyFunc(42).Returns(true); + } + + [Benchmark] + public void Matcher() + { + IMyMethodInterface sut = IMyMethodInterface.CreateMock(); + sut.Mock.Setup.MyFunc(It.IsAny()).Returns(true); + } + + [Benchmark] + public void Predicate() + { + IMyMethodInterface sut = IMyMethodInterface.CreateMock(); + sut.Mock.Setup.MyFunc(x => x > 0).Returns(true); + } +} +#pragma warning restore CA1822 // Mark members as static diff --git a/CLAUDE.md b/CLAUDE.md index 614b754a..8ac88f8a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -53,6 +53,7 @@ An `IIncrementalGenerator` that runs at compile time and generates `Mock.{TypeNa - Handles interfaces, abstract classes, and delegates - Emits method overrides that delegate to `MockRegistry` - Targets .NET Standard 2.0 (Roslyn constraint) +- Union mode (`Sources.MockClass.Unions.cs`): with C# 15 (or `MockolateUnionParameters=true`) the setup/verify overloads take `ParameterArg?` or `Func` per parameter instead of the classic matcher/value set; below that the output is unchanged ### Source/Mockolate.Analyzers + Source/Mockolate.Analyzers.CodeFixers Roslyn analyzers that validate mock usage at compile time: diff --git a/Docs/pages/setup/02-methods.md b/Docs/pages/setup/02-methods.md index b5039984..c996ce31 100644 --- a/Docs/pages/setup/02-methods.md +++ b/Docs/pages/setup/02-methods.md @@ -1,6 +1,7 @@ # Methods -Use `sut.Mock.Setup.MethodName(…)` to set up methods. You can specify argument matchers for each parameter. +Use `sut.Mock.Setup.MethodName(…)` to set up methods. You can specify argument matchers for each parameter; with C# 15 +you can also pass predicates directly (see *Union Parameters* under Parameter Matching). ## Returns / Throws diff --git a/Docs/pages/setup/03-indexers.md b/Docs/pages/setup/03-indexers.md index 2657ed20..81ee5b6f 100644 --- a/Docs/pages/setup/03-indexers.md +++ b/Docs/pages/setup/03-indexers.md @@ -132,3 +132,16 @@ does not intercept. methods. - Use `.SkippingBaseClass(…)` to override the base class behavior for a specific indexer (only for class mocks). - When you specify overlapping setups, the most recently defined setup takes precedence. + +## Union Parameters (C# 15) + +With C# 15, indexer keys accept predicates directly, in setups and verifications alike: + +```csharp +sut.Mock.Setup[type => type.StartsWith("D")].Returns(10); + +sut.Mock.Verify[type => type.StartsWith("D")].Got().Once(); +``` + +Only an indexer that is the sole indexer of its key count on the type takes union-typed keys; indexers sharing a key +count keep the classic matcher/value overloads. See *Union Parameters* under Parameter Matching for the details. diff --git a/Docs/pages/setup/04-parameter-matching.md b/Docs/pages/setup/04-parameter-matching.md index 875fb900..313236f7 100644 --- a/Docs/pages/setup/04-parameter-matching.md +++ b/Docs/pages/setup/04-parameter-matching.md @@ -242,6 +242,43 @@ 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.) +## Union Parameters (C# 15) + +When the consuming project compiles with C# 15, Mockolate generates the setup and verify overloads with union-typed +parameters: every value-capable parameter becomes a `ParameterArg?` that accepts an `It` matcher or a direct value, +and a `Func` overload accepts a predicate. The number of overloads stays the same as before, but predicates no +longer need `It.Satisfies`: + +```csharp +sut.Mock.Setup.Dispense(type => type.StartsWith("D"), It.IsAny()).Returns(true); + +sut.Mock.Verify.Dispense("Dark", amount => amount > 10).Once(); +``` + +Union mode is enabled automatically once the compiler ships C# 15 and the project's effective language version is +C# 15 or later. On a preview compiler, opt in with `true` in the +project file; `false` keeps the classic overloads on any compiler. + +Behaviour of the union-typed parameters: + +- `null` and `default` stand for the parameter's declared default value, or for `default(T)` when it has none, exactly + as with the classic value overloads. +- A parameter whose type is a delegate offers the raw delegate instead of a predicate, so a lambda is still matched as + a value. +- For an `object` parameter, a lambda literal is a predicate, while a delegate stored in a variable is a value. +- Within a union-typed member, `ref`, `out` and `ref readonly` parameters as well as `Span` and `ReadOnlySpan` + parameters keep their matcher slot (no predicate for that parameter); `in` parameters behave like by-value ones. +- Overloaded method names (including a generic sibling), generic methods, `params` methods, members with custom + ref-struct parameters, and indexers that share their key count with another indexer keep the classic matcher/value + overloads. Use `It.Satisfies` for predicates there. + +The generated `ParameterArg` type relies on `UnionAttribute`, `OverloadResolutionPriorityAttribute` and +`CallerArgumentExpressionAttribute`. Mockolate declares whichever of them the compilation lacks (neither the referenced +frameworks nor the project itself provide it). Another generator such as PolySharp can provide them without Mockolate +noticing; set `false` to declare that +`OverloadResolutionPriorityAttribute` and `CallerArgumentExpressionAttribute` come from elsewhere (`UnionAttribute` +keeps following the compilation), or list the attribute names the project provides. + ## 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 512fe577..6c8d4af9 100644 --- a/Mockolate.slnx +++ b/Mockolate.slnx @@ -1,6 +1,7 @@ + diff --git a/README.md b/README.md index 984af0f3..b7aba191 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ It enables fast, compile-time validated mocking with .NET Standard 2.0, .NET 8, - **Fast**: Direct dispatch with no reflection or dynamic proxies. - **Strongly-typed**: Compile-time safety and IntelliSense support. - **AOT compatible**: Works with Native AOT and trimming. -- **Modern C#**: First-class support for ref structs, static interface members, and current language features. +- **Modern C#**: First-class support for ref structs, static interface members, and current language features. With C# 15, setup and verify arguments accept predicates directly through union-typed parameters (see [parameter matching](https://docs.testably.org/Mockolate/setup/parameter-matching)). ## Why Mockolate From 9e405ab2a81effbb7900e9659c3c368bbc543f9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Sat, 5 Sep 2026 08:26:11 +0200 Subject: [PATCH 07/14] chore: address SonarCloud findings Classify Mockolate.Benchmarks.Unions as a test project for SonarCloud, matching the classic benchmark project (which is only classified as test code because it references mocking frameworks), so its lines are neither analysed as production code nor counted as uncovered new code. Split the nested ternary in GenerateUnionSlotCombinations (S3358). --- .../Mockolate.Benchmarks.Unions.csproj | 2 ++ .../Sources/Sources.MockClass.Unions.cs | 7 ++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Benchmarks/Mockolate.Benchmarks.Unions/Mockolate.Benchmarks.Unions.csproj b/Benchmarks/Mockolate.Benchmarks.Unions/Mockolate.Benchmarks.Unions.csproj index 351c9152..0954cf8c 100644 --- a/Benchmarks/Mockolate.Benchmarks.Unions/Mockolate.Benchmarks.Unions.csproj +++ b/Benchmarks/Mockolate.Benchmarks.Unions/Mockolate.Benchmarks.Unions.csproj @@ -13,6 +13,8 @@ false false False + + true diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.Unions.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.Unions.cs index 229d6f5d..56f82519 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.Unions.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.Unions.cs @@ -101,11 +101,8 @@ private static IEnumerable GenerateUnionSlotCombinations(EquatableA for (int bit = 0; bit < valueableIndices.Length; bit++) { int index = valueableIndices[bit]; - slots[index] = (combo & (1 << bit)) == 0 - ? UnionSlot.Union - : all[index].Type.IsDelegate - ? UnionSlot.RawDelegate - : UnionSlot.Predicate; + UnionSlot predicateSlot = all[index].Type.IsDelegate ? UnionSlot.RawDelegate : UnionSlot.Predicate; + slots[index] = (combo & (1 << bit)) == 0 ? UnionSlot.Union : predicateSlot; } yield return slots; From 0ba4ce1e51457236cc03e66db0a01bba2907b826 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Sat, 5 Sep 2026 08:26:35 +0200 Subject: [PATCH 08/14] chore: add the UnionTests target to the Nuke build schema --- .nuke/build.schema.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index 42be27ab..009030e5 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -44,6 +44,7 @@ "Pack", "PublishBenchmarkReport", "Restore", + "UnionTests", "UnitTests", "UpdateReadme" ] From aa12b4d04976655675fb41f92147b1a5b585bcf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Sat, 5 Sep 2026 09:18:55 +0200 Subject: [PATCH 09/14] fix: stop generating runtimeconfig.dev.json for test projects The .NET 11 SDK writes a runtimeconfig.dev.json with hot reload options but without additionalProbingPaths for Debug builds. VsTest 18.0.1, bundled with Stryker 4.10.0, reads that file on Linux (where no testhost.exe exists next to the test assembly) and throws a NullReferenceException in DotnetTestHostManager.GetTestHostPath, so test discovery is aborted and mutation testing fails with "No test result reported". Reproduced and verified in a Debian WSL environment with the same SDK and Stryker version: 0 tests discovered before, 3770 after. --- Tests/Directory.Build.props | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Tests/Directory.Build.props b/Tests/Directory.Build.props index 74fede68..0ddc7406 100644 --- a/Tests/Directory.Build.props +++ b/Tests/Directory.Build.props @@ -14,6 +14,12 @@ false true 701;1702;CA1845 + + false From b66af9ef9ba18b656ac107221a2f9bc4be252bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Sat, 5 Sep 2026 17:09:06 +0200 Subject: [PATCH 10/14] fix: address code review findings in union parameter generation - Delegate mocks: emit [OverloadResolutionPriority] on the IParameters setup/verify overloads so they no longer lose to the union overloads - Methods with more than four parameters keep a raw-delegate value overload so lambda arguments still compile in union mode - Treat System.Delegate/System.MulticastDelegate parameters as delegates (raw value slot instead of a predicate) - Union indexer keys resolve null/default to the declared parameter default, like the method path - Scope the union-eligibility uniqueness checks per member scope and evaluate them lazily (never when union mode is off) - Accept suffix-less attribute names in MockolateUnionAttributePolyfills - Detect C# 15 by enum name instead of the hardcoded value 1500 - Pin Mockolate.Benchmarks to classic mode so the classic-vs-union benchmark comparison survives the C# 15 GA - Share one CovariantParameterAdapter (emitted in Mock.g.cs), the slow-path verify condition, and the summary cref formatting between classic and union emission; hoist union indexer key matchers out of the per-interaction lambdas; use MaxExplicitParameters consistently --- .../Mockolate.Benchmarks.csproj | 4 + Docs/pages/setup/04-parameter-matching.md | 7 +- README.md | 2 +- .../Entities/Type.cs | 4 +- .../MockGenerator.cs | 19 ++- .../Sources/Sources.Mock.cs | 38 +++-- .../Sources/Sources.MockClass.Unions.cs | 161 ++++++++++++------ .../Sources/Sources.MockClass.cs | 107 +++++------- .../Sources/Sources.MockDelegate.cs | 8 +- .../Sources/Sources.ParameterArg.cs | 9 +- .../Mock.ComprehensiveAbstractClass.g.cs | 13 -- .../Mock.ICombinationMockA.g.cs | 13 -- .../Mock.ICombinationMockB.g.cs | 13 -- .../Mock.g.cs | 38 +++-- .../Mock.ComprehensiveAbstractClass.g.cs | 13 -- .../Mock.g.cs | 38 +++-- .../Mock.g.cs | 38 +++-- .../Mock.ComprehensiveDelegate.g.cs | 2 + .../Mock.g.cs | 38 +++-- .../ParameterArg.g.cs | 9 +- .../Mock.IComprehensiveInterface.g.cs | 13 -- .../Mock.g.cs | 38 +++-- .../Mock.IComprehensiveInterface.g.cs | 13 -- .../Mock.g.cs | 38 +++-- .../ParameterArg.g.cs | 9 +- .../Mock.HttpClient.g.cs | 13 -- .../Mock.HttpMessageHandler.g.cs | 13 -- .../HttpClient_CanBeCreated/Mock.g.cs | 38 +++-- .../Mock.HttpClient.g.cs | 13 -- .../Mock.HttpMessageHandler.g.cs | 13 -- .../HttpClient_CanBeCreated_Unions/Mock.g.cs | 38 +++-- .../ParameterArg.g.cs | 9 +- .../Mock.IKeywordEdgeCases.g.cs | 13 -- .../KeywordEdgeCases_CanBeCreated/Mock.g.cs | 38 +++-- .../Mock.IKeywordEdgeCases.g.cs | 13 -- .../Mock.g.cs | 38 +++-- .../ParameterArg.g.cs | 9 +- .../Mock.IRefStructConsumer.g.cs | 13 -- .../RefStructConsumer_CanBeCreated/Mock.g.cs | 38 +++-- .../Mock.IStaticAbstractMembers.g.cs | 13 -- .../Mock.g.cs | 38 +++-- .../Mock.IUnionIndexers.g.cs | 31 ++-- .../Mock.g.cs | 38 +++-- .../ParameterArg.g.cs | 9 +- .../UnionParameterArgTests.cs | 2 +- Tests/Mockolate.Tests/UnionSetupTests.cs | 85 +++++++++ 46 files changed, 570 insertions(+), 630 deletions(-) diff --git a/Benchmarks/Mockolate.Benchmarks/Mockolate.Benchmarks.csproj b/Benchmarks/Mockolate.Benchmarks/Mockolate.Benchmarks.csproj index 6b2d721e..52acc274 100644 --- a/Benchmarks/Mockolate.Benchmarks/Mockolate.Benchmarks.csproj +++ b/Benchmarks/Mockolate.Benchmarks/Mockolate.Benchmarks.csproj @@ -1,8 +1,12 @@ + + + Exe net11.0 + false enable enable false diff --git a/Docs/pages/setup/04-parameter-matching.md b/Docs/pages/setup/04-parameter-matching.md index 313236f7..222cc99e 100644 --- a/Docs/pages/setup/04-parameter-matching.md +++ b/Docs/pages/setup/04-parameter-matching.md @@ -268,9 +268,10 @@ Behaviour of the union-typed parameters: - For an `object` parameter, a lambda literal is a predicate, while a delegate stored in a variable is a value. - Within a union-typed member, `ref`, `out` and `ref readonly` parameters as well as `Span` and `ReadOnlySpan` parameters keep their matcher slot (no predicate for that parameter); `in` parameters behave like by-value ones. -- Overloaded method names (including a generic sibling), generic methods, `params` methods, members with custom - ref-struct parameters, and indexers that share their key count with another indexer keep the classic matcher/value - overloads. Use `It.Satisfies` for predicates there. +- Overloaded method names (including a generic sibling; a same-named member in another scope — public, protected or + static — does not count), generic methods, `params` methods, members with custom ref-struct parameters, and indexers + that share their key count with another same-scope indexer keep the classic matcher/value overloads. Use + `It.Satisfies` for predicates there. The generated `ParameterArg` type relies on `UnionAttribute`, `OverloadResolutionPriorityAttribute` and `CallerArgumentExpressionAttribute`. Mockolate declares whichever of them the compilation lacks (neither the referenced diff --git a/README.md b/README.md index b7aba191..984af0f3 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ It enables fast, compile-time validated mocking with .NET Standard 2.0, .NET 8, - **Fast**: Direct dispatch with no reflection or dynamic proxies. - **Strongly-typed**: Compile-time safety and IntelliSense support. - **AOT compatible**: Works with Native AOT and trimming. -- **Modern C#**: First-class support for ref structs, static interface members, and current language features. With C# 15, setup and verify arguments accept predicates directly through union-typed parameters (see [parameter matching](https://docs.testably.org/Mockolate/setup/parameter-matching)). +- **Modern C#**: First-class support for ref structs, static interface members, and current language features. ## Why Mockolate diff --git a/Source/Mockolate.SourceGenerators/Entities/Type.cs b/Source/Mockolate.SourceGenerators/Entities/Type.cs index 613467db..0b93a400 100644 --- a/Source/Mockolate.SourceGenerators/Entities/Type.cs +++ b/Source/Mockolate.SourceGenerators/Entities/Type.cs @@ -51,7 +51,9 @@ typeSymbol is INamedTypeSymbol IsRefStruct = typeSymbol.IsRefLikeType; // A lambda never converts to a union type, so union-mode setups keep the raw delegate type as the // value alternative of a delegate-typed parameter instead of offering a predicate overload. - IsDelegate = typeSymbol.TypeKind == TypeKind.Delegate; + // System.Delegate / System.MulticastDelegate have TypeKind.Class but accept the same conversions. + IsDelegate = typeSymbol.TypeKind == TypeKind.Delegate || + typeSymbol.SpecialType is SpecialType.System_Delegate or SpecialType.System_MulticastDelegate; } public bool IsFormattable { get; } diff --git a/Source/Mockolate.SourceGenerators/MockGenerator.cs b/Source/Mockolate.SourceGenerators/MockGenerator.cs index 756097ee..7aea1105 100644 --- a/Source/Mockolate.SourceGenerators/MockGenerator.cs +++ b/Source/Mockolate.SourceGenerators/MockGenerator.cs @@ -237,7 +237,13 @@ static HashSet ProvidedUnionAttributes(AnalyzerConfigOptionsProvider ana int lastDot = trimmed.LastIndexOf('.'); if (trimmed.Length > 0 && !string.Equals(trimmed, "true", StringComparison.OrdinalIgnoreCase)) { - provided.Add(lastDot < 0 ? trimmed : trimmed.Substring(lastDot + 1)); + // The lookups check the 'Attribute'-suffixed name; accept the suffix-less spelling too. + string simpleName = lastDot < 0 ? trimmed : trimmed.Substring(lastDot + 1); + provided.Add(simpleName); + if (!simpleName.EndsWith("Attribute", StringComparison.OrdinalIgnoreCase)) + { + provided.Add(simpleName + "Attribute"); + } } } @@ -246,9 +252,9 @@ static HashSet ProvidedUnionAttributes(AnalyzerConfigOptionsProvider ana // The MockolateUnionParameters build property (made compiler-visible by build/Mockolate.props) wins when // set: "true" opts in on a preview compiler, any other value is the kill switch. Otherwise unions are used once the - // host compiler has shipped C# 15 (the generator is compiled against an older Roslyn and cannot name - // LanguageVersion.CSharp15, hence the numeric check) and the compilation's effective language version - // includes it. LanguageVersion.Preview passes the numeric test, but only counts once the compiler is capable. + // host compiler has shipped C# 15 (the generator is compiled against an older Roslyn and cannot reference + // LanguageVersion.CSharp15 directly, hence the name-based lookup) and the compilation's effective language + // version includes it. LanguageVersion.Preview compares greater, but only counts once the compiler is capable. static bool HasUnionSupport(ParseOptions parseOptions, AnalyzerConfigOptionsProvider analyzerConfigOptions) { if (analyzerConfigOptions.GlobalOptions.TryGetValue("build_property.MockolateUnionParameters", @@ -258,10 +264,9 @@ static bool HasUnionSupport(ParseOptions parseOptions, AnalyzerConfigOptionsProv return string.Equals(configured.Trim(), "true", StringComparison.OrdinalIgnoreCase); } - const int csharp15 = 1500; return parseOptions is CSharpParseOptions csharpParseOptions && - Enum.IsDefined(typeof(LanguageVersion), csharp15) && - (int)csharpParseOptions.LanguageVersion >= csharp15; + Enum.TryParse("CSharp15", out LanguageVersion csharp15) && + csharpParseOptions.LanguageVersion >= csharp15; } } diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.Mock.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.Mock.cs index 833905bd..6f7f96b2 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.Mock.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.Mock.cs @@ -120,25 +120,27 @@ internal interface IMockGenerationDidNotRun {} } } - /// - /// Adapts an (non-generic) to - /// so that covariant parameter - /// references (e.g. an IParameter<Derived> passed through an IParameter<Base> - /// slot) can still be invoked at setup/verify time. Only allocated when the direct - /// cast fails. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); + } - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } + /// + /// Adapts an (non-generic) to + /// so that covariant parameter + /// references (e.g. an IParameter<Derived> passed through an IParameter<Base> + /// slot) can still be invoked at setup/verify time. Only allocated when the direct + /// cast fails. Shared by every + /// generated mock file. + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch + { + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); } #nullable disable """); diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.Unions.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.Unions.cs index 56f82519..efa5b274 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.Unions.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.Unions.cs @@ -64,15 +64,28 @@ private static bool UseUnionOverloads(Method method, bool hasUniqueName, bool us !method.Parameters.Any(p => p.NeedsRefStructPipeline() || p.IsParams) && method.Parameters.Any(p => p.CanUseNullableParameterOverload()); + /// + /// + /// Checks the cheap conditions first so the scan never runs when union + /// mode is off. + /// + private static bool UseUnionOverloads(Class @class, Method method, bool useUnionOverloads) + => UseUnionOverloads(method, hasUniqueName: true, useUnionOverloads) && + HasUniqueMethodName(@class, method); + /// - /// Whether no other mockable method of shares the C# name of . + /// Whether no other mockable method of in the same member scope shares the C# name + /// of . The setup/verify interfaces are emitted per , so + /// a same-named method in another scope never competes in overload resolution. /// carries the type parameter list of generic methods (Foo<T>), so the /// comparison strips it: a generic sibling is an overload for the compiler as well. /// private static bool HasUniqueMethodName(Class @class, Method method) { string bareName = BareName(method); - return @class.AllMethods().Count(m => m.ExplicitImplementation is null && BareName(m) == bareName) == 1; + return @class.AllMethods().Count(m => m.ExplicitImplementation is null && + m.MemberType == method.MemberType && + BareName(m) == bareName) == 1; static string BareName(Method m) { @@ -83,8 +96,10 @@ static string BareName(Method m) /// /// Enumerates the slot assignments of the union-mode overload set, all-union first. Above - /// only the all-union overload is emitted (it already covers matchers and - /// values); predicates are not offered there. + /// the all-union overload is emitted (it already covers matchers and + /// values) plus — when delegate-typed parameters exist — one overload with the raw delegate slot for them + /// (a lambda never converts to a union, mirroring the classic all-values overload); predicates are not + /// offered there. /// private static IEnumerable GenerateUnionSlotCombinations(EquatableArray parameters) { @@ -94,7 +109,31 @@ private static IEnumerable GenerateUnionSlotCombinations(EquatableA .Where(x => x.p.CanUseNullableParameterOverload()) .Select(x => x.i) .ToArray(); - int totalCombos = all.Length <= MaxExplicitParameters ? 1 << valueableIndices.Length : 1; + if (all.Length > MaxExplicitParameters) + { + UnionSlot[] allUnion = new UnionSlot[all.Length]; + foreach (int index in valueableIndices) + { + allUnion[index] = UnionSlot.Union; + } + + yield return allUnion; + int[] delegateIndices = valueableIndices.Where(index => all[index].Type.IsDelegate).ToArray(); + if (delegateIndices.Length > 0) + { + UnionSlot[] withRawDelegates = (UnionSlot[])allUnion.Clone(); + foreach (int index in delegateIndices) + { + withRawDelegates[index] = UnionSlot.RawDelegate; + } + + yield return withRawDelegates; + } + + yield break; + } + + int totalCombos = 1 << valueableIndices.Length; for (int combo = 0; combo < totalCombos; combo++) { UnionSlot[] slots = new UnionSlot[all.Length]; @@ -139,12 +178,8 @@ private static void AppendUnionSummary(StringBuilder sb, Class @class, Method me sb.Append("\t\t/// ").AppendLine(); if (methodNameOverride is null) { - sb.Append("\t\t/// ").Append(action).Append(" the method p.RefKind.GetString() + p.Type.Fullname.EscapeForXmlDoc()))) - .Append(")\"/>"); + sb.Append("\t\t/// ").Append(action).Append(" the method "); } else { @@ -305,6 +340,21 @@ private static void AppendUnionExpressionParameters(StringBuilder sb, string[] n } } + /// + /// The fallback expression for an omitted or union argument: the parameter's declared + /// default value when it has one, otherwise the literal default(T). + /// + private static string UnionDefaultFallback(MethodParameter parameter) + { + if (!parameter.HasExplicitDefaultValue) + { + return "default"; + } + + string type = parameter.ToNullableType(); + return $"new global::Mockolate.ParameterArg<{type}>(({type})({parameter.ExplicitDefaultValue}))"; + } + /// /// ParameterArg<T> xArg = x ?? …; per union slot: an omitted or argument falls /// back to the parameter's declared default value when it has one, otherwise to the literal default(T). @@ -320,20 +370,9 @@ private static void AppendUnionArgumentLocals(StringBuilder sb, Method method, U } MethodParameter parameter = parameters[i]; - string type = parameter.ToNullableType(); - sb.Append("\t\t\tglobal::Mockolate.ParameterArg<").Append(type).Append("> ") - .Append(UnionArgumentLocalName(method, parameter)).Append(" = ").Append(parameter.Name).Append(" ?? "); - if (parameter.HasExplicitDefaultValue) - { - sb.Append("new global::Mockolate.ParameterArg<").Append(type).Append(">((").Append(type).Append(")(") - .Append(parameter.ExplicitDefaultValue).Append("))"); - } - else - { - sb.Append("default"); - } - - sb.Append(';').AppendLine(); + sb.Append("\t\t\tglobal::Mockolate.ParameterArg<").Append(parameter.ToNullableType()).Append("> ") + .Append(UnionArgumentLocalName(method, parameter)).Append(" = ").Append(parameter.Name).Append(" ?? ") + .Append(UnionDefaultFallback(parameter)).Append(';').AppendLine(); } } @@ -529,9 +568,9 @@ private static void AppendUnionMethodVerifyImplementation(StringBuilder sb, Meth // matchers through the typed overload when the member has a fast buffer, everything else through the // MethodInvocation predicate. bool noFixedSlots = slots.All(s => s != UnionSlot.Fixed); - bool literalEligible = parameters.Length <= 4 && noFixedSlots && + bool literalEligible = parameters.Length <= MaxExplicitParameters && noFixedSlots && slots.All(s => s is UnionSlot.Union or UnionSlot.RawDelegate); - bool typedEligible = useFastForMethod && parameters.Length <= 4 && noFixedSlots; + bool typedEligible = useFastForMethod && parameters.Length <= MaxExplicitParameters && noFixedSlots; if (literalEligible) { string literalCondition = UnionLiteralCondition(method, slots); @@ -616,19 +655,7 @@ private static void AppendUnionMethodVerifyImplementation(StringBuilder sb, Meth .Append(">.Default.Equals(").Append(parameter.Name).Append(", ").Append(invocationValue).Append("))"); break; default: - if (parameter.RefKind is RefKind.Out or RefKind.Ref or RefKind.RefReadOnlyParameter) - { - // out/ref verify parameters use IVerifyOutParameter / IVerifyRefParameter, which don't inherit - // from IParameter; keep the direct IParameterMatch check like the classic overloads. - sb.Append( - $"({parameter.Name} is global::Mockolate.Parameters.IParameterMatch<{type}> {parameter.Name}Match ? {parameter.Name}Match.Matches({invocationValue}) : global::System.Collections.Generic.EqualityComparer<{type}>.Default.Equals({invocationValue}, default({type})))"); - } - else - { - sb.Append( - $"({parameter.Name} is not null ? CovariantParameterAdapter<{type}>.Wrap({parameter.Name}).Matches({invocationValue}) : global::System.Collections.Generic.EqualityComparer<{type}>.Default.Equals({invocationValue}, default({type})))"); - } - + AppendSlowVerifyMatcherCondition(sb, parameter, invocationValue); break; } } @@ -659,11 +686,21 @@ indexer.IndexerParameters is { } parameters && !parameters.Any(p => p.NeedsRefStructPipeline() || p.IsParams) && parameters.Any(p => p.CanUseNullableParameterOverload()); + /// + /// + /// Checks the cheap conditions first so the scan never runs when + /// union mode is off. + /// + private static bool UseUnionIndexer(Class @class, Property indexer, bool useUnionOverloads) + => UseUnionIndexer(indexer, hasUniqueKeyCount: true, useUnionOverloads) && + HasUniqueIndexerKeyCount(@class, indexer); + private static bool HasUniqueIndexerKeyCount(Class @class, Property indexer) { int keyCount = indexer.IndexerParameters!.Value.Count; return @class.AllProperties().Count(p => - p.IsIndexer && p.ExplicitImplementation is null && p.IndexerParameters?.Count == keyCount) == 1; + p.IsIndexer && p.ExplicitImplementation is null && p.MemberType == indexer.MemberType && + p.IndexerParameters?.Count == keyCount) == 1; } // Indexers have no IParameters overload, so the all-union indexer simply takes the top priority the classic @@ -703,8 +740,8 @@ private static void AppendUnionIndexerParameters(StringBuilder sb, Property inde /// /// The IParameterMatch<T> for one indexer key. Indexers have no literal fast path, so a union slot - /// always goes through ToParameterMatch(); an omitted or key is the literal - /// default(T). + /// always goes through ToParameterMatch(); an omitted or key falls back to the + /// key's declared default value when it has one, otherwise to the literal default(T). /// private static void AppendUnionIndexerKeyMatch(StringBuilder sb, MethodParameter parameter, string name, string expressionName, UnionSlot slot) @@ -712,7 +749,8 @@ private static void AppendUnionIndexerKeyMatch(StringBuilder sb, MethodParameter switch (slot) { case UnionSlot.Union: - sb.Append('(').Append(name).Append(" ?? default).ToParameterMatch()"); + sb.Append('(').Append(name).Append(" ?? ").Append(UnionDefaultFallback(parameter)) + .Append(").ToParameterMatch()"); break; case UnionSlot.Predicate: sb.Append("(global::Mockolate.Parameters.IParameterMatch<").Append(parameter.ToTypeOrWrapper()) @@ -733,7 +771,7 @@ private static void AppendUnionIndexerSetupDefinition(StringBuilder sb, Property { string[] names = UnionIndexerSetupNames(indexer); sb.AppendXmlSummary( - $"Setup for the {indexer.Type.Fullname.EscapeForXmlDoc()} indexer p.RefKind.GetString() + p.Type.Fullname.EscapeForXmlDoc()))}]\" />"); + $"Setup for the {indexer.Type.Fullname.EscapeForXmlDoc()} indexer "); AppendUnionOverloadRemark(sb, names, slots); sb.Append("\t\t[global::System.Runtime.CompilerServices.OverloadResolutionPriority(") .Append(UnionIndexerPriority(slots)).Append(")]").AppendLine(); @@ -806,7 +844,7 @@ private static void AppendUnionIndexerVerifyDefinition(StringBuilder sb, Propert { string[] names = UnionIndexerVerifyNames(indexer); sb.AppendXmlSummary( - $"Verify interactions with the {indexer.Type.Fullname.EscapeForXmlDoc()} indexer p.RefKind.GetString() + p.Type.Fullname.EscapeForXmlDoc()))}]\" />."); + $"Verify interactions with the {indexer.Type.Fullname.EscapeForXmlDoc()} indexer ."); AppendUnionOverloadRemark(sb, names, slots); sb.Append("\t\t[global::System.Runtime.CompilerServices.OverloadResolutionPriority(") .Append(UnionIndexerPriority(slots)).Append(")]").AppendLine(); @@ -850,7 +888,7 @@ private static void AppendUnionIndexerVerifyImplementation(StringBuilder sb, Pro sb.Append("\t\t{").AppendLine(); sb.Append("\t\t\tget").AppendLine(); sb.Append("\t\t\t{").AppendLine(); - if (parameters.Length <= 4) + if (parameters.Length <= MaxExplicitParameters) { // Typed path: one IParameterMatch per key, exactly like the classic matcher indexer. string typedVerifyType = interceptedAccessors switch @@ -888,6 +926,18 @@ private static void AppendUnionIndexerVerifyImplementation(StringBuilder sb, Pro } else { + // Hoist the key matchers out of the per-interaction lambdas, like the method slow path. + string[] matchNames = names + .Select(n => CreateUniqueParameterName(indexer.IndexerParameters!.Value, $"{n}Match")) + .ToArray(); + for (int i = 0; i < parameters.Length; i++) + { + sb.Append("\t\t\t\tglobal::Mockolate.Parameters.IParameterMatch<") + .Append(parameters[i].ToTypeOrWrapper()).Append("> ").Append(matchNames[i]).Append(" = "); + AppendUnionIndexerKeyMatch(sb, parameters[i], names[i], expressionNames[i], slots[i]); + sb.Append(';').AppendLine(); + } + switch (interceptedAccessors) { case PropertyAccessors.GetOnly: @@ -923,7 +973,7 @@ private static void AppendUnionIndexerVerifyImplementation(StringBuilder sb, Pro { sb.Append("\t\t\t\t\tinteraction => interaction is global::Mockolate.Interactions.IndexerGetterAccess<") .Append(string.Join(", ", parameters.Select(p => p.ToTypeOrWrapper()))).Append("> g"); - AppendUnionIndexerKeyMatches(sb, parameters, names, expressionNames, slots, "g"); + AppendUnionIndexerKeyMatches(sb, matchNames, "g"); sb.Append(",").AppendLine(); } @@ -937,7 +987,7 @@ private static void AppendUnionIndexerVerifyImplementation(StringBuilder sb, Pro } sb.AppendTypeOrWrapper(indexer.Type).Append("> s"); - AppendUnionIndexerKeyMatches(sb, parameters, names, expressionNames, slots, "s"); + AppendUnionIndexerKeyMatches(sb, matchNames, "s"); sb.Append(" && value.Matches(s.TypedValue),").AppendLine(); } } @@ -951,7 +1001,8 @@ private static void AppendUnionIndexerVerifyImplementation(StringBuilder sb, Pro switch (slots[i]) { case UnionSlot.Union: - sb.Append("(object?)(").Append(names[i]).Append(" ?? default)"); + sb.Append("(object?)(").Append(names[i]).Append(" ?? ").Append(UnionDefaultFallback(parameters[i])) + .Append(')'); break; case UnionSlot.Predicate: sb.Append("(object?)").Append(expressionNames[i]); @@ -968,14 +1019,12 @@ private static void AppendUnionIndexerVerifyImplementation(StringBuilder sb, Pro sb.AppendLine(); } - private static void AppendUnionIndexerKeyMatches(StringBuilder sb, MethodParameter[] parameters, string[] names, - string[] expressionNames, UnionSlot[] slots, string interactionVar) + private static void AppendUnionIndexerKeyMatches(StringBuilder sb, string[] matchNames, string interactionVar) { - for (int i = 0; i < parameters.Length; i++) + for (int i = 0; i < matchNames.Length; i++) { - sb.Append(" && "); - AppendUnionIndexerKeyMatch(sb, parameters[i], names[i], expressionNames[i], slots[i]); - sb.Append(".Matches(").Append(interactionVar).Append(".Parameter").Append(i + 1).Append(')'); + sb.Append(" && ").Append(matchNames[i]) + .Append(".Matches(").Append(interactionVar).Append(".Parameter").Append(i + 1).Append(')'); } } diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs index 596598d3..a09ba3aa 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.MockClass.cs @@ -1182,8 +1182,6 @@ static bool TryCastWithDefaultValue(object?[] values, int index, TValue #endregion Setup helpers - AppendNestedCovariantParameterAdapter(sb); - sb.Append("}").AppendLine(); #endregion MockForXXXExtensions @@ -3042,32 +3040,6 @@ private static void AppendRefStructIndexerSetterBody(StringBuilder sb, Property #region Setup Helpers - /// - /// Emits a private nested CovariantParameterAdapter<T> class, used so that covariant widening of - /// IParameter<T> parameters can be dispatched at setup/verify time without an - /// IParameterMatch<T> cast failure. - /// - private static void AppendNestedCovariantParameterAdapter(StringBuilder sb) - { - sb.AppendLine(); - sb.Append("\t[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]").AppendLine(); - sb.Append( - "\tprivate sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch") - .AppendLine(); - sb.Append("\t{").AppendLine(); - sb.Append("\t\tpublic bool Matches(T value) => inner.Matches(value);").AppendLine(); - sb.Append("\t\tpublic void InvokeCallbacks(T value) => inner.InvokeCallbacks(value);").AppendLine(); - sb.Append("\t\tpublic override string? ToString() => inner.ToString();").AppendLine(); - sb.AppendLine(); - sb.Append( - "\t\tpublic static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter)") - .AppendLine(); - sb.Append("\t\t\t=> parameter is global::Mockolate.Parameters.IParameterMatch direct").AppendLine(); - sb.Append("\t\t\t\t? direct").AppendLine(); - sb.Append("\t\t\t\t: new CovariantParameterAdapter(parameter);").AppendLine(); - sb.Append("\t}").AppendLine(); - } - private static IEnumerable GenerateValueFlagCombinations(EquatableArray parameters) { int[] valueableIndices = parameters @@ -3300,7 +3272,7 @@ private static void DefineSetupInterface(StringBuilder sb, Class @class, MemberT indexer.MemberType == memberType; foreach (Property indexer in @class.AllProperties().Where(indexerPredicate)) { - if (UseUnionIndexer(indexer, HasUniqueIndexerKeyCount(@class, indexer), useUnionOverloads)) + if (UseUnionIndexer(@class, indexer, useUnionOverloads)) { foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(indexer.IndexerParameters!.Value)) { @@ -3359,7 +3331,7 @@ bool MethodPredicate(Method method) AppendMethodSetupDefinition(sb, @class, method, false, hasOverloadResolutionPriority: hasOverloadResolutionPriority); } - else if (UseUnionOverloads(method, HasUniqueMethodName(@class, method), useUnionOverloads)) + else if (UseUnionOverloads(@class, method, useUnionOverloads)) { foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(method.Parameters)) { @@ -3493,6 +3465,18 @@ private static bool HasParamsValueParameter(Method method, bool[]? valueFlags) !parameter.NeedsRefStructPipeline(); } + /// + /// The cref target for , shared between the classic and union summaries. + /// + private static string MethodCref(Method method) + => $"{method.DeclaredContainingType.EscapeForXmlDoc()}.{method.Name.EscapeForXmlDoc()}({string.Join(", ", method.Parameters.Select(p => p.RefKind.GetString() + p.Type.Fullname.EscapeForXmlDoc()))})"; + + /// + /// The cref target for , shared between the classic and union summaries. + /// + private static string IndexerCref(Property indexer) + => $"{indexer.DeclaredContainingType.EscapeForXmlDoc()}.this[{string.Join(", ", indexer.IndexerParameters!.Value.Select(p => p.RefKind.GetString() + p.Type.Fullname.EscapeForXmlDoc()))}]"; + private static void AppendMethodSetupDefinition(StringBuilder sb, Class @class, Method method, bool useParameters, string? methodNameOverride = null, bool[]? valueFlags = null, bool hasOverloadResolutionPriority = false, bool perElementParams = false) @@ -3527,12 +3511,7 @@ private static void AppendMethodSetupDefinition(StringBuilder sb, Class @class, sb.Append("\t\t/// ").AppendLine(); if (methodNameOverride is null) { - sb.Append("\t\t/// Setup for the method p.RefKind.GetString() + p.Type.Fullname.EscapeForXmlDoc()))) - .Append(")\"/>"); + sb.Append("\t\t/// Setup for the method "); } else { @@ -3781,7 +3760,7 @@ private static void ImplementSetupInterface(StringBuilder sb, Class @class, stri indexer.MemberType == memberType; foreach (Property indexer in @class.AllProperties().Where(indexerPredicate)) { - if (UseUnionIndexer(indexer, HasUniqueIndexerKeyCount(@class, indexer), useUnionOverloads)) + if (UseUnionIndexer(@class, indexer, useUnionOverloads)) { foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(indexer.IndexerParameters!.Value)) { @@ -3844,7 +3823,7 @@ bool MethodPredicate(Method method) AppendMethodSetupImplementation(sb, method, mockRegistryName, setupName, false, memberIds, memberIdPrefix, scopeExpression: scopeExpression); } - else if (UseUnionOverloads(method, HasUniqueMethodName(@class, method), useUnionOverloads)) + else if (UseUnionOverloads(@class, method, useUnionOverloads)) { foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(method.Parameters)) { @@ -4318,7 +4297,7 @@ private static void AppendIndexerSetupDefinition(StringBuilder sb, Property inde } sb.AppendXmlSummary( - $"Setup for the {indexer.Type.Fullname.EscapeForXmlDoc()} indexer p.RefKind.GetString() + p.Type.Fullname.EscapeForXmlDoc()))}]\" />"); + $"Setup for the {indexer.Type.Fullname.EscapeForXmlDoc()} indexer "); string[] indexerNames = Enumerable.Range(1, indexer.IndexerParameters!.Value.Count) .Select(i => $"parameter{i}").ToArray(); AppendOverloadDifferentiatorRemark(sb, indexerNames, false, valueFlags); @@ -4771,7 +4750,7 @@ private static void AppendIndexerVerifyDefinition(StringBuilder sb, Property ind } sb.AppendXmlSummary( - $"Verify interactions with the {indexer.Type.Fullname.EscapeForXmlDoc()} indexer p.RefKind.GetString() + p.Type.Fullname.EscapeForXmlDoc()))}]\" />."); + $"Verify interactions with the {indexer.Type.Fullname.EscapeForXmlDoc()} indexer ."); AppendOverloadDifferentiatorRemark(sb, indexer.IndexerParameters!.Value.Select(p => p.Name).ToArray(), false, valueFlags, true); @@ -5237,7 +5216,7 @@ private static void DefineVerifyInterface(StringBuilder sb, Class @class, string indexer.MemberType == memberType; foreach (Property indexer in @class.AllProperties().Where(indexerPredicate)) { - if (UseUnionIndexer(indexer, HasUniqueIndexerKeyCount(@class, indexer), useUnionOverloads)) + if (UseUnionIndexer(@class, indexer, useUnionOverloads)) { foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(indexer.IndexerParameters!.Value)) { @@ -5298,7 +5277,7 @@ bool MethodPredicate(Method method) AppendMethodVerifyDefinition(sb, method, verifyName, false, hasOverloadResolutionPriority: hasOverloadResolutionPriority); } - else if (UseUnionOverloads(method, HasUniqueMethodName(@class, method), useUnionOverloads)) + else if (UseUnionOverloads(@class, method, useUnionOverloads)) { foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(method.Parameters)) { @@ -5373,12 +5352,8 @@ private static void AppendMethodVerifyDefinition(StringBuilder sb, Method method sb.Append("\t\t/// ").AppendLine(); if (methodNameOverride is null) { - sb.Append("\t\t/// Verify invocations for the method p.RefKind.GetString() + p.Type.Fullname.EscapeForXmlDoc()))); - sb.Append(")\"/>"); + sb.Append("\t\t/// Verify invocations for the method "); } else { @@ -5544,7 +5519,7 @@ private static void ImplementVerifyInterface(StringBuilder sb, Class @class, str indexer.MemberType == memberType; foreach (Property indexer in @class.AllProperties().Where(indexerPredicate)) { - if (UseUnionIndexer(indexer, HasUniqueIndexerKeyCount(@class, indexer), useUnionOverloads)) + if (UseUnionIndexer(@class, indexer, useUnionOverloads)) { foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(indexer.IndexerParameters!.Value)) { @@ -5607,7 +5582,7 @@ bool MethodPredicate(Method method) AppendMethodVerifyImplementation(sb, method, mockRegistryName, verifyName, false, memberIds, memberIdPrefix, useFastBuffers); } - else if (UseUnionOverloads(method, HasUniqueMethodName(@class, method), useUnionOverloads)) + else if (UseUnionOverloads(@class, method, useUnionOverloads)) { foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(method.Parameters)) { @@ -5891,18 +5866,9 @@ private static void AppendMethodVerifyImplementation(StringBuilder sb, Method me ? $"(CovariantParameterAdapter<{parameter.Type.Fullname}>.Wrap(global::Mockolate.It.SequenceEquals<{parameter.Type.ElementType.Fullname}>({parameter.Name})).Matches(__i.Parameter{i + 1}))" : $"(global::System.Collections.Generic.EqualityComparer<{parameter.ToTypeOrWrapper()}>.Default.Equals({parameter.Name}, __i.Parameter{i + 1}))"); } - else if (parameter.RefKind == RefKind.Out || parameter.RefKind == RefKind.Ref || - parameter.RefKind == RefKind.RefReadOnlyParameter) - { - // out/ref verify parameters use IVerifyOutParameter / IVerifyRefParameter, which don't inherit - // from IParameter — covariance isn't applicable, so keep the direct IParameterMatch check. - sb.Append( - $"({parameter.Name} is global::Mockolate.Parameters.IParameterMatch<{parameter.ToTypeOrWrapper()}> {parameter.Name}Match ? {parameter.Name}Match.Matches(__i.Parameter{i + 1}) : global::System.Collections.Generic.EqualityComparer<{parameter.ToTypeOrWrapper()}>.Default.Equals(__i.Parameter{i + 1}, default({parameter.ToTypeOrWrapper()})))"); - } else { - sb.Append( - $"({parameter.Name} is not null ? CovariantParameterAdapter<{parameter.ToTypeOrWrapper()}>.Wrap({parameter.Name}).Matches(__i.Parameter{i + 1}) : global::System.Collections.Generic.EqualityComparer<{parameter.ToTypeOrWrapper()}>.Default.Equals(__i.Parameter{i + 1}, default({parameter.ToTypeOrWrapper()})))"); + AppendSlowVerifyMatcherCondition(sb, parameter, $"__i.Parameter{i + 1}"); } i++; @@ -5914,6 +5880,27 @@ private static void AppendMethodVerifyImplementation(StringBuilder sb, Method me .Append(")\");").AppendLine(); } + /// + /// The slow verify path's condition for one classic matcher argument, shared between the classic and the + /// union-mode emission. out/ref verify parameters don't inherit from IParameter<T>, so they keep + /// the direct IParameterMatch<T> check instead of the covariance adapter. + /// + private static void AppendSlowVerifyMatcherCondition(StringBuilder sb, MethodParameter parameter, + string invocationValue) + { + string type = parameter.ToTypeOrWrapper(); + if (parameter.RefKind is RefKind.Out or RefKind.Ref or RefKind.RefReadOnlyParameter) + { + sb.Append( + $"({parameter.Name} is global::Mockolate.Parameters.IParameterMatch<{type}> {parameter.Name}Match ? {parameter.Name}Match.Matches({invocationValue}) : global::System.Collections.Generic.EqualityComparer<{type}>.Default.Equals({invocationValue}, default({type})))"); + } + else + { + sb.Append( + $"({parameter.Name} is not null ? CovariantParameterAdapter<{type}>.Wrap({parameter.Name}).Matches({invocationValue}) : global::System.Collections.Generic.EqualityComparer<{type}>.Default.Equals({invocationValue}, default({type})))"); + } + } + #endregion Verify Helpers private static void AppendCreateFastInteractions(StringBuilder sb, string indent) diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.MockDelegate.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.MockDelegate.cs index 9db1f01d..5c7c9503 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.MockDelegate.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.MockDelegate.cs @@ -386,7 +386,9 @@ public static string MockDelegate(string name, MockClass @class, Method delegate if (UseUnionOverloads(delegateMethod, true, useUnionOverloads)) { - AppendMethodSetupDefinition(sb, @class, delegateMethod, true, "Setup"); + // Without the priority (guaranteed in union mode) the IParameters overload loses to the union overloads. + AppendMethodSetupDefinition(sb, @class, delegateMethod, true, "Setup", + hasOverloadResolutionPriority: true); foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(delegateMethod.Parameters)) { AppendUnionMethodSetupDefinition(sb, @class, delegateMethod, slots, "Setup"); @@ -431,7 +433,9 @@ public static string MockDelegate(string name, MockClass @class, Method delegate if (UseUnionOverloads(delegateMethod, true, useUnionOverloads)) { - AppendMethodVerifyDefinition(sb, delegateMethod, $"IMockVerifyFor{name}", true, "Verify"); + // Without the priority (guaranteed in union mode) the IParameters overload loses to the union overloads. + AppendMethodVerifyDefinition(sb, delegateMethod, $"IMockVerifyFor{name}", true, "Verify", + hasOverloadResolutionPriority: true); foreach (UnionSlot[] slots in GenerateUnionSlotCombinations(delegateMethod.Parameters)) { AppendUnionMethodVerifyDefinition(sb, @class, delegateMethod, $"IMockVerifyFor{name}", slots, "Verify"); diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.ParameterArg.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.ParameterArg.cs index f4a0dec5..03394762 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.ParameterArg.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.ParameterArg.cs @@ -190,7 +190,7 @@ public bool TryGetValue(out T? literal) return _matcher is global::Mockolate.Parameters.IParameterMatch direct ? direct - : new CovariantAdapter(_matcher); + : new global::Mockolate.CovariantParameterAdapter(_matcher); } /// @@ -199,13 +199,6 @@ public bool TryGetValue(out T? literal) MatcherTag => _matcher?.ToString() ?? "null", _ => _literal?.ToString() ?? "null", }; - - private sealed class CovariantAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - } } } #nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/Mock.ComprehensiveAbstractClass.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/Mock.ComprehensiveAbstractClass.g.cs index f48b324e..a94bccc6 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/Mock.ComprehensiveAbstractClass.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/Mock.ComprehensiveAbstractClass.g.cs @@ -1128,19 +1128,6 @@ internal sealed class MockSetup(global::Mockolate.MockRegistry mockRegistry) : g #endregion IMockProtectedSetupForComprehensiveAbstractClass } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } } #nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/Mock.ICombinationMockA.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/Mock.ICombinationMockA.g.cs index c3358747..83816083 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/Mock.ICombinationMockA.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/Mock.ICombinationMockA.g.cs @@ -597,19 +597,6 @@ internal static partial class MockExtensionsForICombinationMockA return behaviorAccess.Set(setup); } } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } } #nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/Mock.ICombinationMockB.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/Mock.ICombinationMockB.g.cs index 0dc5a39b..9cddd91a 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/Mock.ICombinationMockB.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/Mock.ICombinationMockB.g.cs @@ -597,19 +597,6 @@ internal static partial class MockExtensionsForICombinationMockB return behaviorAccess.Set(setup); } } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } } #nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/Mock.g.cs index 3ce28555..3944360b 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/Mock.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/Mock.g.cs @@ -110,24 +110,26 @@ internal interface IMockGenerationDidNotRun {} } } - /// - /// Adapts an IParameter (non-generic) to - /// IParameterMatch<T> so that covariant parameter - /// references (e.g. an IParameter<Derived> passed through an IParameter<Base> - /// slot) can still be invoked at setup/verify time. Only allocated when the direct - /// IParameterMatch<T> cast fails. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); +} - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } +/// +/// Adapts an IParameter (non-generic) to +/// IParameterMatch<T> so that covariant parameter +/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> +/// slot) can still be invoked at setup/verify time. Only allocated when the direct +/// IParameterMatch<T> cast fails. Shared by every +/// generated mock file. +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch +{ + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); } #nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/Mock.ComprehensiveAbstractClass.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/Mock.ComprehensiveAbstractClass.g.cs index f48b324e..a94bccc6 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/Mock.ComprehensiveAbstractClass.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/Mock.ComprehensiveAbstractClass.g.cs @@ -1128,19 +1128,6 @@ internal sealed class MockSetup(global::Mockolate.MockRegistry mockRegistry) : g #endregion IMockProtectedSetupForComprehensiveAbstractClass } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } } #nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/Mock.g.cs index 3ce28555..3944360b 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/Mock.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/Mock.g.cs @@ -110,24 +110,26 @@ internal interface IMockGenerationDidNotRun {} } } - /// - /// Adapts an IParameter (non-generic) to - /// IParameterMatch<T> so that covariant parameter - /// references (e.g. an IParameter<Derived> passed through an IParameter<Base> - /// slot) can still be invoked at setup/verify time. Only allocated when the direct - /// IParameterMatch<T> cast fails. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); +} - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } +/// +/// Adapts an IParameter (non-generic) to +/// IParameterMatch<T> so that covariant parameter +/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> +/// slot) can still be invoked at setup/verify time. Only allocated when the direct +/// IParameterMatch<T> cast fails. Shared by every +/// generated mock file. +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch +{ + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); } #nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated/Mock.g.cs index 3ce28555..3944360b 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated/Mock.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated/Mock.g.cs @@ -110,24 +110,26 @@ internal interface IMockGenerationDidNotRun {} } } - /// - /// Adapts an IParameter (non-generic) to - /// IParameterMatch<T> so that covariant parameter - /// references (e.g. an IParameter<Derived> passed through an IParameter<Base> - /// slot) can still be invoked at setup/verify time. Only allocated when the direct - /// IParameterMatch<T> cast fails. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); +} - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } +/// +/// Adapts an IParameter (non-generic) to +/// IParameterMatch<T> so that covariant parameter +/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> +/// slot) can still be invoked at setup/verify time. Only allocated when the direct +/// IParameterMatch<T> cast fails. Shared by every +/// generated mock file. +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch +{ + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); } #nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/Mock.ComprehensiveDelegate.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/Mock.ComprehensiveDelegate.g.cs index 594f3711..9e717812 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/Mock.ComprehensiveDelegate.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/Mock.ComprehensiveDelegate.g.cs @@ -335,6 +335,7 @@ internal interface IMockSetupForComprehensiveDelegate : global::Mockolate.Setup. /// /// 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, int, int, string, long> Setup(global::Mockolate.Parameters.IParameters parameters); /// @@ -386,6 +387,7 @@ internal interface IMockVerifyForComprehensiveDelegate : global::Mockolate.Verif /// /// 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 Verify(global::Mockolate.Parameters.IParameters parameters); /// diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/Mock.g.cs index 3ce28555..3944360b 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/Mock.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/Mock.g.cs @@ -110,24 +110,26 @@ internal interface IMockGenerationDidNotRun {} } } - /// - /// Adapts an IParameter (non-generic) to - /// IParameterMatch<T> so that covariant parameter - /// references (e.g. an IParameter<Derived> passed through an IParameter<Base> - /// slot) can still be invoked at setup/verify time. Only allocated when the direct - /// IParameterMatch<T> cast fails. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); +} - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } +/// +/// Adapts an IParameter (non-generic) to +/// IParameterMatch<T> so that covariant parameter +/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> +/// slot) can still be invoked at setup/verify time. Only allocated when the direct +/// IParameterMatch<T> cast fails. Shared by every +/// generated mock file. +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch +{ + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); } #nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/ParameterArg.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/ParameterArg.g.cs index 50826154..284fbf66 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/ParameterArg.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/ParameterArg.g.cs @@ -112,7 +112,7 @@ public bool TryGetValue(out T? literal) return _matcher is global::Mockolate.Parameters.IParameterMatch direct ? direct - : new CovariantAdapter(_matcher); + : new global::Mockolate.CovariantParameterAdapter(_matcher); } /// @@ -121,13 +121,6 @@ public bool TryGetValue(out T? literal) MatcherTag => _matcher?.ToString() ?? "null", _ => _literal?.ToString() ?? "null", }; - - private sealed class CovariantAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - } } } #nullable disable \ No newline at end of file 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 d5c29a48..0190f018 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 @@ -6700,19 +6700,6 @@ internal static partial class MockExtensionsForIComprehensiveInterface return behaviorAccess.Set(setup); } } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } } #nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/Mock.g.cs index 3ce28555..3944360b 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/Mock.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/Mock.g.cs @@ -110,24 +110,26 @@ internal interface IMockGenerationDidNotRun {} } } - /// - /// Adapts an IParameter (non-generic) to - /// IParameterMatch<T> so that covariant parameter - /// references (e.g. an IParameter<Derived> passed through an IParameter<Base> - /// slot) can still be invoked at setup/verify time. Only allocated when the direct - /// IParameterMatch<T> cast fails. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); +} - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } +/// +/// Adapts an IParameter (non-generic) to +/// IParameterMatch<T> so that covariant parameter +/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> +/// slot) can still be invoked at setup/verify time. Only allocated when the direct +/// IParameterMatch<T> cast fails. Shared by every +/// generated mock file. +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch +{ + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); } #nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/Mock.IComprehensiveInterface.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/Mock.IComprehensiveInterface.g.cs index b0b8c9aa..57bec58d 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/Mock.IComprehensiveInterface.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/Mock.IComprehensiveInterface.g.cs @@ -7012,19 +7012,6 @@ internal static partial class MockExtensionsForIComprehensiveInterface return behaviorAccess.Set(setup); } } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } } #nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/Mock.g.cs index 3ce28555..3944360b 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/Mock.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/Mock.g.cs @@ -110,24 +110,26 @@ internal interface IMockGenerationDidNotRun {} } } - /// - /// Adapts an IParameter (non-generic) to - /// IParameterMatch<T> so that covariant parameter - /// references (e.g. an IParameter<Derived> passed through an IParameter<Base> - /// slot) can still be invoked at setup/verify time. Only allocated when the direct - /// IParameterMatch<T> cast fails. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); +} - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } +/// +/// Adapts an IParameter (non-generic) to +/// IParameterMatch<T> so that covariant parameter +/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> +/// slot) can still be invoked at setup/verify time. Only allocated when the direct +/// IParameterMatch<T> cast fails. Shared by every +/// generated mock file. +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch +{ + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); } #nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ParameterArg.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ParameterArg.g.cs index 50826154..284fbf66 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ParameterArg.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ParameterArg.g.cs @@ -112,7 +112,7 @@ public bool TryGetValue(out T? literal) return _matcher is global::Mockolate.Parameters.IParameterMatch direct ? direct - : new CovariantAdapter(_matcher); + : new global::Mockolate.CovariantParameterAdapter(_matcher); } /// @@ -121,13 +121,6 @@ public bool TryGetValue(out T? literal) MatcherTag => _matcher?.ToString() ?? "null", _ => _literal?.ToString() ?? "null", }; - - private sealed class CovariantAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - } } } #nullable disable \ No newline at end of file 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 8ad9deb2..86ee29a3 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 @@ -1631,19 +1631,6 @@ internal sealed class MockSetup(global::Mockolate.MockRegistry mockRegistry) : g #endregion IMockProtectedSetupForHttpClient } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } } #nullable disable annotations 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 be36ce5b..773f7699 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 @@ -1346,19 +1346,6 @@ internal sealed class MockSetup(global::Mockolate.MockRegistry mockRegistry) : g #endregion IMockProtectedSetupForHttpMessageHandler } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } } #nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated/Mock.g.cs index 3ce28555..3944360b 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated/Mock.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated/Mock.g.cs @@ -110,24 +110,26 @@ internal interface IMockGenerationDidNotRun {} } } - /// - /// Adapts an IParameter (non-generic) to - /// IParameterMatch<T> so that covariant parameter - /// references (e.g. an IParameter<Derived> passed through an IParameter<Base> - /// slot) can still be invoked at setup/verify time. Only allocated when the direct - /// IParameterMatch<T> cast fails. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); +} - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } +/// +/// Adapts an IParameter (non-generic) to +/// IParameterMatch<T> so that covariant parameter +/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> +/// slot) can still be invoked at setup/verify time. Only allocated when the direct +/// IParameterMatch<T> cast fails. Shared by every +/// generated mock file. +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch +{ + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); } #nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpClient.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpClient.g.cs index 74974867..5de0bc29 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpClient.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpClient.g.cs @@ -1805,19 +1805,6 @@ internal sealed class MockSetup(global::Mockolate.MockRegistry mockRegistry) : g #endregion IMockProtectedSetupForHttpClient } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } } #nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpMessageHandler.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpMessageHandler.g.cs index c4ab9eae..db4b7750 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpMessageHandler.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpMessageHandler.g.cs @@ -1488,19 +1488,6 @@ internal sealed class MockSetup(global::Mockolate.MockRegistry mockRegistry) : g #endregion IMockProtectedSetupForHttpMessageHandler } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } } #nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.g.cs index 3ce28555..3944360b 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.g.cs @@ -110,24 +110,26 @@ internal interface IMockGenerationDidNotRun {} } } - /// - /// Adapts an IParameter (non-generic) to - /// IParameterMatch<T> so that covariant parameter - /// references (e.g. an IParameter<Derived> passed through an IParameter<Base> - /// slot) can still be invoked at setup/verify time. Only allocated when the direct - /// IParameterMatch<T> cast fails. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); +} - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } +/// +/// Adapts an IParameter (non-generic) to +/// IParameterMatch<T> so that covariant parameter +/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> +/// slot) can still be invoked at setup/verify time. Only allocated when the direct +/// IParameterMatch<T> cast fails. Shared by every +/// generated mock file. +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch +{ + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); } #nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/ParameterArg.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/ParameterArg.g.cs index 50826154..284fbf66 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/ParameterArg.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/ParameterArg.g.cs @@ -112,7 +112,7 @@ public bool TryGetValue(out T? literal) return _matcher is global::Mockolate.Parameters.IParameterMatch direct ? direct - : new CovariantAdapter(_matcher); + : new global::Mockolate.CovariantParameterAdapter(_matcher); } /// @@ -121,13 +121,6 @@ public bool TryGetValue(out T? literal) MatcherTag => _matcher?.ToString() ?? "null", _ => _literal?.ToString() ?? "null", }; - - private sealed class CovariantAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - } } } #nullable disable \ No newline at end of file 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 7c537db5..3eb931b6 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 @@ -1483,19 +1483,6 @@ internal static partial class MockExtensionsForIKeywordEdgeCases return behaviorAccess.Set(setup); } } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } } #nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated/Mock.g.cs index 3ce28555..3944360b 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated/Mock.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated/Mock.g.cs @@ -110,24 +110,26 @@ internal interface IMockGenerationDidNotRun {} } } - /// - /// Adapts an IParameter (non-generic) to - /// IParameterMatch<T> so that covariant parameter - /// references (e.g. an IParameter<Derived> passed through an IParameter<Base> - /// slot) can still be invoked at setup/verify time. Only allocated when the direct - /// IParameterMatch<T> cast fails. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); +} - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } +/// +/// Adapts an IParameter (non-generic) to +/// IParameterMatch<T> so that covariant parameter +/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> +/// slot) can still be invoked at setup/verify time. Only allocated when the direct +/// IParameterMatch<T> cast fails. Shared by every +/// generated mock file. +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch +{ + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); } #nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.IKeywordEdgeCases.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.IKeywordEdgeCases.g.cs index 627f4bdf..027cfa01 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.IKeywordEdgeCases.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.IKeywordEdgeCases.g.cs @@ -1523,19 +1523,6 @@ internal static partial class MockExtensionsForIKeywordEdgeCases return behaviorAccess.Set(setup); } } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } } #nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.g.cs index 3ce28555..3944360b 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.g.cs @@ -110,24 +110,26 @@ internal interface IMockGenerationDidNotRun {} } } - /// - /// Adapts an IParameter (non-generic) to - /// IParameterMatch<T> so that covariant parameter - /// references (e.g. an IParameter<Derived> passed through an IParameter<Base> - /// slot) can still be invoked at setup/verify time. Only allocated when the direct - /// IParameterMatch<T> cast fails. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); +} - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } +/// +/// Adapts an IParameter (non-generic) to +/// IParameterMatch<T> so that covariant parameter +/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> +/// slot) can still be invoked at setup/verify time. Only allocated when the direct +/// IParameterMatch<T> cast fails. Shared by every +/// generated mock file. +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch +{ + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); } #nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/ParameterArg.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/ParameterArg.g.cs index 50826154..284fbf66 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/ParameterArg.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/ParameterArg.g.cs @@ -112,7 +112,7 @@ public bool TryGetValue(out T? literal) return _matcher is global::Mockolate.Parameters.IParameterMatch direct ? direct - : new CovariantAdapter(_matcher); + : new global::Mockolate.CovariantParameterAdapter(_matcher); } /// @@ -121,13 +121,6 @@ public bool TryGetValue(out T? literal) MatcherTag => _matcher?.ToString() ?? "null", _ => _literal?.ToString() ?? "null", }; - - private sealed class CovariantAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - } } } #nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/RefStructConsumer_CanBeCreated/Mock.IRefStructConsumer.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/RefStructConsumer_CanBeCreated/Mock.IRefStructConsumer.g.cs index 40a77913..fa5262d7 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/RefStructConsumer_CanBeCreated/Mock.IRefStructConsumer.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/RefStructConsumer_CanBeCreated/Mock.IRefStructConsumer.g.cs @@ -1478,19 +1478,6 @@ internal static partial class MockExtensionsForIRefStructConsumer return behaviorAccess.Set(setup); } } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } } #nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/RefStructConsumer_CanBeCreated/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/RefStructConsumer_CanBeCreated/Mock.g.cs index 3ce28555..3944360b 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/RefStructConsumer_CanBeCreated/Mock.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/RefStructConsumer_CanBeCreated/Mock.g.cs @@ -110,24 +110,26 @@ internal interface IMockGenerationDidNotRun {} } } - /// - /// Adapts an IParameter (non-generic) to - /// IParameterMatch<T> so that covariant parameter - /// references (e.g. an IParameter<Derived> passed through an IParameter<Base> - /// slot) can still be invoked at setup/verify time. Only allocated when the direct - /// IParameterMatch<T> cast fails. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); +} - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } +/// +/// Adapts an IParameter (non-generic) to +/// IParameterMatch<T> so that covariant parameter +/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> +/// slot) can still be invoked at setup/verify time. Only allocated when the direct +/// IParameterMatch<T> cast fails. Shared by every +/// generated mock file. +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch +{ + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); } #nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/StaticAbstractMembers_CanBeCreated/Mock.IStaticAbstractMembers.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/StaticAbstractMembers_CanBeCreated/Mock.IStaticAbstractMembers.g.cs index 2f1452a5..6bdb1955 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/StaticAbstractMembers_CanBeCreated/Mock.IStaticAbstractMembers.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/StaticAbstractMembers_CanBeCreated/Mock.IStaticAbstractMembers.g.cs @@ -842,19 +842,6 @@ internal static partial class MockExtensionsForIStaticAbstractMembers return behaviorAccess.Set(setup); } } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } } #nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/StaticAbstractMembers_CanBeCreated/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/StaticAbstractMembers_CanBeCreated/Mock.g.cs index 3ce28555..3944360b 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/StaticAbstractMembers_CanBeCreated/Mock.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/StaticAbstractMembers_CanBeCreated/Mock.g.cs @@ -110,24 +110,26 @@ internal interface IMockGenerationDidNotRun {} } } - /// - /// Adapts an IParameter (non-generic) to - /// IParameterMatch<T> so that covariant parameter - /// references (e.g. an IParameter<Derived> passed through an IParameter<Base> - /// slot) can still be invoked at setup/verify time. Only allocated when the direct - /// IParameterMatch<T> cast fails. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); +} - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } +/// +/// Adapts an IParameter (non-generic) to +/// IParameterMatch<T> so that covariant parameter +/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> +/// slot) can still be invoked at setup/verify time. Only allocated when the direct +/// IParameterMatch<T> cast fails. Shared by every +/// generated mock file. +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch +{ + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); } #nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/Mock.IUnionIndexers.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/Mock.IUnionIndexers.g.cs index 5dfd94ba..0493065c 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/Mock.IUnionIndexers.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/Mock.IUnionIndexers.g.cs @@ -1167,9 +1167,14 @@ public string this[int key] { get { + global::Mockolate.Parameters.IParameterMatch aMatch = (a ?? default).ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch bMatch = (b ?? default).ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch cMatch = (c ?? default).ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch dMatch = (d ?? default).ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch eMatch = (e ?? default).ToParameterMatch(); return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, -1, -1, - interaction => interaction is global::Mockolate.Interactions.IndexerGetterAccess g && (a ?? default).ToParameterMatch().Matches(g.Parameter1) && (b ?? default).ToParameterMatch().Matches(g.Parameter2) && (c ?? default).ToParameterMatch().Matches(g.Parameter3) && (d ?? default).ToParameterMatch().Matches(g.Parameter4) && (e ?? default).ToParameterMatch().Matches(g.Parameter5), - (interaction, value) => interaction is global::Mockolate.Interactions.IndexerSetterAccess s && (a ?? default).ToParameterMatch().Matches(s.Parameter1) && (b ?? default).ToParameterMatch().Matches(s.Parameter2) && (c ?? default).ToParameterMatch().Matches(s.Parameter3) && (d ?? default).ToParameterMatch().Matches(s.Parameter4) && (e ?? default).ToParameterMatch().Matches(s.Parameter5) && value.Matches(s.TypedValue), + interaction => interaction is global::Mockolate.Interactions.IndexerGetterAccess g && aMatch.Matches(g.Parameter1) && bMatch.Matches(g.Parameter2) && cMatch.Matches(g.Parameter3) && dMatch.Matches(g.Parameter4) && eMatch.Matches(g.Parameter5), + (interaction, value) => interaction is global::Mockolate.Interactions.IndexerSetterAccess s && aMatch.Matches(s.Parameter1) && bMatch.Matches(s.Parameter2) && cMatch.Matches(s.Parameter3) && dMatch.Matches(s.Parameter4) && eMatch.Matches(s.Parameter5) && value.Matches(s.TypedValue), () => global::System.String.Format("[{0}, {1}, {2}, {3}, {4}]", (object?)(a ?? default), (object?)(b ?? default), (object?)(c ?? default), (object?)(d ?? default), (object?)(e ?? default))); } } @@ -1618,9 +1623,14 @@ private sealed class VerifyMonitorIUnionIndexers(global::Mockolate.MockRegistry { get { + global::Mockolate.Parameters.IParameterMatch aMatch = (a ?? default).ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch bMatch = (b ?? default).ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch cMatch = (c ?? default).ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch dMatch = (d ?? default).ToParameterMatch(); + global::Mockolate.Parameters.IParameterMatch eMatch = (e ?? default).ToParameterMatch(); return new global::Mockolate.Verify.VerificationIndexerResult(this, this.MockRegistry, -1, -1, - interaction => interaction is global::Mockolate.Interactions.IndexerGetterAccess g && (a ?? default).ToParameterMatch().Matches(g.Parameter1) && (b ?? default).ToParameterMatch().Matches(g.Parameter2) && (c ?? default).ToParameterMatch().Matches(g.Parameter3) && (d ?? default).ToParameterMatch().Matches(g.Parameter4) && (e ?? default).ToParameterMatch().Matches(g.Parameter5), - (interaction, value) => interaction is global::Mockolate.Interactions.IndexerSetterAccess s && (a ?? default).ToParameterMatch().Matches(s.Parameter1) && (b ?? default).ToParameterMatch().Matches(s.Parameter2) && (c ?? default).ToParameterMatch().Matches(s.Parameter3) && (d ?? default).ToParameterMatch().Matches(s.Parameter4) && (e ?? default).ToParameterMatch().Matches(s.Parameter5) && value.Matches(s.TypedValue), + interaction => interaction is global::Mockolate.Interactions.IndexerGetterAccess g && aMatch.Matches(g.Parameter1) && bMatch.Matches(g.Parameter2) && cMatch.Matches(g.Parameter3) && dMatch.Matches(g.Parameter4) && eMatch.Matches(g.Parameter5), + (interaction, value) => interaction is global::Mockolate.Interactions.IndexerSetterAccess s && aMatch.Matches(s.Parameter1) && bMatch.Matches(s.Parameter2) && cMatch.Matches(s.Parameter3) && dMatch.Matches(s.Parameter4) && eMatch.Matches(s.Parameter5) && value.Matches(s.TypedValue), () => global::System.String.Format("[{0}, {1}, {2}, {3}, {4}]", (object?)(a ?? default), (object?)(b ?? default), (object?)(c ?? default), (object?)(d ?? default), (object?)(e ?? default))); } } @@ -2874,19 +2884,6 @@ internal static partial class MockExtensionsForIUnionIndexers return behaviorAccess.Set(setup); } } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } } #nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/Mock.g.cs index 3ce28555..3944360b 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/Mock.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/Mock.g.cs @@ -110,24 +110,26 @@ internal interface IMockGenerationDidNotRun {} } } - /// - /// Adapts an IParameter (non-generic) to - /// IParameterMatch<T> so that covariant parameter - /// references (e.g. an IParameter<Derived> passed through an IParameter<Base> - /// slot) can still be invoked at setup/verify time. Only allocated when the direct - /// IParameterMatch<T> cast fails. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); +} - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); - } +/// +/// Adapts an IParameter (non-generic) to +/// IParameterMatch<T> so that covariant parameter +/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> +/// slot) can still be invoked at setup/verify time. Only allocated when the direct +/// IParameterMatch<T> cast fails. Shared by every +/// generated mock file. +/// +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch +{ + public bool Matches(T value) => inner.Matches(value); + public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); + public override string? ToString() => inner.ToString(); + + public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) + => parameter is global::Mockolate.Parameters.IParameterMatch direct + ? direct + : new CovariantParameterAdapter(parameter); } #nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/ParameterArg.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/ParameterArg.g.cs index 50826154..284fbf66 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/ParameterArg.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/ParameterArg.g.cs @@ -112,7 +112,7 @@ public bool TryGetValue(out T? literal) return _matcher is global::Mockolate.Parameters.IParameterMatch direct ? direct - : new CovariantAdapter(_matcher); + : new global::Mockolate.CovariantParameterAdapter(_matcher); } /// @@ -121,13 +121,6 @@ public bool TryGetValue(out T? literal) MatcherTag => _matcher?.ToString() ?? "null", _ => _literal?.ToString() ?? "null", }; - - private sealed class CovariantAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch - { - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - } } } #nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/UnionParameterArgTests.cs b/Tests/Mockolate.SourceGenerators.Tests/UnionParameterArgTests.cs index 28e00ebc..9d0e9bcd 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/UnionParameterArgTests.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/UnionParameterArgTests.cs @@ -45,7 +45,7 @@ public async Task WithoutUnionSupport_ShouldNotEmitParameterArg() [Fact] public async Task WithPreviewLanguageVersion_WithoutProperty_ShouldFollowCompilerCapability() { - bool compilerShipsCSharp15 = Enum.IsDefined(typeof(LanguageVersion), 1500); + bool compilerShipsCSharp15 = Enum.TryParse("CSharp15", out LanguageVersion _); GeneratorResult result = Generator.Run(Source, LanguageVersion.Preview, null); diff --git a/Tests/Mockolate.Tests/UnionSetupTests.cs b/Tests/Mockolate.Tests/UnionSetupTests.cs index abed4f81..02c27cba 100644 --- a/Tests/Mockolate.Tests/UnionSetupTests.cs +++ b/Tests/Mockolate.Tests/UnionSetupTests.cs @@ -282,6 +282,76 @@ await That(Act).Throws() .WithMessage("*[x => x > 10, a]*").AsWildcard(); } + [Fact] + public async Task Setup_WithMoreThanFourParametersAndADelegate_ShouldKeepTheRawDelegateOverload() + { + IUnionService sut = IUnionService.CreateMock(); + Func callback = x => x > 0; + sut.Mock.Setup.SumAll(1, 2, 3, 4, x => x < 0).Returns(1); + sut.Mock.Setup.SumAll(1, 2, 3, 4, callback).Returns(9); + + int matching = sut.SumAll(1, 2, 3, 4, callback); + int differentLambda = sut.SumAll(1, 2, 3, 4, x => x > 100); + + await That(matching).IsEqualTo(9); + await That(differentLambda).IsEqualTo(0); + await That(sut.Mock.Verify.SumAll(It.IsAny(), 2, 3, 4, callback)).Once(); + } + + [Fact] + public async Task Setup_WithSystemDelegateParameter_ShouldTreatLambdasAsValues() + { + IUnionService sut = IUnionService.CreateMock(); + Action handler = () => { }; + sut.Mock.Setup.Attach(() => { }); + sut.Mock.Setup.Attach(handler); + + sut.Attach(handler); + + await That(sut.Mock.Verify.Attach(handler)).Once(); + await That(sut.Mock.Verify.Attach(It.IsAny())).Once(); + } + + [Fact] + public async Task Indexer_Setup_WithNullKey_ShouldUseTheDeclaredDefault() + { + IDefaultKeyIndexer sut = IDefaultKeyIndexer.CreateMock(); + sut.Mock.Setup[1, null].Returns("default"); + + string omitted = sut[1]; + string explicitDefault = sut[1, 7]; + string other = sut[1, 0]; + + await That(omitted).IsEqualTo("default"); + await That(explicitDefault).IsEqualTo("default"); + await That(other).IsNotEqualTo("default"); + await That(sut.Mock.Verify[1, null].Got()).Twice(); + } + + [Fact] + public async Task SameMethodNameInAnotherScope_ShouldStillOfferUnionOverloads() + { + ScopedUnionService sut = ScopedUnionService.CreateMock(); + sut.Mock.Setup.Go(x => x > 0).Returns(1); + + int positive = sut.Go(5); + int negative = sut.Go(-1); + + await That(positive).IsEqualTo(1); + await That(negative).IsEqualTo(0); + } + + [Fact] + public async Task DelegateMock_WithObjectParameter_MatchAnyParameters_ShouldBindTheIParametersOverload() + { + ObjectCallback sut = ObjectCallback.CreateMock(); + sut.Mock.Setup(Match.AnyParameters()); + + sut("state"); + + await That(sut.Mock.Verify(Match.AnyParameters())).Once(); + } + [Fact] public async Task OverloadedIndexers_ShouldKeepTheClassicBindings() { @@ -297,6 +367,8 @@ public async Task OverloadedIndexers_ShouldKeepTheClassicBindings() public delegate int UnionDelegate(int x, string y); + public delegate void ObjectCallback(object? state); + public interface IOverloadedIndexerService { string this[int i] { get; } @@ -304,12 +376,25 @@ public interface IOverloadedIndexerService string this[int a, string b] { get; } } + public interface IDefaultKeyIndexer + { + string this[int key, int offset = 7] { get; } + } + + public abstract class ScopedUnionService + { + public abstract int Go(int v); + protected abstract int Go(string v); + } + public interface IUnionService { int Compute(int value, string text); string Describe(string? s); void Register(Func callback); int Sum(int a, int b, int c, int d); + int SumAll(int a, int b, int c, int d, Func callback); + void Attach(Delegate handler); int WithDefault(int i = 5); bool Take(object? o); bool TryParse(string s, out int result); From 6e428e76bb901b5ab50cc56dbcb3a8f0387d9ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Sat, 5 Sep 2026 17:25:01 +0200 Subject: [PATCH 11/14] chore: remove the union benchmark project Mockolate.Benchmarks.Unions was a local classic-vs-union measurement rig; it is not wired into the Benchmarks pipeline and would only rot. The classic pin on Mockolate.Benchmarks stays so results remain comparable to the CI baseline once the SDK defaults to C# 15. --- .../BenchmarksBase.cs | 26 --------- .../IMyMethodInterface.cs | 6 -- .../Mockolate.Benchmarks.Unions.csproj | 26 --------- .../Mockolate.Benchmarks.Unions/Program.cs | 3 - .../UnionParameterBenchmarks.cs | 58 ------------------- .../UnionSetupBenchmarks.cs | 33 ----------- .../Mockolate.Benchmarks.csproj | 2 +- Mockolate.slnx | 1 - 8 files changed, 1 insertion(+), 154 deletions(-) delete mode 100644 Benchmarks/Mockolate.Benchmarks.Unions/BenchmarksBase.cs delete mode 100644 Benchmarks/Mockolate.Benchmarks.Unions/IMyMethodInterface.cs delete mode 100644 Benchmarks/Mockolate.Benchmarks.Unions/Mockolate.Benchmarks.Unions.csproj delete mode 100644 Benchmarks/Mockolate.Benchmarks.Unions/Program.cs delete mode 100644 Benchmarks/Mockolate.Benchmarks.Unions/UnionParameterBenchmarks.cs delete mode 100644 Benchmarks/Mockolate.Benchmarks.Unions/UnionSetupBenchmarks.cs diff --git a/Benchmarks/Mockolate.Benchmarks.Unions/BenchmarksBase.cs b/Benchmarks/Mockolate.Benchmarks.Unions/BenchmarksBase.cs deleted file mode 100644 index 94282d6b..00000000 --- a/Benchmarks/Mockolate.Benchmarks.Unions/BenchmarksBase.cs +++ /dev/null @@ -1,26 +0,0 @@ -using BenchmarkDotNet.Attributes; -using BenchmarkDotNet.Configs; -using BenchmarkDotNet.Jobs; -using BenchmarkDotNet.Toolchains.InProcess.Emit; - -namespace Mockolate.Benchmarks.Unions; - -/// -/// Same job as the classic Mockolate.Benchmarks, so the union-mode numbers compare job for job. -/// -[Config(typeof(Config))] -[MarkdownExporterAttribute.GitHub] -[MemoryDiagnoser] -public abstract class BenchmarksBase -{ - private sealed class Config : ManualConfig - { - public Config() - { - AddJob(Job.MediumRun - .WithLaunchCount(1) - .WithToolchain(InProcessEmitToolchain.Instance) - .WithId("InProcess")); - } - } -} diff --git a/Benchmarks/Mockolate.Benchmarks.Unions/IMyMethodInterface.cs b/Benchmarks/Mockolate.Benchmarks.Unions/IMyMethodInterface.cs deleted file mode 100644 index 8a55e620..00000000 --- a/Benchmarks/Mockolate.Benchmarks.Unions/IMyMethodInterface.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Mockolate.Benchmarks.Unions; - -public interface IMyMethodInterface -{ - bool MyFunc(int value); -} diff --git a/Benchmarks/Mockolate.Benchmarks.Unions/Mockolate.Benchmarks.Unions.csproj b/Benchmarks/Mockolate.Benchmarks.Unions/Mockolate.Benchmarks.Unions.csproj deleted file mode 100644 index 0954cf8c..00000000 --- a/Benchmarks/Mockolate.Benchmarks.Unions/Mockolate.Benchmarks.Unions.csproj +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - Exe - net11.0 - preview - true - enable - enable - false - false - False - - true - - - - - - - - - diff --git a/Benchmarks/Mockolate.Benchmarks.Unions/Program.cs b/Benchmarks/Mockolate.Benchmarks.Unions/Program.cs deleted file mode 100644 index c9a04672..00000000 --- a/Benchmarks/Mockolate.Benchmarks.Unions/Program.cs +++ /dev/null @@ -1,3 +0,0 @@ -using BenchmarkDotNet.Running; - -BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); diff --git a/Benchmarks/Mockolate.Benchmarks.Unions/UnionParameterBenchmarks.cs b/Benchmarks/Mockolate.Benchmarks.Unions/UnionParameterBenchmarks.cs deleted file mode 100644 index 54b453de..00000000 --- a/Benchmarks/Mockolate.Benchmarks.Unions/UnionParameterBenchmarks.cs +++ /dev/null @@ -1,58 +0,0 @@ -using BenchmarkDotNet.Attributes; -using Mockolate.Verify; - -namespace Mockolate.Benchmarks.Unions; - -#pragma warning disable CA1822 // Mark members as static -/// -/// The CompleteMethodBenchmarks.Method_Mockolate workflow (create, set up one method, invoke -/// times, verify) on the union-typed surface, with a literal value, an It matcher and a predicate as the -/// argument. Compare against Mockolate.Benchmarks, which compiles the same workflow in classic mode. -/// -public class UnionParameterBenchmarks : BenchmarksBase -{ - [Params(1, 10)] public int N { get; set; } - - [Benchmark(Baseline = true)] - public void Value() - { - IMyMethodInterface sut = IMyMethodInterface.CreateMock(); - sut.Mock.Setup.MyFunc(42).Returns(true); - - for (int i = 0; i < N; i++) - { - sut.MyFunc(42); - } - - sut.Mock.Verify.MyFunc(42).Exactly(N); - } - - [Benchmark] - public void Matcher() - { - IMyMethodInterface sut = IMyMethodInterface.CreateMock(); - sut.Mock.Setup.MyFunc(It.IsAny()).Returns(true); - - for (int i = 0; i < N; i++) - { - sut.MyFunc(42); - } - - sut.Mock.Verify.MyFunc(It.IsAny()).Exactly(N); - } - - [Benchmark] - public void Predicate() - { - IMyMethodInterface sut = IMyMethodInterface.CreateMock(); - sut.Mock.Setup.MyFunc(x => x > 0).Returns(true); - - for (int i = 0; i < N; i++) - { - sut.MyFunc(42); - } - - sut.Mock.Verify.MyFunc(x => x > 0).Exactly(N); - } -} -#pragma warning restore CA1822 // Mark members as static diff --git a/Benchmarks/Mockolate.Benchmarks.Unions/UnionSetupBenchmarks.cs b/Benchmarks/Mockolate.Benchmarks.Unions/UnionSetupBenchmarks.cs deleted file mode 100644 index ba8b2852..00000000 --- a/Benchmarks/Mockolate.Benchmarks.Unions/UnionSetupBenchmarks.cs +++ /dev/null @@ -1,33 +0,0 @@ -using BenchmarkDotNet.Attributes; - -namespace Mockolate.Benchmarks.Unions; - -#pragma warning disable CA1822 // Mark members as static -/// -/// Isolates the argument conversion and setup dispatch of the union-typed surface: creates a mock and registers one -/// setup with a literal value, an It matcher or a predicate. -/// -public class UnionSetupBenchmarks : BenchmarksBase -{ - [Benchmark(Baseline = true)] - public void Value() - { - IMyMethodInterface sut = IMyMethodInterface.CreateMock(); - sut.Mock.Setup.MyFunc(42).Returns(true); - } - - [Benchmark] - public void Matcher() - { - IMyMethodInterface sut = IMyMethodInterface.CreateMock(); - sut.Mock.Setup.MyFunc(It.IsAny()).Returns(true); - } - - [Benchmark] - public void Predicate() - { - IMyMethodInterface sut = IMyMethodInterface.CreateMock(); - sut.Mock.Setup.MyFunc(x => x > 0).Returns(true); - } -} -#pragma warning restore CA1822 // Mark members as static diff --git a/Benchmarks/Mockolate.Benchmarks/Mockolate.Benchmarks.csproj b/Benchmarks/Mockolate.Benchmarks/Mockolate.Benchmarks.csproj index 52acc274..92943611 100644 --- a/Benchmarks/Mockolate.Benchmarks/Mockolate.Benchmarks.csproj +++ b/Benchmarks/Mockolate.Benchmarks/Mockolate.Benchmarks.csproj @@ -1,6 +1,6 @@ - + diff --git a/Mockolate.slnx b/Mockolate.slnx index 6c8d4af9..512fe577 100644 --- a/Mockolate.slnx +++ b/Mockolate.slnx @@ -1,7 +1,6 @@ - From 7e0fa78b5160ae06f9c48643c74e44785c3e0a2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Sat, 5 Sep 2026 17:25:01 +0200 Subject: [PATCH 12/14] test: deduplicate generator snapshot files - Store files identical across scenarios once under Expected/_Shared, referenced by a _shared.txt manifest per scenario (~29% fewer lines) - Drop the HttpClient union scenario; its shapes are covered by the comprehensive interface scenario - Mark the Expected snapshots as linguist-generated so GitHub collapses them in pull request diffs --- .gitattributes | 3 + .../_shared.txt | 3 + .../Mock.ComprehensiveAbstractClass.g.cs | 1133 ------ .../Mock.g.cs | 135 - .../MockBehaviorExtensions.g.cs | 285 -- .../_shared.txt | 3 + .../Mock.g.cs | 135 - .../MockBehaviorExtensions.g.cs | 285 -- .../_shared.txt | 4 + .../MethodSetups.g.cs | 771 ---- .../Mock.g.cs | 135 - .../MockBehaviorExtensions.g.cs | 285 -- .../ReturnsThrowsAsyncExtensions.g.cs | 156 - .../_shared.txt | 5 + .../Mock.g.cs | 135 - .../MockBehaviorExtensions.g.cs | 285 -- .../_shared.txt | 6 + .../ActionFunc.g.cs | 34 - .../IndexerSetups.g.cs | 1618 -------- .../MethodSetups.g.cs | 3557 ----------------- .../Mock.g.cs | 135 - .../MockBehaviorExtensions.g.cs | 285 -- .../ParameterArg.g.cs | 126 - .../ReturnsThrowsAsyncExtensions.g.cs | 288 -- .../_shared.txt | 7 + .../HttpClient_CanBeCreated/Mock.g.cs | 135 - .../HttpClient_CanBeCreated/_shared.txt | 1 + .../Mock.HttpClient.g.cs | 1810 --------- .../Mock.HttpMessageHandler.g.cs | 1493 ------- .../HttpClient_CanBeCreated_Unions/Mock.g.cs | 135 - .../MockBehaviorExtensions.g.cs | 301 -- .../ParameterArg.g.cs | 126 - .../KeywordEdgeCases_CanBeCreated/Mock.g.cs | 135 - .../MockBehaviorExtensions.g.cs | 285 -- .../KeywordEdgeCases_CanBeCreated/_shared.txt | 2 + .../Mock.g.cs | 135 - .../MockBehaviorExtensions.g.cs | 285 -- .../ParameterArg.g.cs | 126 - .../_shared.txt | 3 + .../RefStructConsumer_CanBeCreated/Mock.g.cs | 135 - .../MockBehaviorExtensions.g.cs | 285 -- .../_shared.txt | 3 + .../Mock.g.cs | 135 - .../MockBehaviorExtensions.g.cs | 285 -- .../_shared.txt | 2 + .../IndexerSetups.g.cs | 1055 ----- .../Mock.g.cs | 135 - .../MockBehaviorExtensions.g.cs | 285 -- .../ParameterArg.g.cs | 126 - .../_shared.txt | 4 + .../ActionFunc.g.cs | 0 .../IndexerSetups.854c2a72.g.cs} | 0 .../IndexerSetups.d958f396.g.cs} | 0 .../MethodSetups.0483b407.g.cs} | 0 .../MethodSetups.3d601ff0.g.cs} | 0 .../Mock.ComprehensiveAbstractClass.g.cs | 0 .../Mock.g.cs | 0 .../MockBehaviorExtensions.g.cs | 0 .../ParameterArg.g.cs | 0 ...eturnsThrowsAsyncExtensions.d2d185ae.g.cs} | 0 ...eturnsThrowsAsyncExtensions.dd90b829.g.cs} | 0 .../MockGenerationSnapshotAcceptance.cs | 9 +- .../Snapshot/MockGenerationSnapshotTests.cs | 11 +- .../TestHelpers/SnapshotStorage.cs | 106 +- 64 files changed, 149 insertions(+), 17213 deletions(-) create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/_shared.txt delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/Mock.ComprehensiveAbstractClass.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/Mock.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/MockBehaviorExtensions.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/_shared.txt delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated/Mock.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated/MockBehaviorExtensions.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated/_shared.txt delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/MethodSetups.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/Mock.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/MockBehaviorExtensions.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/ReturnsThrowsAsyncExtensions.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/_shared.txt delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/Mock.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/MockBehaviorExtensions.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/_shared.txt delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ActionFunc.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/IndexerSetups.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/MethodSetups.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/Mock.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/MockBehaviorExtensions.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ParameterArg.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ReturnsThrowsAsyncExtensions.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/_shared.txt delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated/Mock.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated/_shared.txt delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpClient.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpMessageHandler.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/MockBehaviorExtensions.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/ParameterArg.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated/Mock.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated/MockBehaviorExtensions.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated/_shared.txt delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/MockBehaviorExtensions.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/ParameterArg.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/_shared.txt delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/RefStructConsumer_CanBeCreated/Mock.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/RefStructConsumer_CanBeCreated/MockBehaviorExtensions.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/RefStructConsumer_CanBeCreated/_shared.txt delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/StaticAbstractMembers_CanBeCreated/Mock.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/StaticAbstractMembers_CanBeCreated/MockBehaviorExtensions.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/StaticAbstractMembers_CanBeCreated/_shared.txt delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/IndexerSetups.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/Mock.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/MockBehaviorExtensions.g.cs delete mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/ParameterArg.g.cs create mode 100644 Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/_shared.txt rename Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/{ComprehensiveInterface_CanBeCreated => _Shared}/ActionFunc.g.cs (100%) rename Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/{RefStructConsumer_CanBeCreated/IndexerSetups.g.cs => _Shared/IndexerSetups.854c2a72.g.cs} (100%) rename Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/{ComprehensiveInterface_CanBeCreated/IndexerSetups.g.cs => _Shared/IndexerSetups.d958f396.g.cs} (100%) rename Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/{ComprehensiveInterface_CanBeCreated/MethodSetups.g.cs => _Shared/MethodSetups.0483b407.g.cs} (100%) rename Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/{ComprehensiveDelegate_CanBeCreated/MethodSetups.g.cs => _Shared/MethodSetups.3d601ff0.g.cs} (100%) rename Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/{BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated => _Shared}/Mock.ComprehensiveAbstractClass.g.cs (100%) rename Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/{BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated => _Shared}/Mock.g.cs (100%) rename Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/{BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated => _Shared}/MockBehaviorExtensions.g.cs (100%) rename Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/{ComprehensiveDelegate_CanBeCreated_Unions => _Shared}/ParameterArg.g.cs (100%) rename Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/{ComprehensiveDelegate_CanBeCreated/ReturnsThrowsAsyncExtensions.g.cs => _Shared/ReturnsThrowsAsyncExtensions.d2d185ae.g.cs} (100%) rename Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/{ComprehensiveInterface_CanBeCreated/ReturnsThrowsAsyncExtensions.g.cs => _Shared/ReturnsThrowsAsyncExtensions.dd90b829.g.cs} (100%) diff --git a/.gitattributes b/.gitattributes index 1f24147a..988aa2d1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -13,3 +13,6 @@ # while mounting and running tests in Linux *.sh text eol=lf build text eol=lf + +# Snapshot files are regenerated by AcceptSnapshotChanges; collapse them in GitHub diffs +Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/** linguist-generated=true diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/_shared.txt b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/_shared.txt new file mode 100644 index 00000000..fabfdeb8 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/_shared.txt @@ -0,0 +1,3 @@ +Mock.ComprehensiveAbstractClass.g.cs|Mock.ComprehensiveAbstractClass.g.cs +Mock.g.cs|Mock.g.cs +MockBehaviorExtensions.g.cs|MockBehaviorExtensions.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/Mock.ComprehensiveAbstractClass.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/Mock.ComprehensiveAbstractClass.g.cs deleted file mode 100644 index a94bccc6..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/Mock.ComprehensiveAbstractClass.g.cs +++ /dev/null @@ -1,1133 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -#nullable enable annotations -namespace Mockolate; - -internal static partial class Mock -{ - /// - /// A mock implementation for ComprehensiveAbstractClass. - /// - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal class ComprehensiveAbstractClass : - global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass, IMockForComprehensiveAbstractClass, IMockSetupForComprehensiveAbstractClass, IMockProtectedSetupForComprehensiveAbstractClass, global::Mockolate.MockExtensionsForComprehensiveAbstractClass.IMockSetupInitializationForComprehensiveAbstractClass, IMockVerifyForComprehensiveAbstractClass, IMockProtectedVerifyForComprehensiveAbstractClass, - global::Mockolate.IMock - { - internal const int MemberId_V_Get = 0; - internal const int MemberId_V_Set = 1; - internal const int MemberId_A = 2; - internal const int MemberId_P = 3; - internal const int MemberCount = 4; - internal static readonly global::Mockolate.Interactions.PropertyGetterAccess PropertyAccess_V_Get = new global::Mockolate.Interactions.PropertyGetterAccess("global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass.V"); - - /// - /// Creates a FastMockInteractions sized to MemberCount for use as the mock's interaction store. - /// Per-member buffers are not allocated up-front: the recording hot paths call GetOrCreateBuffer<TBuffer>(int, Func<FastMockInteractions, TBuffer>) so a slot is materialized only when its member is first invoked. - /// - internal static global::Mockolate.Interactions.FastMockInteractions CreateFastInteractions(global::Mockolate.MockBehavior behavior) - => new global::Mockolate.Interactions.FastMockInteractions(MemberCount, behavior.SkipInteractionRecording); - - /// - /// Builds a MockRegistry backed by a typed-buffer-sized FastMockInteractions from . - /// - private static global::Mockolate.MockRegistry MockolateCreateRegistryFromBehavior(global::Mockolate.MockBehavior behavior) - { - global::Mockolate.MockRegistry registry = new global::Mockolate.MockRegistry(behavior, MemberCount); - MockRegistryProvider.Value = registry; - return registry; - } - - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.MockRegistry global::Mockolate.IMock.MockRegistry => this.MockRegistry; - private global::Mockolate.MockRegistry MockRegistry - { - get => field ?? MockRegistryProvider.Value; - set; - } - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - internal static readonly global::System.Threading.AsyncLocal MockRegistryProvider = new global::System.Threading.AsyncLocal(); - - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - private global::Mockolate.Interactions.FastMethod0Buffer MockolateBuffer_A - => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer(global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_A, static fast => new global::Mockolate.Interactions.FastMethod0Buffer(fast))); - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - private global::Mockolate.Interactions.FastMethod0Buffer MockolateBuffer_P - => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer(global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_P, static fast => new global::Mockolate.Interactions.FastMethod0Buffer(fast))); - - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - IMockSetupForComprehensiveAbstractClass IMockForComprehensiveAbstractClass.Setup - => this; - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - IMockProtectedSetupForComprehensiveAbstractClass IMockForComprehensiveAbstractClass.SetupProtected - => this; - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - IMockProtectedSetupForComprehensiveAbstractClass global::Mockolate.MockExtensionsForComprehensiveAbstractClass.IMockSetupInitializationForComprehensiveAbstractClass.Protected - => this; - /// - IMockInScenarioForComprehensiveAbstractClass IMockForComprehensiveAbstractClass.InScenario(string scenario) - => new MockInScenarioForComprehensiveAbstractClass(this.MockRegistry, scenario); - - /// - IMockForComprehensiveAbstractClass IMockForComprehensiveAbstractClass.InScenario(string scenario, global::System.Action setup) - { - setup.Invoke(new MockInScenarioForComprehensiveAbstractClass(this.MockRegistry, scenario)); - return this; - } - - /// - IMockForComprehensiveAbstractClass IMockForComprehensiveAbstractClass.TransitionTo(string scenario) - { - this.MockRegistry.TransitionTo(scenario); - return this; - } - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - IMockVerifyForComprehensiveAbstractClass IMockForComprehensiveAbstractClass.Verify - => this; - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - IMockProtectedVerifyForComprehensiveAbstractClass IMockForComprehensiveAbstractClass.VerifyProtected - => this; - /// - global::Mockolate.Verify.VerificationResult IMockForComprehensiveAbstractClass.VerifySetup(global::Mockolate.Setup.IMethodSetup setup) - => this.MockRegistry.Method(this, setup); - /// - bool IMockForComprehensiveAbstractClass.VerifyThatAllInteractionsAreVerified() - => this.MockRegistry.Interactions.GetUnverifiedInteractions().Count == 0; - /// - bool IMockForComprehensiveAbstractClass.VerifyThatAllSetupsAreUsed() - => this.MockRegistry.GetUnusedSetups(this.MockRegistry.Interactions).Count == 0; - /// - void IMockForComprehensiveAbstractClass.ClearAllInteractions() - => this.MockRegistry.ClearAllInteractions(); - /// - global::Mockolate.Monitor.MockMonitor IMockForComprehensiveAbstractClass.Monitor() - => new global::Mockolate.Monitor.MockMonitor(this.MockRegistry.Interactions, interactions => new VerifyMonitorComprehensiveAbstractClass(new global::Mockolate.MockRegistry(this.MockRegistry, interactions))); - - /// - string global::Mockolate.IMock.ToString() - => "Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass mock"; - - /// - [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] - public ComprehensiveAbstractClass(global::Mockolate.MockRegistry mockRegistry) - : base() - { - this.MockRegistry = mockRegistry; - } - - /// - [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] - public ComprehensiveAbstractClass(global::Mockolate.MockBehavior behavior) - : this(MockolateCreateRegistryFromBehavior(behavior)) - { - } - - /// - [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] - public ComprehensiveAbstractClass(global::Mockolate.MockRegistry mockRegistry, int v, string text = "x") - : base(v, text) - { - this.MockRegistry = mockRegistry; - } - - /// - [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] - public ComprehensiveAbstractClass(global::Mockolate.MockBehavior behavior, int v, string text = "x") - : this(MockolateCreateRegistryFromBehavior(behavior), v, text) - { - } - - /// - [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] - public ComprehensiveAbstractClass(global::Mockolate.MockRegistry mockRegistry_1, int mockRegistry, bool _) - : base(mockRegistry, _) - { - this.MockRegistry = mockRegistry_1; - } - - /// - [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] - public ComprehensiveAbstractClass(global::Mockolate.MockBehavior behavior, int mockRegistry, bool _) - : this(MockolateCreateRegistryFromBehavior(behavior), mockRegistry, _) - { - } - - /// - [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] - public ComprehensiveAbstractClass(global::Mockolate.MockRegistry mockRegistry, string name) - : base(name) - { - this.MockRegistry = mockRegistry; - } - - /// - [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] - public ComprehensiveAbstractClass(global::Mockolate.MockBehavior behavior, string name) - : this(MockolateCreateRegistryFromBehavior(behavior), name) - { - } - - #region Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass - - /// - public override int V - { - get - { - return this.MockRegistry.GetPropertyFast(global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_V_Get, global::Mockolate.Mock.ComprehensiveAbstractClass.PropertyAccess_V_Get, static b => b.DefaultValue.Generate(default(int)!), this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass wraps ? () => wraps.V : () => base.V); - } - set - { - if (!this.MockRegistry.SetPropertyFast(global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_V_Get, global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_V_Set, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass.V", value)) - { - if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass wraps) - { - wraps.V = value; - } - else - { - base.V = value; - } - } - } - } - - /// - public override int A() - { - global::Mockolate.Setup.ReturnMethodSetup? methodSetup = null; - if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) - { - global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_A); - 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()) - { - methodSetup = s_methodSetup; - break; - } - } - } - } - if (methodSetup is null) - { - foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass.A")) - { - if (s_methodSetup.Matches()) - { - methodSetup = s_methodSetup; - break; - } - } - } - bool hasWrappedResult = false; - int wrappedResult = default!; - if (this.MockRegistry.Behavior.SkipInteractionRecording == false) - { - this.MockolateBuffer_A.Append("global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass.A"); - } - try - { - if (this.MockRegistry.Wraps is global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass wraps) - { - wrappedResult = wraps.A(); - hasWrappedResult = true; - } - } - finally - { - methodSetup?.TriggerCallbacks(); - } - if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) - { - throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass.A()' was invoked without prior setup."); - } - if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) - { - return wrappedResult; - } - return methodSetup?.TryGetReturnValue(out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(int)!); - } - - /// - protected override int P() - { - global::Mockolate.Setup.ReturnMethodSetup? methodSetup = null; - if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) - { - global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_P); - 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()) - { - methodSetup = s_methodSetup; - break; - } - } - } - } - if (methodSetup is null) - { - foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass.P")) - { - if (s_methodSetup.Matches()) - { - methodSetup = s_methodSetup; - break; - } - } - } - bool hasWrappedResult = false; - int wrappedResult = default!; - if (this.MockRegistry.Behavior.SkipInteractionRecording == false) - { - this.MockolateBuffer_P.Append("global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass.P"); - } - try - { - if (!(methodSetup?.SkipBaseClass(this.MockRegistry.Behavior) ?? this.MockRegistry.Behavior.SkipBaseClass)) - { - wrappedResult = base.P(); - hasWrappedResult = true; - } - } - finally - { - methodSetup?.TriggerCallbacks(); - } - if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) - { - throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass.P()' was invoked without prior setup."); - } - if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) - { - return wrappedResult; - } - return methodSetup?.TryGetReturnValue(out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(int)!); - } - - #endregion Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass - - #region IMockSetupForComprehensiveAbstractClass - - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.Setup.PropertySetup global::Mockolate.Mock.IMockSetupForComprehensiveAbstractClass.V - { - get - { - var propertySetup = new global::Mockolate.Setup.PropertySetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass.V"); - this.MockRegistry.SetupProperty(global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_V_Get, propertySetup); - return propertySetup; - } - } - - /// - global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForComprehensiveAbstractClass.A() - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass.A"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_A, methodSetup); - return methodSetup; - } - - #endregion IMockSetupForComprehensiveAbstractClass - - #region IMockProtectedSetupForComprehensiveAbstractClass - - /// - global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockProtectedSetupForComprehensiveAbstractClass.P() - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass.P"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_P, methodSetup); - return methodSetup; - } - - #endregion IMockProtectedSetupForComprehensiveAbstractClass - - #region IMockVerifyForComprehensiveAbstractClass - - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.Verify.VerificationPropertyResult IMockVerifyForComprehensiveAbstractClass.V - { - get - { - return new global::Mockolate.Verify.VerificationPropertyResult(this, this.MockRegistry, global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_V_Get, global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_V_Set, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass.V"); - } - } - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForComprehensiveAbstractClass.A() - => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_A, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass.A", () => $"A()"); - #endregion IMockVerifyForComprehensiveAbstractClass - - #region IMockProtectedVerifyForComprehensiveAbstractClass - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForComprehensiveAbstractClass.P() - => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_P, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass.P", () => $"P()"); - #endregion IMockProtectedVerifyForComprehensiveAbstractClass - } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class VerifyMonitorComprehensiveAbstractClass(global::Mockolate.MockRegistry mockRegistry) : global::Mockolate.Mock.IMockVerifyForComprehensiveAbstractClass - { - private global::Mockolate.MockRegistry MockRegistry { get; } = mockRegistry; - - #region IMockVerifyForComprehensiveAbstractClass - - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.Verify.VerificationPropertyResult IMockVerifyForComprehensiveAbstractClass.V - { - get - { - return new global::Mockolate.Verify.VerificationPropertyResult(this, this.MockRegistry, global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_V_Get, global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_V_Set, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass.V"); - } - } - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForComprehensiveAbstractClass.A() - => this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_A, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass.A", () => $"A()"); - #endregion IMockVerifyForComprehensiveAbstractClass - } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class MockInScenarioForComprehensiveAbstractClass : global::Mockolate.Mock.IMockInScenarioForComprehensiveAbstractClass, global::Mockolate.Mock.IMockSetupForComprehensiveAbstractClass, global::Mockolate.Mock.IMockProtectedSetupForComprehensiveAbstractClass - { - private global::Mockolate.MockRegistry MockRegistry { get; } - private string _scenarioName; - - public MockInScenarioForComprehensiveAbstractClass(global::Mockolate.MockRegistry mockRegistry, string scenario) - { - this.MockRegistry = mockRegistry; - _scenarioName = scenario; - } - - /// - global::Mockolate.Mock.IMockSetupForComprehensiveAbstractClass global::Mockolate.Mock.IMockInScenarioForComprehensiveAbstractClass.Setup - => this; - - /// - global::Mockolate.Mock.IMockProtectedSetupForComprehensiveAbstractClass global::Mockolate.Mock.IMockInScenarioForComprehensiveAbstractClass.SetupProtected - => this; - - #region IMockSetupForComprehensiveAbstractClass - - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.Setup.PropertySetup global::Mockolate.Mock.IMockSetupForComprehensiveAbstractClass.V - { - get - { - var propertySetup = new global::Mockolate.Setup.PropertySetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass.V"); - this.MockRegistry.SetupProperty(global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_V_Get, _scenarioName, propertySetup); - return propertySetup; - } - } - - /// - global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForComprehensiveAbstractClass.A() - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass.A"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_A, _scenarioName, methodSetup); - return methodSetup; - } - - #endregion IMockSetupForComprehensiveAbstractClass - - #region IMockProtectedSetupForComprehensiveAbstractClass - - /// - global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockProtectedSetupForComprehensiveAbstractClass.P() - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass.P"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_P, _scenarioName, methodSetup); - return methodSetup; - } - - #endregion IMockProtectedSetupForComprehensiveAbstractClass - } - - /// - /// The Mockolate accessor for a mock of ComprehensiveAbstractClass, reached through .Mock on the mocked instance. - /// - /// - /// Groups every operation that acts on the mock rather than on the mocked subject: setups, verifications, event raising, scenarios and monitoring. - /// - internal interface IMockForComprehensiveAbstractClass - { - /// - /// Configures how members of the mock of ComprehensiveAbstractClass respond when invoked. - /// - /// - /// Each mocked member is available as a strongly-typed entry on this surface. Chain Returns, ReturnsAsync, Throws, ThrowsAsync or Do to control the response; chain InitializeWith/Register to initialize properties and indexers; chain multiple returns/throws to define a sequence; use .For(n), .Only(n), .Forever(), .When(predicate) to control when a callback runs.
- /// When two setups overlap, the most recently defined one wins. - ///
- IMockSetupForComprehensiveAbstractClass Setup { get; } - - /// - /// Configures how virtual members of the mock of ComprehensiveAbstractClass respond when invoked. - /// - /// - /// Only members declared as (or ) on the mocked class appear here. All setup chain operators (Returns, Throws, Do, sequences, .For/.Only/.Forever, ...) work identically to Setup. - /// - IMockProtectedSetupForComprehensiveAbstractClass SetupProtected { get; } - - /// - /// Opens a named scenario scope on the mock of ComprehensiveAbstractClass so that additional setups can be registered for that scenario. - /// - /// - /// Scenarios let you define per-state behavior. Setups registered inside the returned IMockInScenarioFor... scope only apply while the mock's current scenario matches ; switch scenarios with TransitionTo. - /// - /// Name of the scenario to enter. Any non-null string acts as a key; the mock starts in an unnamed default scenario. - /// A scoped accessor whose Setup (and SetupProtected, where applicable) register scenario-specific setups. - IMockInScenarioForComprehensiveAbstractClass InScenario(string scenario); - - /// - /// Opens a named scenario scope on the mock of ComprehensiveAbstractClass and immediately invokes to register scenario-specific setups. - /// - /// - /// Equivalent to InScenario(scenario) followed by the setup callback, but returns the original IMockFor... accessor so it chains nicely at mock-creation time. - /// - /// Name of the scenario to enter. - /// Callback that receives the scenario-scoped setup surface and registers scenario-specific setups. - /// This accessor, to allow chaining. - IMockForComprehensiveAbstractClass InScenario(string scenario, global::System.Action setup); - - /// - /// Switches the active scenario of the mock of ComprehensiveAbstractClass to . - /// - /// - /// After the transition, setups registered via InScenario(string) under that scenario take effect. Scenarios that have no matching setup for a given member fall back to the default (un-scoped) setups. - /// - /// Name of the scenario to transition to. - /// This accessor, to allow chaining. - IMockForComprehensiveAbstractClass TransitionTo(string scenario); - - /// - /// Asserts how often, and in which order, members of the mock of ComprehensiveAbstractClass were invoked. - /// - /// - /// Each call to a member here returns a VerificationResult that you terminate with a count assertion: Never(), Once(), Twice(), Exactly(n), AtLeast(n)/AtLeastOnce()/AtLeastTwice(), AtMost(n)/AtMostOnce()/AtMostTwice(), Between(min, max) or Times(predicate).
- /// Use Within(TimeSpan) / WithCancellation(CancellationToken) before the terminator to wait for expected interactions that happen on background threads.
- /// Chain Then(...) to assert an ordered sequence of calls. A failing assertion throws a MockVerificationException. - ///
- IMockVerifyForComprehensiveAbstractClass Verify { get; } - - /// - /// Asserts how often, and in which order, members of the mock of ComprehensiveAbstractClass were invoked. - /// - /// - /// Same terminators and modifiers as Verify (Once(), Exactly(n), Within(...), Then(...), ...); applies to members and events instead of public ones. - /// - IMockProtectedVerifyForComprehensiveAbstractClass VerifyProtected { get; } - - /// - /// Verifies how often a specific method setup was matched by actual invocations. - /// - /// - /// Useful when you want to verify "this particular setup was hit N times" without re-stating the matchers. Chain the usual count terminators (Once(), AtLeastOnce(), Exactly(n), ...) on the returned result. - /// - /// The setup previously registered through Setup (typically returned from a Returns(...)/Throws(...) call). - /// A VerificationResult that counts invocations matching the given setup. - global::Mockolate.Verify.VerificationResult VerifySetup(global::Mockolate.Setup.IMethodSetup setup); - - /// - /// Checks whether every recorded interaction on this mock has been observed by at least one Verify call. - /// - /// - /// Useful in test teardown to catch unexpected interactions ("strict verification"): if any recorded call has never been matched by a verification, the method returns . - /// - /// if every recorded interaction was verified at least once; otherwise . - bool VerifyThatAllInteractionsAreVerified(); - - /// - /// Checks whether every registered setup on this mock was matched by at least one actual invocation. - /// - /// - /// Useful to catch unused setups that silently rot as the test subject evolves. - /// - /// if every registered setup was used at least once; otherwise . - bool VerifyThatAllSetupsAreUsed(); - - /// - /// Removes every recorded interaction from this mock while keeping all registered setups intact. - /// - /// - /// Handy when a single test exercises multiple logical phases and you only want to verify the interactions of the latest phase. - /// - void ClearAllInteractions(); - - /// - /// Creates a monitor whose Verify surface is scoped to interactions produced between monitor.Run() and the disposal of its IDisposable scope. - /// - /// - /// The underlying mock keeps recording all interactions as usual - only the monitor's Verify view is scoped. Useful to verify only the interactions produced by a specific block of test code without resetting the mock. - /// - /// A MockMonitor<T> that exposes Verify over the monitored interactions and a Run() method that opens the recording scope. - global::Mockolate.Monitor.MockMonitor Monitor(); - } - - /// - /// Scoped access to setups for a scenario on the mock of ComprehensiveAbstractClass. - /// - internal interface IMockInScenarioForComprehensiveAbstractClass - { - /// - /// Set up the mock of ComprehensiveAbstractClass within the scenario scope. - /// - IMockSetupForComprehensiveAbstractClass Setup { get; } - - /// - /// Set up protected members of the mock of ComprehensiveAbstractClass within the scenario scope. - /// - IMockProtectedSetupForComprehensiveAbstractClass SetupProtected { get; } - } - - /// - /// Set up the mock of ComprehensiveAbstractClass. - /// - internal interface IMockSetupForComprehensiveAbstractClass : global::Mockolate.Setup.IMockSetup - { - /// - /// Setup for the int property V. - /// - global::Mockolate.Setup.PropertySetup V { get; } - - /// - /// Setup for the method A(). - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] - global::Mockolate.Setup.IReturnMethodSetup A(); - - } - - /// - /// Set up protected members for the mock of ComprehensiveAbstractClass. - /// - internal interface IMockProtectedSetupForComprehensiveAbstractClass - { - /// - /// Setup for the method P(). - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] - global::Mockolate.Setup.IReturnMethodSetup P(); - - } - - /// - /// Verify interactions with the mock of ComprehensiveAbstractClass. - /// - internal interface IMockVerifyForComprehensiveAbstractClass : global::Mockolate.Verify.IMockVerify - { - /// - /// Verify interactions with the int property V. - /// - global::Mockolate.Verify.VerificationPropertyResult V { get; } - - /// - /// Verify invocations for the method A(). - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters A(); - - } - - /// - /// Verify protected interactions with the mock of ComprehensiveAbstractClass. - /// - internal interface IMockProtectedVerifyForComprehensiveAbstractClass - { - /// - /// Verify invocations for the method P(). - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters P(); - - } -} -/// -/// Mock extensions for ComprehensiveAbstractClass. -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static partial class MockExtensionsForComprehensiveAbstractClass -{ - /// - extension(global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass mock) - { - /// - /// Gets the mock accessor for ComprehensiveAbstractClass - the entry point for configuring setups, verifying interactions and raising events. - /// - /// - /// The accessor is the bridge between the strongly-typed instance of ComprehensiveAbstractClass returned by CreateMock(...) and the underlying mock registry where setups and recorded interactions live.
- /// Through it you can:
- ///
- /// Setup - configure how members respond when invoked (Returns, Throws, Do, InitializeWith, ...).
- /// Verify - assert how often (and in which order) members were invoked.
- /// SetupProtected / VerifyProtected / RaiseProtected - target members on class mocks.
- /// InScenario / TransitionTo - scope setups and behavior to a named scenario and switch between scenarios.
- /// Monitor, ClearAllInteractions, VerifyThatAllInteractionsAreVerified, VerifyThatAllSetupsAreUsed - manage recorded interactions.
- /// VerifySetup - verify how often a specific setup matched.
- ///
- ///
- /// The instance is not a Mockolate-generated mock of ComprehensiveAbstractClass. - public global::Mockolate.Mock.IMockForComprehensiveAbstractClass Mock - { - get - { - if (mock is global::Mockolate.Mock.IMockForComprehensiveAbstractClass mockInterface) - { - return mockInterface; - } - throw new global::Mockolate.Exceptions.MockException("The subject is no mock."); - } - } - - /// - /// Creates a new mock of ComprehensiveAbstractClass with the default MockBehavior. - /// - /// - /// The returned instance is a strongly-typed mock generated at compile time - it implements ComprehensiveAbstractClass and exposes the Mockolate surface through .Mock:
- ///
- /// .Mock.Setup configures how members respond (Returns, Throws, Do, InitializeWith, sequences, callbacks).
- /// .Mock.Verify asserts how often and in which order members were invoked.
- ///

- /// With the default behavior, un-configured members return default values (empty collections / strings, completed tasks, otherwise) and base-class implementations are invoked for class mocks. Use one of the overloads that accepts a MockBehavior to customize this (for example to make un-configured calls throw or to skip the base class).
- /// Overloads allow you to additionally pass constructor parameters (for class mocks), apply an initial setup callback before the instance is returned, or combine both. - ///
- /// A new mock instance of ComprehensiveAbstractClass. - public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass CreateMock() - => CreateMock(null, null, (object?[]?)null); - - /// - /// Creates a new mock of ComprehensiveAbstractClass with the default MockBehavior, applying the given immediately. - /// - /// - /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. - /// - /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. - /// A new mock instance of ComprehensiveAbstractClass. - public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass CreateMock(global::System.Action setup) - => CreateMock(null, setup, (object?[]?)null); - - /// - /// Creates a new mock of ComprehensiveAbstractClass with the given . - /// - /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. - /// A new mock instance of ComprehensiveAbstractClass. - public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass CreateMock(global::Mockolate.MockBehavior mockBehavior) - => CreateMock(mockBehavior, null, (object?[]?)null); - - /// - /// Creates a new mock of ComprehensiveAbstractClass with the given , applying the given immediately. - /// - /// - /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. - /// - /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. - /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. - /// A new mock instance of ComprehensiveAbstractClass. - public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass CreateMock(global::Mockolate.MockBehavior mockBehavior, global::System.Action setup) - => CreateMock(mockBehavior, setup, (object?[]?)null); - - /// - /// Creates a new mock of ComprehensiveAbstractClass using the given to invoke the base-class constructor. - /// - /// Values forwarded to a matching base-class constructor. Required when no parameterless constructor exists. - /// A new mock instance of ComprehensiveAbstractClass. - public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass CreateMock(object?[] constructorParameters) - => CreateMock(null, null, constructorParameters); - - /// - /// Creates a new mock of ComprehensiveAbstractClass using the given and . - /// - /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. - /// Values forwarded to a matching base-class constructor. Required when no parameterless constructor exists. - /// A new mock instance of ComprehensiveAbstractClass. - public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass CreateMock(global::Mockolate.MockBehavior mockBehavior, object?[] constructorParameters) - => CreateMock(mockBehavior, null, constructorParameters); - - /// - /// Creates a new mock of ComprehensiveAbstractClass applying the given immediately, using the given . - /// - /// - /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. - /// - /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. - /// Values forwarded to a matching base-class constructor. Required when no parameterless constructor exists. - /// A new mock instance of ComprehensiveAbstractClass. - public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass CreateMock(global::System.Action setup, object?[] constructorParameters) - => CreateMock(null, setup, constructorParameters); - - /// - /// Creates a new mock of ComprehensiveAbstractClass using the given constructor parameters to invoke the ComprehensiveAbstractClass(int, string) constructor. - /// - /// Value forwarded to the base-class constructor. - /// Value forwarded to the base-class constructor. - /// A new mock instance of ComprehensiveAbstractClass. - public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass CreateMock(int v, string text = "x") - => CreateMock(null, null, new object?[] { v, text }); - - /// - /// Creates a new mock of ComprehensiveAbstractClass using the given and the given constructor parameters to invoke the ComprehensiveAbstractClass(int, string) constructor. - /// - /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. - /// Value forwarded to the base-class constructor. - /// Value forwarded to the base-class constructor. - /// A new mock instance of ComprehensiveAbstractClass. - public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass CreateMock(global::Mockolate.MockBehavior mockBehavior, int v, string text = "x") - => CreateMock(mockBehavior, null, new object?[] { v, text }); - - /// - /// Creates a new mock of ComprehensiveAbstractClass applying the given immediately, using the given constructor parameters to invoke the ComprehensiveAbstractClass(int, string) constructor. - /// - /// - /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. - /// - /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. - /// Value forwarded to the base-class constructor. - /// Value forwarded to the base-class constructor. - /// A new mock instance of ComprehensiveAbstractClass. - public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass CreateMock(global::System.Action setup, int v, string text = "x") - => CreateMock(null, setup, new object?[] { v, text }); - - /// - /// Creates a new mock of ComprehensiveAbstractClass using the given , applying the given immediately, using the given constructor parameters to invoke the ComprehensiveAbstractClass(int, string) constructor. - /// - /// - /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. - /// - /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. - /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. - /// Value forwarded to the base-class constructor. - /// Value forwarded to the base-class constructor. - /// A new mock instance of ComprehensiveAbstractClass. - public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass CreateMock(global::Mockolate.MockBehavior mockBehavior, global::System.Action setup, int v, string text = "x") - => CreateMock(mockBehavior, setup, new object?[] { v, text }); - - /// - /// Creates a new mock of ComprehensiveAbstractClass using the given constructor parameters to invoke the ComprehensiveAbstractClass(int, bool) constructor. - /// - /// Value forwarded to the base-class constructor. - /// Value forwarded to the base-class constructor. - /// A new mock instance of ComprehensiveAbstractClass. - public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass CreateMock(int mockRegistry, bool _) - => CreateMock(null, null, new object?[] { mockRegistry, _ }); - - /// - /// Creates a new mock of ComprehensiveAbstractClass using the given and the given constructor parameters to invoke the ComprehensiveAbstractClass(int, bool) constructor. - /// - /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. - /// Value forwarded to the base-class constructor. - /// Value forwarded to the base-class constructor. - /// A new mock instance of ComprehensiveAbstractClass. - public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass CreateMock(global::Mockolate.MockBehavior mockBehavior, int mockRegistry, bool _) - => CreateMock(mockBehavior, null, new object?[] { mockRegistry, _ }); - - /// - /// Creates a new mock of ComprehensiveAbstractClass applying the given immediately, using the given constructor parameters to invoke the ComprehensiveAbstractClass(int, bool) constructor. - /// - /// - /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. - /// - /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. - /// Value forwarded to the base-class constructor. - /// Value forwarded to the base-class constructor. - /// A new mock instance of ComprehensiveAbstractClass. - public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass CreateMock(global::System.Action setup, int mockRegistry, bool _) - => CreateMock(null, setup, new object?[] { mockRegistry, _ }); - - /// - /// Creates a new mock of ComprehensiveAbstractClass using the given , applying the given immediately, using the given constructor parameters to invoke the ComprehensiveAbstractClass(int, bool) constructor. - /// - /// - /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. - /// - /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. - /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. - /// Value forwarded to the base-class constructor. - /// Value forwarded to the base-class constructor. - /// A new mock instance of ComprehensiveAbstractClass. - public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass CreateMock(global::Mockolate.MockBehavior mockBehavior, global::System.Action setup, int mockRegistry, bool _) - => CreateMock(mockBehavior, setup, new object?[] { mockRegistry, _ }); - - /// - /// Creates a new mock of ComprehensiveAbstractClass using the given constructor parameters to invoke the ComprehensiveAbstractClass(string) constructor. - /// - /// Value forwarded to the base-class constructor. - /// A new mock instance of ComprehensiveAbstractClass. - public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass CreateMock(string name) - => CreateMock(null, null, new object?[] { name }); - - /// - /// Creates a new mock of ComprehensiveAbstractClass using the given and the given constructor parameters to invoke the ComprehensiveAbstractClass(string) constructor. - /// - /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. - /// Value forwarded to the base-class constructor. - /// A new mock instance of ComprehensiveAbstractClass. - public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass CreateMock(global::Mockolate.MockBehavior mockBehavior, string name) - => CreateMock(mockBehavior, null, new object?[] { name }); - - /// - /// Creates a new mock of ComprehensiveAbstractClass applying the given immediately, using the given constructor parameters to invoke the ComprehensiveAbstractClass(string) constructor. - /// - /// - /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. - /// - /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. - /// Value forwarded to the base-class constructor. - /// A new mock instance of ComprehensiveAbstractClass. - public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass CreateMock(global::System.Action setup, string name) - => CreateMock(null, setup, new object?[] { name }); - - /// - /// Creates a new mock of ComprehensiveAbstractClass using the given , applying the given immediately, using the given constructor parameters to invoke the ComprehensiveAbstractClass(string) constructor. - /// - /// - /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. - /// - /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. - /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. - /// Value forwarded to the base-class constructor. - /// A new mock instance of ComprehensiveAbstractClass. - public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass CreateMock(global::Mockolate.MockBehavior mockBehavior, global::System.Action setup, string name) - => CreateMock(mockBehavior, setup, new object?[] { name }); - - /// - /// Creates a new mock of ComprehensiveAbstractClass using the given , applying the given immediately, using the given . - /// - /// - /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. - /// - /// Controls how the mock responds when members are invoked without a matching setup, or for MockBehavior.Default. - /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned, or to skip. - /// Values forwarded to a matching base-class constructor, or to use the parameterless constructor. - /// A new mock instance of ComprehensiveAbstractClass. - public static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass CreateMock(global::Mockolate.MockBehavior? mockBehavior, global::System.Action? setup, object?[]? constructorParameters) - { - if (mockBehavior is not null) - { - IMockBehaviorAccess mockBehaviorAccess = (global::Mockolate.IMockBehaviorAccess)mockBehavior; - if (mockBehaviorAccess.TryGet?>(out var additionalSetup)) - { - if (setup is null) - { - setup = additionalSetup; - } - else - { - var originalSetup = setup; - setup = s => { additionalSetup.Invoke(s); originalSetup.Invoke(s); }; - } - } - if (constructorParameters is null && mockBehaviorAccess.TryGetConstructorParameters(out object?[]? parameters)) - { - constructorParameters = parameters; - } - } - - mockBehavior ??= global::Mockolate.MockBehavior.Default; - global::Mockolate.MockRegistry mockRegistry = new global::Mockolate.MockRegistry(mockBehavior, global::Mockolate.Mock.ComprehensiveAbstractClass.MemberCount, constructorParameters); - return CreateMockInstance(mockRegistry, constructorParameters, setup); - } - - private static global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass CreateMockInstance(global::Mockolate.MockRegistry mockRegistry, object?[]? constructorParameters, global::System.Action? setup) - { - if (constructorParameters is null || constructorParameters.Length == 0) - { - global::Mockolate.Mock.ComprehensiveAbstractClass.MockRegistryProvider.Value = mockRegistry; - global::Mockolate.MockExtensionsForComprehensiveAbstractClass.MockSetup? setupTarget = null; - if (setup is not null) - { - setupTarget ??= new(mockRegistry); - setup.Invoke(setupTarget); - } - return new global::Mockolate.Mock.ComprehensiveAbstractClass(mockRegistry); - } - else if (constructorParameters.Length == 0) - { - global::Mockolate.Mock.ComprehensiveAbstractClass.MockRegistryProvider.Value = mockRegistry; - global::Mockolate.MockExtensionsForComprehensiveAbstractClass.MockSetup? setupTarget = null; - if (setup is not null) - { - setupTarget ??= new(mockRegistry); - setup.Invoke(setupTarget); - } - return new global::Mockolate.Mock.ComprehensiveAbstractClass(mockRegistry); - } - else if (constructorParameters.Length >= 1 && constructorParameters.Length <= 2 - && TryCast(constructorParameters, 0, mockRegistry.Behavior, out int c2p1) - && TryCastWithDefaultValue(constructorParameters, 1, "x", mockRegistry.Behavior, out string c2p2)) - { - global::Mockolate.Mock.ComprehensiveAbstractClass.MockRegistryProvider.Value = mockRegistry; - global::Mockolate.MockExtensionsForComprehensiveAbstractClass.MockSetup? setupTarget = null; - if (setup is not null) - { - setupTarget ??= new(mockRegistry); - setup.Invoke(setupTarget); - } - return new global::Mockolate.Mock.ComprehensiveAbstractClass(mockRegistry, c2p1, c2p2); - } - else if (constructorParameters.Length == 2 - && TryCast(constructorParameters, 0, mockRegistry.Behavior, out int c3p1) - && TryCast(constructorParameters, 1, mockRegistry.Behavior, out bool c3p2)) - { - global::Mockolate.Mock.ComprehensiveAbstractClass.MockRegistryProvider.Value = mockRegistry; - global::Mockolate.MockExtensionsForComprehensiveAbstractClass.MockSetup? setupTarget = null; - if (setup is not null) - { - setupTarget ??= new(mockRegistry); - setup.Invoke(setupTarget); - } - return new global::Mockolate.Mock.ComprehensiveAbstractClass(mockRegistry, c3p1, c3p2); - } - else if (constructorParameters.Length == 1 - && TryCast(constructorParameters, 0, mockRegistry.Behavior, out string c4p1)) - { - global::Mockolate.Mock.ComprehensiveAbstractClass.MockRegistryProvider.Value = mockRegistry; - global::Mockolate.MockExtensionsForComprehensiveAbstractClass.MockSetup? setupTarget = null; - if (setup is not null) - { - setupTarget ??= new(mockRegistry); - setup.Invoke(setupTarget); - } - return new global::Mockolate.Mock.ComprehensiveAbstractClass(mockRegistry, c4p1); - } - else - { - throw new global::Mockolate.Exceptions.MockException($"Could not find any constructor for 'Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass' that matches the {constructorParameters.Length} given parameters ({string.Join(", ", constructorParameters)})."); - } - static bool TryCast(object?[] values, int index, global::Mockolate.MockBehavior behavior, out TValue result) - { - var value = values[index]; - if (value is TValue typedValue) - { - result = typedValue; - return true; - } - - result = default!; - return value is null; - } - static bool TryCastWithDefaultValue(object?[] values, int index, TValue defaultValue, global::Mockolate.MockBehavior behavior, out TValue result) - { - if (values.Length > index && values[index] is TValue typedValue) - { - result = typedValue; - return true; - } - - result = defaultValue; - return true; - } - } - /// - /// Creates a mock that wraps the given . - /// - /// - /// Public members on the mock forward to unless overridden by a setup; protected members still go through the base-class implementation. All forwarded interactions are recorded and can be verified the same as on a plain mock. - /// - /// The real object whose calls should be forwarded. Must not be . - /// A new mock of ComprehensiveAbstractClass that delegates to . - public global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass Wrapping(global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass instance) - { - if (mock is global::Mockolate.IMock mockInterface) - { - global::Mockolate.MockRegistry wrappingRegistry = new global::Mockolate.MockRegistry(mockInterface.MockRegistry, instance); - wrappingRegistry = new global::Mockolate.MockRegistry(wrappingRegistry, global::Mockolate.Mock.ComprehensiveAbstractClass.CreateFastInteractions(wrappingRegistry.Behavior)); - return CreateMockInstance(wrappingRegistry, mockInterface.MockRegistry.ConstructorParameters, null); - } - throw new global::Mockolate.Exceptions.MockException("The subject is no mock."); - } - - } - - /// - extension(global::Mockolate.MockBehavior behavior) - { - /// - /// Initializes mocks of type with the given . - /// - /// - /// The is applied to the mock before the constructor is executed. Calling Initialize again overlays additional setups on top of any previously registered ones. - /// - /// The mockable type derived from ComprehensiveAbstractClass that this setup should apply to. - /// Callback invoked when a new mock of is created. - /// A new MockBehavior with the registered initializer. The original instance is unchanged. - public global::Mockolate.MockBehavior Initialize(global::System.Action setup) - where T : global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass - { - var behaviorAccess = (global::Mockolate.IMockBehaviorAccess)behavior; - return behaviorAccess.Set(setup); - } - } - internal interface IMockSetupInitializationForComprehensiveAbstractClass : global::Mockolate.Mock.IMockSetupForComprehensiveAbstractClass - { - /// - /// Setup protected members - /// - global::Mockolate.Mock.IMockProtectedSetupForComprehensiveAbstractClass Protected { get; } - } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal sealed class MockSetup(global::Mockolate.MockRegistry mockRegistry) : global::Mockolate.Mock.IMockSetupForComprehensiveAbstractClass, global::Mockolate.Mock.IMockProtectedSetupForComprehensiveAbstractClass, IMockSetupInitializationForComprehensiveAbstractClass - { - /// - global::Mockolate.Mock.IMockProtectedSetupForComprehensiveAbstractClass IMockSetupInitializationForComprehensiveAbstractClass.Protected => this; - private global::Mockolate.MockRegistry MockRegistry { get; } = mockRegistry; - - #region IMockSetupForComprehensiveAbstractClass - - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.Setup.PropertySetup global::Mockolate.Mock.IMockSetupForComprehensiveAbstractClass.V - { - get - { - var propertySetup = new global::Mockolate.Setup.PropertySetup(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass.V"); - this.MockRegistry.SetupProperty(global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_V_Get, propertySetup); - return propertySetup; - } - } - - /// - global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockSetupForComprehensiveAbstractClass.A() - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass.A"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_A, methodSetup); - return methodSetup; - } - - #endregion IMockSetupForComprehensiveAbstractClass - - #region IMockProtectedSetupForComprehensiveAbstractClass - - /// - global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Mock.IMockProtectedSetupForComprehensiveAbstractClass.P() - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::Mockolate.Tests.GeneratorCoverage.ComprehensiveAbstractClass.P"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.ComprehensiveAbstractClass.MemberId_P, methodSetup); - return methodSetup; - } - - #endregion IMockProtectedSetupForComprehensiveAbstractClass - } -} - -#nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/Mock.g.cs deleted file mode 100644 index 3944360b..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/Mock.g.cs +++ /dev/null @@ -1,135 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable -/// -/// Create new mocks by calling the static T.CreateMock() method on your type T. -/// -/// -/// You can also provide a MockBehavior parameter to customize how the mock should behave in certain scenarios.
-/// If your type is a class without a default constructor, you can provide constructor parameters by passing an object?[]? to the corresponding CreateMock(...) overload. -///
-[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static partial class Mock -{ - /// - /// This interface should never be used. If it is, this is an indication that the Mockolate source generator did not run correctly or that the used type is not mockable. - /// - /// - /// The source generator creates overloads with correct return values. - /// - internal interface IMockGenerationDidNotRun {} - - /// - /// Create a new mock of with the default MockBehavior. - /// - /// Type to mock, which can be an interface or a class. - /// - /// Any interface type can be used for mocking, but for classes, only abstract and virtual members can be mocked. - /// - extension(T _) - { - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior = null) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior, object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - } - - extension(global::Mockolate.Mock.IMockGenerationDidNotRun _) - { - /// - /// Fallback Implementing that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Additional interface the mock should implement. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete Implementing overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public global::Mockolate.Mock.IMockGenerationDidNotRun Implementing() where TInterface : class - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(TInterface)}' is not mockable or the source generator did not run correctly."); - } - } - -} - -/// -/// Adapts an IParameter (non-generic) to -/// IParameterMatch<T> so that covariant parameter -/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> -/// slot) can still be invoked at setup/verify time. Only allocated when the direct -/// IParameterMatch<T> cast fails. Shared by every -/// generated mock file. -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch -{ - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); -} -#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/MockBehaviorExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/MockBehaviorExtensions.g.cs deleted file mode 100644 index 888d2c2c..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/MockBehaviorExtensions.g.cs +++ /dev/null @@ -1,285 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable annotations - -/// -/// Extensions for MockBehavior. -/// -internal static partial class Mock -{ - private static readonly global::Mockolate.MockBehavior _default; - - static Mock() - { - _default = new global::Mockolate.MockBehavior(new DefaultValueGenerator()); - } - - extension(global::Mockolate.MockBehavior) - { - /// - /// The default MockBehavior - the starting point for configuring a mock. - /// - /// - /// Un-configured members return the generator-provided default value (empty strings/collections, completed - /// Tasks, otherwise), base-class - /// implementations run for class mocks, and every invocation is recorded for later verification. - /// - /// Chain SkippingBaseClass(), ThrowingWhenNotSetup(), SkippingInteractionRecording(), - /// WithDefaultValueFor<T>(...) or UseConstructorParametersFor<T>(...) to derive - /// a customized MockBehavior; because it is a , - /// each call returns a new instance and this shared default stays unchanged. - /// - public static global::Mockolate.MockBehavior Default => _default; - } - - /// - /// Defines a factory for creating default values for a specified type. - /// - public interface IDefaultValueFactory - { - /// - /// Determines whether the specified can be created by this factory. - /// - bool IsMatch(global::System.Type type); - - /// - /// Creates a new instance of the specified type. - /// - object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, object?[] parameters); - } - - /// - /// A IDefaultValueFactory that returns a specified for the given type - /// parameter . - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal class TypedDefaultValueFactory(T value) : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(T); - - /// - public object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - => value; - } - - /// - /// Provides default values for common types used in mocking scenarios. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private class DefaultValueGenerator : IDefaultValueGenerator - { - private static readonly global::System.Collections.Concurrent.ConcurrentQueue _factories = new([ - new TypedDefaultValueFactory(""), - new CancellableTaskFactory(), - #if NET8_0_OR_GREATER - new CancellableValueTaskFactory(), - #endif - new TypedDefaultValueFactory(global::System.Threading.CancellationToken.None), - new TypedDefaultValueFactory(global::System.Array.Empty()), - ]); - - /// - public object? GenerateValue(global::System.Type type, params object?[] parameters) - { - if (TryGenerate(type, parameters, out object? value)) - { - return value; - } - - return null; - } - - /// - /// Registers a to provide default values for a specific type. - /// - public static void Register(IDefaultValueFactory defaultValueFactory) - => _factories.Enqueue(defaultValueFactory); - - /// - /// Tries to generate a default value for the specified type. - /// - protected virtual bool TryGenerate(global::System.Type type, object?[] parameters, out object? value) - { - IDefaultValueFactory? matchingFactory = global::System.Linq.Enumerable.FirstOrDefault(_factories, Predicate); - if (matchingFactory is not null) - { - value = matchingFactory.Create(type, this, parameters); - return true; - } - - value = null; - return false; - - bool Predicate(global::Mockolate.Mock.IDefaultValueFactory f) - => f.IsMatch(type); - } - - private static bool HasCanceledCancellationToken(object?[] parameters, out global::System.Threading.CancellationToken cancellationToken) - { - global::System.Threading.CancellationToken parameter = global::System.Linq.Enumerable.FirstOrDefault(global::System.Linq.Enumerable.OfType(parameters)); - if (parameter.IsCancellationRequested) - { - cancellationToken = parameter; - return true; - } - - cancellationToken = global::System.Threading.CancellationToken.None; - return false; - } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CancellableTaskFactory : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Threading.Tasks.Task); - - /// - public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - { - if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) - { - return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.Task.CompletedTask; - } - } - #if NET8_0_OR_GREATER - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CancellableValueTaskFactory : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Threading.Tasks.ValueTask); - - /// - public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - { - if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) - { - return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.ValueTask.CompletedTask; - } - } - #endif - } -} - -/// -/// Extensions on IDefaultValueGenerator -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static class DefaultValueGeneratorExtensions -{ - /// - /// Adds a generic Generate method for specific types. - /// - extension(IDefaultValueGenerator generator) - { - /// - /// Generates a Task of , with - /// the for context. - /// - public global::System.Threading.Tasks.Task Generate(global::System.Threading.Tasks.Task nullValue, T value, params object?[] parameters) - { - global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( - global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; - if (cancellationToken.IsCancellationRequested) - { - return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.Task.FromResult(value); - } - -#if NET8_0_OR_GREATER - /// - /// Generates a ValueTask of , with - /// the for context. - /// - public global::System.Threading.Tasks.ValueTask Generate(global::System.Threading.Tasks.ValueTask nullValue, T value, params object?[] parameters) - { - global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( - global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; - if (cancellationToken.IsCancellationRequested) - { - return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.ValueTask.FromResult(value); - } -#endif - - /// - /// Generates an empty enumerable of , with - /// the for context. - /// - public global::System.Collections.Generic.IEnumerable Generate(global::System.Collections.Generic.IEnumerable nullValue, params object?[] parameters) - => global::System.Array.Empty(); - - /// - /// Generates an empty enumerable of , with - /// the for context. - /// - public global::System.Collections.Generic.List Generate(global::System.Collections.Generic.List nullValue, params object?[] parameters) - => new global::System.Collections.Generic.List(); - - /// - /// Generates an empty array of , with - /// the for context. - /// - public T[] Generate(T[] nullValue, params object?[] parameters) - => global::System.Array.Empty(); - - /// - /// Generates an empty two-dimensional array of , with - /// the for context. - /// - public T[,] Generate(T[,] nullValue, params object?[] parameters) - => new T[,] { }; - - /// - /// Generates an empty three-dimensional array of , with - /// the for context. - /// - public T[,,] Generate(T[,,] nullValue, params object?[] parameters) - => new T[,,] { }; - - /// - /// Generates an empty four-dimensional array of , with - /// the for context. - /// - public T[,,,] Generate(T[,,,] nullValue, params object?[] parameters) - => new T[,,,] { }; - - /// - /// Generates a default value of type , with - /// the for context. - /// - public T Generate(T nullValue, params object?[] parameters) - { - if (generator.GenerateValue(typeof(T), parameters) is T value) - { - return value; - } - - return nullValue; - } - } -} - -#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/_shared.txt b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/_shared.txt new file mode 100644 index 00000000..fabfdeb8 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveAbstractClass_CanBeCreated/_shared.txt @@ -0,0 +1,3 @@ +Mock.ComprehensiveAbstractClass.g.cs|Mock.ComprehensiveAbstractClass.g.cs +Mock.g.cs|Mock.g.cs +MockBehaviorExtensions.g.cs|MockBehaviorExtensions.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated/Mock.g.cs deleted file mode 100644 index 3944360b..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated/Mock.g.cs +++ /dev/null @@ -1,135 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable -/// -/// Create new mocks by calling the static T.CreateMock() method on your type T. -/// -/// -/// You can also provide a MockBehavior parameter to customize how the mock should behave in certain scenarios.
-/// If your type is a class without a default constructor, you can provide constructor parameters by passing an object?[]? to the corresponding CreateMock(...) overload. -///
-[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static partial class Mock -{ - /// - /// This interface should never be used. If it is, this is an indication that the Mockolate source generator did not run correctly or that the used type is not mockable. - /// - /// - /// The source generator creates overloads with correct return values. - /// - internal interface IMockGenerationDidNotRun {} - - /// - /// Create a new mock of with the default MockBehavior. - /// - /// Type to mock, which can be an interface or a class. - /// - /// Any interface type can be used for mocking, but for classes, only abstract and virtual members can be mocked. - /// - extension(T _) - { - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior = null) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior, object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - } - - extension(global::Mockolate.Mock.IMockGenerationDidNotRun _) - { - /// - /// Fallback Implementing that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Additional interface the mock should implement. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete Implementing overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public global::Mockolate.Mock.IMockGenerationDidNotRun Implementing() where TInterface : class - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(TInterface)}' is not mockable or the source generator did not run correctly."); - } - } - -} - -/// -/// Adapts an IParameter (non-generic) to -/// IParameterMatch<T> so that covariant parameter -/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> -/// slot) can still be invoked at setup/verify time. Only allocated when the direct -/// IParameterMatch<T> cast fails. Shared by every -/// generated mock file. -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch -{ - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); -} -#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated/MockBehaviorExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated/MockBehaviorExtensions.g.cs deleted file mode 100644 index 888d2c2c..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated/MockBehaviorExtensions.g.cs +++ /dev/null @@ -1,285 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable annotations - -/// -/// Extensions for MockBehavior. -/// -internal static partial class Mock -{ - private static readonly global::Mockolate.MockBehavior _default; - - static Mock() - { - _default = new global::Mockolate.MockBehavior(new DefaultValueGenerator()); - } - - extension(global::Mockolate.MockBehavior) - { - /// - /// The default MockBehavior - the starting point for configuring a mock. - /// - /// - /// Un-configured members return the generator-provided default value (empty strings/collections, completed - /// Tasks, otherwise), base-class - /// implementations run for class mocks, and every invocation is recorded for later verification. - /// - /// Chain SkippingBaseClass(), ThrowingWhenNotSetup(), SkippingInteractionRecording(), - /// WithDefaultValueFor<T>(...) or UseConstructorParametersFor<T>(...) to derive - /// a customized MockBehavior; because it is a , - /// each call returns a new instance and this shared default stays unchanged. - /// - public static global::Mockolate.MockBehavior Default => _default; - } - - /// - /// Defines a factory for creating default values for a specified type. - /// - public interface IDefaultValueFactory - { - /// - /// Determines whether the specified can be created by this factory. - /// - bool IsMatch(global::System.Type type); - - /// - /// Creates a new instance of the specified type. - /// - object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, object?[] parameters); - } - - /// - /// A IDefaultValueFactory that returns a specified for the given type - /// parameter . - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal class TypedDefaultValueFactory(T value) : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(T); - - /// - public object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - => value; - } - - /// - /// Provides default values for common types used in mocking scenarios. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private class DefaultValueGenerator : IDefaultValueGenerator - { - private static readonly global::System.Collections.Concurrent.ConcurrentQueue _factories = new([ - new TypedDefaultValueFactory(""), - new CancellableTaskFactory(), - #if NET8_0_OR_GREATER - new CancellableValueTaskFactory(), - #endif - new TypedDefaultValueFactory(global::System.Threading.CancellationToken.None), - new TypedDefaultValueFactory(global::System.Array.Empty()), - ]); - - /// - public object? GenerateValue(global::System.Type type, params object?[] parameters) - { - if (TryGenerate(type, parameters, out object? value)) - { - return value; - } - - return null; - } - - /// - /// Registers a to provide default values for a specific type. - /// - public static void Register(IDefaultValueFactory defaultValueFactory) - => _factories.Enqueue(defaultValueFactory); - - /// - /// Tries to generate a default value for the specified type. - /// - protected virtual bool TryGenerate(global::System.Type type, object?[] parameters, out object? value) - { - IDefaultValueFactory? matchingFactory = global::System.Linq.Enumerable.FirstOrDefault(_factories, Predicate); - if (matchingFactory is not null) - { - value = matchingFactory.Create(type, this, parameters); - return true; - } - - value = null; - return false; - - bool Predicate(global::Mockolate.Mock.IDefaultValueFactory f) - => f.IsMatch(type); - } - - private static bool HasCanceledCancellationToken(object?[] parameters, out global::System.Threading.CancellationToken cancellationToken) - { - global::System.Threading.CancellationToken parameter = global::System.Linq.Enumerable.FirstOrDefault(global::System.Linq.Enumerable.OfType(parameters)); - if (parameter.IsCancellationRequested) - { - cancellationToken = parameter; - return true; - } - - cancellationToken = global::System.Threading.CancellationToken.None; - return false; - } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CancellableTaskFactory : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Threading.Tasks.Task); - - /// - public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - { - if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) - { - return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.Task.CompletedTask; - } - } - #if NET8_0_OR_GREATER - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CancellableValueTaskFactory : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Threading.Tasks.ValueTask); - - /// - public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - { - if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) - { - return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.ValueTask.CompletedTask; - } - } - #endif - } -} - -/// -/// Extensions on IDefaultValueGenerator -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static class DefaultValueGeneratorExtensions -{ - /// - /// Adds a generic Generate method for specific types. - /// - extension(IDefaultValueGenerator generator) - { - /// - /// Generates a Task of , with - /// the for context. - /// - public global::System.Threading.Tasks.Task Generate(global::System.Threading.Tasks.Task nullValue, T value, params object?[] parameters) - { - global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( - global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; - if (cancellationToken.IsCancellationRequested) - { - return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.Task.FromResult(value); - } - -#if NET8_0_OR_GREATER - /// - /// Generates a ValueTask of , with - /// the for context. - /// - public global::System.Threading.Tasks.ValueTask Generate(global::System.Threading.Tasks.ValueTask nullValue, T value, params object?[] parameters) - { - global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( - global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; - if (cancellationToken.IsCancellationRequested) - { - return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.ValueTask.FromResult(value); - } -#endif - - /// - /// Generates an empty enumerable of , with - /// the for context. - /// - public global::System.Collections.Generic.IEnumerable Generate(global::System.Collections.Generic.IEnumerable nullValue, params object?[] parameters) - => global::System.Array.Empty(); - - /// - /// Generates an empty enumerable of , with - /// the for context. - /// - public global::System.Collections.Generic.List Generate(global::System.Collections.Generic.List nullValue, params object?[] parameters) - => new global::System.Collections.Generic.List(); - - /// - /// Generates an empty array of , with - /// the for context. - /// - public T[] Generate(T[] nullValue, params object?[] parameters) - => global::System.Array.Empty(); - - /// - /// Generates an empty two-dimensional array of , with - /// the for context. - /// - public T[,] Generate(T[,] nullValue, params object?[] parameters) - => new T[,] { }; - - /// - /// Generates an empty three-dimensional array of , with - /// the for context. - /// - public T[,,] Generate(T[,,] nullValue, params object?[] parameters) - => new T[,,] { }; - - /// - /// Generates an empty four-dimensional array of , with - /// the for context. - /// - public T[,,,] Generate(T[,,,] nullValue, params object?[] parameters) - => new T[,,,] { }; - - /// - /// Generates a default value of type , with - /// the for context. - /// - public T Generate(T nullValue, params object?[] parameters) - { - if (generator.GenerateValue(typeof(T), parameters) is T value) - { - return value; - } - - return nullValue; - } - } -} - -#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated/_shared.txt b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated/_shared.txt new file mode 100644 index 00000000..74c0aa3c --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated/_shared.txt @@ -0,0 +1,4 @@ +MethodSetups.g.cs|MethodSetups.3d601ff0.g.cs +Mock.g.cs|Mock.g.cs +MockBehaviorExtensions.g.cs|MockBehaviorExtensions.g.cs +ReturnsThrowsAsyncExtensions.g.cs|ReturnsThrowsAsyncExtensions.d2d185ae.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/MethodSetups.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/MethodSetups.g.cs deleted file mode 100644 index be5c6940..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/MethodSetups.g.cs +++ /dev/null @@ -1,771 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -#nullable enable - -namespace Mockolate.Setup -{ - /// - /// Sets up a method with 6 parameters , , , , and returning . - /// - internal interface IReturnMethodSetup : global::Mockolate.Setup.IMethodSetup - { - /// - /// Overrides SkipBaseClass for this method only. - /// - /// - /// If not specified, use SkipBaseClass. - /// - global::Mockolate.Setup.IReturnMethodSetup SkippingBaseClass(bool skipBaseClass = true); - - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Transitions the scenario to the given when the method is called. - /// - global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder TransitionTo(string scenario); - - /// - /// Registers a to setup the return value for this method. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(global::System.Func callback); - - /// - /// Registers the for this method. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(TReturn returnValue); - - /// - /// Registers an to throw when the method is invoked. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws() - where TException : global::System.Exception, new(); - - /// - /// Registers an to throw when the method is invoked. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(global::System.Exception exception); - - /// - /// Registers a that will calculate the exception to throw when the method is invoked. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(global::System.Func callback); - } - - /// - /// Sets up a method with 6 parameters , , , , and returning with callback support for the parameters. - /// - internal interface IReturnMethodSetupWithCallback : global::Mockolate.Setup.IReturnMethodSetup - { - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Registers a to setup the return value for this method. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(global::System.Func callback); - - /// - /// Registers a that will calculate the exception to throw when the method is invoked. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(global::System.Func callback); - } - - /// - /// Sets up a callback for a method with 6 parameters , , , , and returning . - /// - internal interface IReturnMethodSetupCallbackBuilder : global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder - { - /// - /// Runs the callback in parallel to the other callbacks. - /// - global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder InParallel(); - } - - /// - /// Sets up a parallel callback for a method with 6 parameters , , , , and returning . - /// - internal interface IReturnMethodSetupParallelCallbackBuilder : global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder - { - /// - /// Limits the callback to only execute for method invocations where the predicate returns true. - /// - /// - /// Provides a zero-based counter indicating how many times the method has been invoked so far. - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder When(global::System.Func predicate); - } - - /// - /// Sets up a when callback for a method with 6 parameters , , , , and returning . - /// - internal interface IReturnMethodSetupCallbackWhenBuilder : global::Mockolate.Setup.IReturnMethodSetupWithCallback - { - /// - /// Repeats the callback for the given number of . - /// - /// - /// The number of times is only counted for actual executions (IReturnMethodSetupParallelCallbackBuilder<TReturn, T1, T2, T3, T4, T5, T6>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder For(int times); - - /// - /// Deactivates the callback after the given number of . - /// - /// - /// The number of times is only counted for actual executions (IReturnMethodSetupParallelCallbackBuilder<TReturn, T1, T2, T3, T4, T5, T6>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IReturnMethodSetup Only(int times); - } - - /// - /// Sets up a return callback for a method with 6 parameters , , , , and returning . - /// - internal interface IReturnMethodSetupReturnBuilder : global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder - { - /// - /// Limits the return/throw to only execute for method invocations where the predicate returns true. - /// - /// - /// Provides a zero-based counter indicating how many times the method has been invoked so far. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder When(global::System.Func predicate); - } - - /// - /// Sets up a when return callback for a method with 6 parameters , , , , and returning . - /// - internal interface IReturnMethodSetupReturnWhenBuilder : global::Mockolate.Setup.IReturnMethodSetupWithCallback - { - /// - /// Repeats the callback for the given number of . - /// - /// - /// The number of times is only counted for actual executions (IReturnMethodSetupReturnBuilder<TReturn, T1, T2, T3, T4, T5, T6>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder For(int times); - - /// - /// Deactivates the return/throw after the given number of . - /// - /// - /// The number of times is only counted for actual executions (IReturnMethodSetupReturnBuilder<TReturn, T1, T2, T3, T4, T5, T6>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IReturnMethodSetup Only(int times); - } - - /// - /// Allows ignoring the provided parameters. - /// - internal interface IReturnMethodSetupParameterIgnorer : global::Mockolate.Setup.IReturnMethodSetupWithCallback - { - /// - /// Replaces the explicit parameter matcher with AnyParameters(). - /// - global::Mockolate.Setup.IReturnMethodSetup AnyParameters(); - } - - /// - /// Sets up a method with 6 parameters , , , , and returning . - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal abstract class ReturnMethodSetup : global::Mockolate.Setup.MethodSetup, - global::Mockolate.Setup.IReturnMethodSetupWithCallback, - global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder, - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder - { - private readonly global::Mockolate.MockRegistry _mockRegistry; - private global::Mockolate.Setup.Callbacks>? _callbacks = []; - private global::Mockolate.Setup.Callbacks>? _returnCallbacks = []; - private bool? _skipBaseClass; - - protected ReturnMethodSetup(global::Mockolate.MockRegistry mockRegistry, string name) - : base(name) - { - _mockRegistry = mockRegistry; - } - - /// - global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetup.SkippingBaseClass(bool skipBaseClass) - { - _skipBaseClass = skipBaseClass; - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder global::Mockolate.Setup.IReturnMethodSetup.Do(global::System.Action callback) - { - global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _, _) => callback()); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Do(global::System.Action callback) - { - global::Mockolate.Setup.Callback>? currentCallback = new((_, p1, p2, p3, p4, p5, p6) => callback(p1, p2, p3, p4, p5, p6)); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Do(global::System.Action callback) - { - global::Mockolate.Setup.Callback>? currentCallback = new(callback); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IReturnMethodSetup.TransitionTo(string scenario) - { - global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _, _) => _mockRegistry.TransitionTo(scenario)); - currentCallback.InParallel(); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Returns(global::System.Func callback) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, p1, p2, p3, p4, p5, p6) => callback(p1, p2, p3, p4, p5, p6)); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Returns(global::System.Func callback) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _) => callback()); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Returns(TReturn returnValue) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _) => returnValue); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Throws() - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _) => throw new TException()); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Throws(global::System.Exception exception) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _) => throw exception); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Throws(global::System.Func callback) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, p1, p2, p3, p4, p5, p6) => throw callback(p1, p2, p3, p4, p5, p6)); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Throws(global::System.Func callback) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _) => throw callback()); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder.InParallel() - { - _callbacks?.Active?.InParallel(); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder.When(global::System.Func predicate) - { - _callbacks?.Active?.When(predicate); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder.For(int times) - { - _callbacks?.Active?.For(times); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder.Only(int times) - { - _callbacks?.Active?.Only(times); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder global::Mockolate.Setup.IReturnMethodSetupReturnBuilder.When(global::System.Func predicate) - { - _returnCallbacks?.Active?.When(predicate); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder.For(int times) - { - _returnCallbacks?.Active?.For(times); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder.Only(int times) - { - _returnCallbacks?.Active?.Only(times); - return this; - } - - /// - protected override bool MatchesInteraction(global::Mockolate.Interactions.IMethodInteraction interaction) - { - if (interaction is global::Mockolate.Interactions.MethodInvocation invocation) - { - return Matches(invocation.Parameter1, invocation.Parameter2, invocation.Parameter3, invocation.Parameter4, invocation.Parameter5, invocation.Parameter6); - } - return false; - } - - /// - /// Flag indicating, if any return callbacks have been registered on this setup. - /// - public bool HasReturnCallbacks - => _returnCallbacks is { Count: > 0, }; - - /// - /// Gets the flag indicating if the base class implementation should be skipped. - /// - public bool SkipBaseClass(global::Mockolate.MockBehavior behavior) - => _skipBaseClass ?? behavior.SkipBaseClass; - - /// - /// Gets the registered return value. - /// - public bool TryGetReturnValue(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, out TReturn returnValue) - { - if (_returnCallbacks != null) - { - foreach (var _ in _returnCallbacks) - { - var returnCallback = _returnCallbacks[_returnCallbacks.CurrentIndex % _returnCallbacks.Count]; - if (returnCallback.Invoke(ref _returnCallbacks.CurrentIndex, (p1, p2, p3, p4, p5, p6), - static (invocationCount, @delegate, state) => @delegate(invocationCount, state.p1, state.p2, state.p3, state.p4, state.p5, state.p6), - out TReturn? newValue)) - { - returnValue = newValue; - return true; - } - } - } - returnValue = default!; - return false; - } - - /// - /// Checks if the given parameters match the setup. - /// - public abstract bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value); - - /// - /// Triggers any configured parameter callbacks for the method setup with the specified parameters. - /// - public virtual void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6) - { - if (_callbacks is not null) - { - bool wasInvoked = false; - int currentCallbacksIndex = _callbacks.CurrentIndex; - for (int i = 0; i < _callbacks.Count; i++) - { - var callback = _callbacks[(currentCallbacksIndex + i) % _callbacks.Count]; - if (callback.Invoke(wasInvoked, ref _callbacks.CurrentIndex, (parameter1, parameter2, parameter3, parameter4, parameter5, parameter6), - static (invocationCount, @delegate, state) => @delegate(invocationCount, state.parameter1, state.parameter2, state.parameter3, state.parameter4, state.parameter5, state.parameter6))) - { - wasInvoked = true; - } - } - } - } - - /// Setup for a method with 6 parameters matching against IParameters. - internal class WithParameters : ReturnMethodSetup - { - private readonly string _parameterName1; - private readonly string _parameterName2; - private readonly string _parameterName3; - private readonly string _parameterName4; - private readonly string _parameterName5; - private readonly string _parameterName6; - - /// - public WithParameters(global::Mockolate.MockRegistry mockRegistry, string name, global::Mockolate.Parameters.IParameters parameters, string parameterName1, string parameterName2, string parameterName3, string parameterName4, string parameterName5, string parameterName6) - : base(mockRegistry, name) - { - Parameters = parameters; - _parameterName1 = parameterName1; - _parameterName2 = parameterName2; - _parameterName3 = parameterName3; - _parameterName4 = parameterName4; - _parameterName5 = parameterName5; - _parameterName6 = parameterName6; - } - - private global::Mockolate.Parameters.IParameters Parameters { get; } - - /// - public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value) - => Parameters switch - { - global::Mockolate.Parameters.IParametersMatch m => m.Matches([p1Value, p2Value, p3Value, p4Value, p5Value, p6Value]), - global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([(_parameterName1, p1Value), (_parameterName2, p2Value), (_parameterName3, p3Value), (_parameterName4, p4Value), (_parameterName5, p5Value), (_parameterName6, p6Value)]), - _ => true, - }; - - /// - public override string ToString() - { - return $"{FormatType(typeof(TReturn))} {SubstringAfterLast(Name, '.')}({Parameters})"; - static string SubstringAfterLast(string name, char c) - { - int index = name.LastIndexOf(c); - return index >= 0 ? name.Substring(index + 1) : name; - } - } - } - - /// Setup for a method with 6 parameters matching against individual IParameterMatch<T>. - internal class WithParameterCollection : ReturnMethodSetup, - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer - { - private bool _matchAnyParameters; - - /// - public WithParameterCollection( - global::Mockolate.MockRegistry mockRegistry, - string name, - global::Mockolate.Parameters.IParameterMatch parameter1, - global::Mockolate.Parameters.IParameterMatch parameter2, - global::Mockolate.Parameters.IParameterMatch parameter3, - global::Mockolate.Parameters.IParameterMatch parameter4, - global::Mockolate.Parameters.IParameterMatch parameter5, - global::Mockolate.Parameters.IParameterMatch parameter6) - : base(mockRegistry, name) - { - Parameter1 = parameter1; - Parameter2 = parameter2; - Parameter3 = parameter3; - Parameter4 = parameter4; - Parameter5 = parameter5; - Parameter6 = parameter6; - } - - /// The first parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter1 { get; } - - /// The second parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter2 { get; } - - /// The third parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter3 { get; } - - /// The 4th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter4 { get; } - - /// The 5th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter5 { get; } - - /// The 6th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter6 { get; } - - /// - global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer.AnyParameters() - { - _matchAnyParameters = true; - return this; - } - - /// - public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value) - => _matchAnyParameters || (Parameter1.Matches(p1Value) && Parameter2.Matches(p2Value) && Parameter3.Matches(p3Value) && Parameter4.Matches(p4Value) && Parameter5.Matches(p5Value) && Parameter6.Matches(p6Value)); - - /// - public override void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6) - { - Parameter1?.InvokeCallbacks(parameter1); - Parameter2?.InvokeCallbacks(parameter2); - Parameter3?.InvokeCallbacks(parameter3); - Parameter4?.InvokeCallbacks(parameter4); - Parameter5?.InvokeCallbacks(parameter5); - Parameter6?.InvokeCallbacks(parameter6); - base.TriggerCallbacks(parameter1, parameter2, parameter3, parameter4, parameter5, parameter6); - } - - /// - public override string ToString() - { - return $"{FormatType(typeof(TReturn))} {SubstringAfterLast(Name, '.')}({Parameter1}, {Parameter2}, {Parameter3}, {Parameter4}, {Parameter5}, {Parameter6})"; - static string SubstringAfterLast(string name, char c) - { - int index = name.LastIndexOf(c); - return index >= 0 ? name.Substring(index + 1) : name; - } - } - } - } - -} - -namespace Mockolate -{ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal static class MethodSetupExtensions - { - - /// - /// Extensions for method callback setup returning with 6 parameters. - /// - extension(global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder setup) - { - /// - /// Executes the callback only once. - /// - public global::Mockolate.Setup.IReturnMethodSetup OnlyOnce() - => setup.Only(1); - } - - /// - /// Extensions for method setup returning with 6 parameters. - /// - extension(global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder setup) - { - /// - /// Returns/throws forever. - /// - public void Forever() - { - setup.For(int.MaxValue); - } - - /// - /// Uses the return value only once. - /// - public global::Mockolate.Setup.IReturnMethodSetup OnlyOnce() - => setup.Only(1); - } - } -} -namespace Mockolate.Interactions -{ - /// - /// An invocation of a method with 6 parameters , , , , and . - /// - [global::System.Diagnostics.DebuggerDisplay("{ToString()}")] - internal class MethodInvocation(string name, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6) : IMethodInteraction - { - /// - /// The name of the method. - /// - public string Name { get; } = name; - /// - /// The first parameter value of the method. - /// - public T1 Parameter1 { get; } = parameter1; - /// - /// The second parameter value of the method. - /// - public T2 Parameter2 { get; } = parameter2; - /// - /// The third parameter value of the method. - /// - public T3 Parameter3 { get; } = parameter3; - /// - /// The 4th parameter value of the method. - /// - public T4 Parameter4 { get; } = parameter4; - /// - /// The 5th parameter value of the method. - /// - public T5 Parameter5 { get; } = parameter5; - /// - /// The 6th parameter value of the method. - /// - public T6 Parameter6 { get; } = parameter6; - /// - public override string ToString() - { - return $"invoke method {SubstringAfterLast(Name, '.')}({Parameter1?.ToString() ?? "null"}, {Parameter2?.ToString() ?? "null"}, {Parameter3?.ToString() ?? "null"}, {Parameter4?.ToString() ?? "null"}, {Parameter5?.ToString() ?? "null"}, {Parameter6?.ToString() ?? "null"})"; - static string SubstringAfterLast(string name, char c) - { - int index = name.LastIndexOf(c); - return index >= 0 ? name.Substring(index + 1) : name; - } - } - } - /// - /// Per-member buffer for 6-parameter methods, synthesized for arity 6 use sites. - /// - [global::System.Diagnostics.DebuggerDisplay("{Count} method calls")] - internal sealed class FastMethod6Buffer : IFastMemberBuffer - { - private readonly FastMockInteractions _owner; -#if NET10_0_OR_GREATER - private readonly global::System.Threading.Lock _growLock = new(); -#else - private readonly object _growLock = new(); -#endif - private Record[] _records = new Record[4]; - private bool[] _verifiedSlots = new bool[4]; - private int _reserved; - private int _published; - - internal FastMethod6Buffer(FastMockInteractions owner) => _owner = owner; - - public int Count => global::System.Threading.Volatile.Read(ref _published); - - public void Append(string name, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6) - { - long seq = _owner.NextSequence(); - int slot = global::System.Threading.Interlocked.Increment(ref _reserved) - 1; - Record[] records = global::System.Threading.Volatile.Read(ref _records); - if (slot >= records.Length) records = GrowToFit(slot); - - records[slot].Seq = seq; - records[slot].Name = name; - records[slot].P1 = parameter1; - records[slot].P2 = parameter2; - records[slot].P3 = parameter3; - records[slot].P4 = parameter4; - records[slot].P5 = parameter5; - records[slot].P6 = parameter6; - records[slot].Boxed = null; - global::System.Threading.Interlocked.Increment(ref _published); - - if (_owner.HasInteractionAddedSubscribers) _owner.RaiseAdded(); - } - - private Record[] GrowToFit(int slot) - { - lock (_growLock) - { - Record[] records = _records; - while (slot >= records.Length) - { - Record[] bigger = new Record[records.Length * 2]; - global::System.Array.Copy(records, bigger, records.Length); - records = bigger; - } - global::System.Threading.Volatile.Write(ref _records, records); - if (_verifiedSlots.Length < records.Length) - { - bool[] biggerBits = new bool[records.Length]; - global::System.Array.Copy(_verifiedSlots, biggerBits, _verifiedSlots.Length); - _verifiedSlots = biggerBits; - } - return records; - } - } - - public void Clear() - { - lock (_growLock) { global::System.Array.Clear(_records, 0, _published); _reserved = 0; global::System.Threading.Volatile.Write(ref _published, 0); global::System.Array.Clear(_verifiedSlots, 0, _verifiedSlots.Length); } - } - - void IFastMemberBuffer.AppendBoxed(global::System.Collections.Generic.List> dest) - { - lock (_growLock) - { - int n = _published; - Record[] records = _records; - for (int i = 0; i < n; i++) - { - ref Record r = ref records[i]; - r.Boxed ??= new MethodInvocation(r.Name, r.P1, r.P2, r.P3, r.P4, r.P5, r.P6); - dest.Add(new global::System.ValueTuple(r.Seq, r.Boxed)); - } - } - } - - void IFastMemberBuffer.AppendBoxedUnverified(global::System.Collections.Generic.List> dest) - { - lock (_growLock) - { - int n = _published; - Record[] records = _records; - bool[] verified = _verifiedSlots; - for (int i = 0; i < n; i++) - { - if (verified[i]) continue; - ref Record r = ref records[i]; - r.Boxed ??= new MethodInvocation(r.Name, r.P1, r.P2, r.P3, r.P4, r.P5, r.P6); - dest.Add(new global::System.ValueTuple(r.Seq, r.Boxed)); - } - } - } - - public int ConsumeMatching(global::Mockolate.Parameters.IParameterMatch match1, global::Mockolate.Parameters.IParameterMatch match2, global::Mockolate.Parameters.IParameterMatch match3, global::Mockolate.Parameters.IParameterMatch match4, global::Mockolate.Parameters.IParameterMatch match5, global::Mockolate.Parameters.IParameterMatch match6) - { - int matches = 0; - lock (_growLock) - { - int n = _published; - Record[] records = _records; - bool[] verified = _verifiedSlots; - for (int i = 0; i < n; i++) - { - ref Record r = ref records[i]; - if (match1.Matches(r.P1) && match2.Matches(r.P2) && match3.Matches(r.P3) && match4.Matches(r.P4) && match5.Matches(r.P5) && match6.Matches(r.P6)) - { - matches++; - verified[i] = true; - } - } - } - - return matches; - } - - private struct Record - { - public long Seq; - public string Name; - public T1 P1; - public T2 P2; - public T3 P3; - public T4 P4; - public T5 P5; - public T6 P6; - public IInteraction? Boxed; - } - } -} - -#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/Mock.g.cs deleted file mode 100644 index 3944360b..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/Mock.g.cs +++ /dev/null @@ -1,135 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable -/// -/// Create new mocks by calling the static T.CreateMock() method on your type T. -/// -/// -/// You can also provide a MockBehavior parameter to customize how the mock should behave in certain scenarios.
-/// If your type is a class without a default constructor, you can provide constructor parameters by passing an object?[]? to the corresponding CreateMock(...) overload. -///
-[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static partial class Mock -{ - /// - /// This interface should never be used. If it is, this is an indication that the Mockolate source generator did not run correctly or that the used type is not mockable. - /// - /// - /// The source generator creates overloads with correct return values. - /// - internal interface IMockGenerationDidNotRun {} - - /// - /// Create a new mock of with the default MockBehavior. - /// - /// Type to mock, which can be an interface or a class. - /// - /// Any interface type can be used for mocking, but for classes, only abstract and virtual members can be mocked. - /// - extension(T _) - { - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior = null) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior, object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - } - - extension(global::Mockolate.Mock.IMockGenerationDidNotRun _) - { - /// - /// Fallback Implementing that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Additional interface the mock should implement. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete Implementing overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public global::Mockolate.Mock.IMockGenerationDidNotRun Implementing() where TInterface : class - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(TInterface)}' is not mockable or the source generator did not run correctly."); - } - } - -} - -/// -/// Adapts an IParameter (non-generic) to -/// IParameterMatch<T> so that covariant parameter -/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> -/// slot) can still be invoked at setup/verify time. Only allocated when the direct -/// IParameterMatch<T> cast fails. Shared by every -/// generated mock file. -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch -{ - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); -} -#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/MockBehaviorExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/MockBehaviorExtensions.g.cs deleted file mode 100644 index 888d2c2c..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/MockBehaviorExtensions.g.cs +++ /dev/null @@ -1,285 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable annotations - -/// -/// Extensions for MockBehavior. -/// -internal static partial class Mock -{ - private static readonly global::Mockolate.MockBehavior _default; - - static Mock() - { - _default = new global::Mockolate.MockBehavior(new DefaultValueGenerator()); - } - - extension(global::Mockolate.MockBehavior) - { - /// - /// The default MockBehavior - the starting point for configuring a mock. - /// - /// - /// Un-configured members return the generator-provided default value (empty strings/collections, completed - /// Tasks, otherwise), base-class - /// implementations run for class mocks, and every invocation is recorded for later verification. - /// - /// Chain SkippingBaseClass(), ThrowingWhenNotSetup(), SkippingInteractionRecording(), - /// WithDefaultValueFor<T>(...) or UseConstructorParametersFor<T>(...) to derive - /// a customized MockBehavior; because it is a , - /// each call returns a new instance and this shared default stays unchanged. - /// - public static global::Mockolate.MockBehavior Default => _default; - } - - /// - /// Defines a factory for creating default values for a specified type. - /// - public interface IDefaultValueFactory - { - /// - /// Determines whether the specified can be created by this factory. - /// - bool IsMatch(global::System.Type type); - - /// - /// Creates a new instance of the specified type. - /// - object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, object?[] parameters); - } - - /// - /// A IDefaultValueFactory that returns a specified for the given type - /// parameter . - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal class TypedDefaultValueFactory(T value) : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(T); - - /// - public object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - => value; - } - - /// - /// Provides default values for common types used in mocking scenarios. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private class DefaultValueGenerator : IDefaultValueGenerator - { - private static readonly global::System.Collections.Concurrent.ConcurrentQueue _factories = new([ - new TypedDefaultValueFactory(""), - new CancellableTaskFactory(), - #if NET8_0_OR_GREATER - new CancellableValueTaskFactory(), - #endif - new TypedDefaultValueFactory(global::System.Threading.CancellationToken.None), - new TypedDefaultValueFactory(global::System.Array.Empty()), - ]); - - /// - public object? GenerateValue(global::System.Type type, params object?[] parameters) - { - if (TryGenerate(type, parameters, out object? value)) - { - return value; - } - - return null; - } - - /// - /// Registers a to provide default values for a specific type. - /// - public static void Register(IDefaultValueFactory defaultValueFactory) - => _factories.Enqueue(defaultValueFactory); - - /// - /// Tries to generate a default value for the specified type. - /// - protected virtual bool TryGenerate(global::System.Type type, object?[] parameters, out object? value) - { - IDefaultValueFactory? matchingFactory = global::System.Linq.Enumerable.FirstOrDefault(_factories, Predicate); - if (matchingFactory is not null) - { - value = matchingFactory.Create(type, this, parameters); - return true; - } - - value = null; - return false; - - bool Predicate(global::Mockolate.Mock.IDefaultValueFactory f) - => f.IsMatch(type); - } - - private static bool HasCanceledCancellationToken(object?[] parameters, out global::System.Threading.CancellationToken cancellationToken) - { - global::System.Threading.CancellationToken parameter = global::System.Linq.Enumerable.FirstOrDefault(global::System.Linq.Enumerable.OfType(parameters)); - if (parameter.IsCancellationRequested) - { - cancellationToken = parameter; - return true; - } - - cancellationToken = global::System.Threading.CancellationToken.None; - return false; - } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CancellableTaskFactory : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Threading.Tasks.Task); - - /// - public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - { - if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) - { - return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.Task.CompletedTask; - } - } - #if NET8_0_OR_GREATER - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CancellableValueTaskFactory : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Threading.Tasks.ValueTask); - - /// - public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - { - if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) - { - return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.ValueTask.CompletedTask; - } - } - #endif - } -} - -/// -/// Extensions on IDefaultValueGenerator -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static class DefaultValueGeneratorExtensions -{ - /// - /// Adds a generic Generate method for specific types. - /// - extension(IDefaultValueGenerator generator) - { - /// - /// Generates a Task of , with - /// the for context. - /// - public global::System.Threading.Tasks.Task Generate(global::System.Threading.Tasks.Task nullValue, T value, params object?[] parameters) - { - global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( - global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; - if (cancellationToken.IsCancellationRequested) - { - return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.Task.FromResult(value); - } - -#if NET8_0_OR_GREATER - /// - /// Generates a ValueTask of , with - /// the for context. - /// - public global::System.Threading.Tasks.ValueTask Generate(global::System.Threading.Tasks.ValueTask nullValue, T value, params object?[] parameters) - { - global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( - global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; - if (cancellationToken.IsCancellationRequested) - { - return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.ValueTask.FromResult(value); - } -#endif - - /// - /// Generates an empty enumerable of , with - /// the for context. - /// - public global::System.Collections.Generic.IEnumerable Generate(global::System.Collections.Generic.IEnumerable nullValue, params object?[] parameters) - => global::System.Array.Empty(); - - /// - /// Generates an empty enumerable of , with - /// the for context. - /// - public global::System.Collections.Generic.List Generate(global::System.Collections.Generic.List nullValue, params object?[] parameters) - => new global::System.Collections.Generic.List(); - - /// - /// Generates an empty array of , with - /// the for context. - /// - public T[] Generate(T[] nullValue, params object?[] parameters) - => global::System.Array.Empty(); - - /// - /// Generates an empty two-dimensional array of , with - /// the for context. - /// - public T[,] Generate(T[,] nullValue, params object?[] parameters) - => new T[,] { }; - - /// - /// Generates an empty three-dimensional array of , with - /// the for context. - /// - public T[,,] Generate(T[,,] nullValue, params object?[] parameters) - => new T[,,] { }; - - /// - /// Generates an empty four-dimensional array of , with - /// the for context. - /// - public T[,,,] Generate(T[,,,] nullValue, params object?[] parameters) - => new T[,,,] { }; - - /// - /// Generates a default value of type , with - /// the for context. - /// - public T Generate(T nullValue, params object?[] parameters) - { - if (generator.GenerateValue(typeof(T), parameters) is T value) - { - return value; - } - - return nullValue; - } - } -} - -#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/ReturnsThrowsAsyncExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/ReturnsThrowsAsyncExtensions.g.cs deleted file mode 100644 index bffa4be5..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/ReturnsThrowsAsyncExtensions.g.cs +++ /dev/null @@ -1,156 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable - -/// -/// Extensions for setting up return values and throwing exceptions for methods. -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static class ReturnsThrowsAsyncExtensions2 -{ - /// - /// Appends to the sequence - the next matching invocation returns a completed - /// Task<TReturn> carrying this value. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6> setup, TReturn returnValue) - => setup.Returns(global::System.Threading.Tasks.Task.FromResult(returnValue)); - - /// - /// Appends a lazy async return to the sequence; is invoked on each matching - /// invocation and its result is wrapped in a completed Task<TReturn>. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6> setup, global::System.Func callback) - => setup.Returns(() => global::System.Threading.Tasks.Task.FromResult(callback())); - - /// - /// Appends a lazy async return that receives the method's arguments and produces the value wrapped in a - /// completed Task<TReturn>. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5, T6> setup, global::System.Func callback) - => setup.Returns((v1, v2, v3, v4, v5, v6) => global::System.Threading.Tasks.Task.FromResult(callback(v1, v2, v3, v4, v5, v6))); - - /// - /// Appends an entry that faults the returned Task<TReturn> with - /// so awaiting it throws. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6> setup, global::System.Exception exception) - => setup.Returns(global::System.Threading.Tasks.Task.FromException(exception)); - - /// - /// Appends an entry that invokes to build the exception the returned - /// Task<TReturn> is faulted with. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6> setup, global::System.Func callback) - => setup.Returns(() => global::System.Threading.Tasks.Task.FromException(callback())); - - /// - /// Appends an entry that invokes with the method's arguments to build the - /// exception the returned Task<TReturn> is faulted with. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5, T6> setup, global::System.Func callback) - => setup.Returns((v1, v2, v3, v4, v5, v6) => global::System.Threading.Tasks.Task.FromException(callback(v1, v2, v3, v4, v5, v6))); - -#if NET8_0_OR_GREATER - - /// - /// Appends to the sequence - the next matching invocation returns a completed - /// ValueTask<TReturn> carrying this value. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6> setup, TReturn returnValue) - => setup.Returns(global::System.Threading.Tasks.ValueTask.FromResult(returnValue)); - - /// - /// Appends a lazy async return to the sequence; is invoked on each matching - /// invocation and its result is wrapped in a completed ValueTask<TReturn>. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6> setup, global::System.Func callback) - => setup.Returns(() => global::System.Threading.Tasks.ValueTask.FromResult(callback())); - - /// - /// Appends a lazy async return that receives the method's arguments and produces the value wrapped in a - /// completed ValueTask<TReturn>. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5, T6> setup, global::System.Func callback) - => setup.Returns((v1, v2, v3, v4, v5, v6) => global::System.Threading.Tasks.ValueTask.FromResult(callback(v1, v2, v3, v4, v5, v6))); - - /// - /// Appends an entry that faults the returned ValueTask<TReturn> with - /// so awaiting it throws. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6> setup, global::System.Exception exception) - => setup.Returns(global::System.Threading.Tasks.ValueTask.FromException(exception)); - - /// - /// Appends an entry that invokes to build the exception the returned - /// ValueTask<TReturn> is faulted with. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6> setup, global::System.Func callback) - => setup.Returns(() => global::System.Threading.Tasks.ValueTask.FromException(callback())); - - /// - /// Appends an entry that invokes with the method's arguments to build the - /// exception the returned ValueTask<TReturn> is faulted with. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5, T6> setup, global::System.Func callback) - => setup.Returns((v1, v2, v3, v4, v5, v6) => global::System.Threading.Tasks.ValueTask.FromException(callback(v1, v2, v3, v4, v5, v6))); - -#endif -} -#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/_shared.txt b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/_shared.txt new file mode 100644 index 00000000..635f684d --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/_shared.txt @@ -0,0 +1,5 @@ +MethodSetups.g.cs|MethodSetups.3d601ff0.g.cs +Mock.g.cs|Mock.g.cs +MockBehaviorExtensions.g.cs|MockBehaviorExtensions.g.cs +ParameterArg.g.cs|ParameterArg.g.cs +ReturnsThrowsAsyncExtensions.g.cs|ReturnsThrowsAsyncExtensions.d2d185ae.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/Mock.g.cs deleted file mode 100644 index 3944360b..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/Mock.g.cs +++ /dev/null @@ -1,135 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable -/// -/// Create new mocks by calling the static T.CreateMock() method on your type T. -/// -/// -/// You can also provide a MockBehavior parameter to customize how the mock should behave in certain scenarios.
-/// If your type is a class without a default constructor, you can provide constructor parameters by passing an object?[]? to the corresponding CreateMock(...) overload. -///
-[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static partial class Mock -{ - /// - /// This interface should never be used. If it is, this is an indication that the Mockolate source generator did not run correctly or that the used type is not mockable. - /// - /// - /// The source generator creates overloads with correct return values. - /// - internal interface IMockGenerationDidNotRun {} - - /// - /// Create a new mock of with the default MockBehavior. - /// - /// Type to mock, which can be an interface or a class. - /// - /// Any interface type can be used for mocking, but for classes, only abstract and virtual members can be mocked. - /// - extension(T _) - { - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior = null) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior, object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - } - - extension(global::Mockolate.Mock.IMockGenerationDidNotRun _) - { - /// - /// Fallback Implementing that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Additional interface the mock should implement. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete Implementing overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public global::Mockolate.Mock.IMockGenerationDidNotRun Implementing() where TInterface : class - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(TInterface)}' is not mockable or the source generator did not run correctly."); - } - } - -} - -/// -/// Adapts an IParameter (non-generic) to -/// IParameterMatch<T> so that covariant parameter -/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> -/// slot) can still be invoked at setup/verify time. Only allocated when the direct -/// IParameterMatch<T> cast fails. Shared by every -/// generated mock file. -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch -{ - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); -} -#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/MockBehaviorExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/MockBehaviorExtensions.g.cs deleted file mode 100644 index 888d2c2c..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/MockBehaviorExtensions.g.cs +++ /dev/null @@ -1,285 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable annotations - -/// -/// Extensions for MockBehavior. -/// -internal static partial class Mock -{ - private static readonly global::Mockolate.MockBehavior _default; - - static Mock() - { - _default = new global::Mockolate.MockBehavior(new DefaultValueGenerator()); - } - - extension(global::Mockolate.MockBehavior) - { - /// - /// The default MockBehavior - the starting point for configuring a mock. - /// - /// - /// Un-configured members return the generator-provided default value (empty strings/collections, completed - /// Tasks, otherwise), base-class - /// implementations run for class mocks, and every invocation is recorded for later verification. - /// - /// Chain SkippingBaseClass(), ThrowingWhenNotSetup(), SkippingInteractionRecording(), - /// WithDefaultValueFor<T>(...) or UseConstructorParametersFor<T>(...) to derive - /// a customized MockBehavior; because it is a , - /// each call returns a new instance and this shared default stays unchanged. - /// - public static global::Mockolate.MockBehavior Default => _default; - } - - /// - /// Defines a factory for creating default values for a specified type. - /// - public interface IDefaultValueFactory - { - /// - /// Determines whether the specified can be created by this factory. - /// - bool IsMatch(global::System.Type type); - - /// - /// Creates a new instance of the specified type. - /// - object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, object?[] parameters); - } - - /// - /// A IDefaultValueFactory that returns a specified for the given type - /// parameter . - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal class TypedDefaultValueFactory(T value) : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(T); - - /// - public object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - => value; - } - - /// - /// Provides default values for common types used in mocking scenarios. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private class DefaultValueGenerator : IDefaultValueGenerator - { - private static readonly global::System.Collections.Concurrent.ConcurrentQueue _factories = new([ - new TypedDefaultValueFactory(""), - new CancellableTaskFactory(), - #if NET8_0_OR_GREATER - new CancellableValueTaskFactory(), - #endif - new TypedDefaultValueFactory(global::System.Threading.CancellationToken.None), - new TypedDefaultValueFactory(global::System.Array.Empty()), - ]); - - /// - public object? GenerateValue(global::System.Type type, params object?[] parameters) - { - if (TryGenerate(type, parameters, out object? value)) - { - return value; - } - - return null; - } - - /// - /// Registers a to provide default values for a specific type. - /// - public static void Register(IDefaultValueFactory defaultValueFactory) - => _factories.Enqueue(defaultValueFactory); - - /// - /// Tries to generate a default value for the specified type. - /// - protected virtual bool TryGenerate(global::System.Type type, object?[] parameters, out object? value) - { - IDefaultValueFactory? matchingFactory = global::System.Linq.Enumerable.FirstOrDefault(_factories, Predicate); - if (matchingFactory is not null) - { - value = matchingFactory.Create(type, this, parameters); - return true; - } - - value = null; - return false; - - bool Predicate(global::Mockolate.Mock.IDefaultValueFactory f) - => f.IsMatch(type); - } - - private static bool HasCanceledCancellationToken(object?[] parameters, out global::System.Threading.CancellationToken cancellationToken) - { - global::System.Threading.CancellationToken parameter = global::System.Linq.Enumerable.FirstOrDefault(global::System.Linq.Enumerable.OfType(parameters)); - if (parameter.IsCancellationRequested) - { - cancellationToken = parameter; - return true; - } - - cancellationToken = global::System.Threading.CancellationToken.None; - return false; - } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CancellableTaskFactory : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Threading.Tasks.Task); - - /// - public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - { - if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) - { - return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.Task.CompletedTask; - } - } - #if NET8_0_OR_GREATER - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CancellableValueTaskFactory : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Threading.Tasks.ValueTask); - - /// - public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - { - if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) - { - return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.ValueTask.CompletedTask; - } - } - #endif - } -} - -/// -/// Extensions on IDefaultValueGenerator -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static class DefaultValueGeneratorExtensions -{ - /// - /// Adds a generic Generate method for specific types. - /// - extension(IDefaultValueGenerator generator) - { - /// - /// Generates a Task of , with - /// the for context. - /// - public global::System.Threading.Tasks.Task Generate(global::System.Threading.Tasks.Task nullValue, T value, params object?[] parameters) - { - global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( - global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; - if (cancellationToken.IsCancellationRequested) - { - return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.Task.FromResult(value); - } - -#if NET8_0_OR_GREATER - /// - /// Generates a ValueTask of , with - /// the for context. - /// - public global::System.Threading.Tasks.ValueTask Generate(global::System.Threading.Tasks.ValueTask nullValue, T value, params object?[] parameters) - { - global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( - global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; - if (cancellationToken.IsCancellationRequested) - { - return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.ValueTask.FromResult(value); - } -#endif - - /// - /// Generates an empty enumerable of , with - /// the for context. - /// - public global::System.Collections.Generic.IEnumerable Generate(global::System.Collections.Generic.IEnumerable nullValue, params object?[] parameters) - => global::System.Array.Empty(); - - /// - /// Generates an empty enumerable of , with - /// the for context. - /// - public global::System.Collections.Generic.List Generate(global::System.Collections.Generic.List nullValue, params object?[] parameters) - => new global::System.Collections.Generic.List(); - - /// - /// Generates an empty array of , with - /// the for context. - /// - public T[] Generate(T[] nullValue, params object?[] parameters) - => global::System.Array.Empty(); - - /// - /// Generates an empty two-dimensional array of , with - /// the for context. - /// - public T[,] Generate(T[,] nullValue, params object?[] parameters) - => new T[,] { }; - - /// - /// Generates an empty three-dimensional array of , with - /// the for context. - /// - public T[,,] Generate(T[,,] nullValue, params object?[] parameters) - => new T[,,] { }; - - /// - /// Generates an empty four-dimensional array of , with - /// the for context. - /// - public T[,,,] Generate(T[,,,] nullValue, params object?[] parameters) - => new T[,,,] { }; - - /// - /// Generates a default value of type , with - /// the for context. - /// - public T Generate(T nullValue, params object?[] parameters) - { - if (generator.GenerateValue(typeof(T), parameters) is T value) - { - return value; - } - - return nullValue; - } - } -} - -#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/_shared.txt b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/_shared.txt new file mode 100644 index 00000000..158aba32 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/_shared.txt @@ -0,0 +1,6 @@ +ActionFunc.g.cs|ActionFunc.g.cs +IndexerSetups.g.cs|IndexerSetups.d958f396.g.cs +MethodSetups.g.cs|MethodSetups.0483b407.g.cs +Mock.g.cs|Mock.g.cs +MockBehaviorExtensions.g.cs|MockBehaviorExtensions.g.cs +ReturnsThrowsAsyncExtensions.g.cs|ReturnsThrowsAsyncExtensions.dd90b829.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ActionFunc.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ActionFunc.g.cs deleted file mode 100644 index 5bf20d0a..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ActionFunc.g.cs +++ /dev/null @@ -1,34 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace System; - -#nullable enable - -/// -/// Encapsulates a method that has 17 parameters and does not return a value. -/// -public delegate void Action(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16, T17 arg17); - -/// -/// Encapsulates a method that has 17 parameters and returns a value of the type specified by the parameter. -/// -public delegate TResult Func(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16, T17 arg17); - -/// -/// Encapsulates a method that has 18 parameters and does not return a value. -/// -public delegate void Action(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16, T17 arg17, T18 arg18); - -/// -/// Encapsulates a method that has 18 parameters and returns a value of the type specified by the parameter. -/// -public delegate TResult Func(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16, T17 arg17, T18 arg18); - -#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/IndexerSetups.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/IndexerSetups.g.cs deleted file mode 100644 index 426a1255..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/IndexerSetups.g.cs +++ /dev/null @@ -1,1618 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -#nullable enable - -namespace Mockolate.Setup -{ - /// - /// Sets up a indexer getter for , , , and . - /// - internal interface IIndexerGetterSetup - { - /// - /// Registers a to be invoked whenever the indexer's getter is accessed. - /// - IIndexerGetterSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Transitions the scenario to the given whenever the indexer is read. - /// - IIndexerGetterSetupParallelCallbackBuilder TransitionTo(string scenario); - } - - /// - /// Sets up a indexer getter for , , , and with callback support for the parameters. - /// - internal interface IIndexerGetterSetupWithCallback : global::Mockolate.Setup.IIndexerGetterSetup - { - /// - /// Registers a to be invoked whenever the indexer's getter is accessed. - /// - /// - /// The callback receives the parameters of the indexer. - /// - IIndexerGetterSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Registers a to be invoked whenever the indexer's getter is accessed. - /// - /// - /// The callback receives the parameters of the indexer and the value of the indexer as last parameter. - /// - IIndexerGetterSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Registers a to be invoked whenever the indexer's getter is accessed. - /// - /// - /// The callback receives an incrementing access counter as first parameter, the parameters of the indexer and the value of the indexer as last parameter. - /// - IIndexerGetterSetupCallbackBuilder Do(global::System.Action callback); - } - - /// - /// Sets up a indexer setter for , , , and . - /// - internal interface IIndexerSetterSetup - { - /// - /// Registers a to be invoked whenever the indexer's setter is accessed. - /// - IIndexerSetterSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Registers a to be invoked whenever the indexer's setter is accessed. - /// - /// - /// The callback receives the value the indexer is set to as single parameter. - /// - IIndexerSetterSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Transitions the scenario to the given whenever the indexer is written to. - /// - IIndexerSetterSetupParallelCallbackBuilder TransitionTo(string scenario); - } - - /// - /// Sets up a indexer setter for , , , and with callback support for the parameters. - /// - internal interface IIndexerSetterSetupWithCallback : global::Mockolate.Setup.IIndexerSetterSetup - { - /// - /// Registers a to be invoked whenever the indexer's setter is accessed. - /// - /// - /// The callback receives the parameters of the indexer and the value the indexer is set to as last parameter. - /// - IIndexerSetterSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Registers a to be invoked whenever the indexer's setter is accessed. - /// - /// - /// The callback receives an incrementing access counter as first parameter, the parameters of the indexer and the value the indexer is set to as last parameter. - /// - IIndexerSetterSetupCallbackBuilder Do(global::System.Action callback); - } - - /// - /// Sets up a indexer for , , , and . - /// - internal interface IIndexerSetup - { - /// - /// Sets up callbacks on the getter. - /// - IIndexerGetterSetupWithCallback OnGet { get; } - - /// - /// Sets up callbacks on the setter. - /// - IIndexerSetterSetupWithCallback OnSet { get; } - - /// - /// Overrides SkipBaseClass for this indexer only. - /// - /// - /// If not specified, use SkipBaseClass. - /// - global::Mockolate.Setup.IIndexerSetup SkippingBaseClass(bool skipBaseClass = true); - - /// - /// Initializes the indexer with the given . - /// - global::Mockolate.Setup.IIndexerSetup InitializeWith(TValue value); - - /// - /// Registers the for this indexer. - /// - IIndexerSetupReturnBuilder Returns(TValue returnValue); - - /// - /// Registers a to setup the return value for this indexer. - /// - IIndexerSetupReturnBuilder Returns(global::System.Func callback); - - /// - /// Registers an to throw when the indexer is read. - /// - IIndexerSetupReturnBuilder Throws() - where TException : global::System.Exception, new(); - - /// - /// Registers an to throw when the indexer is read. - /// - IIndexerSetupReturnBuilder Throws(global::System.Exception exception); - - /// - /// Registers a that will calculate the exception to throw when the indexer is read. - /// - IIndexerSetupReturnBuilder Throws(global::System.Func callback); - } - - /// - /// Sets up a indexer for , , , and with callback support for the parameters. - /// - internal interface IIndexerSetupWithCallback : global::Mockolate.Setup.IIndexerSetup - { - /// - /// Initializes the indexer according to the given . - /// - global::Mockolate.Setup.IIndexerSetup InitializeWith(global::System.Func valueGenerator); - - /// - /// Registers a to setup the return value for this indexer. - /// - /// - /// The callback receives the parameters of the indexer. - /// - IIndexerSetupReturnBuilder Returns(global::System.Func callback); - - /// - /// Registers a to setup the return value for this indexer. - /// - /// - /// The callback receives the parameters of the indexer and the value of the indexer as last parameter. - /// - IIndexerSetupReturnBuilder Returns(global::System.Func callback); - - /// - /// Registers a that will calculate the exception to throw when the indexer is read. - /// - /// - /// The callback receives the parameters of the indexer. - /// - IIndexerSetupReturnBuilder Throws(global::System.Func callback); - - /// - /// Registers a that will calculate the exception to throw when the indexer is read. - /// - /// - /// The callback receives the parameters of the indexer and the value of the indexer as last parameter. - /// - IIndexerSetupReturnBuilder Throws(global::System.Func callback); - } - - /// - /// Sets up a getter callback for a indexer for , , , and . - /// - internal interface IIndexerGetterSetupCallbackBuilder : IIndexerGetterSetupParallelCallbackBuilder - { - /// - /// Runs the callback in parallel to the other callbacks. - /// - IIndexerGetterSetupParallelCallbackBuilder InParallel(); - } - - /// - /// Sets up a parallel getter callback for a indexer for , , , and . - /// - internal interface IIndexerGetterSetupParallelCallbackBuilder : IIndexerGetterSetupCallbackWhenBuilder - { - /// - /// Limits the callback to only execute for indexer accesses where the predicate returns true. - /// - /// - /// Provides a zero-based counter indicating how many times the indexer has been accessed so far. - /// - IIndexerGetterSetupCallbackWhenBuilder When(global::System.Func predicate); - } - - /// - /// Sets up a when getter callback for a indexer for , , , and . - /// - internal interface IIndexerGetterSetupCallbackWhenBuilder : global::Mockolate.Setup.IIndexerSetupWithCallback - { - /// - /// Repeats the callback for the given number of . - /// - /// - /// The number of times is only counted for actual executions (IIndexerGetterSetupParallelCallbackBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). - /// - IIndexerGetterSetupCallbackWhenBuilder For(int times); - - /// - /// Deactivates the callback after the given number of . - /// - /// - /// The number of times is only counted for actual executions (IIndexerGetterSetupParallelCallbackBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IIndexerSetup Only(int times); - } - - /// - /// Sets up a setter callback for a indexer for , , , and . - /// - internal interface IIndexerSetterSetupCallbackBuilder : IIndexerSetterSetupParallelCallbackBuilder - { - /// - /// Runs the callback in parallel to the other callbacks. - /// - IIndexerSetterSetupParallelCallbackBuilder InParallel(); - } - - /// - /// Sets up a parallel setter callback for a indexer for , , , and . - /// - internal interface IIndexerSetterSetupParallelCallbackBuilder : IIndexerSetterSetupCallbackWhenBuilder - { - /// - /// Limits the callback to only execute for indexer accesses where the predicate returns true. - /// - /// - /// Provides a zero-based counter indicating how many times the indexer has been accessed so far. - /// - IIndexerSetterSetupCallbackWhenBuilder When(global::System.Func predicate); - } - - /// - /// Sets up a when setter callback for a indexer for , , , and . - /// - internal interface IIndexerSetterSetupCallbackWhenBuilder : global::Mockolate.Setup.IIndexerSetupWithCallback - { - /// - /// Repeats the callback for the given number of . - /// - /// - /// The number of times is only counted for actual executions (IIndexerSetterSetupParallelCallbackBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). - /// - IIndexerSetterSetupCallbackWhenBuilder For(int times); - - /// - /// Deactivates the callback after the given number of . - /// - /// - /// The number of times is only counted for actual executions (IIndexerSetterSetupParallelCallbackBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IIndexerSetup Only(int times); - } - - /// - /// Sets up a return/throw callback for a indexer for , , , and . - /// - internal interface IIndexerSetupReturnBuilder : IIndexerSetupReturnWhenBuilder - { - /// - /// Limits the return/throw callback to only execute for indexer accesses where the predicate returns true. - /// - /// - /// Provides a zero-based counter indicating how many times the indexer has been accessed so far. - /// - IIndexerSetupReturnWhenBuilder When(global::System.Func predicate); - } - - /// - /// Sets up a when return/throw callback for a indexer for , , , and . - /// - internal interface IIndexerSetupReturnWhenBuilder : global::Mockolate.Setup.IIndexerSetupWithCallback - { - /// - /// Repeats the return/throw callback for the given number of . - /// - /// - /// The number of times is only counted for actual executions (IIndexerSetupReturnBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). - /// - IIndexerSetupReturnWhenBuilder For(int times); - - /// - /// Deactivates the return/throw after the given number of . - /// - /// - /// The number of times is only counted for actual executions (IIndexerSetupReturnBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IIndexerSetup Only(int times); - } - - /// - /// Sets up a indexer for , , , and . - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal class IndexerSetup(global::Mockolate.MockRegistry mockRegistry, global::Mockolate.Parameters.IParameterMatch parameter1, global::Mockolate.Parameters.IParameterMatch parameter2, global::Mockolate.Parameters.IParameterMatch parameter3, global::Mockolate.Parameters.IParameterMatch parameter4, global::Mockolate.Parameters.IParameterMatch parameter5) : global::Mockolate.Setup.IndexerSetup(mockRegistry), - global::Mockolate.Setup.IIndexerSetupWithCallback, - global::Mockolate.Setup.IIndexerGetterSetupCallbackBuilder, - global::Mockolate.Setup.IIndexerSetterSetupCallbackBuilder, - global::Mockolate.Setup.IIndexerSetupReturnBuilder, - global::Mockolate.Setup.IIndexerGetterSetupWithCallback, - global::Mockolate.Setup.IIndexerSetterSetupWithCallback, - global::Mockolate.Setup.IIndexerGetterOnlySetup, - global::Mockolate.Setup.IIndexerGetterOnlyGetterSetup, - global::Mockolate.Setup.IIndexerGetterOnlySetupCallbackBuilder, - global::Mockolate.Setup.IIndexerGetterOnlySetupReturnBuilder, - global::Mockolate.Setup.IIndexerSetterOnlySetup, - global::Mockolate.Setup.IIndexerSetterOnlySetterSetup, - global::Mockolate.Setup.IIndexerSetterOnlySetupCallbackBuilder - { - private Callbacks>? _getterCallbacks; - private Callbacks>? _setterCallbacks; - private Callbacks>? _returnCallbacks; - private bool? _skipBaseClass; - private global::System.Func? _initialization; - - /// - public global::Mockolate.Setup.IIndexerSetup SkippingBaseClass(bool skipBaseClass = true) - { - _skipBaseClass = skipBaseClass; - return this; - } - - /// - public global::Mockolate.Setup.IIndexerSetupWithCallback InitializeWith(TValue value) - { - if (_initialization is not null) - { - throw new global::Mockolate.Exceptions.MockException("The indexer is already initialized. You cannot initialize it twice."); - } - - _initialization = (_, _, _, _, _) => value; - return this; - } - - global::Mockolate.Setup.IIndexerSetup global::Mockolate.Setup.IIndexerSetup.InitializeWith(TValue value) - => InitializeWith(value); - - /// - public global::Mockolate.Setup.IIndexerSetup InitializeWith(global::System.Func valueGenerator) - { - if (_initialization is not null) - { - throw new global::Mockolate.Exceptions.MockException("The indexer is already initialized. You cannot initialize it twice."); - } - - _initialization = valueGenerator; - return this; - } - - /// - public IIndexerGetterSetupWithCallback OnGet - => this; - - /// - IIndexerGetterSetupCallbackBuilder IIndexerGetterSetup.Do(global::System.Action callback) - { - Callback>? currentCallback = new((_, _, _, _, _, _, _) => callback()); - _getterCallbacks = _getterCallbacks.Register(currentCallback); - return this; - } - - /// - IIndexerGetterSetupCallbackBuilder IIndexerGetterSetupWithCallback.Do(global::System.Action callback) - { - Callback>? currentCallback = new((_, p1, p2, p3, p4, p5, _) => callback(p1, p2, p3, p4, p5)); - _getterCallbacks = _getterCallbacks.Register(currentCallback); - return this; - } - - /// - IIndexerGetterSetupCallbackBuilder IIndexerGetterSetupWithCallback.Do(global::System.Action callback) - { - Callback>? currentCallback = new((_, p1, p2, p3, p4, p5, v) => callback(p1, p2, p3, p4, p5, v)); - _getterCallbacks = _getterCallbacks.Register(currentCallback); - return this; - } - - /// - IIndexerGetterSetupCallbackBuilder IIndexerGetterSetupWithCallback.Do(global::System.Action callback) - { - Callback>? currentCallback = new(callback); - _getterCallbacks = _getterCallbacks.Register(currentCallback); - return this; - } - - IIndexerGetterSetupParallelCallbackBuilder IIndexerGetterSetup.TransitionTo(string scenario) - { - Callback>? currentCallback = new((_, _, _, _, _, _, _) => TransitionScenario(scenario)); - currentCallback.InParallel(); - _getterCallbacks = _getterCallbacks.Register(currentCallback); - return this; - } - - /// - public IIndexerSetterSetupWithCallback OnSet - => this; - - /// - IIndexerSetterSetupCallbackBuilder IIndexerSetterSetup.Do(global::System.Action callback) - { - Callback>? currentCallback = new((_, _, _, _, _, _, _) => callback()); - _setterCallbacks = _setterCallbacks.Register(currentCallback); - return this; - } - - /// - IIndexerSetterSetupCallbackBuilder IIndexerSetterSetup.Do(global::System.Action callback) - { - Callback>? currentCallback = new((_, _, _, _, _, _, v) => callback(v)); - _setterCallbacks = _setterCallbacks.Register(currentCallback); - return this; - } - - /// - IIndexerSetterSetupCallbackBuilder IIndexerSetterSetupWithCallback.Do(global::System.Action callback) - { - Callback>? currentCallback = new((_, p1, p2, p3, p4, p5, v) => callback(p1, p2, p3, p4, p5, v)); - _setterCallbacks = _setterCallbacks.Register(currentCallback); - return this; - } - - /// - IIndexerSetterSetupCallbackBuilder IIndexerSetterSetupWithCallback.Do(global::System.Action callback) - { - Callback>? currentCallback = new(callback); - _setterCallbacks = _setterCallbacks.Register(currentCallback); - return this; - } - - IIndexerSetterSetupParallelCallbackBuilder IIndexerSetterSetup.TransitionTo(string scenario) - { - Callback>? currentCallback = new((_, _, _, _, _, _, _) => TransitionScenario(scenario)); - currentCallback.InParallel(); - _setterCallbacks = _setterCallbacks.Register(currentCallback); - return this; - } - - /// - public IIndexerSetupReturnBuilder Returns(TValue returnValue) - { - var currentCallback = new Callback>((_, _, _, _, _, _, _) => returnValue); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - public IIndexerSetupReturnBuilder Returns(global::System.Func callback) - { - var currentCallback = new Callback>((_, _, _, _, _, _, _) => callback()); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - public IIndexerSetupReturnBuilder Returns(global::System.Func callback) - { - var currentCallback = new Callback>((_, p1, p2, p3, p4, p5, _) => callback(p1, p2, p3, p4, p5)); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - public IIndexerSetupReturnBuilder Returns(global::System.Func callback) - { - var currentCallback = new Callback>((_, v, p1, p2, p3, p4, p5) => callback(v, p1, p2, p3, p4, p5)); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - public IIndexerSetupReturnBuilder Throws() - where TException : global::System.Exception, new() - { - var currentCallback = new Callback>((_, _, _, _, _, _, _) => throw new TException()); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - public IIndexerSetupReturnBuilder Throws(global::System.Exception exception) - { - var currentCallback = new Callback>((_, _, _, _, _, _, _) => throw exception); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - public IIndexerSetupReturnBuilder Throws(global::System.Func callback) - { - var currentCallback = new Callback>((_, _, _, _, _, _, _) => throw callback()); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - public IIndexerSetupReturnBuilder Throws(global::System.Func callback) - { - var currentCallback = new Callback>((_, p1, p2, p3, p4, p5, _) => throw callback(p1, p2, p3, p4, p5)); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - public IIndexerSetupReturnBuilder Throws(global::System.Func callback) - { - var currentCallback = new Callback>((_, p1, p2, p3, p4, p5, v) => throw callback(p1, p2, p3, p4, p5, v)); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - IIndexerGetterSetupCallbackWhenBuilder IIndexerGetterSetupParallelCallbackBuilder.When(global::System.Func predicate) - { - _getterCallbacks?.Active?.When(predicate); - return this; - } - - /// - IIndexerGetterSetupParallelCallbackBuilder IIndexerGetterSetupCallbackBuilder.InParallel() - { - _getterCallbacks?.Active?.InParallel(); - return this; - } - - /// - IIndexerGetterSetupCallbackWhenBuilder IIndexerGetterSetupCallbackWhenBuilder.For(int times) - { - _getterCallbacks?.Active?.For(times); - return this; - } - - /// - global::Mockolate.Setup.IIndexerSetup IIndexerGetterSetupCallbackWhenBuilder.Only(int times) - { - _getterCallbacks?.Active?.Only(times); - return this; - } - - /// - IIndexerSetterSetupCallbackWhenBuilder IIndexerSetterSetupParallelCallbackBuilder.When(global::System.Func predicate) - { - _setterCallbacks?.Active?.When(predicate); - return this; - } - - /// - IIndexerSetterSetupParallelCallbackBuilder IIndexerSetterSetupCallbackBuilder.InParallel() - { - _setterCallbacks?.Active?.InParallel(); - return this; - } - - /// - IIndexerSetterSetupCallbackWhenBuilder IIndexerSetterSetupCallbackWhenBuilder.For(int times) - { - _setterCallbacks?.Active?.For(times); - return this; - } - - /// - global::Mockolate.Setup.IIndexerSetup IIndexerSetterSetupCallbackWhenBuilder.Only(int times) - { - _setterCallbacks?.Active?.Only(times); - return this; - } - - /// - IIndexerSetupReturnWhenBuilder IIndexerSetupReturnBuilder.When(global::System.Func predicate) - { - _returnCallbacks?.Active?.When(predicate); - return this; - } - - /// - IIndexerSetupReturnWhenBuilder IIndexerSetupReturnWhenBuilder.For(int times) - { - _returnCallbacks?.Active?.For(times); - return this; - } - - /// - global::Mockolate.Setup.IIndexerSetup IIndexerSetupReturnWhenBuilder.Only(int times) - { - _returnCallbacks?.Active?.Only(times); - return this; - } - - /// - /// Check if the setup matches the specified parameter values. - /// - public virtual bool Matches(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5) - { - if (!parameter1.Matches(p1) || !parameter2.Matches(p2) || !parameter3.Matches(p3) || !parameter4.Matches(p4) || !parameter5.Matches(p5)) - { - return false; - } - - parameter1.InvokeCallbacks(p1); - parameter2.InvokeCallbacks(p2); - parameter3.InvokeCallbacks(p3); - parameter4.InvokeCallbacks(p4); - parameter5.InvokeCallbacks(p5); - return true; - } - - /// - /// Check if the setup matches the specified parameter values. - /// - public virtual bool Matches(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, TValue value) - => Matches(p1, p2, p3, p4, p5); - - /// - protected override bool MatchesAccess(global::Mockolate.Interactions.IndexerAccess access) - { - if (access is global::Mockolate.Interactions.IndexerGetterAccess getter) - { - return Matches(getter.Parameter1, getter.Parameter2, getter.Parameter3, getter.Parameter4, getter.Parameter5); - } - - if (access is global::Mockolate.Interactions.IndexerSetterAccess setter) - { - return Matches(setter.Parameter1, setter.Parameter2, setter.Parameter3, setter.Parameter4, setter.Parameter5, setter.TypedValue); - } - - return false; - } - - /// - public override bool? SkipBaseClass() - => _skipBaseClass; - - /// - public override TResult GetResult(global::Mockolate.Interactions.IndexerAccess access, global::Mockolate.MockBehavior behavior, TResult baseValue) - { - if (!TryExtractParameters(access, out T1 p1, out T2 p2, out T3 p3, out T4 p4, out T5 p5)) - { - return baseValue; - } - - TValue currentValue = TryCast(baseValue, out TValue casted, behavior) ? casted : default!; - currentValue = ExecuteGetterCallbacks(p1, p2, p3, p4, p5, currentValue); - currentValue = ExecuteReturnCallbacks(p1, p2, p3, p4, p5, currentValue); - access.StoreValue(currentValue); - return TryCast(currentValue, out TResult result, behavior) ? result : baseValue; - } - - /// - public override TResult GetResult(global::Mockolate.Interactions.IndexerAccess access, global::Mockolate.MockBehavior behavior) - { - if (!TryExtractParameters(access, out T1 p1, out T2 p2, out T3 p3, out T4 p4, out T5 p5)) - { - return behavior.DefaultValue.Generate(default(TResult)!); - } - - TValue currentValue; - if (access.TryFindStoredValue(out TValue existing)) - { - currentValue = existing; - } - else if (_initialization is not null) - { - currentValue = _initialization.Invoke(p1, p2, p3, p4, p5); - } - else - { - currentValue = TryCast(behavior.DefaultValue.Generate(default(TValue)!), out TValue casted, behavior) ? casted : default!; - } - - currentValue = ExecuteGetterCallbacks(p1, p2, p3, p4, p5, currentValue); - currentValue = ExecuteReturnCallbacks(p1, p2, p3, p4, p5, currentValue); - access.StoreValue(currentValue); - return TryCast(currentValue, out TResult result, behavior) ? result : behavior.DefaultValue.Generate(default(TResult)!); - } - - /// - public override TResult GetResult(global::Mockolate.Interactions.IndexerAccess access, global::Mockolate.MockBehavior behavior, global::System.Func defaultValueGenerator) - { - if (!TryExtractParameters(access, out T1 p1, out T2 p2, out T3 p3, out T4 p4, out T5 p5)) - { - return defaultValueGenerator(); - } - - TValue currentValue; - if (access.TryFindStoredValue(out TValue existing)) - { - currentValue = existing; - } - else if (_initialization is not null) - { - currentValue = _initialization.Invoke(p1, p2, p3, p4, p5); - } - else - { - currentValue = TryCast(defaultValueGenerator(), out TValue casted, behavior) ? casted : default!; - } - - currentValue = ExecuteGetterCallbacks(p1, p2, p3, p4, p5, currentValue); - currentValue = ExecuteReturnCallbacks(p1, p2, p3, p4, p5, currentValue); - access.StoreValue(currentValue); - return TryCast(currentValue, out TResult result, behavior) ? result : defaultValueGenerator(); - } - - /// - public override void SetResult(global::Mockolate.Interactions.IndexerAccess access, global::Mockolate.MockBehavior behavior, TResult value) - { - access.StoreValue(value); - if (!TryExtractParameters(access, out T1 p1, out T2 p2, out T3 p3, out T4 p4, out T5 p5)) - { - return; - } - - if (!TryCast(value, out TValue resultValue, behavior)) - { - return; - } - - if (_setterCallbacks is not null) - { - bool wasInvoked = false; - int currentSetterCallbacksIndex = _setterCallbacks.CurrentIndex; - for (int i = 0; i < _setterCallbacks.Count; i++) - { - Callback> setterCallback = - _setterCallbacks[(currentSetterCallbacksIndex + i) % _setterCallbacks.Count]; - if (setterCallback.Invoke(wasInvoked, ref _setterCallbacks.CurrentIndex, (p1, p2, p3, p4, p5, resultValue), - static (count, @delegate, state) => @delegate(count, state.p1, state.p2, state.p3, state.p4, state.p5, state.resultValue))) - { - wasInvoked = true; - } - } - } - } - - private TValue ExecuteGetterCallbacks(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, TValue currentValue) - { - if (_getterCallbacks is not null) - { - bool wasInvoked = false; - int currentGetterCallbacksIndex = _getterCallbacks.CurrentIndex; - for (int i = 0; i < _getterCallbacks.Count; i++) - { - Callback> getterCallback = - _getterCallbacks[(currentGetterCallbacksIndex + i) % _getterCallbacks.Count]; - if (getterCallback.Invoke(wasInvoked, ref _getterCallbacks.CurrentIndex, (p1, p2, p3, p4, p5, currentValue), - static (count, @delegate, state) => @delegate(count, state.p1, state.p2, state.p3, state.p4, state.p5, state.currentValue))) - { - wasInvoked = true; - } - } - } - - return currentValue; - } - - private TValue ExecuteReturnCallbacks(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, TValue currentValue) - { - if (_returnCallbacks is not null) - { - foreach (Callback> _ in _returnCallbacks) - { - Callback> returnCallback = - _returnCallbacks[_returnCallbacks.CurrentIndex % _returnCallbacks.Count]; - if (returnCallback.Invoke(ref _returnCallbacks.CurrentIndex, (p1, p2, p3, p4, p5, currentValue), - static (count, @delegate, state) => @delegate(count, state.p1, state.p2, state.p3, state.p4, state.p5, state.currentValue), - out TValue? newValue)) - { - return newValue!; - } - } - } - - return currentValue; - } - - private static bool TryExtractParameters(global::Mockolate.Interactions.IndexerAccess access, out T1 p1, out T2 p2, out T3 p3, out T4 p4, out T5 p5) - { - if (access is global::Mockolate.Interactions.IndexerGetterAccess getter) - { - p1 = getter.Parameter1; - p2 = getter.Parameter2; - p3 = getter.Parameter3; - p4 = getter.Parameter4; - p5 = getter.Parameter5; - return true; - } - - if (access is global::Mockolate.Interactions.IndexerSetterAccess setter) - { - p1 = setter.Parameter1; - p2 = setter.Parameter2; - p3 = setter.Parameter3; - p4 = setter.Parameter4; - p5 = setter.Parameter5; - return true; - } - - p1 = default!; - p2 = default!; - p3 = default!; - p4 = default!; - p5 = default!; - return false; - } - - /// - public override string ToString() - => $"{FormatType(typeof(TValue))} this[{parameter1}, {parameter2}, {parameter3}, {parameter4}, {parameter5}]"; - - /// - IIndexerGetterOnlySetup IIndexerGetterOnlySetup.SkippingBaseClass(bool skipBaseClass) - { - SkippingBaseClass(skipBaseClass); - return this; - } - - /// - IIndexerGetterOnlySetup IIndexerGetterOnlySetup.InitializeWith(TValue value) - { - InitializeWith(value); - return this; - } - - /// - IIndexerGetterOnlySetup IIndexerGetterOnlySetup.InitializeWith(global::System.Func valueGenerator) - { - InitializeWith(valueGenerator); - return this; - } - - /// - IIndexerGetterOnlyGetterSetup IIndexerGetterOnlySetup.OnGet - => this; - - /// - IIndexerGetterOnlySetupCallbackBuilder IIndexerGetterOnlyGetterSetup.Do(global::System.Action callback) - { - ((IIndexerGetterSetup)this).Do(callback); - return this; - } - - /// - IIndexerGetterOnlySetupCallbackBuilder IIndexerGetterOnlyGetterSetup.Do(global::System.Action callback) - { - ((IIndexerGetterSetupWithCallback)this).Do(callback); - return this; - } - - /// - IIndexerGetterOnlySetupCallbackBuilder IIndexerGetterOnlyGetterSetup.Do(global::System.Action callback) - { - ((IIndexerGetterSetupWithCallback)this).Do(callback); - return this; - } - - /// - IIndexerGetterOnlySetupCallbackBuilder IIndexerGetterOnlyGetterSetup.Do(global::System.Action callback) - { - ((IIndexerGetterSetupWithCallback)this).Do(callback); - return this; - } - - /// - IIndexerGetterOnlySetupParallelCallbackBuilder IIndexerGetterOnlyGetterSetup.TransitionTo(string scenario) - { - ((IIndexerGetterSetup)this).TransitionTo(scenario); - return this; - } - - /// - IIndexerGetterOnlySetupParallelCallbackBuilder IIndexerGetterOnlySetupCallbackBuilder.InParallel() - { - ((IIndexerGetterSetupCallbackBuilder)this).InParallel(); - return this; - } - - /// - IIndexerGetterOnlySetupCallbackWhenBuilder IIndexerGetterOnlySetupParallelCallbackBuilder.When(global::System.Func predicate) - { - ((IIndexerGetterSetupParallelCallbackBuilder)this).When(predicate); - return this; - } - - /// - IIndexerGetterOnlySetupCallbackWhenBuilder IIndexerGetterOnlySetupCallbackWhenBuilder.For(int times) - { - ((IIndexerGetterSetupCallbackWhenBuilder)this).For(times); - return this; - } - - /// - IIndexerGetterOnlySetup IIndexerGetterOnlySetupCallbackWhenBuilder.Only(int times) - { - ((IIndexerGetterSetupCallbackWhenBuilder)this).Only(times); - return this; - } - - /// - IIndexerGetterOnlySetupReturnBuilder IIndexerGetterOnlySetup.Returns(TValue returnValue) - { - Returns(returnValue); - return this; - } - - /// - IIndexerGetterOnlySetupReturnBuilder IIndexerGetterOnlySetup.Returns(global::System.Func callback) - { - Returns(callback); - return this; - } - - /// - IIndexerGetterOnlySetupReturnBuilder IIndexerGetterOnlySetup.Returns(global::System.Func callback) - { - Returns(callback); - return this; - } - - /// - IIndexerGetterOnlySetupReturnBuilder IIndexerGetterOnlySetup.Returns(global::System.Func callback) - { - Returns(callback); - return this; - } - - /// - IIndexerGetterOnlySetupReturnBuilder IIndexerGetterOnlySetup.Throws() - { - Throws(); - return this; - } - - /// - IIndexerGetterOnlySetupReturnBuilder IIndexerGetterOnlySetup.Throws(global::System.Exception exception) - { - Throws(exception); - return this; - } - - /// - IIndexerGetterOnlySetupReturnBuilder IIndexerGetterOnlySetup.Throws(global::System.Func callback) - { - Throws(callback); - return this; - } - - /// - IIndexerGetterOnlySetupReturnBuilder IIndexerGetterOnlySetup.Throws(global::System.Func callback) - { - Throws(callback); - return this; - } - - /// - IIndexerGetterOnlySetupReturnBuilder IIndexerGetterOnlySetup.Throws(global::System.Func callback) - { - Throws(callback); - return this; - } - - /// - IIndexerGetterOnlySetupReturnWhenBuilder IIndexerGetterOnlySetupReturnBuilder.When(global::System.Func predicate) - { - ((IIndexerSetupReturnBuilder)this).When(predicate); - return this; - } - - /// - IIndexerGetterOnlySetupReturnWhenBuilder IIndexerGetterOnlySetupReturnWhenBuilder.For(int times) - { - ((IIndexerSetupReturnWhenBuilder)this).For(times); - return this; - } - - /// - IIndexerGetterOnlySetup IIndexerGetterOnlySetupReturnWhenBuilder.Only(int times) - { - ((IIndexerSetupReturnWhenBuilder)this).Only(times); - return this; - } - - /// - IIndexerSetterOnlySetup IIndexerSetterOnlySetup.SkippingBaseClass(bool skipBaseClass) - { - SkippingBaseClass(skipBaseClass); - return this; - } - - /// - IIndexerSetterOnlySetterSetup IIndexerSetterOnlySetup.OnSet - => this; - - /// - IIndexerSetterOnlySetupCallbackBuilder IIndexerSetterOnlySetterSetup.Do(global::System.Action callback) - { - ((IIndexerSetterSetup)this).Do(callback); - return this; - } - - /// - IIndexerSetterOnlySetupCallbackBuilder IIndexerSetterOnlySetterSetup.Do(global::System.Action callback) - { - ((IIndexerSetterSetup)this).Do(callback); - return this; - } - - /// - IIndexerSetterOnlySetupCallbackBuilder IIndexerSetterOnlySetterSetup.Do(global::System.Action callback) - { - ((IIndexerSetterSetupWithCallback)this).Do(callback); - return this; - } - - /// - IIndexerSetterOnlySetupCallbackBuilder IIndexerSetterOnlySetterSetup.Do(global::System.Action callback) - { - ((IIndexerSetterSetupWithCallback)this).Do(callback); - return this; - } - - /// - IIndexerSetterOnlySetupParallelCallbackBuilder IIndexerSetterOnlySetterSetup.TransitionTo(string scenario) - { - ((IIndexerSetterSetup)this).TransitionTo(scenario); - return this; - } - - /// - IIndexerSetterOnlySetupParallelCallbackBuilder IIndexerSetterOnlySetupCallbackBuilder.InParallel() - { - ((IIndexerSetterSetupCallbackBuilder)this).InParallel(); - return this; - } - - /// - IIndexerSetterOnlySetupCallbackWhenBuilder IIndexerSetterOnlySetupParallelCallbackBuilder.When(global::System.Func predicate) - { - ((IIndexerSetterSetupParallelCallbackBuilder)this).When(predicate); - return this; - } - - /// - IIndexerSetterOnlySetupCallbackWhenBuilder IIndexerSetterOnlySetupCallbackWhenBuilder.For(int times) - { - ((IIndexerSetterSetupCallbackWhenBuilder)this).For(times); - return this; - } - - /// - IIndexerSetterOnlySetup IIndexerSetterOnlySetupCallbackWhenBuilder.Only(int times) - { - ((IIndexerSetterSetupCallbackWhenBuilder)this).Only(times); - return this; - } - - } - - /// - /// Setup for a mocked indexer for , , , and that the mock only reads. - /// - /// - /// Used instead of IIndexerSetup<TValue, T1, T2, T3, T4, T5> when the mock has no setter to intercept, either - /// because the indexer is declared without one or because its setter is not accessible from the mock's assembly. - /// Writes then never reach the mock, so IIndexerSetup<TValue, T1, T2, T3, T4, T5>.OnSet is not offered. - /// - internal interface IIndexerGetterOnlySetup - { - /// - IIndexerGetterOnlyGetterSetup OnGet { get; } - - /// - IIndexerGetterOnlySetup SkippingBaseClass(bool skipBaseClass = true); - - /// - /// - /// Seeds the value that reads return. Unlike a read-write indexer there is no setter to update the - /// slot afterwards, so it stays at unless a Returns entry applies. - /// - IIndexerGetterOnlySetup InitializeWith(TValue value); - - /// - IIndexerGetterOnlySetup InitializeWith(global::System.Func valueGenerator); - - /// - IIndexerGetterOnlySetupReturnBuilder Returns(TValue returnValue); - - /// - IIndexerGetterOnlySetupReturnBuilder Returns(global::System.Func callback); - - /// - IIndexerGetterOnlySetupReturnBuilder Returns(global::System.Func callback); - - /// - IIndexerGetterOnlySetupReturnBuilder Returns(global::System.Func callback); - - /// - IIndexerGetterOnlySetupReturnBuilder Throws() - where TException : global::System.Exception, new(); - - /// - IIndexerGetterOnlySetupReturnBuilder Throws(global::System.Exception exception); - - /// - IIndexerGetterOnlySetupReturnBuilder Throws(global::System.Func callback); - - /// - IIndexerGetterOnlySetupReturnBuilder Throws(global::System.Func callback); - - /// - IIndexerGetterOnlySetupReturnBuilder Throws(global::System.Func callback); - } - - /// - /// Setup for attaching side-effects to the getter of a get-only indexer for , , , and . - /// - /// - /// The counterpart of IIndexerGetterSetupWithCallback<TValue, T1, T2, T3, T4, T5> for - /// IIndexerGetterOnlySetup<TValue, T1, T2, T3, T4, T5>: the returned builders stay on the getter-only surface, - /// so chaining can never reach IIndexerSetup<TValue, T1, T2, T3, T4, T5>.OnSet. - /// - internal interface IIndexerGetterOnlyGetterSetup - { - /// - IIndexerGetterOnlySetupCallbackBuilder Do(global::System.Action callback); - - /// - IIndexerGetterOnlySetupCallbackBuilder Do(global::System.Action callback); - - /// - IIndexerGetterOnlySetupCallbackBuilder Do(global::System.Action callback); - - /// - IIndexerGetterOnlySetupCallbackBuilder Do(global::System.Action callback); - - /// - IIndexerGetterOnlySetupParallelCallbackBuilder TransitionTo(string scenario); - } - - /// - /// Sets up a callback for a get-only indexer for , , , and . - /// - internal interface IIndexerGetterOnlySetupCallbackBuilder - : IIndexerGetterOnlySetupParallelCallbackBuilder - { - /// - IIndexerGetterOnlySetupParallelCallbackBuilder InParallel(); - } - - /// - /// Sets up a parallel callback for a get-only indexer for , , , and . - /// - internal interface IIndexerGetterOnlySetupParallelCallbackBuilder - : IIndexerGetterOnlySetupCallbackWhenBuilder - { - /// - IIndexerGetterOnlySetupCallbackWhenBuilder When(global::System.Func predicate); - } - - /// - /// Sets up a when callback for a get-only indexer for , , , and . - /// - internal interface IIndexerGetterOnlySetupCallbackWhenBuilder - : IIndexerGetterOnlySetup - { - /// - IIndexerGetterOnlySetupCallbackWhenBuilder For(int times); - - /// - IIndexerGetterOnlySetup Only(int times); - } - - /// - /// Sets up a return/throw builder for a get-only indexer for , , , and . - /// - internal interface IIndexerGetterOnlySetupReturnBuilder - : IIndexerGetterOnlySetupReturnWhenBuilder - { - /// - IIndexerGetterOnlySetupReturnWhenBuilder When(global::System.Func predicate); - } - - /// - /// Sets up a when builder for returns/throws for a get-only indexer for , , , and . - /// - internal interface IIndexerGetterOnlySetupReturnWhenBuilder - : IIndexerGetterOnlySetup - { - /// - IIndexerGetterOnlySetupReturnWhenBuilder For(int times); - - /// - IIndexerGetterOnlySetup Only(int times); - } - - /// - /// Setup for a mocked indexer for , , , and that the mock only writes. - /// - /// - /// The write-only counterpart of IIndexerGetterOnlySetup<TValue, T1, T2, T3, T4, T5>: the mock has no getter to - /// intercept, so IIndexerSetup<TValue, T1, T2, T3, T4, T5>.OnGet, InitializeWith and the - /// Returns/Throws read-sequence are not offered. - /// - internal interface IIndexerSetterOnlySetup - { - /// - IIndexerSetterOnlySetterSetup OnSet { get; } - - /// - IIndexerSetterOnlySetup SkippingBaseClass(bool skipBaseClass = true); - } - - /// - /// Setup for attaching side-effects to the setter of a set-only indexer for , , , and . - /// - /// - /// The counterpart of IIndexerSetterSetupWithCallback<TValue, T1, T2, T3, T4, T5> for - /// IIndexerSetterOnlySetup<TValue, T1, T2, T3, T4, T5>: the returned builders stay on the setter-only surface, - /// so chaining can never reach IIndexerSetup<TValue, T1, T2, T3, T4, T5>.OnGet or the - /// Returns/Throws read-sequence. - /// - internal interface IIndexerSetterOnlySetterSetup - { - /// - IIndexerSetterOnlySetupCallbackBuilder Do(global::System.Action callback); - - /// - IIndexerSetterOnlySetupCallbackBuilder Do(global::System.Action callback); - - /// - IIndexerSetterOnlySetupCallbackBuilder Do(global::System.Action callback); - - /// - IIndexerSetterOnlySetupCallbackBuilder Do(global::System.Action callback); - - /// - IIndexerSetterOnlySetupParallelCallbackBuilder TransitionTo(string scenario); - } - - /// - /// Sets up a setter callback for a set-only indexer for , , , and . - /// - internal interface IIndexerSetterOnlySetupCallbackBuilder - : IIndexerSetterOnlySetupParallelCallbackBuilder - { - /// - IIndexerSetterOnlySetupParallelCallbackBuilder InParallel(); - } - - /// - /// Sets up a parallel setter callback for a set-only indexer for , , , and . - /// - internal interface IIndexerSetterOnlySetupParallelCallbackBuilder - : IIndexerSetterOnlySetupCallbackWhenBuilder - { - /// - IIndexerSetterOnlySetupCallbackWhenBuilder When(global::System.Func predicate); - } - - /// - /// Sets up a when setter callback for a set-only indexer for , , , and . - /// - internal interface IIndexerSetterOnlySetupCallbackWhenBuilder - : IIndexerSetterOnlySetup - { - /// - IIndexerSetterOnlySetupCallbackWhenBuilder For(int times); - - /// - IIndexerSetterOnlySetup Only(int times); - } - -} - -namespace Mockolate -{ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal static class IndexerSetupExtensions - { - - /// - /// Extensions for indexer getter callback setups with 5 parameters. - /// - extension(Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder setup) - { - /// - /// Executes the callback only once. - /// - public global::Mockolate.Setup.IIndexerSetup OnlyOnce() - => setup.Only(1); - } - - /// - /// Extensions for indexer setter callback setups with 5 parameters. - /// - extension(Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder setup) - { - /// - /// Executes the callback only once. - /// - public global::Mockolate.Setup.IIndexerSetup OnlyOnce() - => setup.Only(1); - } - - /// - /// Extensions for indexer setups with 5 parameters. - /// - extension(Mockolate.Setup.IIndexerSetupReturnWhenBuilder setup) - { - /// - /// Returns/throws forever. - /// - public void Forever() - { - setup.For(int.MaxValue); - } - - /// - /// Uses the return value only once. - /// - public global::Mockolate.Setup.IIndexerSetup OnlyOnce() - => setup.Only(1); - } - - /// - /// Extensions for setups of get-only indexers with 5 parameters. - /// - extension(Mockolate.Setup.IIndexerGetterOnlySetupReturnWhenBuilder setup) - { - /// - /// Returns/throws forever. - /// - public void Forever() - { - setup.For(int.MaxValue); - } - - /// - /// Uses the return value only once. - /// - public global::Mockolate.Setup.IIndexerGetterOnlySetup OnlyOnce() - => setup.Only(1); - } - - /// - /// Extensions for getter callback setups of get-only indexers with 5 parameters. - /// - extension(Mockolate.Setup.IIndexerGetterOnlySetupCallbackWhenBuilder setup) - { - /// - /// Executes the callback only once. - /// - public global::Mockolate.Setup.IIndexerGetterOnlySetup OnlyOnce() - => setup.Only(1); - } - - /// - /// Extensions for setter callback setups of set-only indexers with 5 parameters. - /// - extension(Mockolate.Setup.IIndexerSetterOnlySetupCallbackWhenBuilder setup) - { - /// - /// Executes the callback only once. - /// - public global::Mockolate.Setup.IIndexerSetterOnlySetup OnlyOnce() - => setup.Only(1); - } - } -} -namespace Mockolate.Interactions -{ - /// - /// An access of an indexer getter with 5 typed parameters. - /// - [global::System.Diagnostics.DebuggerDisplay("{ToString()}")] - internal class IndexerGetterAccess(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5) - : global::Mockolate.Interactions.IndexerAccess - { - /// - /// The value of parameter 1. - /// - public T1 Parameter1 { get; } = parameter1; - /// - /// The value of parameter 2. - /// - public T2 Parameter2 { get; } = parameter2; - /// - /// The value of parameter 3. - /// - public T3 Parameter3 { get; } = parameter3; - /// - /// The value of parameter 4. - /// - public T4 Parameter4 { get; } = parameter4; - /// - /// The value of parameter 5. - /// - public T5 Parameter5 { get; } = parameter5; - /// - public override int ParameterCount => 5; - /// - public override object? GetParameterValueAt(int index) - => index switch - { - 0 => Parameter1, - 1 => Parameter2, - 2 => Parameter3, - 3 => Parameter4, - 4 => Parameter5, - _ => null, - }; - /// - protected override global::Mockolate.Setup.IndexerValueStorage? TraverseStorage(global::Mockolate.Setup.IndexerValueStorage? storage, bool createMissing) - { - global::Mockolate.Setup.IndexerValueStorage? s = storage; - if (s is null) - { - return null; - } - s = createMissing ? s.GetOrAddChildDispatch(Parameter1) : s.GetChildDispatch(Parameter1); - if (s is null) - { - return null; - } - s = createMissing ? s.GetOrAddChildDispatch(Parameter2) : s.GetChildDispatch(Parameter2); - if (s is null) - { - return null; - } - s = createMissing ? s.GetOrAddChildDispatch(Parameter3) : s.GetChildDispatch(Parameter3); - if (s is null) - { - return null; - } - s = createMissing ? s.GetOrAddChildDispatch(Parameter4) : s.GetChildDispatch(Parameter4); - if (s is null) - { - return null; - } - return createMissing ? s.GetOrAddChildDispatch(Parameter5) : s.GetChildDispatch(Parameter5); - } - /// - public override string ToString() - => $"get indexer [{Parameter1?.ToString() ?? "null"}, {Parameter2?.ToString() ?? "null"}, {Parameter3?.ToString() ?? "null"}, {Parameter4?.ToString() ?? "null"}, {Parameter5?.ToString() ?? "null"}]"; - } - /// - /// An access of an indexer setter with 5 typed parameters. - /// - [global::System.Diagnostics.DebuggerDisplay("{ToString()}")] - internal class IndexerSetterAccess(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, TValue value) - : global::Mockolate.Interactions.IndexerAccess - { - /// - /// The value of parameter 1. - /// - public T1 Parameter1 { get; } = parameter1; - /// - /// The value of parameter 2. - /// - public T2 Parameter2 { get; } = parameter2; - /// - /// The value of parameter 3. - /// - public T3 Parameter3 { get; } = parameter3; - /// - /// The value of parameter 4. - /// - public T4 Parameter4 { get; } = parameter4; - /// - /// The value of parameter 5. - /// - public T5 Parameter5 { get; } = parameter5; - /// - /// The typed value the indexer was being set to. - /// - public TValue TypedValue { get; } = value; - /// - public override int ParameterCount => 5; - /// - public override object? GetParameterValueAt(int index) - => index switch - { - 0 => Parameter1, - 1 => Parameter2, - 2 => Parameter3, - 3 => Parameter4, - 4 => Parameter5, - _ => null, - }; - /// - protected override global::Mockolate.Setup.IndexerValueStorage? TraverseStorage(global::Mockolate.Setup.IndexerValueStorage? storage, bool createMissing) - { - global::Mockolate.Setup.IndexerValueStorage? s = storage; - if (s is null) - { - return null; - } - s = createMissing ? s.GetOrAddChildDispatch(Parameter1) : s.GetChildDispatch(Parameter1); - if (s is null) - { - return null; - } - s = createMissing ? s.GetOrAddChildDispatch(Parameter2) : s.GetChildDispatch(Parameter2); - if (s is null) - { - return null; - } - s = createMissing ? s.GetOrAddChildDispatch(Parameter3) : s.GetChildDispatch(Parameter3); - if (s is null) - { - return null; - } - s = createMissing ? s.GetOrAddChildDispatch(Parameter4) : s.GetChildDispatch(Parameter4); - if (s is null) - { - return null; - } - return createMissing ? s.GetOrAddChildDispatch(Parameter5) : s.GetChildDispatch(Parameter5); - } - /// - public override string ToString() - => $"set indexer [{Parameter1?.ToString() ?? "null"}, {Parameter2?.ToString() ?? "null"}, {Parameter3?.ToString() ?? "null"}, {Parameter4?.ToString() ?? "null"}, {Parameter5?.ToString() ?? "null"}] to {TypedValue?.ToString() ?? "null"}"; - } -} - -namespace Mockolate.Verify -{ - /// - /// Verifications on a 5-key indexer for , , , and that the mock only reads. - /// - /// - /// Used instead of VerificationIndexerResult<TSubject, TParameter> when the - /// mock has no setter to intercept. Writes then never reach the mock, so offering Set(...) here would - /// always report zero interactions. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal class VerificationIndexerGetterResult( - TSubject subject, - global::Mockolate.MockRegistry mockRegistry, - int getMemberId, - global::System.Func gotPredicate, - global::System.Func parametersDescription) - { - /// - public global::Mockolate.Verify.VerificationResult Got() - => mockRegistry.IndexerGot(subject, getMemberId, gotPredicate, parametersDescription); - } - /// - /// Verifications on a 5-key indexer of type for , , , and that the mock only writes. - /// - /// - /// Used instead of VerificationIndexerResult<TSubject, TParameter> when the - /// mock has no getter to intercept, so Got() is not offered. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal class VerificationIndexerSetterResult( - TSubject subject, - global::Mockolate.MockRegistry mockRegistry, - int setMemberId, - global::System.Func, bool> setPredicate, - global::System.Func parametersDescription) - { - /// - public global::Mockolate.Verify.VerificationResult Set(global::Mockolate.Parameters.IParameter value) - => mockRegistry.IndexerSet(subject, setMemberId, setPredicate, - (global::Mockolate.Parameters.IParameterMatch)value, parametersDescription); - - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] - /// - /// Verifies the indexer write access on the mock with the given . - /// - public global::Mockolate.Verify.VerificationResult Set(TParameter value) - => mockRegistry.IndexerSet(subject, setMemberId, setPredicate, - (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(value), parametersDescription); - } -} - -#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/MethodSetups.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/MethodSetups.g.cs deleted file mode 100644 index e9e03399..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/MethodSetups.g.cs +++ /dev/null @@ -1,3557 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -#nullable enable - -namespace Mockolate.Setup -{ - /// - /// Sets up a method with 5 parameters , , , and returning . - /// - internal interface IReturnMethodSetup : global::Mockolate.Setup.IMethodSetup - { - /// - /// Overrides SkipBaseClass for this method only. - /// - /// - /// If not specified, use SkipBaseClass. - /// - global::Mockolate.Setup.IReturnMethodSetup SkippingBaseClass(bool skipBaseClass = true); - - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Transitions the scenario to the given when the method is called. - /// - global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder TransitionTo(string scenario); - - /// - /// Registers a to setup the return value for this method. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(global::System.Func callback); - - /// - /// Registers the for this method. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(TReturn returnValue); - - /// - /// Registers an to throw when the method is invoked. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws() - where TException : global::System.Exception, new(); - - /// - /// Registers an to throw when the method is invoked. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(global::System.Exception exception); - - /// - /// Registers a that will calculate the exception to throw when the method is invoked. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(global::System.Func callback); - } - - /// - /// Sets up a method with 5 parameters , , , and returning with callback support for the parameters. - /// - internal interface IReturnMethodSetupWithCallback : global::Mockolate.Setup.IReturnMethodSetup - { - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Registers a to setup the return value for this method. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(global::System.Func callback); - - /// - /// Registers a that will calculate the exception to throw when the method is invoked. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(global::System.Func callback); - } - - /// - /// Sets up a callback for a method with 5 parameters , , , and returning . - /// - internal interface IReturnMethodSetupCallbackBuilder : global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder - { - /// - /// Runs the callback in parallel to the other callbacks. - /// - global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder InParallel(); - } - - /// - /// Sets up a parallel callback for a method with 5 parameters , , , and returning . - /// - internal interface IReturnMethodSetupParallelCallbackBuilder : global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder - { - /// - /// Limits the callback to only execute for method invocations where the predicate returns true. - /// - /// - /// Provides a zero-based counter indicating how many times the method has been invoked so far. - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder When(global::System.Func predicate); - } - - /// - /// Sets up a when callback for a method with 5 parameters , , , and returning . - /// - internal interface IReturnMethodSetupCallbackWhenBuilder : global::Mockolate.Setup.IReturnMethodSetupWithCallback - { - /// - /// Repeats the callback for the given number of . - /// - /// - /// The number of times is only counted for actual executions (IReturnMethodSetupParallelCallbackBuilder<TReturn, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder For(int times); - - /// - /// Deactivates the callback after the given number of . - /// - /// - /// The number of times is only counted for actual executions (IReturnMethodSetupParallelCallbackBuilder<TReturn, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IReturnMethodSetup Only(int times); - } - - /// - /// Sets up a return callback for a method with 5 parameters , , , and returning . - /// - internal interface IReturnMethodSetupReturnBuilder : global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder - { - /// - /// Limits the return/throw to only execute for method invocations where the predicate returns true. - /// - /// - /// Provides a zero-based counter indicating how many times the method has been invoked so far. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder When(global::System.Func predicate); - } - - /// - /// Sets up a when return callback for a method with 5 parameters , , , and returning . - /// - internal interface IReturnMethodSetupReturnWhenBuilder : global::Mockolate.Setup.IReturnMethodSetupWithCallback - { - /// - /// Repeats the callback for the given number of . - /// - /// - /// The number of times is only counted for actual executions (IReturnMethodSetupReturnBuilder<TReturn, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder For(int times); - - /// - /// Deactivates the return/throw after the given number of . - /// - /// - /// The number of times is only counted for actual executions (IReturnMethodSetupReturnBuilder<TReturn, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IReturnMethodSetup Only(int times); - } - - /// - /// Allows ignoring the provided parameters. - /// - internal interface IReturnMethodSetupParameterIgnorer : global::Mockolate.Setup.IReturnMethodSetupWithCallback - { - /// - /// Replaces the explicit parameter matcher with AnyParameters(). - /// - global::Mockolate.Setup.IReturnMethodSetup AnyParameters(); - } - - /// - /// Sets up a method with 5 parameters , , , and returning . - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal abstract class ReturnMethodSetup : global::Mockolate.Setup.MethodSetup, - global::Mockolate.Setup.IReturnMethodSetupWithCallback, - global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder, - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder - { - private readonly global::Mockolate.MockRegistry _mockRegistry; - private global::Mockolate.Setup.Callbacks>? _callbacks = []; - private global::Mockolate.Setup.Callbacks>? _returnCallbacks = []; - private bool? _skipBaseClass; - - protected ReturnMethodSetup(global::Mockolate.MockRegistry mockRegistry, string name) - : base(name) - { - _mockRegistry = mockRegistry; - } - - /// - global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetup.SkippingBaseClass(bool skipBaseClass) - { - _skipBaseClass = skipBaseClass; - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder global::Mockolate.Setup.IReturnMethodSetup.Do(global::System.Action callback) - { - global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _) => callback()); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Do(global::System.Action callback) - { - global::Mockolate.Setup.Callback>? currentCallback = new((_, p1, p2, p3, p4, p5) => callback(p1, p2, p3, p4, p5)); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Do(global::System.Action callback) - { - global::Mockolate.Setup.Callback>? currentCallback = new(callback); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IReturnMethodSetup.TransitionTo(string scenario) - { - global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _) => _mockRegistry.TransitionTo(scenario)); - currentCallback.InParallel(); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Returns(global::System.Func callback) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, p1, p2, p3, p4, p5) => callback(p1, p2, p3, p4, p5)); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Returns(global::System.Func callback) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _) => callback()); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Returns(TReturn returnValue) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _) => returnValue); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Throws() - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _) => throw new TException()); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Throws(global::System.Exception exception) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _) => throw exception); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Throws(global::System.Func callback) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, p1, p2, p3, p4, p5) => throw callback(p1, p2, p3, p4, p5)); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Throws(global::System.Func callback) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _) => throw callback()); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder.InParallel() - { - _callbacks?.Active?.InParallel(); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder.When(global::System.Func predicate) - { - _callbacks?.Active?.When(predicate); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder.For(int times) - { - _callbacks?.Active?.For(times); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder.Only(int times) - { - _callbacks?.Active?.Only(times); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder global::Mockolate.Setup.IReturnMethodSetupReturnBuilder.When(global::System.Func predicate) - { - _returnCallbacks?.Active?.When(predicate); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder.For(int times) - { - _returnCallbacks?.Active?.For(times); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder.Only(int times) - { - _returnCallbacks?.Active?.Only(times); - return this; - } - - /// - protected override bool MatchesInteraction(global::Mockolate.Interactions.IMethodInteraction interaction) - { - if (interaction is global::Mockolate.Interactions.MethodInvocation invocation) - { - return Matches(invocation.Parameter1, invocation.Parameter2, invocation.Parameter3, invocation.Parameter4, invocation.Parameter5); - } - return false; - } - - /// - /// Flag indicating, if any return callbacks have been registered on this setup. - /// - public bool HasReturnCallbacks - => _returnCallbacks is { Count: > 0, }; - - /// - /// Gets the flag indicating if the base class implementation should be skipped. - /// - public bool SkipBaseClass(global::Mockolate.MockBehavior behavior) - => _skipBaseClass ?? behavior.SkipBaseClass; - - /// - /// Gets the registered return value. - /// - public bool TryGetReturnValue(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, out TReturn returnValue) - { - if (_returnCallbacks != null) - { - foreach (var _ in _returnCallbacks) - { - var returnCallback = _returnCallbacks[_returnCallbacks.CurrentIndex % _returnCallbacks.Count]; - if (returnCallback.Invoke(ref _returnCallbacks.CurrentIndex, (p1, p2, p3, p4, p5), - static (invocationCount, @delegate, state) => @delegate(invocationCount, state.p1, state.p2, state.p3, state.p4, state.p5), - out TReturn? newValue)) - { - returnValue = newValue; - return true; - } - } - } - returnValue = default!; - return false; - } - - /// - /// Checks if the given parameters match the setup. - /// - public abstract bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value); - - /// - /// Triggers any configured parameter callbacks for the method setup with the specified parameters. - /// - public virtual void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5) - { - if (_callbacks is not null) - { - bool wasInvoked = false; - int currentCallbacksIndex = _callbacks.CurrentIndex; - for (int i = 0; i < _callbacks.Count; i++) - { - var callback = _callbacks[(currentCallbacksIndex + i) % _callbacks.Count]; - if (callback.Invoke(wasInvoked, ref _callbacks.CurrentIndex, (parameter1, parameter2, parameter3, parameter4, parameter5), - static (invocationCount, @delegate, state) => @delegate(invocationCount, state.parameter1, state.parameter2, state.parameter3, state.parameter4, state.parameter5))) - { - wasInvoked = true; - } - } - } - } - - /// Setup for a method with 5 parameters matching against IParameters. - internal class WithParameters : ReturnMethodSetup - { - private readonly string _parameterName1; - private readonly string _parameterName2; - private readonly string _parameterName3; - private readonly string _parameterName4; - private readonly string _parameterName5; - - /// - public WithParameters(global::Mockolate.MockRegistry mockRegistry, string name, global::Mockolate.Parameters.IParameters parameters, string parameterName1, string parameterName2, string parameterName3, string parameterName4, string parameterName5) - : base(mockRegistry, name) - { - Parameters = parameters; - _parameterName1 = parameterName1; - _parameterName2 = parameterName2; - _parameterName3 = parameterName3; - _parameterName4 = parameterName4; - _parameterName5 = parameterName5; - } - - private global::Mockolate.Parameters.IParameters Parameters { get; } - - /// - public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value) - => Parameters switch - { - global::Mockolate.Parameters.IParametersMatch m => m.Matches([p1Value, p2Value, p3Value, p4Value, p5Value]), - global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([(_parameterName1, p1Value), (_parameterName2, p2Value), (_parameterName3, p3Value), (_parameterName4, p4Value), (_parameterName5, p5Value)]), - _ => true, - }; - - /// - public override string ToString() - { - return $"{FormatType(typeof(TReturn))} {SubstringAfterLast(Name, '.')}({Parameters})"; - static string SubstringAfterLast(string name, char c) - { - int index = name.LastIndexOf(c); - return index >= 0 ? name.Substring(index + 1) : name; - } - } - } - - /// Setup for a method with 5 parameters matching against individual IParameterMatch<T>. - internal class WithParameterCollection : ReturnMethodSetup, - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer - { - private bool _matchAnyParameters; - - /// - public WithParameterCollection( - global::Mockolate.MockRegistry mockRegistry, - string name, - global::Mockolate.Parameters.IParameterMatch parameter1, - global::Mockolate.Parameters.IParameterMatch parameter2, - global::Mockolate.Parameters.IParameterMatch parameter3, - global::Mockolate.Parameters.IParameterMatch parameter4, - global::Mockolate.Parameters.IParameterMatch parameter5) - : base(mockRegistry, name) - { - Parameter1 = parameter1; - Parameter2 = parameter2; - Parameter3 = parameter3; - Parameter4 = parameter4; - Parameter5 = parameter5; - } - - /// The first parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter1 { get; } - - /// The second parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter2 { get; } - - /// The third parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter3 { get; } - - /// The 4th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter4 { get; } - - /// The 5th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter5 { get; } - - /// - global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer.AnyParameters() - { - _matchAnyParameters = true; - return this; - } - - /// - public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value) - => _matchAnyParameters || (Parameter1.Matches(p1Value) && Parameter2.Matches(p2Value) && Parameter3.Matches(p3Value) && Parameter4.Matches(p4Value) && Parameter5.Matches(p5Value)); - - /// - public override void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5) - { - Parameter1?.InvokeCallbacks(parameter1); - Parameter2?.InvokeCallbacks(parameter2); - Parameter3?.InvokeCallbacks(parameter3); - Parameter4?.InvokeCallbacks(parameter4); - Parameter5?.InvokeCallbacks(parameter5); - base.TriggerCallbacks(parameter1, parameter2, parameter3, parameter4, parameter5); - } - - /// - public override string ToString() - { - return $"{FormatType(typeof(TReturn))} {SubstringAfterLast(Name, '.')}({Parameter1}, {Parameter2}, {Parameter3}, {Parameter4}, {Parameter5})"; - static string SubstringAfterLast(string name, char c) - { - int index = name.LastIndexOf(c); - return index >= 0 ? name.Substring(index + 1) : name; - } - } - } - } - - - /// - /// Sets up a method with 5 parameters , , , and returning . - /// - internal interface IVoidMethodSetup : IMethodSetup - { - /// - /// Overrides SkipBaseClass for this method only. - /// - /// - /// If not specified, use SkipBaseClass. - /// - global::Mockolate.Setup.IVoidMethodSetup SkippingBaseClass(bool skipBaseClass = true); - - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Transitions the scenario to the given when the method is called. - /// - global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder TransitionTo(string scenario); - - /// - /// Registers an iteration in the sequence of method invocations, that does not throw. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder DoesNotThrow(); - - /// - /// Registers an to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws() - where TException : global::System.Exception, new(); - - /// - /// Registers an to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(global::System.Exception exception); - - /// - /// Registers a that will calculate the exception to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(global::System.Func callback); -} - - /// - /// Sets up a method with 5 parameters , , , and returning with callback support for the parameters. - /// - internal interface IVoidMethodSetupWithCallback : global::Mockolate.Setup.IVoidMethodSetup - { - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Registers a that will calculate the exception to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(global::System.Func callback); -} - - /// - /// Sets up a callback for a method with 5 parameters , , , and returning . - /// - internal interface IVoidMethodSetupCallbackBuilder : global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder - { - /// - /// Runs the callback in parallel to the other callbacks. - /// - global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder InParallel(); - } - - /// - /// Sets up a callback for a method with 5 parameters , , , and returning . - /// - internal interface IVoidMethodSetupParallelCallbackBuilder : global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder - { - /// - /// Limits the callback to only execute for method invocations where the predicate returns true. - /// - /// - /// Provides a zero-based counter indicating how many times the method has been invoked so far. - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder When(global::System.Func predicate); - } - - /// - /// Sets up a when callback for a method with 5 parameters , , , and returning . - /// - internal interface IVoidMethodSetupCallbackWhenBuilder : global::Mockolate.Setup.IVoidMethodSetupWithCallback - { - /// - /// Repeats the callback for the given number of . - /// - /// - /// The number of times is only counted for actual executions (IVoidMethodSetupParallelCallbackBuilder<T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder For(int times); - - /// - /// Deactivates the callback after the given number of . - /// - /// - /// The number of times is only counted for actual executions (IVoidMethodSetupParallelCallbackBuilder<T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IVoidMethodSetup Only(int times); - } - - /// - /// Sets up a return callback for a method with 5 parameters , , , and returning . - /// - internal interface IVoidMethodSetupReturnBuilder : global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder - { - /// - /// Limits the throw to only execute for method invocations where the predicate returns true. - /// - /// - /// Provides a zero-based counter indicating how many times the method has been invoked so far. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder When(global::System.Func predicate); - } - - /// - /// Sets up a when return callback for a method with 5 parameters , , , and returning . - /// - internal interface IVoidMethodSetupReturnWhenBuilder : global::Mockolate.Setup.IVoidMethodSetupWithCallback - { - /// - /// Repeats the throw for the given number of . - /// - /// - /// The number of times is only counted for actual executions (IVoidMethodSetupReturnBuilder<T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder For(int times); - - /// - /// Deactivates the throw after the given number of . - /// - /// - /// The number of times is only counted for actual executions (IVoidMethodSetupReturnBuilder<T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IVoidMethodSetup Only(int times); - } - - /// - /// Allows ignoring the provided parameters. - /// - internal interface IVoidMethodSetupParameterIgnorer : global::Mockolate.Setup.IVoidMethodSetupWithCallback - { - /// - /// Replaces the explicit parameter matcher with AnyParameters(). - /// - global::Mockolate.Setup.IVoidMethodSetup AnyParameters(); - } - - /// - /// Sets up a method with 5 parameters , , , and returning . - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal abstract class VoidMethodSetup : global::Mockolate.Setup.MethodSetup, - global::Mockolate.Setup.IVoidMethodSetupWithCallback, - global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder, - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder -{ - private readonly global::Mockolate.MockRegistry _mockRegistry; - private global::Mockolate.Setup.Callbacks>? _callbacks = []; - private global::Mockolate.Setup.Callbacks>? _returnCallbacks = []; - private bool? _skipBaseClass; - - protected VoidMethodSetup(global::Mockolate.MockRegistry mockRegistry, string name) - : base(name) - { - _mockRegistry = mockRegistry; - } - - /// - /// Overrides SkipBaseClass for this method only. - /// - /// - /// If not specified, use SkipBaseClass. - /// - global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetup.SkippingBaseClass(bool skipBaseClass) - { - _skipBaseClass = skipBaseClass; - return this; - } - - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder global::Mockolate.Setup.IVoidMethodSetup.Do(global::System.Action callback) - { - global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _) => callback()); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder global::Mockolate.Setup.IVoidMethodSetupWithCallback.Do(global::System.Action callback) - { - global::Mockolate.Setup.Callback>? currentCallback = new((_, p1, p2, p3, p4, p5) => callback(p1, p2, p3, p4, p5)); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder global::Mockolate.Setup.IVoidMethodSetupWithCallback.Do(global::System.Action callback) - { - global::Mockolate.Setup.Callback>? currentCallback = new(callback); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IVoidMethodSetup.TransitionTo(string scenario) - { - global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _) => _mockRegistry.TransitionTo(scenario)); - currentCallback.InParallel(); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - /// Registers an iteration in the sequence of method invocations, that does not throw. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.DoesNotThrow() - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _) => { }); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - /// Registers an to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.Throws() - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _) => throw new TException()); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - /// Registers an to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.Throws(global::System.Exception exception) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _) => throw exception); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - /// Registers a that will calculate the exception to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetupWithCallback.Throws(global::System.Func callback) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, p1, p2, p3, p4, p5) => throw callback(p1, p2, p3, p4, p5)); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - /// Registers a that will calculate the exception to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.Throws(global::System.Func callback) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _) => throw callback()); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder.InParallel() - { - _callbacks?.Active?.InParallel(); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder.When(global::System.Func predicate) - { - _callbacks?.Active?.When(predicate); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder.For(int times) - { - _callbacks?.Active?.For(times); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder.Only(int times) - { - _callbacks?.Active?.Only(times); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder global::Mockolate.Setup.IVoidMethodSetupReturnBuilder.When(global::System.Func predicate) - { - _returnCallbacks?.Active?.When(predicate); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder.For(int times) - { - _returnCallbacks?.Active?.For(times); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder.Only(int times) - { - _returnCallbacks?.Active?.Only(times); - return this; - } - - /// - protected override bool MatchesInteraction(global::Mockolate.Interactions.IMethodInteraction interaction) - { - if (interaction is global::Mockolate.Interactions.MethodInvocation invocation) - { - return Matches(invocation.Parameter1, invocation.Parameter2, invocation.Parameter3, invocation.Parameter4, invocation.Parameter5); - } - return false; - } - - /// - /// Gets the flag indicating if the base class implementation should be skipped. - /// - public bool SkipBaseClass(global::Mockolate.MockBehavior behavior) - => _skipBaseClass ?? behavior.SkipBaseClass; - - /// - /// Checks if the given parameters match the setup. - /// - public abstract bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value); - - /// - /// Triggers any configured parameter callbacks for the method setup with the specified parameters. - /// - public virtual void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5) - { - if (_callbacks is not null) - { - bool wasInvoked = false; - int currentCallbacksIndex = _callbacks.CurrentIndex; - for (int i = 0; i < _callbacks.Count; i++) - { - var callback = _callbacks[(currentCallbacksIndex + i) % _callbacks.Count]; - if (callback.Invoke(wasInvoked, ref _callbacks.CurrentIndex, (parameter1, parameter2, parameter3, parameter4, parameter5), - static (invocationCount, @delegate, state) => @delegate(invocationCount, state.parameter1, state.parameter2, state.parameter3, state.parameter4, state.parameter5))) - { - wasInvoked = true; - } - } - } - if (_returnCallbacks is not null) - { - foreach (var _ in _returnCallbacks) - { - var returnCallback = _returnCallbacks[_returnCallbacks.CurrentIndex % _returnCallbacks.Count]; - if (returnCallback.Invoke(ref _returnCallbacks.CurrentIndex, (parameter1, parameter2, parameter3, parameter4, parameter5), - static (invocationCount, @delegate, state) => @delegate(invocationCount, state.parameter1, state.parameter2, state.parameter3, state.parameter4, state.parameter5))) - { - return; - } - } - } - } - - /// Setup for a method with 5 parameters matching against IParameters. - internal class WithParameters : VoidMethodSetup - { - private readonly string _parameterName1; - private readonly string _parameterName2; - private readonly string _parameterName3; - private readonly string _parameterName4; - private readonly string _parameterName5; - - /// - public WithParameters(global::Mockolate.MockRegistry mockRegistry, string name, global::Mockolate.Parameters.IParameters parameters, string parameterName1, string parameterName2, string parameterName3, string parameterName4, string parameterName5) - : base(mockRegistry, name) - { - Parameters = parameters; - _parameterName1 = parameterName1; - _parameterName2 = parameterName2; - _parameterName3 = parameterName3; - _parameterName4 = parameterName4; - _parameterName5 = parameterName5; - } - - private global::Mockolate.Parameters.IParameters Parameters { get; } - - /// - public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value) - => Parameters switch - { - global::Mockolate.Parameters.IParametersMatch m => m.Matches([p1Value, p2Value, p3Value, p4Value, p5Value]), - global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([(_parameterName1, p1Value), (_parameterName2, p2Value), (_parameterName3, p3Value), (_parameterName4, p4Value), (_parameterName5, p5Value)]), - _ => true, - }; - - /// - public override string ToString() - { - return $"void {SubstringAfterLast(Name, '.')}({Parameters})"; - static string SubstringAfterLast(string name, char c) - { - int index = name.LastIndexOf(c); - return index >= 0 ? name.Substring(index + 1) : name; - } - } - } - - /// Setup for a method with 5 parameters matching against individual IParameterMatch<T>. - internal class WithParameterCollection : VoidMethodSetup, - global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer - { - private bool _matchAnyParameters; - - /// - public WithParameterCollection( - global::Mockolate.MockRegistry mockRegistry, - string name, - global::Mockolate.Parameters.IParameterMatch parameter1, - global::Mockolate.Parameters.IParameterMatch parameter2, - global::Mockolate.Parameters.IParameterMatch parameter3, - global::Mockolate.Parameters.IParameterMatch parameter4, - global::Mockolate.Parameters.IParameterMatch parameter5) - : base(mockRegistry, name) - { - Parameter1 = parameter1; - Parameter2 = parameter2; - Parameter3 = parameter3; - Parameter4 = parameter4; - Parameter5 = parameter5; - } - - /// The first parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter1 { get; } - - /// The second parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter2 { get; } - - /// The third parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter3 { get; } - - /// The 4th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter4 { get; } - - /// The 5th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter5 { get; } - - /// - global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer.AnyParameters() - { - _matchAnyParameters = true; - return this; - } - - /// - public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value) - => _matchAnyParameters || (Parameter1.Matches(p1Value) && Parameter2.Matches(p2Value) && Parameter3.Matches(p3Value) && Parameter4.Matches(p4Value) && Parameter5.Matches(p5Value)); - - /// - public override void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5) - { - Parameter1?.InvokeCallbacks(parameter1); - Parameter2?.InvokeCallbacks(parameter2); - Parameter3?.InvokeCallbacks(parameter3); - Parameter4?.InvokeCallbacks(parameter4); - Parameter5?.InvokeCallbacks(parameter5); - base.TriggerCallbacks(parameter1, parameter2, parameter3, parameter4, parameter5); - } - - /// - public override string ToString() - { - return $"void {SubstringAfterLast(Name, '.')}({Parameter1}, {Parameter2}, {Parameter3}, {Parameter4}, {Parameter5})"; - static string SubstringAfterLast(string name, char c) - { - int index = name.LastIndexOf(c); - return index >= 0 ? name.Substring(index + 1) : name; - } - } - } - } - - - /// - /// Sets up a method with 7 parameters , , , , , and returning . - /// - internal interface IVoidMethodSetup : IMethodSetup - { - /// - /// Overrides SkipBaseClass for this method only. - /// - /// - /// If not specified, use SkipBaseClass. - /// - global::Mockolate.Setup.IVoidMethodSetup SkippingBaseClass(bool skipBaseClass = true); - - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Transitions the scenario to the given when the method is called. - /// - global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder TransitionTo(string scenario); - - /// - /// Registers an iteration in the sequence of method invocations, that does not throw. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder DoesNotThrow(); - - /// - /// Registers an to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws() - where TException : global::System.Exception, new(); - - /// - /// Registers an to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(global::System.Exception exception); - - /// - /// Registers a that will calculate the exception to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(global::System.Func callback); -} - - /// - /// Sets up a method with 7 parameters , , , , , and returning with callback support for the parameters. - /// - internal interface IVoidMethodSetupWithCallback : global::Mockolate.Setup.IVoidMethodSetup - { - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Registers a that will calculate the exception to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(global::System.Func callback); -} - - /// - /// Sets up a callback for a method with 7 parameters , , , , , and returning . - /// - internal interface IVoidMethodSetupCallbackBuilder : global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder - { - /// - /// Runs the callback in parallel to the other callbacks. - /// - global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder InParallel(); - } - - /// - /// Sets up a callback for a method with 7 parameters , , , , , and returning . - /// - internal interface IVoidMethodSetupParallelCallbackBuilder : global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder - { - /// - /// Limits the callback to only execute for method invocations where the predicate returns true. - /// - /// - /// Provides a zero-based counter indicating how many times the method has been invoked so far. - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder When(global::System.Func predicate); - } - - /// - /// Sets up a when callback for a method with 7 parameters , , , , , and returning . - /// - internal interface IVoidMethodSetupCallbackWhenBuilder : global::Mockolate.Setup.IVoidMethodSetupWithCallback - { - /// - /// Repeats the callback for the given number of . - /// - /// - /// The number of times is only counted for actual executions (IVoidMethodSetupParallelCallbackBuilder<T1, T2, T3, T4, T5, T6, T7>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder For(int times); - - /// - /// Deactivates the callback after the given number of . - /// - /// - /// The number of times is only counted for actual executions (IVoidMethodSetupParallelCallbackBuilder<T1, T2, T3, T4, T5, T6, T7>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IVoidMethodSetup Only(int times); - } - - /// - /// Sets up a return callback for a method with 7 parameters , , , , , and returning . - /// - internal interface IVoidMethodSetupReturnBuilder : global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder - { - /// - /// Limits the throw to only execute for method invocations where the predicate returns true. - /// - /// - /// Provides a zero-based counter indicating how many times the method has been invoked so far. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder When(global::System.Func predicate); - } - - /// - /// Sets up a when return callback for a method with 7 parameters , , , , , and returning . - /// - internal interface IVoidMethodSetupReturnWhenBuilder : global::Mockolate.Setup.IVoidMethodSetupWithCallback - { - /// - /// Repeats the throw for the given number of . - /// - /// - /// The number of times is only counted for actual executions (IVoidMethodSetupReturnBuilder<T1, T2, T3, T4, T5, T6, T7>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder For(int times); - - /// - /// Deactivates the throw after the given number of . - /// - /// - /// The number of times is only counted for actual executions (IVoidMethodSetupReturnBuilder<T1, T2, T3, T4, T5, T6, T7>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IVoidMethodSetup Only(int times); - } - - /// - /// Allows ignoring the provided parameters. - /// - internal interface IVoidMethodSetupParameterIgnorer : global::Mockolate.Setup.IVoidMethodSetupWithCallback - { - /// - /// Replaces the explicit parameter matcher with AnyParameters(). - /// - global::Mockolate.Setup.IVoidMethodSetup AnyParameters(); - } - - /// - /// Sets up a method with 7 parameters , , , , , and returning . - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal abstract class VoidMethodSetup : global::Mockolate.Setup.MethodSetup, - global::Mockolate.Setup.IVoidMethodSetupWithCallback, - global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder, - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder -{ - private readonly global::Mockolate.MockRegistry _mockRegistry; - private global::Mockolate.Setup.Callbacks>? _callbacks = []; - private global::Mockolate.Setup.Callbacks>? _returnCallbacks = []; - private bool? _skipBaseClass; - - protected VoidMethodSetup(global::Mockolate.MockRegistry mockRegistry, string name) - : base(name) - { - _mockRegistry = mockRegistry; - } - - /// - /// Overrides SkipBaseClass for this method only. - /// - /// - /// If not specified, use SkipBaseClass. - /// - global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetup.SkippingBaseClass(bool skipBaseClass) - { - _skipBaseClass = skipBaseClass; - return this; - } - - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder global::Mockolate.Setup.IVoidMethodSetup.Do(global::System.Action callback) - { - global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _, _, _) => callback()); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder global::Mockolate.Setup.IVoidMethodSetupWithCallback.Do(global::System.Action callback) - { - global::Mockolate.Setup.Callback>? currentCallback = new((_, p1, p2, p3, p4, p5, p6, p7) => callback(p1, p2, p3, p4, p5, p6, p7)); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder global::Mockolate.Setup.IVoidMethodSetupWithCallback.Do(global::System.Action callback) - { - global::Mockolate.Setup.Callback>? currentCallback = new(callback); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IVoidMethodSetup.TransitionTo(string scenario) - { - global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _, _, _) => _mockRegistry.TransitionTo(scenario)); - currentCallback.InParallel(); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - /// Registers an iteration in the sequence of method invocations, that does not throw. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.DoesNotThrow() - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _) => { }); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - /// Registers an to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.Throws() - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _) => throw new TException()); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - /// Registers an to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.Throws(global::System.Exception exception) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _) => throw exception); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - /// Registers a that will calculate the exception to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetupWithCallback.Throws(global::System.Func callback) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, p1, p2, p3, p4, p5, p6, p7) => throw callback(p1, p2, p3, p4, p5, p6, p7)); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - /// Registers a that will calculate the exception to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.Throws(global::System.Func callback) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _) => throw callback()); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder.InParallel() - { - _callbacks?.Active?.InParallel(); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder.When(global::System.Func predicate) - { - _callbacks?.Active?.When(predicate); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder.For(int times) - { - _callbacks?.Active?.For(times); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder.Only(int times) - { - _callbacks?.Active?.Only(times); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder global::Mockolate.Setup.IVoidMethodSetupReturnBuilder.When(global::System.Func predicate) - { - _returnCallbacks?.Active?.When(predicate); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder.For(int times) - { - _returnCallbacks?.Active?.For(times); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder.Only(int times) - { - _returnCallbacks?.Active?.Only(times); - return this; - } - - /// - protected override bool MatchesInteraction(global::Mockolate.Interactions.IMethodInteraction interaction) - { - if (interaction is global::Mockolate.Interactions.MethodInvocation invocation) - { - return Matches(invocation.Parameter1, invocation.Parameter2, invocation.Parameter3, invocation.Parameter4, invocation.Parameter5, invocation.Parameter6, invocation.Parameter7); - } - return false; - } - - /// - /// Gets the flag indicating if the base class implementation should be skipped. - /// - public bool SkipBaseClass(global::Mockolate.MockBehavior behavior) - => _skipBaseClass ?? behavior.SkipBaseClass; - - /// - /// Checks if the given parameters match the setup. - /// - public abstract bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value, T7 p7Value); - - /// - /// Triggers any configured parameter callbacks for the method setup with the specified parameters. - /// - public virtual void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7) - { - if (_callbacks is not null) - { - bool wasInvoked = false; - int currentCallbacksIndex = _callbacks.CurrentIndex; - for (int i = 0; i < _callbacks.Count; i++) - { - var callback = _callbacks[(currentCallbacksIndex + i) % _callbacks.Count]; - if (callback.Invoke(wasInvoked, ref _callbacks.CurrentIndex, (parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7), - static (invocationCount, @delegate, state) => @delegate(invocationCount, state.parameter1, state.parameter2, state.parameter3, state.parameter4, state.parameter5, state.parameter6, state.parameter7))) - { - wasInvoked = true; - } - } - } - if (_returnCallbacks is not null) - { - foreach (var _ in _returnCallbacks) - { - var returnCallback = _returnCallbacks[_returnCallbacks.CurrentIndex % _returnCallbacks.Count]; - if (returnCallback.Invoke(ref _returnCallbacks.CurrentIndex, (parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7), - static (invocationCount, @delegate, state) => @delegate(invocationCount, state.parameter1, state.parameter2, state.parameter3, state.parameter4, state.parameter5, state.parameter6, state.parameter7))) - { - return; - } - } - } - } - - /// Setup for a method with 7 parameters matching against IParameters. - internal class WithParameters : VoidMethodSetup - { - private readonly string _parameterName1; - private readonly string _parameterName2; - private readonly string _parameterName3; - private readonly string _parameterName4; - private readonly string _parameterName5; - private readonly string _parameterName6; - private readonly string _parameterName7; - - /// - public WithParameters(global::Mockolate.MockRegistry mockRegistry, string name, global::Mockolate.Parameters.IParameters parameters, string parameterName1, string parameterName2, string parameterName3, string parameterName4, string parameterName5, string parameterName6, string parameterName7) - : base(mockRegistry, name) - { - Parameters = parameters; - _parameterName1 = parameterName1; - _parameterName2 = parameterName2; - _parameterName3 = parameterName3; - _parameterName4 = parameterName4; - _parameterName5 = parameterName5; - _parameterName6 = parameterName6; - _parameterName7 = parameterName7; - } - - private global::Mockolate.Parameters.IParameters Parameters { get; } - - /// - public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value, T7 p7Value) - => Parameters switch - { - global::Mockolate.Parameters.IParametersMatch m => m.Matches([p1Value, p2Value, p3Value, p4Value, p5Value, p6Value, p7Value]), - global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([(_parameterName1, p1Value), (_parameterName2, p2Value), (_parameterName3, p3Value), (_parameterName4, p4Value), (_parameterName5, p5Value), (_parameterName6, p6Value), (_parameterName7, p7Value)]), - _ => true, - }; - - /// - public override string ToString() - { - return $"void {SubstringAfterLast(Name, '.')}({Parameters})"; - static string SubstringAfterLast(string name, char c) - { - int index = name.LastIndexOf(c); - return index >= 0 ? name.Substring(index + 1) : name; - } - } - } - - /// Setup for a method with 7 parameters matching against individual IParameterMatch<T>. - internal class WithParameterCollection : VoidMethodSetup, - global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer - { - private bool _matchAnyParameters; - - /// - public WithParameterCollection( - global::Mockolate.MockRegistry mockRegistry, - string name, - global::Mockolate.Parameters.IParameterMatch parameter1, - global::Mockolate.Parameters.IParameterMatch parameter2, - global::Mockolate.Parameters.IParameterMatch parameter3, - global::Mockolate.Parameters.IParameterMatch parameter4, - global::Mockolate.Parameters.IParameterMatch parameter5, - global::Mockolate.Parameters.IParameterMatch parameter6, - global::Mockolate.Parameters.IParameterMatch parameter7) - : base(mockRegistry, name) - { - Parameter1 = parameter1; - Parameter2 = parameter2; - Parameter3 = parameter3; - Parameter4 = parameter4; - Parameter5 = parameter5; - Parameter6 = parameter6; - Parameter7 = parameter7; - } - - /// The first parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter1 { get; } - - /// The second parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter2 { get; } - - /// The third parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter3 { get; } - - /// The 4th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter4 { get; } - - /// The 5th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter5 { get; } - - /// The 6th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter6 { get; } - - /// The 7th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter7 { get; } - - /// - global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer.AnyParameters() - { - _matchAnyParameters = true; - return this; - } - - /// - public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value, T7 p7Value) - => _matchAnyParameters || (Parameter1.Matches(p1Value) && Parameter2.Matches(p2Value) && Parameter3.Matches(p3Value) && Parameter4.Matches(p4Value) && Parameter5.Matches(p5Value) && Parameter6.Matches(p6Value) && Parameter7.Matches(p7Value)); - - /// - public override void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7) - { - Parameter1?.InvokeCallbacks(parameter1); - Parameter2?.InvokeCallbacks(parameter2); - Parameter3?.InvokeCallbacks(parameter3); - Parameter4?.InvokeCallbacks(parameter4); - Parameter5?.InvokeCallbacks(parameter5); - Parameter6?.InvokeCallbacks(parameter6); - Parameter7?.InvokeCallbacks(parameter7); - base.TriggerCallbacks(parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7); - } - - /// - public override string ToString() - { - return $"void {SubstringAfterLast(Name, '.')}({Parameter1}, {Parameter2}, {Parameter3}, {Parameter4}, {Parameter5}, {Parameter6}, {Parameter7})"; - static string SubstringAfterLast(string name, char c) - { - int index = name.LastIndexOf(c); - return index >= 0 ? name.Substring(index + 1) : name; - } - } - } - } - - - /// - /// Sets up a method with 17 parameters , , , , , , , , , , , , , , , and returning . - /// - internal interface IReturnMethodSetup : global::Mockolate.Setup.IMethodSetup - { - /// - /// Overrides SkipBaseClass for this method only. - /// - /// - /// If not specified, use SkipBaseClass. - /// - global::Mockolate.Setup.IReturnMethodSetup SkippingBaseClass(bool skipBaseClass = true); - - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Transitions the scenario to the given when the method is called. - /// - global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder TransitionTo(string scenario); - - /// - /// Registers a to setup the return value for this method. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(global::System.Func callback); - - /// - /// Registers the for this method. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(TReturn returnValue); - - /// - /// Registers an to throw when the method is invoked. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws() - where TException : global::System.Exception, new(); - - /// - /// Registers an to throw when the method is invoked. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(global::System.Exception exception); - - /// - /// Registers a that will calculate the exception to throw when the method is invoked. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(global::System.Func callback); - } - - /// - /// Sets up a method with 17 parameters , , , , , , , , , , , , , , , and returning with callback support for the parameters. - /// - internal interface IReturnMethodSetupWithCallback : global::Mockolate.Setup.IReturnMethodSetup - { - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Registers a to setup the return value for this method. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Returns(global::System.Func callback); - - /// - /// Registers a that will calculate the exception to throw when the method is invoked. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder Throws(global::System.Func callback); - } - - /// - /// Sets up a callback for a method with 17 parameters , , , , , , , , , , , , , , , and returning . - /// - internal interface IReturnMethodSetupCallbackBuilder : global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder - { - /// - /// Runs the callback in parallel to the other callbacks. - /// - global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder InParallel(); - } - - /// - /// Sets up a parallel callback for a method with 17 parameters , , , , , , , , , , , , , , , and returning . - /// - internal interface IReturnMethodSetupParallelCallbackBuilder : global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder - { - /// - /// Limits the callback to only execute for method invocations where the predicate returns true. - /// - /// - /// Provides a zero-based counter indicating how many times the method has been invoked so far. - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder When(global::System.Func predicate); - } - - /// - /// Sets up a when callback for a method with 17 parameters , , , , , , , , , , , , , , , and returning . - /// - internal interface IReturnMethodSetupCallbackWhenBuilder : global::Mockolate.Setup.IReturnMethodSetupWithCallback - { - /// - /// Repeats the callback for the given number of . - /// - /// - /// The number of times is only counted for actual executions (IReturnMethodSetupParallelCallbackBuilder<TReturn, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder For(int times); - - /// - /// Deactivates the callback after the given number of . - /// - /// - /// The number of times is only counted for actual executions (IReturnMethodSetupParallelCallbackBuilder<TReturn, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IReturnMethodSetup Only(int times); - } - - /// - /// Sets up a return callback for a method with 17 parameters , , , , , , , , , , , , , , , and returning . - /// - internal interface IReturnMethodSetupReturnBuilder : global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder - { - /// - /// Limits the return/throw to only execute for method invocations where the predicate returns true. - /// - /// - /// Provides a zero-based counter indicating how many times the method has been invoked so far. - /// - global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder When(global::System.Func predicate); - } - - /// - /// Sets up a when return callback for a method with 17 parameters , , , , , , , , , , , , , , , and returning . - /// - internal interface IReturnMethodSetupReturnWhenBuilder : global::Mockolate.Setup.IReturnMethodSetupWithCallback - { - /// - /// Repeats the callback for the given number of . - /// - /// - /// The number of times is only counted for actual executions (IReturnMethodSetupReturnBuilder<TReturn, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder For(int times); - - /// - /// Deactivates the return/throw after the given number of . - /// - /// - /// The number of times is only counted for actual executions (IReturnMethodSetupReturnBuilder<TReturn, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IReturnMethodSetup Only(int times); - } - - /// - /// Allows ignoring the provided parameters. - /// - internal interface IReturnMethodSetupParameterIgnorer : global::Mockolate.Setup.IReturnMethodSetupWithCallback - { - /// - /// Replaces the explicit parameter matcher with AnyParameters(). - /// - global::Mockolate.Setup.IReturnMethodSetup AnyParameters(); - } - - /// - /// Sets up a method with 17 parameters , , , , , , , , , , , , , , , and returning . - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal abstract class ReturnMethodSetup : global::Mockolate.Setup.MethodSetup, - global::Mockolate.Setup.IReturnMethodSetupWithCallback, - global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder, - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder - { - private readonly global::Mockolate.MockRegistry _mockRegistry; - private global::Mockolate.Setup.Callbacks>? _callbacks = []; - private global::Mockolate.Setup.Callbacks>? _returnCallbacks = []; - private bool? _skipBaseClass; - - protected ReturnMethodSetup(global::Mockolate.MockRegistry mockRegistry, string name) - : base(name) - { - _mockRegistry = mockRegistry; - } - - /// - global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetup.SkippingBaseClass(bool skipBaseClass) - { - _skipBaseClass = skipBaseClass; - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder global::Mockolate.Setup.IReturnMethodSetup.Do(global::System.Action callback) - { - global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => callback()); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Do(global::System.Action callback) - { - global::Mockolate.Setup.Callback>? currentCallback = new((_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17) => callback(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17)); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Do(global::System.Action callback) - { - global::Mockolate.Setup.Callback>? currentCallback = new(callback); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IReturnMethodSetup.TransitionTo(string scenario) - { - global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => _mockRegistry.TransitionTo(scenario)); - currentCallback.InParallel(); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Returns(global::System.Func callback) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17) => callback(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17)); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Returns(global::System.Func callback) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => callback()); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Returns(TReturn returnValue) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => returnValue); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Throws() - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => throw new TException()); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Throws(global::System.Exception exception) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => throw exception); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetupWithCallback.Throws(global::System.Func callback) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17) => throw callback(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17)); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnBuilder global::Mockolate.Setup.IReturnMethodSetup.Throws(global::System.Func callback) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => throw callback()); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IReturnMethodSetupCallbackBuilder.InParallel() - { - _callbacks?.Active?.InParallel(); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IReturnMethodSetupParallelCallbackBuilder.When(global::System.Func predicate) - { - _callbacks?.Active?.When(predicate); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder.For(int times) - { - _callbacks?.Active?.For(times); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder.Only(int times) - { - _callbacks?.Active?.Only(times); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder global::Mockolate.Setup.IReturnMethodSetupReturnBuilder.When(global::System.Func predicate) - { - _returnCallbacks?.Active?.When(predicate); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder.For(int times) - { - _returnCallbacks?.Active?.For(times); - return this; - } - - /// - global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder.Only(int times) - { - _returnCallbacks?.Active?.Only(times); - return this; - } - - /// - protected override bool MatchesInteraction(global::Mockolate.Interactions.IMethodInteraction interaction) - { - if (interaction is global::Mockolate.Interactions.MethodInvocation invocation) - { - return Matches(invocation.Parameter1, invocation.Parameter2, invocation.Parameter3, invocation.Parameter4, invocation.Parameter5, invocation.Parameter6, invocation.Parameter7, invocation.Parameter8, invocation.Parameter9, invocation.Parameter10, invocation.Parameter11, invocation.Parameter12, invocation.Parameter13, invocation.Parameter14, invocation.Parameter15, invocation.Parameter16, invocation.Parameter17); - } - return false; - } - - /// - /// Flag indicating, if any return callbacks have been registered on this setup. - /// - public bool HasReturnCallbacks - => _returnCallbacks is { Count: > 0, }; - - /// - /// Gets the flag indicating if the base class implementation should be skipped. - /// - public bool SkipBaseClass(global::Mockolate.MockBehavior behavior) - => _skipBaseClass ?? behavior.SkipBaseClass; - - /// - /// Gets the registered return value. - /// - public bool TryGetReturnValue(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7, T8 p8, T9 p9, T10 p10, T11 p11, T12 p12, T13 p13, T14 p14, T15 p15, T16 p16, T17 p17, out TReturn returnValue) - { - if (_returnCallbacks != null) - { - foreach (var _ in _returnCallbacks) - { - var returnCallback = _returnCallbacks[_returnCallbacks.CurrentIndex % _returnCallbacks.Count]; - if (returnCallback.Invoke(ref _returnCallbacks.CurrentIndex, (p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17), - static (invocationCount, @delegate, state) => @delegate(invocationCount, state.p1, state.p2, state.p3, state.p4, state.p5, state.p6, state.p7, state.p8, state.p9, state.p10, state.p11, state.p12, state.p13, state.p14, state.p15, state.p16, state.p17), - out TReturn? newValue)) - { - returnValue = newValue; - return true; - } - } - } - returnValue = default!; - return false; - } - - /// - /// Checks if the given parameters match the setup. - /// - public abstract bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value, T7 p7Value, T8 p8Value, T9 p9Value, T10 p10Value, T11 p11Value, T12 p12Value, T13 p13Value, T14 p14Value, T15 p15Value, T16 p16Value, T17 p17Value); - - /// - /// Triggers any configured parameter callbacks for the method setup with the specified parameters. - /// - public virtual void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7, T8 parameter8, T9 parameter9, T10 parameter10, T11 parameter11, T12 parameter12, T13 parameter13, T14 parameter14, T15 parameter15, T16 parameter16, T17 parameter17) - { - if (_callbacks is not null) - { - bool wasInvoked = false; - int currentCallbacksIndex = _callbacks.CurrentIndex; - for (int i = 0; i < _callbacks.Count; i++) - { - var callback = _callbacks[(currentCallbacksIndex + i) % _callbacks.Count]; - if (callback.Invoke(wasInvoked, ref _callbacks.CurrentIndex, (parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7, parameter8, parameter9, parameter10, parameter11, parameter12, parameter13, parameter14, parameter15, parameter16, parameter17), - static (invocationCount, @delegate, state) => @delegate(invocationCount, state.parameter1, state.parameter2, state.parameter3, state.parameter4, state.parameter5, state.parameter6, state.parameter7, state.parameter8, state.parameter9, state.parameter10, state.parameter11, state.parameter12, state.parameter13, state.parameter14, state.parameter15, state.parameter16, state.parameter17))) - { - wasInvoked = true; - } - } - } - } - - /// Setup for a method with 17 parameters matching against IParameters. - internal class WithParameters : ReturnMethodSetup - { - private readonly string _parameterName1; - private readonly string _parameterName2; - private readonly string _parameterName3; - private readonly string _parameterName4; - private readonly string _parameterName5; - private readonly string _parameterName6; - private readonly string _parameterName7; - private readonly string _parameterName8; - private readonly string _parameterName9; - private readonly string _parameterName10; - private readonly string _parameterName11; - private readonly string _parameterName12; - private readonly string _parameterName13; - private readonly string _parameterName14; - private readonly string _parameterName15; - private readonly string _parameterName16; - private readonly string _parameterName17; - - /// - public WithParameters(global::Mockolate.MockRegistry mockRegistry, string name, global::Mockolate.Parameters.IParameters parameters, string parameterName1, string parameterName2, string parameterName3, string parameterName4, string parameterName5, string parameterName6, string parameterName7, string parameterName8, string parameterName9, string parameterName10, string parameterName11, string parameterName12, string parameterName13, string parameterName14, string parameterName15, string parameterName16, string parameterName17) - : base(mockRegistry, name) - { - Parameters = parameters; - _parameterName1 = parameterName1; - _parameterName2 = parameterName2; - _parameterName3 = parameterName3; - _parameterName4 = parameterName4; - _parameterName5 = parameterName5; - _parameterName6 = parameterName6; - _parameterName7 = parameterName7; - _parameterName8 = parameterName8; - _parameterName9 = parameterName9; - _parameterName10 = parameterName10; - _parameterName11 = parameterName11; - _parameterName12 = parameterName12; - _parameterName13 = parameterName13; - _parameterName14 = parameterName14; - _parameterName15 = parameterName15; - _parameterName16 = parameterName16; - _parameterName17 = parameterName17; - } - - private global::Mockolate.Parameters.IParameters Parameters { get; } - - /// - public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value, T7 p7Value, T8 p8Value, T9 p9Value, T10 p10Value, T11 p11Value, T12 p12Value, T13 p13Value, T14 p14Value, T15 p15Value, T16 p16Value, T17 p17Value) - => Parameters switch - { - global::Mockolate.Parameters.IParametersMatch m => m.Matches([p1Value, p2Value, p3Value, p4Value, p5Value, p6Value, p7Value, p8Value, p9Value, p10Value, p11Value, p12Value, p13Value, p14Value, p15Value, p16Value, p17Value]), - global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([(_parameterName1, p1Value), (_parameterName2, p2Value), (_parameterName3, p3Value), (_parameterName4, p4Value), (_parameterName5, p5Value), (_parameterName6, p6Value), (_parameterName7, p7Value), (_parameterName8, p8Value), (_parameterName9, p9Value), (_parameterName10, p10Value), (_parameterName11, p11Value), (_parameterName12, p12Value), (_parameterName13, p13Value), (_parameterName14, p14Value), (_parameterName15, p15Value), (_parameterName16, p16Value), (_parameterName17, p17Value)]), - _ => true, - }; - - /// - public override string ToString() - { - return $"{FormatType(typeof(TReturn))} {SubstringAfterLast(Name, '.')}({Parameters})"; - static string SubstringAfterLast(string name, char c) - { - int index = name.LastIndexOf(c); - return index >= 0 ? name.Substring(index + 1) : name; - } - } - } - - /// Setup for a method with 17 parameters matching against individual IParameterMatch<T>. - internal class WithParameterCollection : ReturnMethodSetup, - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer - { - private bool _matchAnyParameters; - - /// - public WithParameterCollection( - global::Mockolate.MockRegistry mockRegistry, - string name, - global::Mockolate.Parameters.IParameterMatch parameter1, - global::Mockolate.Parameters.IParameterMatch parameter2, - global::Mockolate.Parameters.IParameterMatch parameter3, - global::Mockolate.Parameters.IParameterMatch parameter4, - global::Mockolate.Parameters.IParameterMatch parameter5, - global::Mockolate.Parameters.IParameterMatch parameter6, - global::Mockolate.Parameters.IParameterMatch parameter7, - global::Mockolate.Parameters.IParameterMatch parameter8, - global::Mockolate.Parameters.IParameterMatch parameter9, - global::Mockolate.Parameters.IParameterMatch parameter10, - global::Mockolate.Parameters.IParameterMatch parameter11, - global::Mockolate.Parameters.IParameterMatch parameter12, - global::Mockolate.Parameters.IParameterMatch parameter13, - global::Mockolate.Parameters.IParameterMatch parameter14, - global::Mockolate.Parameters.IParameterMatch parameter15, - global::Mockolate.Parameters.IParameterMatch parameter16, - global::Mockolate.Parameters.IParameterMatch parameter17) - : base(mockRegistry, name) - { - Parameter1 = parameter1; - Parameter2 = parameter2; - Parameter3 = parameter3; - Parameter4 = parameter4; - Parameter5 = parameter5; - Parameter6 = parameter6; - Parameter7 = parameter7; - Parameter8 = parameter8; - Parameter9 = parameter9; - Parameter10 = parameter10; - Parameter11 = parameter11; - Parameter12 = parameter12; - Parameter13 = parameter13; - Parameter14 = parameter14; - Parameter15 = parameter15; - Parameter16 = parameter16; - Parameter17 = parameter17; - } - - /// The first parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter1 { get; } - - /// The second parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter2 { get; } - - /// The third parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter3 { get; } - - /// The 4th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter4 { get; } - - /// The 5th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter5 { get; } - - /// The 6th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter6 { get; } - - /// The 7th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter7 { get; } - - /// The 8th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter8 { get; } - - /// The 9th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter9 { get; } - - /// The 10th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter10 { get; } - - /// The 11th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter11 { get; } - - /// The 12th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter12 { get; } - - /// The 13th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter13 { get; } - - /// The 14th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter14 { get; } - - /// The 15th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter15 { get; } - - /// The 16th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter16 { get; } - - /// The 17th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter17 { get; } - - /// - global::Mockolate.Setup.IReturnMethodSetup global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer.AnyParameters() - { - _matchAnyParameters = true; - return this; - } - - /// - public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value, T7 p7Value, T8 p8Value, T9 p9Value, T10 p10Value, T11 p11Value, T12 p12Value, T13 p13Value, T14 p14Value, T15 p15Value, T16 p16Value, T17 p17Value) - => _matchAnyParameters || (Parameter1.Matches(p1Value) && Parameter2.Matches(p2Value) && Parameter3.Matches(p3Value) && Parameter4.Matches(p4Value) && Parameter5.Matches(p5Value) && Parameter6.Matches(p6Value) && Parameter7.Matches(p7Value) && Parameter8.Matches(p8Value) && Parameter9.Matches(p9Value) && Parameter10.Matches(p10Value) && Parameter11.Matches(p11Value) && Parameter12.Matches(p12Value) && Parameter13.Matches(p13Value) && Parameter14.Matches(p14Value) && Parameter15.Matches(p15Value) && Parameter16.Matches(p16Value) && Parameter17.Matches(p17Value)); - - /// - public override void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7, T8 parameter8, T9 parameter9, T10 parameter10, T11 parameter11, T12 parameter12, T13 parameter13, T14 parameter14, T15 parameter15, T16 parameter16, T17 parameter17) - { - Parameter1?.InvokeCallbacks(parameter1); - Parameter2?.InvokeCallbacks(parameter2); - Parameter3?.InvokeCallbacks(parameter3); - Parameter4?.InvokeCallbacks(parameter4); - Parameter5?.InvokeCallbacks(parameter5); - Parameter6?.InvokeCallbacks(parameter6); - Parameter7?.InvokeCallbacks(parameter7); - Parameter8?.InvokeCallbacks(parameter8); - Parameter9?.InvokeCallbacks(parameter9); - Parameter10?.InvokeCallbacks(parameter10); - Parameter11?.InvokeCallbacks(parameter11); - Parameter12?.InvokeCallbacks(parameter12); - Parameter13?.InvokeCallbacks(parameter13); - Parameter14?.InvokeCallbacks(parameter14); - Parameter15?.InvokeCallbacks(parameter15); - Parameter16?.InvokeCallbacks(parameter16); - Parameter17?.InvokeCallbacks(parameter17); - base.TriggerCallbacks(parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7, parameter8, parameter9, parameter10, parameter11, parameter12, parameter13, parameter14, parameter15, parameter16, parameter17); - } - - /// - public override string ToString() - { - return $"{FormatType(typeof(TReturn))} {SubstringAfterLast(Name, '.')}({Parameter1}, {Parameter2}, {Parameter3}, {Parameter4}, {Parameter5}, {Parameter6}, {Parameter7}, {Parameter8}, {Parameter9}, {Parameter10}, {Parameter11}, {Parameter12}, {Parameter13}, {Parameter14}, {Parameter15}, {Parameter16}, {Parameter17})"; - static string SubstringAfterLast(string name, char c) - { - int index = name.LastIndexOf(c); - return index >= 0 ? name.Substring(index + 1) : name; - } - } - } - } - - - /// - /// Sets up a method with 17 parameters , , , , , , , , , , , , , , , and returning . - /// - internal interface IVoidMethodSetup : IMethodSetup - { - /// - /// Overrides SkipBaseClass for this method only. - /// - /// - /// If not specified, use SkipBaseClass. - /// - global::Mockolate.Setup.IVoidMethodSetup SkippingBaseClass(bool skipBaseClass = true); - - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Transitions the scenario to the given when the method is called. - /// - global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder TransitionTo(string scenario); - - /// - /// Registers an iteration in the sequence of method invocations, that does not throw. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder DoesNotThrow(); - - /// - /// Registers an to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws() - where TException : global::System.Exception, new(); - - /// - /// Registers an to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(global::System.Exception exception); - - /// - /// Registers a that will calculate the exception to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(global::System.Func callback); -} - - /// - /// Sets up a method with 17 parameters , , , , , , , , , , , , , , , and returning with callback support for the parameters. - /// - internal interface IVoidMethodSetupWithCallback : global::Mockolate.Setup.IVoidMethodSetup - { - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Registers a that will calculate the exception to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder Throws(global::System.Func callback); -} - - /// - /// Sets up a callback for a method with 17 parameters , , , , , , , , , , , , , , , and returning . - /// - internal interface IVoidMethodSetupCallbackBuilder : global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder - { - /// - /// Runs the callback in parallel to the other callbacks. - /// - global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder InParallel(); - } - - /// - /// Sets up a callback for a method with 17 parameters , , , , , , , , , , , , , , , and returning . - /// - internal interface IVoidMethodSetupParallelCallbackBuilder : global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder - { - /// - /// Limits the callback to only execute for method invocations where the predicate returns true. - /// - /// - /// Provides a zero-based counter indicating how many times the method has been invoked so far. - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder When(global::System.Func predicate); - } - - /// - /// Sets up a when callback for a method with 17 parameters , , , , , , , , , , , , , , , and returning . - /// - internal interface IVoidMethodSetupCallbackWhenBuilder : global::Mockolate.Setup.IVoidMethodSetupWithCallback - { - /// - /// Repeats the callback for the given number of . - /// - /// - /// The number of times is only counted for actual executions (IVoidMethodSetupParallelCallbackBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder For(int times); - - /// - /// Deactivates the callback after the given number of . - /// - /// - /// The number of times is only counted for actual executions (IVoidMethodSetupParallelCallbackBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IVoidMethodSetup Only(int times); - } - - /// - /// Sets up a return callback for a method with 17 parameters , , , , , , , , , , , , , , , and returning . - /// - internal interface IVoidMethodSetupReturnBuilder : global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder - { - /// - /// Limits the throw to only execute for method invocations where the predicate returns true. - /// - /// - /// Provides a zero-based counter indicating how many times the method has been invoked so far. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder When(global::System.Func predicate); - } - - /// - /// Sets up a when return callback for a method with 17 parameters , , , , , , , , , , , , , , , and returning . - /// - internal interface IVoidMethodSetupReturnWhenBuilder : global::Mockolate.Setup.IVoidMethodSetupWithCallback - { - /// - /// Repeats the throw for the given number of . - /// - /// - /// The number of times is only counted for actual executions (IVoidMethodSetupReturnBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder For(int times); - - /// - /// Deactivates the throw after the given number of . - /// - /// - /// The number of times is only counted for actual executions (IVoidMethodSetupReturnBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IVoidMethodSetup Only(int times); - } - - /// - /// Allows ignoring the provided parameters. - /// - internal interface IVoidMethodSetupParameterIgnorer : global::Mockolate.Setup.IVoidMethodSetupWithCallback - { - /// - /// Replaces the explicit parameter matcher with AnyParameters(). - /// - global::Mockolate.Setup.IVoidMethodSetup AnyParameters(); - } - - /// - /// Sets up a method with 17 parameters , , , , , , , , , , , , , , , and returning . - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal abstract class VoidMethodSetup : global::Mockolate.Setup.MethodSetup, - global::Mockolate.Setup.IVoidMethodSetupWithCallback, - global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder, - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder -{ - private readonly global::Mockolate.MockRegistry _mockRegistry; - private global::Mockolate.Setup.Callbacks>? _callbacks = []; - private global::Mockolate.Setup.Callbacks>? _returnCallbacks = []; - private bool? _skipBaseClass; - - protected VoidMethodSetup(global::Mockolate.MockRegistry mockRegistry, string name) - : base(name) - { - _mockRegistry = mockRegistry; - } - - /// - /// Overrides SkipBaseClass for this method only. - /// - /// - /// If not specified, use SkipBaseClass. - /// - global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetup.SkippingBaseClass(bool skipBaseClass) - { - _skipBaseClass = skipBaseClass; - return this; - } - - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder global::Mockolate.Setup.IVoidMethodSetup.Do(global::System.Action callback) - { - global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => callback()); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder global::Mockolate.Setup.IVoidMethodSetupWithCallback.Do(global::System.Action callback) - { - global::Mockolate.Setup.Callback>? currentCallback = new((_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17) => callback(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17)); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - /// Registers a to execute when the method is called. - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder global::Mockolate.Setup.IVoidMethodSetupWithCallback.Do(global::System.Action callback) - { - global::Mockolate.Setup.Callback>? currentCallback = new(callback); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IVoidMethodSetup.TransitionTo(string scenario) - { - global::Mockolate.Setup.Callback>? currentCallback = new((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => _mockRegistry.TransitionTo(scenario)); - currentCallback.InParallel(); - _callbacks = _callbacks.Register(currentCallback); - return this; - } - - /// - /// Registers an iteration in the sequence of method invocations, that does not throw. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.DoesNotThrow() - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => { }); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - /// Registers an to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.Throws() - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => throw new TException()); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - /// Registers an to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.Throws(global::System.Exception exception) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => throw exception); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - /// Registers a that will calculate the exception to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetupWithCallback.Throws(global::System.Func callback) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17) => throw callback(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17)); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - /// Registers a that will calculate the exception to throw when the method is invoked. - /// - global::Mockolate.Setup.IVoidMethodSetupReturnBuilder global::Mockolate.Setup.IVoidMethodSetup.Throws(global::System.Func callback) - { - var currentCallback = new global::Mockolate.Setup.Callback>((_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => throw callback()); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder global::Mockolate.Setup.IVoidMethodSetupCallbackBuilder.InParallel() - { - _callbacks?.Active?.InParallel(); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IVoidMethodSetupParallelCallbackBuilder.When(global::System.Func predicate) - { - _callbacks?.Active?.When(predicate); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder.For(int times) - { - _callbacks?.Active?.For(times); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder.Only(int times) - { - _callbacks?.Active?.Only(times); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder global::Mockolate.Setup.IVoidMethodSetupReturnBuilder.When(global::System.Func predicate) - { - _returnCallbacks?.Active?.When(predicate); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder.For(int times) - { - _returnCallbacks?.Active?.For(times); - return this; - } - - /// - global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder.Only(int times) - { - _returnCallbacks?.Active?.Only(times); - return this; - } - - /// - protected override bool MatchesInteraction(global::Mockolate.Interactions.IMethodInteraction interaction) - { - if (interaction is global::Mockolate.Interactions.MethodInvocation invocation) - { - return Matches(invocation.Parameter1, invocation.Parameter2, invocation.Parameter3, invocation.Parameter4, invocation.Parameter5, invocation.Parameter6, invocation.Parameter7, invocation.Parameter8, invocation.Parameter9, invocation.Parameter10, invocation.Parameter11, invocation.Parameter12, invocation.Parameter13, invocation.Parameter14, invocation.Parameter15, invocation.Parameter16, invocation.Parameter17); - } - return false; - } - - /// - /// Gets the flag indicating if the base class implementation should be skipped. - /// - public bool SkipBaseClass(global::Mockolate.MockBehavior behavior) - => _skipBaseClass ?? behavior.SkipBaseClass; - - /// - /// Checks if the given parameters match the setup. - /// - public abstract bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value, T7 p7Value, T8 p8Value, T9 p9Value, T10 p10Value, T11 p11Value, T12 p12Value, T13 p13Value, T14 p14Value, T15 p15Value, T16 p16Value, T17 p17Value); - - /// - /// Triggers any configured parameter callbacks for the method setup with the specified parameters. - /// - public virtual void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7, T8 parameter8, T9 parameter9, T10 parameter10, T11 parameter11, T12 parameter12, T13 parameter13, T14 parameter14, T15 parameter15, T16 parameter16, T17 parameter17) - { - if (_callbacks is not null) - { - bool wasInvoked = false; - int currentCallbacksIndex = _callbacks.CurrentIndex; - for (int i = 0; i < _callbacks.Count; i++) - { - var callback = _callbacks[(currentCallbacksIndex + i) % _callbacks.Count]; - if (callback.Invoke(wasInvoked, ref _callbacks.CurrentIndex, (parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7, parameter8, parameter9, parameter10, parameter11, parameter12, parameter13, parameter14, parameter15, parameter16, parameter17), - static (invocationCount, @delegate, state) => @delegate(invocationCount, state.parameter1, state.parameter2, state.parameter3, state.parameter4, state.parameter5, state.parameter6, state.parameter7, state.parameter8, state.parameter9, state.parameter10, state.parameter11, state.parameter12, state.parameter13, state.parameter14, state.parameter15, state.parameter16, state.parameter17))) - { - wasInvoked = true; - } - } - } - if (_returnCallbacks is not null) - { - foreach (var _ in _returnCallbacks) - { - var returnCallback = _returnCallbacks[_returnCallbacks.CurrentIndex % _returnCallbacks.Count]; - if (returnCallback.Invoke(ref _returnCallbacks.CurrentIndex, (parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7, parameter8, parameter9, parameter10, parameter11, parameter12, parameter13, parameter14, parameter15, parameter16, parameter17), - static (invocationCount, @delegate, state) => @delegate(invocationCount, state.parameter1, state.parameter2, state.parameter3, state.parameter4, state.parameter5, state.parameter6, state.parameter7, state.parameter8, state.parameter9, state.parameter10, state.parameter11, state.parameter12, state.parameter13, state.parameter14, state.parameter15, state.parameter16, state.parameter17))) - { - return; - } - } - } - } - - /// Setup for a method with 17 parameters matching against IParameters. - internal class WithParameters : VoidMethodSetup - { - private readonly string _parameterName1; - private readonly string _parameterName2; - private readonly string _parameterName3; - private readonly string _parameterName4; - private readonly string _parameterName5; - private readonly string _parameterName6; - private readonly string _parameterName7; - private readonly string _parameterName8; - private readonly string _parameterName9; - private readonly string _parameterName10; - private readonly string _parameterName11; - private readonly string _parameterName12; - private readonly string _parameterName13; - private readonly string _parameterName14; - private readonly string _parameterName15; - private readonly string _parameterName16; - private readonly string _parameterName17; - - /// - public WithParameters(global::Mockolate.MockRegistry mockRegistry, string name, global::Mockolate.Parameters.IParameters parameters, string parameterName1, string parameterName2, string parameterName3, string parameterName4, string parameterName5, string parameterName6, string parameterName7, string parameterName8, string parameterName9, string parameterName10, string parameterName11, string parameterName12, string parameterName13, string parameterName14, string parameterName15, string parameterName16, string parameterName17) - : base(mockRegistry, name) - { - Parameters = parameters; - _parameterName1 = parameterName1; - _parameterName2 = parameterName2; - _parameterName3 = parameterName3; - _parameterName4 = parameterName4; - _parameterName5 = parameterName5; - _parameterName6 = parameterName6; - _parameterName7 = parameterName7; - _parameterName8 = parameterName8; - _parameterName9 = parameterName9; - _parameterName10 = parameterName10; - _parameterName11 = parameterName11; - _parameterName12 = parameterName12; - _parameterName13 = parameterName13; - _parameterName14 = parameterName14; - _parameterName15 = parameterName15; - _parameterName16 = parameterName16; - _parameterName17 = parameterName17; - } - - private global::Mockolate.Parameters.IParameters Parameters { get; } - - /// - public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value, T7 p7Value, T8 p8Value, T9 p9Value, T10 p10Value, T11 p11Value, T12 p12Value, T13 p13Value, T14 p14Value, T15 p15Value, T16 p16Value, T17 p17Value) - => Parameters switch - { - global::Mockolate.Parameters.IParametersMatch m => m.Matches([p1Value, p2Value, p3Value, p4Value, p5Value, p6Value, p7Value, p8Value, p9Value, p10Value, p11Value, p12Value, p13Value, p14Value, p15Value, p16Value, p17Value]), - global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([(_parameterName1, p1Value), (_parameterName2, p2Value), (_parameterName3, p3Value), (_parameterName4, p4Value), (_parameterName5, p5Value), (_parameterName6, p6Value), (_parameterName7, p7Value), (_parameterName8, p8Value), (_parameterName9, p9Value), (_parameterName10, p10Value), (_parameterName11, p11Value), (_parameterName12, p12Value), (_parameterName13, p13Value), (_parameterName14, p14Value), (_parameterName15, p15Value), (_parameterName16, p16Value), (_parameterName17, p17Value)]), - _ => true, - }; - - /// - public override string ToString() - { - return $"void {SubstringAfterLast(Name, '.')}({Parameters})"; - static string SubstringAfterLast(string name, char c) - { - int index = name.LastIndexOf(c); - return index >= 0 ? name.Substring(index + 1) : name; - } - } - } - - /// Setup for a method with 17 parameters matching against individual IParameterMatch<T>. - internal class WithParameterCollection : VoidMethodSetup, - global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer - { - private bool _matchAnyParameters; - - /// - public WithParameterCollection( - global::Mockolate.MockRegistry mockRegistry, - string name, - global::Mockolate.Parameters.IParameterMatch parameter1, - global::Mockolate.Parameters.IParameterMatch parameter2, - global::Mockolate.Parameters.IParameterMatch parameter3, - global::Mockolate.Parameters.IParameterMatch parameter4, - global::Mockolate.Parameters.IParameterMatch parameter5, - global::Mockolate.Parameters.IParameterMatch parameter6, - global::Mockolate.Parameters.IParameterMatch parameter7, - global::Mockolate.Parameters.IParameterMatch parameter8, - global::Mockolate.Parameters.IParameterMatch parameter9, - global::Mockolate.Parameters.IParameterMatch parameter10, - global::Mockolate.Parameters.IParameterMatch parameter11, - global::Mockolate.Parameters.IParameterMatch parameter12, - global::Mockolate.Parameters.IParameterMatch parameter13, - global::Mockolate.Parameters.IParameterMatch parameter14, - global::Mockolate.Parameters.IParameterMatch parameter15, - global::Mockolate.Parameters.IParameterMatch parameter16, - global::Mockolate.Parameters.IParameterMatch parameter17) - : base(mockRegistry, name) - { - Parameter1 = parameter1; - Parameter2 = parameter2; - Parameter3 = parameter3; - Parameter4 = parameter4; - Parameter5 = parameter5; - Parameter6 = parameter6; - Parameter7 = parameter7; - Parameter8 = parameter8; - Parameter9 = parameter9; - Parameter10 = parameter10; - Parameter11 = parameter11; - Parameter12 = parameter12; - Parameter13 = parameter13; - Parameter14 = parameter14; - Parameter15 = parameter15; - Parameter16 = parameter16; - Parameter17 = parameter17; - } - - /// The first parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter1 { get; } - - /// The second parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter2 { get; } - - /// The third parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter3 { get; } - - /// The 4th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter4 { get; } - - /// The 5th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter5 { get; } - - /// The 6th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter6 { get; } - - /// The 7th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter7 { get; } - - /// The 8th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter8 { get; } - - /// The 9th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter9 { get; } - - /// The 10th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter10 { get; } - - /// The 11th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter11 { get; } - - /// The 12th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter12 { get; } - - /// The 13th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter13 { get; } - - /// The 14th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter14 { get; } - - /// The 15th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter15 { get; } - - /// The 16th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter16 { get; } - - /// The 17th parameter of the method. - public global::Mockolate.Parameters.IParameterMatch Parameter17 { get; } - - /// - global::Mockolate.Setup.IVoidMethodSetup global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer.AnyParameters() - { - _matchAnyParameters = true; - return this; - } - - /// - public override bool Matches(T1 p1Value, T2 p2Value, T3 p3Value, T4 p4Value, T5 p5Value, T6 p6Value, T7 p7Value, T8 p8Value, T9 p9Value, T10 p10Value, T11 p11Value, T12 p12Value, T13 p13Value, T14 p14Value, T15 p15Value, T16 p16Value, T17 p17Value) - => _matchAnyParameters || (Parameter1.Matches(p1Value) && Parameter2.Matches(p2Value) && Parameter3.Matches(p3Value) && Parameter4.Matches(p4Value) && Parameter5.Matches(p5Value) && Parameter6.Matches(p6Value) && Parameter7.Matches(p7Value) && Parameter8.Matches(p8Value) && Parameter9.Matches(p9Value) && Parameter10.Matches(p10Value) && Parameter11.Matches(p11Value) && Parameter12.Matches(p12Value) && Parameter13.Matches(p13Value) && Parameter14.Matches(p14Value) && Parameter15.Matches(p15Value) && Parameter16.Matches(p16Value) && Parameter17.Matches(p17Value)); - - /// - public override void TriggerCallbacks(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7, T8 parameter8, T9 parameter9, T10 parameter10, T11 parameter11, T12 parameter12, T13 parameter13, T14 parameter14, T15 parameter15, T16 parameter16, T17 parameter17) - { - Parameter1?.InvokeCallbacks(parameter1); - Parameter2?.InvokeCallbacks(parameter2); - Parameter3?.InvokeCallbacks(parameter3); - Parameter4?.InvokeCallbacks(parameter4); - Parameter5?.InvokeCallbacks(parameter5); - Parameter6?.InvokeCallbacks(parameter6); - Parameter7?.InvokeCallbacks(parameter7); - Parameter8?.InvokeCallbacks(parameter8); - Parameter9?.InvokeCallbacks(parameter9); - Parameter10?.InvokeCallbacks(parameter10); - Parameter11?.InvokeCallbacks(parameter11); - Parameter12?.InvokeCallbacks(parameter12); - Parameter13?.InvokeCallbacks(parameter13); - Parameter14?.InvokeCallbacks(parameter14); - Parameter15?.InvokeCallbacks(parameter15); - Parameter16?.InvokeCallbacks(parameter16); - Parameter17?.InvokeCallbacks(parameter17); - base.TriggerCallbacks(parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7, parameter8, parameter9, parameter10, parameter11, parameter12, parameter13, parameter14, parameter15, parameter16, parameter17); - } - - /// - public override string ToString() - { - return $"void {SubstringAfterLast(Name, '.')}({Parameter1}, {Parameter2}, {Parameter3}, {Parameter4}, {Parameter5}, {Parameter6}, {Parameter7}, {Parameter8}, {Parameter9}, {Parameter10}, {Parameter11}, {Parameter12}, {Parameter13}, {Parameter14}, {Parameter15}, {Parameter16}, {Parameter17})"; - static string SubstringAfterLast(string name, char c) - { - int index = name.LastIndexOf(c); - return index >= 0 ? name.Substring(index + 1) : name; - } - } - } - } - -} - -namespace Mockolate -{ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal static class MethodSetupExtensions - { - - /// - /// Extensions for method callback setup returning with 5 parameters. - /// - extension(global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder setup) - { - /// - /// Executes the callback only once. - /// - public global::Mockolate.Setup.IReturnMethodSetup OnlyOnce() - => setup.Only(1); - } - - /// - /// Extensions for method setup returning with 5 parameters. - /// - extension(global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder setup) - { - /// - /// Returns/throws forever. - /// - public void Forever() - { - setup.For(int.MaxValue); - } - - /// - /// Uses the return value only once. - /// - public global::Mockolate.Setup.IReturnMethodSetup OnlyOnce() - => setup.Only(1); - } - /// - /// Extensions for method callback setup returning void with 5 parameters. - /// - extension(global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder setup) - { - /// - /// Executes the callback only once. - /// - public global::Mockolate.Setup.IVoidMethodSetup OnlyOnce() - => setup.Only(1); - } - - /// - /// Extensions for method setup returning void with 5 parameters. - /// - extension(global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder setup) - { - /// - /// Returns/throws forever. - /// - public void Forever() - { - setup.For(int.MaxValue); - } - - /// - /// Uses the return value only once. - /// - public global::Mockolate.Setup.IVoidMethodSetup OnlyOnce() - => setup.Only(1); - } - /// - /// Extensions for method callback setup returning void with 7 parameters. - /// - extension(global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder setup) - { - /// - /// Executes the callback only once. - /// - public global::Mockolate.Setup.IVoidMethodSetup OnlyOnce() - => setup.Only(1); - } - - /// - /// Extensions for method setup returning void with 7 parameters. - /// - extension(global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder setup) - { - /// - /// Returns/throws forever. - /// - public void Forever() - { - setup.For(int.MaxValue); - } - - /// - /// Uses the return value only once. - /// - public global::Mockolate.Setup.IVoidMethodSetup OnlyOnce() - => setup.Only(1); - } - /// - /// Extensions for method callback setup returning with 17 parameters. - /// - extension(global::Mockolate.Setup.IReturnMethodSetupCallbackWhenBuilder setup) - { - /// - /// Executes the callback only once. - /// - public global::Mockolate.Setup.IReturnMethodSetup OnlyOnce() - => setup.Only(1); - } - - /// - /// Extensions for method setup returning with 17 parameters. - /// - extension(global::Mockolate.Setup.IReturnMethodSetupReturnWhenBuilder setup) - { - /// - /// Returns/throws forever. - /// - public void Forever() - { - setup.For(int.MaxValue); - } - - /// - /// Uses the return value only once. - /// - public global::Mockolate.Setup.IReturnMethodSetup OnlyOnce() - => setup.Only(1); - } - /// - /// Extensions for method callback setup returning void with 17 parameters. - /// - extension(global::Mockolate.Setup.IVoidMethodSetupCallbackWhenBuilder setup) - { - /// - /// Executes the callback only once. - /// - public global::Mockolate.Setup.IVoidMethodSetup OnlyOnce() - => setup.Only(1); - } - - /// - /// Extensions for method setup returning void with 17 parameters. - /// - extension(global::Mockolate.Setup.IVoidMethodSetupReturnWhenBuilder setup) - { - /// - /// Returns/throws forever. - /// - public void Forever() - { - setup.For(int.MaxValue); - } - - /// - /// Uses the return value only once. - /// - public global::Mockolate.Setup.IVoidMethodSetup OnlyOnce() - => setup.Only(1); - } - } -} -namespace Mockolate.Interactions -{ - /// - /// An invocation of a method with 5 parameters , , , and . - /// - [global::System.Diagnostics.DebuggerDisplay("{ToString()}")] - internal class MethodInvocation(string name, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5) : IMethodInteraction - { - /// - /// The name of the method. - /// - public string Name { get; } = name; - /// - /// The first parameter value of the method. - /// - public T1 Parameter1 { get; } = parameter1; - /// - /// The second parameter value of the method. - /// - public T2 Parameter2 { get; } = parameter2; - /// - /// The third parameter value of the method. - /// - public T3 Parameter3 { get; } = parameter3; - /// - /// The 4th parameter value of the method. - /// - public T4 Parameter4 { get; } = parameter4; - /// - /// The 5th parameter value of the method. - /// - public T5 Parameter5 { get; } = parameter5; - /// - public override string ToString() - { - return $"invoke method {SubstringAfterLast(Name, '.')}({Parameter1?.ToString() ?? "null"}, {Parameter2?.ToString() ?? "null"}, {Parameter3?.ToString() ?? "null"}, {Parameter4?.ToString() ?? "null"}, {Parameter5?.ToString() ?? "null"})"; - static string SubstringAfterLast(string name, char c) - { - int index = name.LastIndexOf(c); - return index >= 0 ? name.Substring(index + 1) : name; - } - } - } - /// - /// Per-member buffer for 5-parameter methods, synthesized for arity 5 use sites. - /// - [global::System.Diagnostics.DebuggerDisplay("{Count} method calls")] - internal sealed class FastMethod5Buffer : IFastMemberBuffer - { - private readonly FastMockInteractions _owner; -#if NET10_0_OR_GREATER - private readonly global::System.Threading.Lock _growLock = new(); -#else - private readonly object _growLock = new(); -#endif - private Record[] _records = new Record[4]; - private bool[] _verifiedSlots = new bool[4]; - private int _reserved; - private int _published; - - internal FastMethod5Buffer(FastMockInteractions owner) => _owner = owner; - - public int Count => global::System.Threading.Volatile.Read(ref _published); - - public void Append(string name, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5) - { - long seq = _owner.NextSequence(); - int slot = global::System.Threading.Interlocked.Increment(ref _reserved) - 1; - Record[] records = global::System.Threading.Volatile.Read(ref _records); - if (slot >= records.Length) records = GrowToFit(slot); - - records[slot].Seq = seq; - records[slot].Name = name; - records[slot].P1 = parameter1; - records[slot].P2 = parameter2; - records[slot].P3 = parameter3; - records[slot].P4 = parameter4; - records[slot].P5 = parameter5; - records[slot].Boxed = null; - global::System.Threading.Interlocked.Increment(ref _published); - - if (_owner.HasInteractionAddedSubscribers) _owner.RaiseAdded(); - } - - private Record[] GrowToFit(int slot) - { - lock (_growLock) - { - Record[] records = _records; - while (slot >= records.Length) - { - Record[] bigger = new Record[records.Length * 2]; - global::System.Array.Copy(records, bigger, records.Length); - records = bigger; - } - global::System.Threading.Volatile.Write(ref _records, records); - if (_verifiedSlots.Length < records.Length) - { - bool[] biggerBits = new bool[records.Length]; - global::System.Array.Copy(_verifiedSlots, biggerBits, _verifiedSlots.Length); - _verifiedSlots = biggerBits; - } - return records; - } - } - - public void Clear() - { - lock (_growLock) { global::System.Array.Clear(_records, 0, _published); _reserved = 0; global::System.Threading.Volatile.Write(ref _published, 0); global::System.Array.Clear(_verifiedSlots, 0, _verifiedSlots.Length); } - } - - void IFastMemberBuffer.AppendBoxed(global::System.Collections.Generic.List> dest) - { - lock (_growLock) - { - int n = _published; - Record[] records = _records; - for (int i = 0; i < n; i++) - { - ref Record r = ref records[i]; - r.Boxed ??= new MethodInvocation(r.Name, r.P1, r.P2, r.P3, r.P4, r.P5); - dest.Add(new global::System.ValueTuple(r.Seq, r.Boxed)); - } - } - } - - void IFastMemberBuffer.AppendBoxedUnverified(global::System.Collections.Generic.List> dest) - { - lock (_growLock) - { - int n = _published; - Record[] records = _records; - bool[] verified = _verifiedSlots; - for (int i = 0; i < n; i++) - { - if (verified[i]) continue; - ref Record r = ref records[i]; - r.Boxed ??= new MethodInvocation(r.Name, r.P1, r.P2, r.P3, r.P4, r.P5); - dest.Add(new global::System.ValueTuple(r.Seq, r.Boxed)); - } - } - } - - public int ConsumeMatching(global::Mockolate.Parameters.IParameterMatch match1, global::Mockolate.Parameters.IParameterMatch match2, global::Mockolate.Parameters.IParameterMatch match3, global::Mockolate.Parameters.IParameterMatch match4, global::Mockolate.Parameters.IParameterMatch match5) - { - int matches = 0; - lock (_growLock) - { - int n = _published; - Record[] records = _records; - bool[] verified = _verifiedSlots; - for (int i = 0; i < n; i++) - { - ref Record r = ref records[i]; - if (match1.Matches(r.P1) && match2.Matches(r.P2) && match3.Matches(r.P3) && match4.Matches(r.P4) && match5.Matches(r.P5)) - { - matches++; - verified[i] = true; - } - } - } - - return matches; - } - - private struct Record - { - public long Seq; - public string Name; - public T1 P1; - public T2 P2; - public T3 P3; - public T4 P4; - public T5 P5; - public IInteraction? Boxed; - } - } - /// - /// An invocation of a method with 7 parameters , , , , , and . - /// - [global::System.Diagnostics.DebuggerDisplay("{ToString()}")] - internal class MethodInvocation(string name, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7) : IMethodInteraction - { - /// - /// The name of the method. - /// - public string Name { get; } = name; - /// - /// The first parameter value of the method. - /// - public T1 Parameter1 { get; } = parameter1; - /// - /// The second parameter value of the method. - /// - public T2 Parameter2 { get; } = parameter2; - /// - /// The third parameter value of the method. - /// - public T3 Parameter3 { get; } = parameter3; - /// - /// The 4th parameter value of the method. - /// - public T4 Parameter4 { get; } = parameter4; - /// - /// The 5th parameter value of the method. - /// - public T5 Parameter5 { get; } = parameter5; - /// - /// The 6th parameter value of the method. - /// - public T6 Parameter6 { get; } = parameter6; - /// - /// The 7th parameter value of the method. - /// - public T7 Parameter7 { get; } = parameter7; - /// - public override string ToString() - { - return $"invoke method {SubstringAfterLast(Name, '.')}({Parameter1?.ToString() ?? "null"}, {Parameter2?.ToString() ?? "null"}, {Parameter3?.ToString() ?? "null"}, {Parameter4?.ToString() ?? "null"}, {Parameter5?.ToString() ?? "null"}, {Parameter6?.ToString() ?? "null"}, {Parameter7?.ToString() ?? "null"})"; - static string SubstringAfterLast(string name, char c) - { - int index = name.LastIndexOf(c); - return index >= 0 ? name.Substring(index + 1) : name; - } - } - } - /// - /// Per-member buffer for 7-parameter methods, synthesized for arity 7 use sites. - /// - [global::System.Diagnostics.DebuggerDisplay("{Count} method calls")] - internal sealed class FastMethod7Buffer : IFastMemberBuffer - { - private readonly FastMockInteractions _owner; -#if NET10_0_OR_GREATER - private readonly global::System.Threading.Lock _growLock = new(); -#else - private readonly object _growLock = new(); -#endif - private Record[] _records = new Record[4]; - private bool[] _verifiedSlots = new bool[4]; - private int _reserved; - private int _published; - - internal FastMethod7Buffer(FastMockInteractions owner) => _owner = owner; - - public int Count => global::System.Threading.Volatile.Read(ref _published); - - public void Append(string name, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7) - { - long seq = _owner.NextSequence(); - int slot = global::System.Threading.Interlocked.Increment(ref _reserved) - 1; - Record[] records = global::System.Threading.Volatile.Read(ref _records); - if (slot >= records.Length) records = GrowToFit(slot); - - records[slot].Seq = seq; - records[slot].Name = name; - records[slot].P1 = parameter1; - records[slot].P2 = parameter2; - records[slot].P3 = parameter3; - records[slot].P4 = parameter4; - records[slot].P5 = parameter5; - records[slot].P6 = parameter6; - records[slot].P7 = parameter7; - records[slot].Boxed = null; - global::System.Threading.Interlocked.Increment(ref _published); - - if (_owner.HasInteractionAddedSubscribers) _owner.RaiseAdded(); - } - - private Record[] GrowToFit(int slot) - { - lock (_growLock) - { - Record[] records = _records; - while (slot >= records.Length) - { - Record[] bigger = new Record[records.Length * 2]; - global::System.Array.Copy(records, bigger, records.Length); - records = bigger; - } - global::System.Threading.Volatile.Write(ref _records, records); - if (_verifiedSlots.Length < records.Length) - { - bool[] biggerBits = new bool[records.Length]; - global::System.Array.Copy(_verifiedSlots, biggerBits, _verifiedSlots.Length); - _verifiedSlots = biggerBits; - } - return records; - } - } - - public void Clear() - { - lock (_growLock) { global::System.Array.Clear(_records, 0, _published); _reserved = 0; global::System.Threading.Volatile.Write(ref _published, 0); global::System.Array.Clear(_verifiedSlots, 0, _verifiedSlots.Length); } - } - - void IFastMemberBuffer.AppendBoxed(global::System.Collections.Generic.List> dest) - { - lock (_growLock) - { - int n = _published; - Record[] records = _records; - for (int i = 0; i < n; i++) - { - ref Record r = ref records[i]; - r.Boxed ??= new MethodInvocation(r.Name, r.P1, r.P2, r.P3, r.P4, r.P5, r.P6, r.P7); - dest.Add(new global::System.ValueTuple(r.Seq, r.Boxed)); - } - } - } - - void IFastMemberBuffer.AppendBoxedUnverified(global::System.Collections.Generic.List> dest) - { - lock (_growLock) - { - int n = _published; - Record[] records = _records; - bool[] verified = _verifiedSlots; - for (int i = 0; i < n; i++) - { - if (verified[i]) continue; - ref Record r = ref records[i]; - r.Boxed ??= new MethodInvocation(r.Name, r.P1, r.P2, r.P3, r.P4, r.P5, r.P6, r.P7); - dest.Add(new global::System.ValueTuple(r.Seq, r.Boxed)); - } - } - } - - public int ConsumeMatching(global::Mockolate.Parameters.IParameterMatch match1, global::Mockolate.Parameters.IParameterMatch match2, global::Mockolate.Parameters.IParameterMatch match3, global::Mockolate.Parameters.IParameterMatch match4, global::Mockolate.Parameters.IParameterMatch match5, global::Mockolate.Parameters.IParameterMatch match6, global::Mockolate.Parameters.IParameterMatch match7) - { - int matches = 0; - lock (_growLock) - { - int n = _published; - Record[] records = _records; - bool[] verified = _verifiedSlots; - for (int i = 0; i < n; i++) - { - ref Record r = ref records[i]; - if (match1.Matches(r.P1) && match2.Matches(r.P2) && match3.Matches(r.P3) && match4.Matches(r.P4) && match5.Matches(r.P5) && match6.Matches(r.P6) && match7.Matches(r.P7)) - { - matches++; - verified[i] = true; - } - } - } - - return matches; - } - - private struct Record - { - public long Seq; - public string Name; - public T1 P1; - public T2 P2; - public T3 P3; - public T4 P4; - public T5 P5; - public T6 P6; - public T7 P7; - public IInteraction? Boxed; - } - } - /// - /// An invocation of a method with 17 parameters , , , , , , , , , , , , , , , and . - /// - [global::System.Diagnostics.DebuggerDisplay("{ToString()}")] - internal class MethodInvocation(string name, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7, T8 parameter8, T9 parameter9, T10 parameter10, T11 parameter11, T12 parameter12, T13 parameter13, T14 parameter14, T15 parameter15, T16 parameter16, T17 parameter17) : IMethodInteraction - { - /// - /// The name of the method. - /// - public string Name { get; } = name; - /// - /// The first parameter value of the method. - /// - public T1 Parameter1 { get; } = parameter1; - /// - /// The second parameter value of the method. - /// - public T2 Parameter2 { get; } = parameter2; - /// - /// The third parameter value of the method. - /// - public T3 Parameter3 { get; } = parameter3; - /// - /// The 4th parameter value of the method. - /// - public T4 Parameter4 { get; } = parameter4; - /// - /// The 5th parameter value of the method. - /// - public T5 Parameter5 { get; } = parameter5; - /// - /// The 6th parameter value of the method. - /// - public T6 Parameter6 { get; } = parameter6; - /// - /// The 7th parameter value of the method. - /// - public T7 Parameter7 { get; } = parameter7; - /// - /// The 8th parameter value of the method. - /// - public T8 Parameter8 { get; } = parameter8; - /// - /// The 9th parameter value of the method. - /// - public T9 Parameter9 { get; } = parameter9; - /// - /// The 10th parameter value of the method. - /// - public T10 Parameter10 { get; } = parameter10; - /// - /// The 11th parameter value of the method. - /// - public T11 Parameter11 { get; } = parameter11; - /// - /// The 12th parameter value of the method. - /// - public T12 Parameter12 { get; } = parameter12; - /// - /// The 13th parameter value of the method. - /// - public T13 Parameter13 { get; } = parameter13; - /// - /// The 14th parameter value of the method. - /// - public T14 Parameter14 { get; } = parameter14; - /// - /// The 15th parameter value of the method. - /// - public T15 Parameter15 { get; } = parameter15; - /// - /// The 16th parameter value of the method. - /// - public T16 Parameter16 { get; } = parameter16; - /// - /// The 17th parameter value of the method. - /// - public T17 Parameter17 { get; } = parameter17; - /// - public override string ToString() - { - return $"invoke method {SubstringAfterLast(Name, '.')}({Parameter1?.ToString() ?? "null"}, {Parameter2?.ToString() ?? "null"}, {Parameter3?.ToString() ?? "null"}, {Parameter4?.ToString() ?? "null"}, {Parameter5?.ToString() ?? "null"}, {Parameter6?.ToString() ?? "null"}, {Parameter7?.ToString() ?? "null"}, {Parameter8?.ToString() ?? "null"}, {Parameter9?.ToString() ?? "null"}, {Parameter10?.ToString() ?? "null"}, {Parameter11?.ToString() ?? "null"}, {Parameter12?.ToString() ?? "null"}, {Parameter13?.ToString() ?? "null"}, {Parameter14?.ToString() ?? "null"}, {Parameter15?.ToString() ?? "null"}, {Parameter16?.ToString() ?? "null"}, {Parameter17?.ToString() ?? "null"})"; - static string SubstringAfterLast(string name, char c) - { - int index = name.LastIndexOf(c); - return index >= 0 ? name.Substring(index + 1) : name; - } - } - } - /// - /// Per-member buffer for 17-parameter methods, synthesized for arity 17 use sites. - /// - [global::System.Diagnostics.DebuggerDisplay("{Count} method calls")] - internal sealed class FastMethod17Buffer : IFastMemberBuffer - { - private readonly FastMockInteractions _owner; -#if NET10_0_OR_GREATER - private readonly global::System.Threading.Lock _growLock = new(); -#else - private readonly object _growLock = new(); -#endif - private Record[] _records = new Record[4]; - private bool[] _verifiedSlots = new bool[4]; - private int _reserved; - private int _published; - - internal FastMethod17Buffer(FastMockInteractions owner) => _owner = owner; - - public int Count => global::System.Threading.Volatile.Read(ref _published); - - public void Append(string name, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7, T8 parameter8, T9 parameter9, T10 parameter10, T11 parameter11, T12 parameter12, T13 parameter13, T14 parameter14, T15 parameter15, T16 parameter16, T17 parameter17) - { - long seq = _owner.NextSequence(); - int slot = global::System.Threading.Interlocked.Increment(ref _reserved) - 1; - Record[] records = global::System.Threading.Volatile.Read(ref _records); - if (slot >= records.Length) records = GrowToFit(slot); - - records[slot].Seq = seq; - records[slot].Name = name; - records[slot].P1 = parameter1; - records[slot].P2 = parameter2; - records[slot].P3 = parameter3; - records[slot].P4 = parameter4; - records[slot].P5 = parameter5; - records[slot].P6 = parameter6; - records[slot].P7 = parameter7; - records[slot].P8 = parameter8; - records[slot].P9 = parameter9; - records[slot].P10 = parameter10; - records[slot].P11 = parameter11; - records[slot].P12 = parameter12; - records[slot].P13 = parameter13; - records[slot].P14 = parameter14; - records[slot].P15 = parameter15; - records[slot].P16 = parameter16; - records[slot].P17 = parameter17; - records[slot].Boxed = null; - global::System.Threading.Interlocked.Increment(ref _published); - - if (_owner.HasInteractionAddedSubscribers) _owner.RaiseAdded(); - } - - private Record[] GrowToFit(int slot) - { - lock (_growLock) - { - Record[] records = _records; - while (slot >= records.Length) - { - Record[] bigger = new Record[records.Length * 2]; - global::System.Array.Copy(records, bigger, records.Length); - records = bigger; - } - global::System.Threading.Volatile.Write(ref _records, records); - if (_verifiedSlots.Length < records.Length) - { - bool[] biggerBits = new bool[records.Length]; - global::System.Array.Copy(_verifiedSlots, biggerBits, _verifiedSlots.Length); - _verifiedSlots = biggerBits; - } - return records; - } - } - - public void Clear() - { - lock (_growLock) { global::System.Array.Clear(_records, 0, _published); _reserved = 0; global::System.Threading.Volatile.Write(ref _published, 0); global::System.Array.Clear(_verifiedSlots, 0, _verifiedSlots.Length); } - } - - void IFastMemberBuffer.AppendBoxed(global::System.Collections.Generic.List> dest) - { - lock (_growLock) - { - int n = _published; - Record[] records = _records; - for (int i = 0; i < n; i++) - { - ref Record r = ref records[i]; - r.Boxed ??= new MethodInvocation(r.Name, r.P1, r.P2, r.P3, r.P4, r.P5, r.P6, r.P7, r.P8, r.P9, r.P10, r.P11, r.P12, r.P13, r.P14, r.P15, r.P16, r.P17); - dest.Add(new global::System.ValueTuple(r.Seq, r.Boxed)); - } - } - } - - void IFastMemberBuffer.AppendBoxedUnverified(global::System.Collections.Generic.List> dest) - { - lock (_growLock) - { - int n = _published; - Record[] records = _records; - bool[] verified = _verifiedSlots; - for (int i = 0; i < n; i++) - { - if (verified[i]) continue; - ref Record r = ref records[i]; - r.Boxed ??= new MethodInvocation(r.Name, r.P1, r.P2, r.P3, r.P4, r.P5, r.P6, r.P7, r.P8, r.P9, r.P10, r.P11, r.P12, r.P13, r.P14, r.P15, r.P16, r.P17); - dest.Add(new global::System.ValueTuple(r.Seq, r.Boxed)); - } - } - } - - public int ConsumeMatching(global::Mockolate.Parameters.IParameterMatch match1, global::Mockolate.Parameters.IParameterMatch match2, global::Mockolate.Parameters.IParameterMatch match3, global::Mockolate.Parameters.IParameterMatch match4, global::Mockolate.Parameters.IParameterMatch match5, global::Mockolate.Parameters.IParameterMatch match6, global::Mockolate.Parameters.IParameterMatch match7, global::Mockolate.Parameters.IParameterMatch match8, global::Mockolate.Parameters.IParameterMatch match9, global::Mockolate.Parameters.IParameterMatch match10, global::Mockolate.Parameters.IParameterMatch match11, global::Mockolate.Parameters.IParameterMatch match12, global::Mockolate.Parameters.IParameterMatch match13, global::Mockolate.Parameters.IParameterMatch match14, global::Mockolate.Parameters.IParameterMatch match15, global::Mockolate.Parameters.IParameterMatch match16, global::Mockolate.Parameters.IParameterMatch match17) - { - int matches = 0; - lock (_growLock) - { - int n = _published; - Record[] records = _records; - bool[] verified = _verifiedSlots; - for (int i = 0; i < n; i++) - { - ref Record r = ref records[i]; - if (match1.Matches(r.P1) && match2.Matches(r.P2) && match3.Matches(r.P3) && match4.Matches(r.P4) && match5.Matches(r.P5) && match6.Matches(r.P6) && match7.Matches(r.P7) && match8.Matches(r.P8) && match9.Matches(r.P9) && match10.Matches(r.P10) && match11.Matches(r.P11) && match12.Matches(r.P12) && match13.Matches(r.P13) && match14.Matches(r.P14) && match15.Matches(r.P15) && match16.Matches(r.P16) && match17.Matches(r.P17)) - { - matches++; - verified[i] = true; - } - } - } - - return matches; - } - - private struct Record - { - public long Seq; - public string Name; - public T1 P1; - public T2 P2; - public T3 P3; - public T4 P4; - public T5 P5; - public T6 P6; - public T7 P7; - public T8 P8; - public T9 P9; - public T10 P10; - public T11 P11; - public T12 P12; - public T13 P13; - public T14 P14; - public T15 P15; - public T16 P16; - public T17 P17; - public IInteraction? Boxed; - } - } -} - -#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/Mock.g.cs deleted file mode 100644 index 3944360b..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/Mock.g.cs +++ /dev/null @@ -1,135 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable -/// -/// Create new mocks by calling the static T.CreateMock() method on your type T. -/// -/// -/// You can also provide a MockBehavior parameter to customize how the mock should behave in certain scenarios.
-/// If your type is a class without a default constructor, you can provide constructor parameters by passing an object?[]? to the corresponding CreateMock(...) overload. -///
-[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static partial class Mock -{ - /// - /// This interface should never be used. If it is, this is an indication that the Mockolate source generator did not run correctly or that the used type is not mockable. - /// - /// - /// The source generator creates overloads with correct return values. - /// - internal interface IMockGenerationDidNotRun {} - - /// - /// Create a new mock of with the default MockBehavior. - /// - /// Type to mock, which can be an interface or a class. - /// - /// Any interface type can be used for mocking, but for classes, only abstract and virtual members can be mocked. - /// - extension(T _) - { - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior = null) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior, object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - } - - extension(global::Mockolate.Mock.IMockGenerationDidNotRun _) - { - /// - /// Fallback Implementing that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Additional interface the mock should implement. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete Implementing overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public global::Mockolate.Mock.IMockGenerationDidNotRun Implementing() where TInterface : class - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(TInterface)}' is not mockable or the source generator did not run correctly."); - } - } - -} - -/// -/// Adapts an IParameter (non-generic) to -/// IParameterMatch<T> so that covariant parameter -/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> -/// slot) can still be invoked at setup/verify time. Only allocated when the direct -/// IParameterMatch<T> cast fails. Shared by every -/// generated mock file. -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch -{ - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); -} -#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/MockBehaviorExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/MockBehaviorExtensions.g.cs deleted file mode 100644 index 888d2c2c..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/MockBehaviorExtensions.g.cs +++ /dev/null @@ -1,285 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable annotations - -/// -/// Extensions for MockBehavior. -/// -internal static partial class Mock -{ - private static readonly global::Mockolate.MockBehavior _default; - - static Mock() - { - _default = new global::Mockolate.MockBehavior(new DefaultValueGenerator()); - } - - extension(global::Mockolate.MockBehavior) - { - /// - /// The default MockBehavior - the starting point for configuring a mock. - /// - /// - /// Un-configured members return the generator-provided default value (empty strings/collections, completed - /// Tasks, otherwise), base-class - /// implementations run for class mocks, and every invocation is recorded for later verification. - /// - /// Chain SkippingBaseClass(), ThrowingWhenNotSetup(), SkippingInteractionRecording(), - /// WithDefaultValueFor<T>(...) or UseConstructorParametersFor<T>(...) to derive - /// a customized MockBehavior; because it is a , - /// each call returns a new instance and this shared default stays unchanged. - /// - public static global::Mockolate.MockBehavior Default => _default; - } - - /// - /// Defines a factory for creating default values for a specified type. - /// - public interface IDefaultValueFactory - { - /// - /// Determines whether the specified can be created by this factory. - /// - bool IsMatch(global::System.Type type); - - /// - /// Creates a new instance of the specified type. - /// - object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, object?[] parameters); - } - - /// - /// A IDefaultValueFactory that returns a specified for the given type - /// parameter . - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal class TypedDefaultValueFactory(T value) : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(T); - - /// - public object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - => value; - } - - /// - /// Provides default values for common types used in mocking scenarios. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private class DefaultValueGenerator : IDefaultValueGenerator - { - private static readonly global::System.Collections.Concurrent.ConcurrentQueue _factories = new([ - new TypedDefaultValueFactory(""), - new CancellableTaskFactory(), - #if NET8_0_OR_GREATER - new CancellableValueTaskFactory(), - #endif - new TypedDefaultValueFactory(global::System.Threading.CancellationToken.None), - new TypedDefaultValueFactory(global::System.Array.Empty()), - ]); - - /// - public object? GenerateValue(global::System.Type type, params object?[] parameters) - { - if (TryGenerate(type, parameters, out object? value)) - { - return value; - } - - return null; - } - - /// - /// Registers a to provide default values for a specific type. - /// - public static void Register(IDefaultValueFactory defaultValueFactory) - => _factories.Enqueue(defaultValueFactory); - - /// - /// Tries to generate a default value for the specified type. - /// - protected virtual bool TryGenerate(global::System.Type type, object?[] parameters, out object? value) - { - IDefaultValueFactory? matchingFactory = global::System.Linq.Enumerable.FirstOrDefault(_factories, Predicate); - if (matchingFactory is not null) - { - value = matchingFactory.Create(type, this, parameters); - return true; - } - - value = null; - return false; - - bool Predicate(global::Mockolate.Mock.IDefaultValueFactory f) - => f.IsMatch(type); - } - - private static bool HasCanceledCancellationToken(object?[] parameters, out global::System.Threading.CancellationToken cancellationToken) - { - global::System.Threading.CancellationToken parameter = global::System.Linq.Enumerable.FirstOrDefault(global::System.Linq.Enumerable.OfType(parameters)); - if (parameter.IsCancellationRequested) - { - cancellationToken = parameter; - return true; - } - - cancellationToken = global::System.Threading.CancellationToken.None; - return false; - } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CancellableTaskFactory : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Threading.Tasks.Task); - - /// - public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - { - if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) - { - return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.Task.CompletedTask; - } - } - #if NET8_0_OR_GREATER - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CancellableValueTaskFactory : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Threading.Tasks.ValueTask); - - /// - public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - { - if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) - { - return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.ValueTask.CompletedTask; - } - } - #endif - } -} - -/// -/// Extensions on IDefaultValueGenerator -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static class DefaultValueGeneratorExtensions -{ - /// - /// Adds a generic Generate method for specific types. - /// - extension(IDefaultValueGenerator generator) - { - /// - /// Generates a Task of , with - /// the for context. - /// - public global::System.Threading.Tasks.Task Generate(global::System.Threading.Tasks.Task nullValue, T value, params object?[] parameters) - { - global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( - global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; - if (cancellationToken.IsCancellationRequested) - { - return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.Task.FromResult(value); - } - -#if NET8_0_OR_GREATER - /// - /// Generates a ValueTask of , with - /// the for context. - /// - public global::System.Threading.Tasks.ValueTask Generate(global::System.Threading.Tasks.ValueTask nullValue, T value, params object?[] parameters) - { - global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( - global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; - if (cancellationToken.IsCancellationRequested) - { - return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.ValueTask.FromResult(value); - } -#endif - - /// - /// Generates an empty enumerable of , with - /// the for context. - /// - public global::System.Collections.Generic.IEnumerable Generate(global::System.Collections.Generic.IEnumerable nullValue, params object?[] parameters) - => global::System.Array.Empty(); - - /// - /// Generates an empty enumerable of , with - /// the for context. - /// - public global::System.Collections.Generic.List Generate(global::System.Collections.Generic.List nullValue, params object?[] parameters) - => new global::System.Collections.Generic.List(); - - /// - /// Generates an empty array of , with - /// the for context. - /// - public T[] Generate(T[] nullValue, params object?[] parameters) - => global::System.Array.Empty(); - - /// - /// Generates an empty two-dimensional array of , with - /// the for context. - /// - public T[,] Generate(T[,] nullValue, params object?[] parameters) - => new T[,] { }; - - /// - /// Generates an empty three-dimensional array of , with - /// the for context. - /// - public T[,,] Generate(T[,,] nullValue, params object?[] parameters) - => new T[,,] { }; - - /// - /// Generates an empty four-dimensional array of , with - /// the for context. - /// - public T[,,,] Generate(T[,,,] nullValue, params object?[] parameters) - => new T[,,,] { }; - - /// - /// Generates a default value of type , with - /// the for context. - /// - public T Generate(T nullValue, params object?[] parameters) - { - if (generator.GenerateValue(typeof(T), parameters) is T value) - { - return value; - } - - return nullValue; - } - } -} - -#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ParameterArg.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ParameterArg.g.cs deleted file mode 100644 index 284fbf66..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ParameterArg.g.cs +++ /dev/null @@ -1,126 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -#nullable enable - -namespace Mockolate -{ - /// - /// A setup or verify argument that is either an It matcher - /// (IParameter<T>) or a literal value of type . - /// - /// - /// Both case types convert implicitly, so Setup.Method(42) and Setup.Method(It.IsAny<int>()) - /// bind to the same overload. A instance stands for the literal default(T). - /// - [global::System.Runtime.CompilerServices.Union] - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal readonly struct ParameterArg - { - private const byte MatcherTag = 1; - private const byte LiteralTag = 2; - - private readonly global::Mockolate.Parameters.IParameter? _matcher; - private readonly T? _literal; - private readonly byte _tag; - - /// - /// Creates the matcher case. - /// - public ParameterArg(global::Mockolate.Parameters.IParameter matcher) - { - _matcher = matcher; - _literal = default; - _tag = MatcherTag; - } - - /// - /// Creates the literal value case. - /// - public ParameterArg(T? literal) - { - _matcher = null; - _literal = literal; - _tag = LiteralTag; - } - - /// - /// The contained matcher or literal value, boxed. Part of the union pattern; the generated mocks use the - /// typed accessors instead. - /// - public object? Value => _tag switch - { - MatcherTag => _matcher, - LiteralTag => _literal, - _ => null, - }; - - /// - /// unless this is the instance. - /// - public bool HasValue => _tag != 0; - - /// - /// when the argument is a literal value (including the instance). - /// - public bool IsLiteral => _tag != MatcherTag; - - /// - /// The literal value; default(T) for the matcher case and the instance. - /// - public T? Literal => _literal; - - /// - /// Gets the matcher, when this is the matcher case. - /// - public bool TryGetValue(out global::Mockolate.Parameters.IParameter? matcher) - { - matcher = _matcher; - return _tag == MatcherTag; - } - - /// - /// Gets the literal value, when this is the literal case. - /// - public bool TryGetValue(out T? literal) - { - literal = _literal; - return _tag == LiteralTag; - } - - /// - /// The IParameterMatch<T> for this argument: the matcher itself, - /// or an equality match for the literal value. - /// - public global::Mockolate.Parameters.IParameterMatch ToParameterMatch() - { - if (_tag != MatcherTag) - { - return (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(_literal!); - } - - if (_matcher is null) - { - return (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsNull("null"); - } - - return _matcher is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new global::Mockolate.CovariantParameterAdapter(_matcher); - } - - /// - public override string ToString() => _tag switch - { - MatcherTag => _matcher?.ToString() ?? "null", - _ => _literal?.ToString() ?? "null", - }; - } -} -#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ReturnsThrowsAsyncExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ReturnsThrowsAsyncExtensions.g.cs deleted file mode 100644 index 9a4ac933..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/ReturnsThrowsAsyncExtensions.g.cs +++ /dev/null @@ -1,288 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable - -/// -/// Extensions for setting up return values and throwing exceptions for methods. -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static class ReturnsThrowsAsyncExtensions2 -{ - /// - /// Appends to the sequence - the next matching invocation returns a completed - /// Task<TReturn> carrying this value. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5> setup, TReturn returnValue) - => setup.Returns(global::System.Threading.Tasks.Task.FromResult(returnValue)); - - /// - /// Appends a lazy async return to the sequence; is invoked on each matching - /// invocation and its result is wrapped in a completed Task<TReturn>. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5> setup, global::System.Func callback) - => setup.Returns(() => global::System.Threading.Tasks.Task.FromResult(callback())); - - /// - /// Appends a lazy async return that receives the method's arguments and produces the value wrapped in a - /// completed Task<TReturn>. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5> setup, global::System.Func callback) - => setup.Returns((v1, v2, v3, v4, v5) => global::System.Threading.Tasks.Task.FromResult(callback(v1, v2, v3, v4, v5))); - - /// - /// Appends an entry that faults the returned Task<TReturn> with - /// so awaiting it throws. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5> setup, global::System.Exception exception) - => setup.Returns(global::System.Threading.Tasks.Task.FromException(exception)); - - /// - /// Appends an entry that invokes to build the exception the returned - /// Task<TReturn> is faulted with. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5> setup, global::System.Func callback) - => setup.Returns(() => global::System.Threading.Tasks.Task.FromException(callback())); - - /// - /// Appends an entry that invokes with the method's arguments to build the - /// exception the returned Task<TReturn> is faulted with. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5> setup, global::System.Func callback) - => setup.Returns((v1, v2, v3, v4, v5) => global::System.Threading.Tasks.Task.FromException(callback(v1, v2, v3, v4, v5))); - - /// - /// Appends to the sequence - the next matching invocation returns a completed - /// Task<TReturn> carrying this value. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, TReturn returnValue) - => setup.Returns(global::System.Threading.Tasks.Task.FromResult(returnValue)); - - /// - /// Appends a lazy async return to the sequence; is invoked on each matching - /// invocation and its result is wrapped in a completed Task<TReturn>. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, global::System.Func callback) - => setup.Returns(() => global::System.Threading.Tasks.Task.FromResult(callback())); - - /// - /// Appends a lazy async return that receives the method's arguments and produces the value wrapped in a - /// completed Task<TReturn>. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, global::System.Func callback) - => setup.Returns((v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) => global::System.Threading.Tasks.Task.FromResult(callback(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17))); - - /// - /// Appends an entry that faults the returned Task<TReturn> with - /// so awaiting it throws. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, global::System.Exception exception) - => setup.Returns(global::System.Threading.Tasks.Task.FromException(exception)); - - /// - /// Appends an entry that invokes to build the exception the returned - /// Task<TReturn> is faulted with. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, global::System.Func callback) - => setup.Returns(() => global::System.Threading.Tasks.Task.FromException(callback())); - - /// - /// Appends an entry that invokes with the method's arguments to build the - /// exception the returned Task<TReturn> is faulted with. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, global::System.Func callback) - => setup.Returns((v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) => global::System.Threading.Tasks.Task.FromException(callback(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17))); - -#if NET8_0_OR_GREATER - - /// - /// Appends to the sequence - the next matching invocation returns a completed - /// ValueTask<TReturn> carrying this value. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5> setup, TReturn returnValue) - => setup.Returns(global::System.Threading.Tasks.ValueTask.FromResult(returnValue)); - - /// - /// Appends a lazy async return to the sequence; is invoked on each matching - /// invocation and its result is wrapped in a completed ValueTask<TReturn>. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5> setup, global::System.Func callback) - => setup.Returns(() => global::System.Threading.Tasks.ValueTask.FromResult(callback())); - - /// - /// Appends a lazy async return that receives the method's arguments and produces the value wrapped in a - /// completed ValueTask<TReturn>. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5> setup, global::System.Func callback) - => setup.Returns((v1, v2, v3, v4, v5) => global::System.Threading.Tasks.ValueTask.FromResult(callback(v1, v2, v3, v4, v5))); - - /// - /// Appends an entry that faults the returned ValueTask<TReturn> with - /// so awaiting it throws. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5> setup, global::System.Exception exception) - => setup.Returns(global::System.Threading.Tasks.ValueTask.FromException(exception)); - - /// - /// Appends an entry that invokes to build the exception the returned - /// ValueTask<TReturn> is faulted with. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5> setup, global::System.Func callback) - => setup.Returns(() => global::System.Threading.Tasks.ValueTask.FromException(callback())); - - /// - /// Appends an entry that invokes with the method's arguments to build the - /// exception the returned ValueTask<TReturn> is faulted with. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5> setup, global::System.Func callback) - => setup.Returns((v1, v2, v3, v4, v5) => global::System.Threading.Tasks.ValueTask.FromException(callback(v1, v2, v3, v4, v5))); - - /// - /// Appends to the sequence - the next matching invocation returns a completed - /// ValueTask<TReturn> carrying this value. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, TReturn returnValue) - => setup.Returns(global::System.Threading.Tasks.ValueTask.FromResult(returnValue)); - - /// - /// Appends a lazy async return to the sequence; is invoked on each matching - /// invocation and its result is wrapped in a completed ValueTask<TReturn>. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, global::System.Func callback) - => setup.Returns(() => global::System.Threading.Tasks.ValueTask.FromResult(callback())); - - /// - /// Appends a lazy async return that receives the method's arguments and produces the value wrapped in a - /// completed ValueTask<TReturn>. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ReturnsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, global::System.Func callback) - => setup.Returns((v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) => global::System.Threading.Tasks.ValueTask.FromResult(callback(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17))); - - /// - /// Appends an entry that faults the returned ValueTask<TReturn> with - /// so awaiting it throws. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, global::System.Exception exception) - => setup.Returns(global::System.Threading.Tasks.ValueTask.FromException(exception)); - - /// - /// Appends an entry that invokes to build the exception the returned - /// ValueTask<TReturn> is faulted with. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetup, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, global::System.Func callback) - => setup.Returns(() => global::System.Threading.Tasks.ValueTask.FromException(callback())); - - /// - /// Appends an entry that invokes with the method's arguments to build the - /// exception the returned ValueTask<TReturn> is faulted with. - /// - /// - /// Call ReturnsAsync/ThrowsAsync multiple times to build a sequence; once exhausted it cycles - /// back to the first entry unless the last one is followed by .Forever(). - /// - public static global::Mockolate.Setup.IReturnMethodSetupReturnBuilder, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> ThrowsAsync(this global::Mockolate.Setup.IReturnMethodSetupWithCallback, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> setup, global::System.Func callback) - => setup.Returns((v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) => global::System.Threading.Tasks.ValueTask.FromException(callback(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17))); - -#endif -} -#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/_shared.txt b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/_shared.txt new file mode 100644 index 00000000..3ad919ac --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated_Unions/_shared.txt @@ -0,0 +1,7 @@ +ActionFunc.g.cs|ActionFunc.g.cs +IndexerSetups.g.cs|IndexerSetups.d958f396.g.cs +MethodSetups.g.cs|MethodSetups.0483b407.g.cs +Mock.g.cs|Mock.g.cs +MockBehaviorExtensions.g.cs|MockBehaviorExtensions.g.cs +ParameterArg.g.cs|ParameterArg.g.cs +ReturnsThrowsAsyncExtensions.g.cs|ReturnsThrowsAsyncExtensions.dd90b829.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated/Mock.g.cs deleted file mode 100644 index 3944360b..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated/Mock.g.cs +++ /dev/null @@ -1,135 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable -/// -/// Create new mocks by calling the static T.CreateMock() method on your type T. -/// -/// -/// You can also provide a MockBehavior parameter to customize how the mock should behave in certain scenarios.
-/// If your type is a class without a default constructor, you can provide constructor parameters by passing an object?[]? to the corresponding CreateMock(...) overload. -///
-[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static partial class Mock -{ - /// - /// This interface should never be used. If it is, this is an indication that the Mockolate source generator did not run correctly or that the used type is not mockable. - /// - /// - /// The source generator creates overloads with correct return values. - /// - internal interface IMockGenerationDidNotRun {} - - /// - /// Create a new mock of with the default MockBehavior. - /// - /// Type to mock, which can be an interface or a class. - /// - /// Any interface type can be used for mocking, but for classes, only abstract and virtual members can be mocked. - /// - extension(T _) - { - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior = null) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior, object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - } - - extension(global::Mockolate.Mock.IMockGenerationDidNotRun _) - { - /// - /// Fallback Implementing that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Additional interface the mock should implement. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete Implementing overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public global::Mockolate.Mock.IMockGenerationDidNotRun Implementing() where TInterface : class - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(TInterface)}' is not mockable or the source generator did not run correctly."); - } - } - -} - -/// -/// Adapts an IParameter (non-generic) to -/// IParameterMatch<T> so that covariant parameter -/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> -/// slot) can still be invoked at setup/verify time. Only allocated when the direct -/// IParameterMatch<T> cast fails. Shared by every -/// generated mock file. -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch -{ - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); -} -#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated/_shared.txt b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated/_shared.txt new file mode 100644 index 00000000..c5ee181f --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated/_shared.txt @@ -0,0 +1 @@ +Mock.g.cs|Mock.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpClient.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpClient.g.cs deleted file mode 100644 index 5de0bc29..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpClient.g.cs +++ /dev/null @@ -1,1810 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -#nullable enable annotations -namespace Mockolate; - -internal static partial class Mock -{ - /// - /// A mock implementation for HttpClient. - /// - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal class HttpClient : - global::System.Net.Http.HttpClient, IMockForHttpClient, IMockSetupForHttpClient, IMockProtectedSetupForHttpClient, global::Mockolate.MockExtensionsForHttpClient.IMockSetupInitializationForHttpClient, IMockVerifyForHttpClient, IMockProtectedVerifyForHttpClient, - global::Mockolate.IMock - { - internal const int MemberId_Send = 0; - internal const int MemberId_SendAsync = 1; - internal const int MemberId_Dispose = 2; - internal const int MemberCount = 3; - - /// - /// Creates a FastMockInteractions sized to MemberCount for use as the mock's interaction store. - /// Per-member buffers are not allocated up-front: the recording hot paths call GetOrCreateBuffer<TBuffer>(int, Func<FastMockInteractions, TBuffer>) so a slot is materialized only when its member is first invoked. - /// - internal static global::Mockolate.Interactions.FastMockInteractions CreateFastInteractions(global::Mockolate.MockBehavior behavior) - => new global::Mockolate.Interactions.FastMockInteractions(MemberCount, behavior.SkipInteractionRecording); - - /// - /// Builds a MockRegistry backed by a typed-buffer-sized FastMockInteractions from . - /// - private static global::Mockolate.MockRegistry MockolateCreateRegistryFromBehavior(global::Mockolate.MockBehavior behavior) - { - global::Mockolate.MockRegistry registry = new global::Mockolate.MockRegistry(behavior, MemberCount); - MockRegistryProvider.Value = registry; - return registry; - } - - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.MockRegistry global::Mockolate.IMock.MockRegistry => this.MockRegistry; - private global::Mockolate.MockRegistry MockRegistry - { - get => field ?? MockRegistryProvider.Value; - set; - } - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - internal static readonly global::System.Threading.AsyncLocal MockRegistryProvider = new global::System.Threading.AsyncLocal(); - - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - private global::Mockolate.Interactions.FastMethod2Buffer MockolateBuffer_Send - => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.HttpClient.MemberId_Send, static fast => new global::Mockolate.Interactions.FastMethod2Buffer(fast))); - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - private global::Mockolate.Interactions.FastMethod2Buffer MockolateBuffer_SendAsync - => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, static fast => new global::Mockolate.Interactions.FastMethod2Buffer(fast))); - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - private global::Mockolate.Interactions.FastMethod1Buffer MockolateBuffer_Dispose - => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.HttpClient.MemberId_Dispose, static fast => new global::Mockolate.Interactions.FastMethod1Buffer(fast))); - - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - IMockSetupForHttpClient IMockForHttpClient.Setup - => this; - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - IMockProtectedSetupForHttpClient IMockForHttpClient.SetupProtected - => this; - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - IMockProtectedSetupForHttpClient global::Mockolate.MockExtensionsForHttpClient.IMockSetupInitializationForHttpClient.Protected - => this; - /// - IMockInScenarioForHttpClient IMockForHttpClient.InScenario(string scenario) - => new MockInScenarioForHttpClient(this.MockRegistry, scenario); - - /// - IMockForHttpClient IMockForHttpClient.InScenario(string scenario, global::System.Action setup) - { - setup.Invoke(new MockInScenarioForHttpClient(this.MockRegistry, scenario)); - return this; - } - - /// - IMockForHttpClient IMockForHttpClient.TransitionTo(string scenario) - { - this.MockRegistry.TransitionTo(scenario); - return this; - } - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - IMockVerifyForHttpClient IMockForHttpClient.Verify - => this; - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - IMockProtectedVerifyForHttpClient IMockForHttpClient.VerifyProtected - => this; - /// - global::Mockolate.Verify.VerificationResult IMockForHttpClient.VerifySetup(global::Mockolate.Setup.IMethodSetup setup) - => this.MockRegistry.Method(this, setup); - /// - bool IMockForHttpClient.VerifyThatAllInteractionsAreVerified() - => this.MockRegistry.Interactions.GetUnverifiedInteractions().Count == 0; - /// - bool IMockForHttpClient.VerifyThatAllSetupsAreUsed() - => this.MockRegistry.GetUnusedSetups(this.MockRegistry.Interactions).Count == 0; - /// - void IMockForHttpClient.ClearAllInteractions() - => this.MockRegistry.ClearAllInteractions(); - /// - global::Mockolate.Monitor.MockMonitor IMockForHttpClient.Monitor() - => new global::Mockolate.Monitor.MockMonitor(this.MockRegistry.Interactions, interactions => new VerifyMonitorHttpClient(new global::Mockolate.MockRegistry(this.MockRegistry, interactions))); - - /// - string global::Mockolate.IMock.ToString() - => "System.Net.Http.HttpClient mock"; - - /// - public HttpClient(global::Mockolate.MockRegistry mockRegistry) - : base() - { - this.MockRegistry = mockRegistry; - } - - /// - public HttpClient(global::Mockolate.MockBehavior behavior) - : this(MockolateCreateRegistryFromBehavior(behavior)) - { - } - - /// - public HttpClient(global::Mockolate.MockRegistry mockRegistry, global::System.Net.Http.HttpMessageHandler handler) - : base(handler) - { - this.MockRegistry = mockRegistry; - } - - /// - public HttpClient(global::Mockolate.MockBehavior behavior, global::System.Net.Http.HttpMessageHandler handler) - : this(MockolateCreateRegistryFromBehavior(behavior), handler) - { - } - - /// - public HttpClient(global::Mockolate.MockRegistry mockRegistry, global::System.Net.Http.HttpMessageHandler handler, bool disposeHandler) - : base(handler, disposeHandler) - { - this.MockRegistry = mockRegistry; - } - - /// - public HttpClient(global::Mockolate.MockBehavior behavior, global::System.Net.Http.HttpMessageHandler handler, bool disposeHandler) - : this(MockolateCreateRegistryFromBehavior(behavior), handler, disposeHandler) - { - } - - #region System.Net.Http.HttpClient - - /// - [global::System.Runtime.Versioning.UnsupportedOSPlatform("android")] - [global::System.Runtime.Versioning.UnsupportedOSPlatform("browser")] - [global::System.Runtime.Versioning.UnsupportedOSPlatform("ios")] - [global::System.Runtime.Versioning.UnsupportedOSPlatform("tvos")] - public override global::System.Net.Http.HttpResponseMessage Send(global::System.Net.Http.HttpRequestMessage request, global::System.Threading.CancellationToken cancellationToken) - { - global::Mockolate.Setup.ReturnMethodSetup? methodSetup = null; - if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) - { - global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.HttpClient.MemberId_Send); - 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(request, cancellationToken)) - { - methodSetup = s_methodSetup; - break; - } - } - } - } - if (methodSetup is null) - { - foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::System.Net.Http.HttpMessageInvoker.Send")) - { - if (s_methodSetup.Matches(request, cancellationToken)) - { - methodSetup = s_methodSetup; - break; - } - } - } - bool hasWrappedResult = false; - global::System.Net.Http.HttpResponseMessage wrappedResult = default!; - if (this.MockRegistry.Behavior.SkipInteractionRecording == false) - { - this.MockolateBuffer_Send.Append("global::System.Net.Http.HttpMessageInvoker.Send", request, cancellationToken); - } - try - { - if (this.MockRegistry.Wraps is global::System.Net.Http.HttpClient wraps) - { - wrappedResult = wraps.Send(request, cancellationToken); - hasWrappedResult = true; - } - #if NETFRAMEWORK - // Persist the HttpContent, because it gets automatically disposed on .NET Framework - if (request.Content != null) - { - var stream = request.Content.ReadAsStreamAsync().ConfigureAwait(false).GetAwaiter().GetResult(); - using global::System.IO.MemoryStream ms = new(); - stream.CopyTo(ms); - byte[] bytes = ms.ToArray(); - stream.Position = 0L; - request.Properties.Add("Mockolate:HttpContent", bytes); - } - #endif - if (!(methodSetup?.SkipBaseClass(this.MockRegistry.Behavior) ?? this.MockRegistry.Behavior.SkipBaseClass) && !hasWrappedResult) - { - wrappedResult = base.Send(request, cancellationToken); - hasWrappedResult = true; - } - } - finally - { - methodSetup?.TriggerCallbacks(request, cancellationToken); - } - if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) - { - throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::System.Net.Http.HttpMessageInvoker.Send(HttpRequestMessage, CancellationToken)' was invoked without prior setup."); - } - if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) - { - return wrappedResult; - } - return methodSetup?.TryGetReturnValue(request, cancellationToken, out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(global::System.Net.Http.HttpResponseMessage)!, request, cancellationToken); - } - - /// - public override global::System.Threading.Tasks.Task SendAsync(global::System.Net.Http.HttpRequestMessage request, global::System.Threading.CancellationToken cancellationToken) - { - global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>? methodSetup = null; - if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) - { - global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.HttpClient.MemberId_SendAsync); - 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, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> s_methodSetup && s_methodSetup.Matches(request, cancellationToken)) - { - methodSetup = s_methodSetup; - break; - } - } - } - } - if (methodSetup is null) - { - foreach (global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> s_methodSetup in this.MockRegistry.GetMethodSetups, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>>("global::System.Net.Http.HttpMessageInvoker.SendAsync")) - { - if (s_methodSetup.Matches(request, cancellationToken)) - { - methodSetup = s_methodSetup; - break; - } - } - } - bool hasWrappedResult = false; - global::System.Threading.Tasks.Task wrappedResult = default!; - if (this.MockRegistry.Behavior.SkipInteractionRecording == false) - { - this.MockolateBuffer_SendAsync.Append("global::System.Net.Http.HttpMessageInvoker.SendAsync", request, cancellationToken); - } - try - { - if (this.MockRegistry.Wraps is global::System.Net.Http.HttpClient wraps) - { - wrappedResult = wraps.SendAsync(request, cancellationToken); - hasWrappedResult = true; - } - #if NETFRAMEWORK - // Persist the HttpContent, because it gets automatically disposed on .NET Framework - if (request.Content != null) - { - var stream = request.Content.ReadAsStreamAsync().ConfigureAwait(false).GetAwaiter().GetResult(); - using global::System.IO.MemoryStream ms = new(); - stream.CopyTo(ms); - byte[] bytes = ms.ToArray(); - stream.Position = 0L; - request.Properties.Add("Mockolate:HttpContent", bytes); - } - #endif - if (!(methodSetup?.SkipBaseClass(this.MockRegistry.Behavior) ?? this.MockRegistry.Behavior.SkipBaseClass) && !hasWrappedResult) - { - wrappedResult = base.SendAsync(request, cancellationToken); - hasWrappedResult = true; - } - } - finally - { - methodSetup?.TriggerCallbacks(request, cancellationToken); - } - if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) - { - throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage, CancellationToken)' was invoked without prior setup."); - } - if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) - { - return wrappedResult; - } - return methodSetup?.TryGetReturnValue(request, cancellationToken, out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(global::System.Threading.Tasks.Task)!, this.MockRegistry.Behavior.DefaultValue.Generate(default(global::System.Net.Http.HttpResponseMessage)!, request, cancellationToken), request, cancellationToken); - } - - /// - protected override void Dispose(bool disposing) - { - global::Mockolate.Setup.VoidMethodSetup? methodSetup = null; - if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) - { - global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.HttpClient.MemberId_Dispose); - 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.VoidMethodSetup s_methodSetup && s_methodSetup.Matches(disposing)) - { - methodSetup = s_methodSetup; - break; - } - } - } - } - if (methodSetup is null) - { - foreach (global::Mockolate.Setup.VoidMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::System.Net.Http.HttpMessageInvoker.Dispose")) - { - if (s_methodSetup.Matches(disposing)) - { - methodSetup = s_methodSetup; - break; - } - } - } - bool hasWrappedResult = false; - if (this.MockRegistry.Behavior.SkipInteractionRecording == false) - { - this.MockolateBuffer_Dispose.Append("global::System.Net.Http.HttpMessageInvoker.Dispose", disposing); - } - try - { - if (!(methodSetup?.SkipBaseClass(this.MockRegistry.Behavior) ?? this.MockRegistry.Behavior.SkipBaseClass)) - { - base.Dispose(disposing); - hasWrappedResult = true; - } - } - finally - { - methodSetup?.TriggerCallbacks(disposing); - } - if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) - { - throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::System.Net.Http.HttpMessageInvoker.Dispose(bool)' was invoked without prior setup."); - } - } - - #endregion System.Net.Http.HttpClient - - #region IMockSetupForHttpClient - - /// - global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::Mockolate.Parameters.IParameters parameters) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", parameters, "request", "cancellationToken"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, methodSetup); - return methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - global::Mockolate.Setup.ReturnMethodSetup methodSetup; - if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.Literal!, cancellationTokenArg.Literal!); - } - else - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); - } - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) - { - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupWithCallback, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::Mockolate.Parameters.IParameters parameters) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", parameters, "request", "cancellationToken"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, methodSetup); - return methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> methodSetup; - if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.Literal!, cancellationTokenArg.Literal!); - } - else - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); - } - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) - { - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - #endregion IMockSetupForHttpClient - - #region IMockProtectedSetupForHttpClient - - /// - global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockProtectedSetupForHttpClient.Dispose(global::Mockolate.Parameters.IParameters parameters) - { - var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", parameters, "disposing"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Dispose, methodSetup); - return methodSetup; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpClient.Dispose(global::Mockolate.ParameterArg? disposing) - { - global::Mockolate.ParameterArg disposingArg = disposing ?? default; - global::Mockolate.Setup.VoidMethodSetup methodSetup; - if (disposingArg.IsLiteral) - { - methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", disposingArg.Literal!); - } - else - { - methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", disposingArg.ToParameterMatch()); - } - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Dispose, methodSetup); - return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpClient.Dispose(global::System.Func disposing, string disposingExpression) - { - var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(disposing, disposingExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Dispose, methodSetup); - return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; - } - - #endregion IMockProtectedSetupForHttpClient - - #region IMockVerifyForHttpClient - - /// - global::Mockolate.Verify.VerificationResult IMockVerifyForHttpClient.Send(global::Mockolate.Parameters.IParameters parameters) - => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", __i => parameters switch - { - global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2]), - global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("request", __i.Parameter1), ("cancellationToken", __i.Parameter2)]), - _ => true - }, () => $"Send({parameters})"); - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) - { - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.Literal!, cancellationTokenArg.Literal!, () => $"Send({requestArg}, {cancellationTokenArg})"); - } - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch(), () => $"Send({requestArg}, {cancellationTokenArg})"); - } - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) - { - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch(), () => $"Send({requestExpression}, {cancellationTokenArg})"); - } - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"Send({requestArg}, {cancellationTokenExpression})"); - } - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.Send(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) - { - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"Send({requestExpression}, {cancellationTokenExpression})"); - } - - /// - global::Mockolate.Verify.VerificationResult IMockVerifyForHttpClient.SendAsync(global::Mockolate.Parameters.IParameters parameters) - => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", __i => parameters switch - { - global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2]), - global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("request", __i.Parameter1), ("cancellationToken", __i.Parameter2)]), - _ => true - }, () => $"SendAsync({parameters})"); - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) - { - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.Literal!, cancellationTokenArg.Literal!, () => $"SendAsync({requestArg}, {cancellationTokenArg})"); - } - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch(), () => $"SendAsync({requestArg}, {cancellationTokenArg})"); - } - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) - { - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch(), () => $"SendAsync({requestExpression}, {cancellationTokenArg})"); - } - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"SendAsync({requestArg}, {cancellationTokenExpression})"); - } - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.SendAsync(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) - { - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"SendAsync({requestExpression}, {cancellationTokenExpression})"); - } - - #endregion IMockVerifyForHttpClient - - #region IMockProtectedVerifyForHttpClient - - /// - global::Mockolate.Verify.VerificationResult IMockProtectedVerifyForHttpClient.Dispose(global::Mockolate.Parameters.IParameters parameters) - => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.HttpClient.MemberId_Dispose, "global::System.Net.Http.HttpMessageInvoker.Dispose", __i => parameters switch - { - global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1]), - global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("disposing", __i.Parameter1)]), - _ => true - }, () => $"Dispose({parameters})"); - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpClient.Dispose(global::Mockolate.ParameterArg? disposing) - { - global::Mockolate.ParameterArg disposingArg = disposing ?? default; - if (disposingArg.IsLiteral) - { - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Dispose, "global::System.Net.Http.HttpMessageInvoker.Dispose", disposingArg.Literal!, () => $"Dispose({disposingArg})"); - } - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Dispose, "global::System.Net.Http.HttpMessageInvoker.Dispose", disposingArg.ToParameterMatch(), () => $"Dispose({disposingArg})"); - } - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpClient.Dispose(global::System.Func disposing, string disposingExpression) - { - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Dispose, "global::System.Net.Http.HttpMessageInvoker.Dispose", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(disposing, disposingExpression), () => $"Dispose({disposingExpression})"); - } - - #endregion IMockProtectedVerifyForHttpClient - } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class VerifyMonitorHttpClient(global::Mockolate.MockRegistry mockRegistry) : global::Mockolate.Mock.IMockVerifyForHttpClient - { - private global::Mockolate.MockRegistry MockRegistry { get; } = mockRegistry; - - #region IMockVerifyForHttpClient - - /// - global::Mockolate.Verify.VerificationResult IMockVerifyForHttpClient.Send(global::Mockolate.Parameters.IParameters parameters) - => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", __i => parameters switch - { - global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2]), - global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("request", __i.Parameter1), ("cancellationToken", __i.Parameter2)]), - _ => true - }, () => $"Send({parameters})"); - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) - { - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.Literal!, cancellationTokenArg.Literal!, () => $"Send({requestArg}, {cancellationTokenArg})"); - } - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch(), () => $"Send({requestArg}, {cancellationTokenArg})"); - } - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) - { - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch(), () => $"Send({requestExpression}, {cancellationTokenArg})"); - } - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"Send({requestArg}, {cancellationTokenExpression})"); - } - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.Send(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) - { - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_Send, "global::System.Net.Http.HttpMessageInvoker.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"Send({requestExpression}, {cancellationTokenExpression})"); - } - - /// - global::Mockolate.Verify.VerificationResult IMockVerifyForHttpClient.SendAsync(global::Mockolate.Parameters.IParameters parameters) - => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", __i => parameters switch - { - global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2]), - global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("request", __i.Parameter1), ("cancellationToken", __i.Parameter2)]), - _ => true - }, () => $"SendAsync({parameters})"); - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) - { - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.Literal!, cancellationTokenArg.Literal!, () => $"SendAsync({requestArg}, {cancellationTokenArg})"); - } - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch(), () => $"SendAsync({requestArg}, {cancellationTokenArg})"); - } - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) - { - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch(), () => $"SendAsync({requestExpression}, {cancellationTokenArg})"); - } - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"SendAsync({requestArg}, {cancellationTokenExpression})"); - } - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockVerifyForHttpClient.SendAsync(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) - { - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpClient.MemberId_SendAsync, "global::System.Net.Http.HttpMessageInvoker.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"SendAsync({requestExpression}, {cancellationTokenExpression})"); - } - - #endregion IMockVerifyForHttpClient - } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class MockInScenarioForHttpClient : global::Mockolate.Mock.IMockInScenarioForHttpClient, global::Mockolate.Mock.IMockSetupForHttpClient, global::Mockolate.Mock.IMockProtectedSetupForHttpClient - { - private global::Mockolate.MockRegistry MockRegistry { get; } - private string _scenarioName; - - public MockInScenarioForHttpClient(global::Mockolate.MockRegistry mockRegistry, string scenario) - { - this.MockRegistry = mockRegistry; - _scenarioName = scenario; - } - - /// - global::Mockolate.Mock.IMockSetupForHttpClient global::Mockolate.Mock.IMockInScenarioForHttpClient.Setup - => this; - - /// - global::Mockolate.Mock.IMockProtectedSetupForHttpClient global::Mockolate.Mock.IMockInScenarioForHttpClient.SetupProtected - => this; - - #region IMockSetupForHttpClient - - /// - global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::Mockolate.Parameters.IParameters parameters) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", parameters, "request", "cancellationToken"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, _scenarioName, methodSetup); - return methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - global::Mockolate.Setup.ReturnMethodSetup methodSetup; - if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.Literal!, cancellationTokenArg.Literal!); - } - else - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); - } - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, _scenarioName, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) - { - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, _scenarioName, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, _scenarioName, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, _scenarioName, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupWithCallback, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::Mockolate.Parameters.IParameters parameters) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", parameters, "request", "cancellationToken"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, _scenarioName, methodSetup); - return methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> methodSetup; - if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.Literal!, cancellationTokenArg.Literal!); - } - else - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); - } - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, _scenarioName, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) - { - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, _scenarioName, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, _scenarioName, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, _scenarioName, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - #endregion IMockSetupForHttpClient - - #region IMockProtectedSetupForHttpClient - - /// - global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockProtectedSetupForHttpClient.Dispose(global::Mockolate.Parameters.IParameters parameters) - { - var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", parameters, "disposing"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Dispose, _scenarioName, methodSetup); - return methodSetup; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpClient.Dispose(global::Mockolate.ParameterArg? disposing) - { - global::Mockolate.ParameterArg disposingArg = disposing ?? default; - global::Mockolate.Setup.VoidMethodSetup methodSetup; - if (disposingArg.IsLiteral) - { - methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", disposingArg.Literal!); - } - else - { - methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", disposingArg.ToParameterMatch()); - } - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Dispose, _scenarioName, methodSetup); - return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpClient.Dispose(global::System.Func disposing, string disposingExpression) - { - var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(disposing, disposingExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Dispose, _scenarioName, methodSetup); - return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; - } - - #endregion IMockProtectedSetupForHttpClient - } - - /// - /// The Mockolate accessor for a mock of HttpClient, reached through .Mock on the mocked instance. - /// - /// - /// Groups every operation that acts on the mock rather than on the mocked subject: setups, verifications, event raising, scenarios and monitoring. - /// - internal interface IMockForHttpClient - { - /// - /// Configures how members of the mock of HttpClient respond when invoked. - /// - /// - /// Each mocked member is available as a strongly-typed entry on this surface. Chain Returns, ReturnsAsync, Throws, ThrowsAsync or Do to control the response; chain InitializeWith/Register to initialize properties and indexers; chain multiple returns/throws to define a sequence; use .For(n), .Only(n), .Forever(), .When(predicate) to control when a callback runs.
- /// When two setups overlap, the most recently defined one wins. - ///
- IMockSetupForHttpClient Setup { get; } - - /// - /// Configures how virtual members of the mock of HttpClient respond when invoked. - /// - /// - /// Only members declared as (or ) on the mocked class appear here. All setup chain operators (Returns, Throws, Do, sequences, .For/.Only/.Forever, ...) work identically to Setup. - /// - IMockProtectedSetupForHttpClient SetupProtected { get; } - - /// - /// Opens a named scenario scope on the mock of HttpClient so that additional setups can be registered for that scenario. - /// - /// - /// Scenarios let you define per-state behavior. Setups registered inside the returned IMockInScenarioFor... scope only apply while the mock's current scenario matches ; switch scenarios with TransitionTo. - /// - /// Name of the scenario to enter. Any non-null string acts as a key; the mock starts in an unnamed default scenario. - /// A scoped accessor whose Setup (and SetupProtected, where applicable) register scenario-specific setups. - IMockInScenarioForHttpClient InScenario(string scenario); - - /// - /// Opens a named scenario scope on the mock of HttpClient and immediately invokes to register scenario-specific setups. - /// - /// - /// Equivalent to InScenario(scenario) followed by the setup callback, but returns the original IMockFor... accessor so it chains nicely at mock-creation time. - /// - /// Name of the scenario to enter. - /// Callback that receives the scenario-scoped setup surface and registers scenario-specific setups. - /// This accessor, to allow chaining. - IMockForHttpClient InScenario(string scenario, global::System.Action setup); - - /// - /// Switches the active scenario of the mock of HttpClient to . - /// - /// - /// After the transition, setups registered via InScenario(string) under that scenario take effect. Scenarios that have no matching setup for a given member fall back to the default (un-scoped) setups. - /// - /// Name of the scenario to transition to. - /// This accessor, to allow chaining. - IMockForHttpClient TransitionTo(string scenario); - - /// - /// Asserts how often, and in which order, members of the mock of HttpClient were invoked. - /// - /// - /// Each call to a member here returns a VerificationResult that you terminate with a count assertion: Never(), Once(), Twice(), Exactly(n), AtLeast(n)/AtLeastOnce()/AtLeastTwice(), AtMost(n)/AtMostOnce()/AtMostTwice(), Between(min, max) or Times(predicate).
- /// Use Within(TimeSpan) / WithCancellation(CancellationToken) before the terminator to wait for expected interactions that happen on background threads.
- /// Chain Then(...) to assert an ordered sequence of calls. A failing assertion throws a MockVerificationException. - ///
- IMockVerifyForHttpClient Verify { get; } - - /// - /// Asserts how often, and in which order, members of the mock of HttpClient were invoked. - /// - /// - /// Same terminators and modifiers as Verify (Once(), Exactly(n), Within(...), Then(...), ...); applies to members and events instead of public ones. - /// - IMockProtectedVerifyForHttpClient VerifyProtected { get; } - - /// - /// Verifies how often a specific method setup was matched by actual invocations. - /// - /// - /// Useful when you want to verify "this particular setup was hit N times" without re-stating the matchers. Chain the usual count terminators (Once(), AtLeastOnce(), Exactly(n), ...) on the returned result. - /// - /// The setup previously registered through Setup (typically returned from a Returns(...)/Throws(...) call). - /// A VerificationResult that counts invocations matching the given setup. - global::Mockolate.Verify.VerificationResult VerifySetup(global::Mockolate.Setup.IMethodSetup setup); - - /// - /// Checks whether every recorded interaction on this mock has been observed by at least one Verify call. - /// - /// - /// Useful in test teardown to catch unexpected interactions ("strict verification"): if any recorded call has never been matched by a verification, the method returns . - /// - /// if every recorded interaction was verified at least once; otherwise . - bool VerifyThatAllInteractionsAreVerified(); - - /// - /// Checks whether every registered setup on this mock was matched by at least one actual invocation. - /// - /// - /// Useful to catch unused setups that silently rot as the test subject evolves. - /// - /// if every registered setup was used at least once; otherwise . - bool VerifyThatAllSetupsAreUsed(); - - /// - /// Removes every recorded interaction from this mock while keeping all registered setups intact. - /// - /// - /// Handy when a single test exercises multiple logical phases and you only want to verify the interactions of the latest phase. - /// - void ClearAllInteractions(); - - /// - /// Creates a monitor whose Verify surface is scoped to interactions produced between monitor.Run() and the disposal of its IDisposable scope. - /// - /// - /// The underlying mock keeps recording all interactions as usual - only the monitor's Verify view is scoped. Useful to verify only the interactions produced by a specific block of test code without resetting the mock. - /// - /// A MockMonitor<T> that exposes Verify over the monitored interactions and a Run() method that opens the recording scope. - global::Mockolate.Monitor.MockMonitor Monitor(); - } - - /// - /// Scoped access to setups for a scenario on the mock of HttpClient. - /// - internal interface IMockInScenarioForHttpClient - { - /// - /// Set up the mock of HttpClient within the scenario scope. - /// - IMockSetupForHttpClient Setup { get; } - - /// - /// Set up protected members of the mock of HttpClient within the scenario scope. - /// - IMockProtectedSetupForHttpClient SetupProtected { get; } - } - - /// - /// Set up the mock of HttpClient. - /// - internal interface IMockSetupForHttpClient : global::Mockolate.Setup.IMockSetup - { - /// - /// Setup for the method Send(HttpRequestMessage, CancellationToken) 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 Send(global::Mockolate.Parameters.IParameters parameters); - - /// - /// Setup for the method Send(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken); - - /// - /// Setup for the method Send(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = ""); - - /// - /// Setup for the method Send(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); - - /// - /// Setup for the method Send(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts a predicate for , . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Send(global::System.Func request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); - - /// - /// Setup for the method SendAsync(HttpRequestMessage, CancellationToken) 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, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::Mockolate.Parameters.IParameters parameters); - - /// - /// Setup for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken); - - /// - /// Setup for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = ""); - - /// - /// Setup for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); - - /// - /// Setup for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts a predicate for , . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::System.Func request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); - - } - - /// - /// Set up protected members for the mock of HttpClient. - /// - internal interface IMockProtectedSetupForHttpClient - { - /// - /// Setup for the method Dispose(bool) 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.IVoidMethodSetupWithCallback Dispose(global::Mockolate.Parameters.IParameters parameters); - - /// - /// Setup for the method Dispose(bool) with the given . - /// - /// - /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] - global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer Dispose(global::Mockolate.ParameterArg? disposing); - - /// - /// Setup for the method Dispose(bool) with the given . - /// - /// - /// This overload accepts a predicate for . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] - global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer Dispose(global::System.Func disposing, [global::System.Runtime.CompilerServices.CallerArgumentExpression("disposing")] string disposingExpression = ""); - - } - - /// - /// Verify interactions with the mock of HttpClient. - /// - internal interface IMockVerifyForHttpClient : global::Mockolate.Verify.IMockVerify - { - /// - /// Verify invocations for the method Send(HttpRequestMessage, CancellationToken) 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 Send(global::Mockolate.Parameters.IParameters parameters); - - /// - /// Verify invocations for the method Send(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] - global::Mockolate.Verify.VerificationResult.IgnoreParameters Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken); - - /// - /// Verify invocations for the method Send(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] - global::Mockolate.Verify.VerificationResult.IgnoreParameters Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = ""); - - /// - /// Verify invocations for the method Send(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] - global::Mockolate.Verify.VerificationResult.IgnoreParameters Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); - - /// - /// Verify invocations for the method Send(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts a predicate for , . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] - global::Mockolate.Verify.VerificationResult.IgnoreParameters Send(global::System.Func request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); - - /// - /// Verify invocations for the method SendAsync(HttpRequestMessage, CancellationToken) 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 SendAsync(global::Mockolate.Parameters.IParameters parameters); - - /// - /// Verify invocations for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] - global::Mockolate.Verify.VerificationResult.IgnoreParameters SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken); - - /// - /// Verify invocations for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] - global::Mockolate.Verify.VerificationResult.IgnoreParameters SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = ""); - - /// - /// Verify invocations for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] - global::Mockolate.Verify.VerificationResult.IgnoreParameters SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); - - /// - /// Verify invocations for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts a predicate for , . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] - global::Mockolate.Verify.VerificationResult.IgnoreParameters SendAsync(global::System.Func request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); - - } - - /// - /// Verify protected interactions with the mock of HttpClient. - /// - internal interface IMockProtectedVerifyForHttpClient - { - /// - /// Verify invocations for the method Dispose(bool) 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 Dispose(global::Mockolate.Parameters.IParameters parameters); - - /// - /// Verify invocations for the method Dispose(bool) with the given . - /// - /// - /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] - global::Mockolate.Verify.VerificationResult.IgnoreParameters Dispose(global::Mockolate.ParameterArg? disposing); - - /// - /// Verify invocations for the method Dispose(bool) with the given . - /// - /// - /// This overload accepts a predicate for . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] - global::Mockolate.Verify.VerificationResult.IgnoreParameters Dispose(global::System.Func disposing, [global::System.Runtime.CompilerServices.CallerArgumentExpression("disposing")] string disposingExpression = ""); - - } -} -/// -/// Mock extensions for HttpClient. -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static partial class MockExtensionsForHttpClient -{ - /// - extension(global::System.Net.Http.HttpClient mock) - { - /// - /// Gets the mock accessor for HttpClient - the entry point for configuring setups, verifying interactions and raising events. - /// - /// - /// The accessor is the bridge between the strongly-typed instance of HttpClient returned by CreateMock(...) and the underlying mock registry where setups and recorded interactions live.
- /// Through it you can:
- ///
- /// Setup - configure how members respond when invoked (Returns, Throws, Do, InitializeWith, ...).
- /// Verify - assert how often (and in which order) members were invoked.
- /// SetupProtected / VerifyProtected / RaiseProtected - target members on class mocks.
- /// InScenario / TransitionTo - scope setups and behavior to a named scenario and switch between scenarios.
- /// Monitor, ClearAllInteractions, VerifyThatAllInteractionsAreVerified, VerifyThatAllSetupsAreUsed - manage recorded interactions.
- /// VerifySetup - verify how often a specific setup matched.
- ///
- ///
- /// The instance is not a Mockolate-generated mock of HttpClient. - public global::Mockolate.Mock.IMockForHttpClient Mock - { - get - { - if (mock is global::Mockolate.Mock.IMockForHttpClient mockInterface) - { - return mockInterface; - } - throw new global::Mockolate.Exceptions.MockException("The subject is no mock."); - } - } - - /// - /// Creates a new mock of HttpClient with the default MockBehavior. - /// - /// - /// The returned instance is a strongly-typed mock generated at compile time - it implements HttpClient and exposes the Mockolate surface through .Mock:
- ///
- /// .Mock.Setup configures how members respond (Returns, Throws, Do, InitializeWith, sequences, callbacks).
- /// .Mock.Verify asserts how often and in which order members were invoked.
- ///

- /// With the default behavior, un-configured members return default values (empty collections / strings, completed tasks, otherwise) and base-class implementations are invoked for class mocks. Use one of the overloads that accepts a MockBehavior to customize this (for example to make un-configured calls throw or to skip the base class).
- /// Overloads allow you to additionally pass constructor parameters (for class mocks), apply an initial setup callback before the instance is returned, or combine both. - ///
- /// A new mock instance of HttpClient. - public static global::System.Net.Http.HttpClient CreateMock() - => CreateMock(null, null, (object?[]?)null); - - /// - /// Creates a new mock of HttpClient with the default MockBehavior, applying the given immediately. - /// - /// - /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. - /// - /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. - /// A new mock instance of HttpClient. - public static global::System.Net.Http.HttpClient CreateMock(global::System.Action setup) - => CreateMock(null, setup, (object?[]?)null); - - /// - /// Creates a new mock of HttpClient with the given . - /// - /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. - /// A new mock instance of HttpClient. - public static global::System.Net.Http.HttpClient CreateMock(global::Mockolate.MockBehavior mockBehavior) - => CreateMock(mockBehavior, null, (object?[]?)null); - - /// - /// Creates a new mock of HttpClient with the given , applying the given immediately. - /// - /// - /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. - /// - /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. - /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. - /// A new mock instance of HttpClient. - public static global::System.Net.Http.HttpClient CreateMock(global::Mockolate.MockBehavior mockBehavior, global::System.Action setup) - => CreateMock(mockBehavior, setup, (object?[]?)null); - - /// - /// Creates a new mock of HttpClient using the given to invoke the base-class constructor. - /// - /// Values forwarded to a matching base-class constructor. Required when no parameterless constructor exists. - /// A new mock instance of HttpClient. - public static global::System.Net.Http.HttpClient CreateMock(object?[] constructorParameters) - => CreateMock(null, null, constructorParameters); - - /// - /// Creates a new mock of HttpClient using the given and . - /// - /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. - /// Values forwarded to a matching base-class constructor. Required when no parameterless constructor exists. - /// A new mock instance of HttpClient. - public static global::System.Net.Http.HttpClient CreateMock(global::Mockolate.MockBehavior mockBehavior, object?[] constructorParameters) - => CreateMock(mockBehavior, null, constructorParameters); - - /// - /// Creates a new mock of HttpClient applying the given immediately, using the given . - /// - /// - /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. - /// - /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. - /// Values forwarded to a matching base-class constructor. Required when no parameterless constructor exists. - /// A new mock instance of HttpClient. - public static global::System.Net.Http.HttpClient CreateMock(global::System.Action setup, object?[] constructorParameters) - => CreateMock(null, setup, constructorParameters); - - /// - /// Creates a new mock of HttpClient using the given constructor parameters to invoke the HttpClient(HttpMessageHandler) constructor. - /// - /// Value forwarded to the base-class constructor. - /// A new mock instance of HttpClient. - public static global::System.Net.Http.HttpClient CreateMock(global::System.Net.Http.HttpMessageHandler handler) - => CreateMock(null, null, new object?[] { handler }); - - /// - /// Creates a new mock of HttpClient using the given and the given constructor parameters to invoke the HttpClient(HttpMessageHandler) constructor. - /// - /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. - /// Value forwarded to the base-class constructor. - /// A new mock instance of HttpClient. - public static global::System.Net.Http.HttpClient CreateMock(global::Mockolate.MockBehavior mockBehavior, global::System.Net.Http.HttpMessageHandler handler) - => CreateMock(mockBehavior, null, new object?[] { handler }); - - /// - /// Creates a new mock of HttpClient applying the given immediately, using the given constructor parameters to invoke the HttpClient(HttpMessageHandler) constructor. - /// - /// - /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. - /// - /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. - /// Value forwarded to the base-class constructor. - /// A new mock instance of HttpClient. - public static global::System.Net.Http.HttpClient CreateMock(global::System.Action setup, global::System.Net.Http.HttpMessageHandler handler) - => CreateMock(null, setup, new object?[] { handler }); - - /// - /// Creates a new mock of HttpClient using the given , applying the given immediately, using the given constructor parameters to invoke the HttpClient(HttpMessageHandler) constructor. - /// - /// - /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. - /// - /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. - /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. - /// Value forwarded to the base-class constructor. - /// A new mock instance of HttpClient. - public static global::System.Net.Http.HttpClient CreateMock(global::Mockolate.MockBehavior mockBehavior, global::System.Action setup, global::System.Net.Http.HttpMessageHandler handler) - => CreateMock(mockBehavior, setup, new object?[] { handler }); - - /// - /// Creates a new mock of HttpClient using the given constructor parameters to invoke the HttpClient(HttpMessageHandler, bool) constructor. - /// - /// Value forwarded to the base-class constructor. - /// Value forwarded to the base-class constructor. - /// A new mock instance of HttpClient. - public static global::System.Net.Http.HttpClient CreateMock(global::System.Net.Http.HttpMessageHandler handler, bool disposeHandler) - => CreateMock(null, null, new object?[] { handler, disposeHandler }); - - /// - /// Creates a new mock of HttpClient using the given and the given constructor parameters to invoke the HttpClient(HttpMessageHandler, bool) constructor. - /// - /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. - /// Value forwarded to the base-class constructor. - /// Value forwarded to the base-class constructor. - /// A new mock instance of HttpClient. - public static global::System.Net.Http.HttpClient CreateMock(global::Mockolate.MockBehavior mockBehavior, global::System.Net.Http.HttpMessageHandler handler, bool disposeHandler) - => CreateMock(mockBehavior, null, new object?[] { handler, disposeHandler }); - - /// - /// Creates a new mock of HttpClient applying the given immediately, using the given constructor parameters to invoke the HttpClient(HttpMessageHandler, bool) constructor. - /// - /// - /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. - /// - /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. - /// Value forwarded to the base-class constructor. - /// Value forwarded to the base-class constructor. - /// A new mock instance of HttpClient. - public static global::System.Net.Http.HttpClient CreateMock(global::System.Action setup, global::System.Net.Http.HttpMessageHandler handler, bool disposeHandler) - => CreateMock(null, setup, new object?[] { handler, disposeHandler }); - - /// - /// Creates a new mock of HttpClient using the given , applying the given immediately, using the given constructor parameters to invoke the HttpClient(HttpMessageHandler, bool) constructor. - /// - /// - /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. - /// - /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. - /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. - /// Value forwarded to the base-class constructor. - /// Value forwarded to the base-class constructor. - /// A new mock instance of HttpClient. - public static global::System.Net.Http.HttpClient CreateMock(global::Mockolate.MockBehavior mockBehavior, global::System.Action setup, global::System.Net.Http.HttpMessageHandler handler, bool disposeHandler) - => CreateMock(mockBehavior, setup, new object?[] { handler, disposeHandler }); - - /// - /// Creates a new mock of HttpClient using the given , applying the given immediately, using the given . - /// - /// - /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. - /// - /// Controls how the mock responds when members are invoked without a matching setup, or for MockBehavior.Default. - /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned, or to skip. - /// Values forwarded to a matching base-class constructor, or to use the parameterless constructor. - /// A new mock instance of HttpClient. - public static global::System.Net.Http.HttpClient CreateMock(global::Mockolate.MockBehavior? mockBehavior, global::System.Action? setup, object?[]? constructorParameters) - { - if (mockBehavior is not null) - { - IMockBehaviorAccess mockBehaviorAccess = (global::Mockolate.IMockBehaviorAccess)mockBehavior; - if (mockBehaviorAccess.TryGet?>(out var additionalSetup)) - { - if (setup is null) - { - setup = additionalSetup; - } - else - { - var originalSetup = setup; - setup = s => { additionalSetup.Invoke(s); originalSetup.Invoke(s); }; - } - } - if (constructorParameters is null && mockBehaviorAccess.TryGetConstructorParameters(out object?[]? parameters)) - { - constructorParameters = parameters; - } - } - - global::Mockolate.MockBehavior effectiveBehavior = mockBehavior ?? global::Mockolate.MockBehavior.Default; - global::Mockolate.MockRegistry mockRegistry = new global::Mockolate.MockRegistry(effectiveBehavior, global::Mockolate.Mock.HttpClient.CreateFastInteractions(effectiveBehavior), constructorParameters); - if (constructorParameters is null) - { - constructorParameters = [new global::Mockolate.Mock.HttpMessageHandler(mockRegistry),]; - mockRegistry = new global::Mockolate.MockRegistry(mockRegistry, constructorParameters); - } - else if (constructorParameters.Length > 0 && constructorParameters[0] is global::Mockolate.Mock.HttpMessageHandler && constructorParameters[0] is global::Mockolate.IMock httpMessageHandlerMock) - { - if (mockBehavior is not null && httpMessageHandlerMock.MockRegistry.Behavior != mockBehavior) - { - throw new global::Mockolate.Exceptions.MockException($"Mock of type 'System.Net.Http.HttpClient' cannot be created with behavior '{mockBehavior}' because it shares its mock registry with a mock of type 'System.Net.Http.HttpMessageHandler' that has behavior '{httpMessageHandlerMock.MockRegistry.Behavior}'."); - } - mockRegistry = new global::Mockolate.MockRegistry(httpMessageHandlerMock.MockRegistry, constructorParameters); - } - mockBehavior ??= global::Mockolate.MockBehavior.Default; - return CreateMockInstance(mockRegistry, constructorParameters, setup); - } - - private static global::System.Net.Http.HttpClient CreateMockInstance(global::Mockolate.MockRegistry mockRegistry, object?[]? constructorParameters, global::System.Action? setup) - { - if (constructorParameters is null || constructorParameters.Length == 0) - { - global::Mockolate.Mock.HttpClient.MockRegistryProvider.Value = mockRegistry; - global::Mockolate.MockExtensionsForHttpClient.MockSetup? setupTarget = null; - if (setup is not null) - { - setupTarget ??= new(mockRegistry); - setup.Invoke(setupTarget); - } - return new global::Mockolate.Mock.HttpClient(mockRegistry); - } - else if (constructorParameters.Length == 0) - { - global::Mockolate.Mock.HttpClient.MockRegistryProvider.Value = mockRegistry; - global::Mockolate.MockExtensionsForHttpClient.MockSetup? setupTarget = null; - if (setup is not null) - { - setupTarget ??= new(mockRegistry); - setup.Invoke(setupTarget); - } - return new global::Mockolate.Mock.HttpClient(mockRegistry); - } - else if (constructorParameters.Length == 1 - && TryCast(constructorParameters, 0, mockRegistry.Behavior, out global::System.Net.Http.HttpMessageHandler c2p1)) - { - global::Mockolate.Mock.HttpClient.MockRegistryProvider.Value = mockRegistry; - global::Mockolate.MockExtensionsForHttpClient.MockSetup? setupTarget = null; - if (setup is not null) - { - setupTarget ??= new(mockRegistry); - setup.Invoke(setupTarget); - } - return new global::Mockolate.Mock.HttpClient(mockRegistry, c2p1); - } - else if (constructorParameters.Length == 2 - && TryCast(constructorParameters, 0, mockRegistry.Behavior, out global::System.Net.Http.HttpMessageHandler c3p1) - && TryCast(constructorParameters, 1, mockRegistry.Behavior, out bool c3p2)) - { - global::Mockolate.Mock.HttpClient.MockRegistryProvider.Value = mockRegistry; - global::Mockolate.MockExtensionsForHttpClient.MockSetup? setupTarget = null; - if (setup is not null) - { - setupTarget ??= new(mockRegistry); - setup.Invoke(setupTarget); - } - return new global::Mockolate.Mock.HttpClient(mockRegistry, c3p1, c3p2); - } - else - { - throw new global::Mockolate.Exceptions.MockException($"Could not find any constructor for 'System.Net.Http.HttpClient' that matches the {constructorParameters.Length} given parameters ({string.Join(", ", constructorParameters)})."); - } - static bool TryCast(object?[] values, int index, global::Mockolate.MockBehavior behavior, out TValue result) - { - var value = values[index]; - if (value is TValue typedValue) - { - result = typedValue; - return true; - } - - result = default!; - return value is null; - } - } - /// - /// Creates a mock that wraps the given . - /// - /// - /// Public members on the mock forward to unless overridden by a setup; protected members still go through the base-class implementation. All forwarded interactions are recorded and can be verified the same as on a plain mock. - /// - /// The real object whose calls should be forwarded. Must not be . - /// A new mock of HttpClient that delegates to . - public global::System.Net.Http.HttpClient Wrapping(global::System.Net.Http.HttpClient instance) - { - if (mock is global::Mockolate.IMock mockInterface) - { - global::Mockolate.MockRegistry wrappingRegistry = new global::Mockolate.MockRegistry(mockInterface.MockRegistry, instance); - wrappingRegistry = new global::Mockolate.MockRegistry(wrappingRegistry, global::Mockolate.Mock.HttpClient.CreateFastInteractions(wrappingRegistry.Behavior)); - return CreateMockInstance(wrappingRegistry, mockInterface.MockRegistry.ConstructorParameters, null); - } - throw new global::Mockolate.Exceptions.MockException("The subject is no mock."); - } - - } - - /// - extension(global::Mockolate.MockBehavior behavior) - { - /// - /// Initializes mocks of type with the given . - /// - /// - /// The is applied to the mock before the constructor is executed. Calling Initialize again overlays additional setups on top of any previously registered ones. - /// - /// The mockable type derived from HttpClient that this setup should apply to. - /// Callback invoked when a new mock of is created. - /// A new MockBehavior with the registered initializer. The original instance is unchanged. - public global::Mockolate.MockBehavior Initialize(global::System.Action setup) - where T : global::System.Net.Http.HttpClient - { - var behaviorAccess = (global::Mockolate.IMockBehaviorAccess)behavior; - return behaviorAccess.Set(setup); - } - } - internal interface IMockSetupInitializationForHttpClient : global::Mockolate.Mock.IMockSetupForHttpClient - { - /// - /// Setup protected members - /// - global::Mockolate.Mock.IMockProtectedSetupForHttpClient Protected { get; } - } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal sealed class MockSetup(global::Mockolate.MockRegistry mockRegistry) : global::Mockolate.Mock.IMockSetupForHttpClient, global::Mockolate.Mock.IMockProtectedSetupForHttpClient, IMockSetupInitializationForHttpClient - { - /// - global::Mockolate.Mock.IMockProtectedSetupForHttpClient IMockSetupInitializationForHttpClient.Protected => this; - private global::Mockolate.MockRegistry MockRegistry { get; } = mockRegistry; - - #region IMockSetupForHttpClient - - /// - global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::Mockolate.Parameters.IParameters parameters) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", parameters, "request", "cancellationToken"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, methodSetup); - return methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - global::Mockolate.Setup.ReturnMethodSetup methodSetup; - if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.Literal!, cancellationTokenArg.Literal!); - } - else - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); - } - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) - { - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockSetupForHttpClient.Send(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Send, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupWithCallback, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::Mockolate.Parameters.IParameters parameters) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", parameters, "request", "cancellationToken"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, methodSetup); - return methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> methodSetup; - if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.Literal!, cancellationTokenArg.Literal!); - } - else - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); - } - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) - { - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockSetupForHttpClient.SendAsync(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_SendAsync, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - #endregion IMockSetupForHttpClient - - #region IMockProtectedSetupForHttpClient - - /// - global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockProtectedSetupForHttpClient.Dispose(global::Mockolate.Parameters.IParameters parameters) - { - var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", parameters, "disposing"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Dispose, methodSetup); - return methodSetup; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpClient.Dispose(global::Mockolate.ParameterArg? disposing) - { - global::Mockolate.ParameterArg disposingArg = disposing ?? default; - global::Mockolate.Setup.VoidMethodSetup methodSetup; - if (disposingArg.IsLiteral) - { - methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", disposingArg.Literal!); - } - else - { - methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", disposingArg.ToParameterMatch()); - } - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Dispose, methodSetup); - return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpClient.Dispose(global::System.Func disposing, string disposingExpression) - { - var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageInvoker.Dispose", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(disposing, disposingExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpClient.MemberId_Dispose, methodSetup); - return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; - } - - #endregion IMockProtectedSetupForHttpClient - } -} - -#nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpMessageHandler.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpMessageHandler.g.cs deleted file mode 100644 index db4b7750..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.HttpMessageHandler.g.cs +++ /dev/null @@ -1,1493 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -#nullable enable annotations -namespace Mockolate; - -internal static partial class Mock -{ - /// - /// A mock implementation for HttpMessageHandler. - /// - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal class HttpMessageHandler : - global::System.Net.Http.HttpMessageHandler, IMockForHttpMessageHandler, IMockSetupForHttpMessageHandler, IMockProtectedSetupForHttpMessageHandler, global::Mockolate.MockExtensionsForHttpMessageHandler.IMockSetupInitializationForHttpMessageHandler, IMockVerifyForHttpMessageHandler, IMockProtectedVerifyForHttpMessageHandler, - global::Mockolate.IMock - { - internal const int MemberId_Send = 0; - internal const int MemberId_SendAsync = 1; - internal const int MemberId_Dispose = 2; - internal const int MemberCount = 3; - - /// - /// Creates a FastMockInteractions sized to MemberCount for use as the mock's interaction store. - /// Per-member buffers are not allocated up-front: the recording hot paths call GetOrCreateBuffer<TBuffer>(int, Func<FastMockInteractions, TBuffer>) so a slot is materialized only when its member is first invoked. - /// - internal static global::Mockolate.Interactions.FastMockInteractions CreateFastInteractions(global::Mockolate.MockBehavior behavior) - => new global::Mockolate.Interactions.FastMockInteractions(MemberCount, behavior.SkipInteractionRecording); - - /// - /// Builds a MockRegistry backed by a typed-buffer-sized FastMockInteractions from . - /// - private static global::Mockolate.MockRegistry MockolateCreateRegistryFromBehavior(global::Mockolate.MockBehavior behavior) - { - global::Mockolate.MockRegistry registry = new global::Mockolate.MockRegistry(behavior, MemberCount); - MockRegistryProvider.Value = registry; - return registry; - } - - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - global::Mockolate.MockRegistry global::Mockolate.IMock.MockRegistry => this.MockRegistry; - private global::Mockolate.MockRegistry MockRegistry - { - get => field ?? MockRegistryProvider.Value; - set; - } - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - internal static readonly global::System.Threading.AsyncLocal MockRegistryProvider = new global::System.Threading.AsyncLocal(); - - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - private global::Mockolate.Interactions.FastMethod2Buffer MockolateBuffer_Send - => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, static fast => new global::Mockolate.Interactions.FastMethod2Buffer(fast))); - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - private global::Mockolate.Interactions.FastMethod2Buffer MockolateBuffer_SendAsync - => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, static fast => new global::Mockolate.Interactions.FastMethod2Buffer(fast))); - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - private global::Mockolate.Interactions.FastMethod1Buffer MockolateBuffer_Dispose - => field ?? (field = ((global::Mockolate.Interactions.FastMockInteractions)this.MockRegistry.Interactions).GetOrCreateBuffer>(global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, static fast => new global::Mockolate.Interactions.FastMethod1Buffer(fast))); - - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - IMockSetupForHttpMessageHandler IMockForHttpMessageHandler.Setup - => this; - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - IMockProtectedSetupForHttpMessageHandler IMockForHttpMessageHandler.SetupProtected - => this; - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - IMockProtectedSetupForHttpMessageHandler global::Mockolate.MockExtensionsForHttpMessageHandler.IMockSetupInitializationForHttpMessageHandler.Protected - => this; - /// - IMockInScenarioForHttpMessageHandler IMockForHttpMessageHandler.InScenario(string scenario) - => new MockInScenarioForHttpMessageHandler(this.MockRegistry, scenario); - - /// - IMockForHttpMessageHandler IMockForHttpMessageHandler.InScenario(string scenario, global::System.Action setup) - { - setup.Invoke(new MockInScenarioForHttpMessageHandler(this.MockRegistry, scenario)); - return this; - } - - /// - IMockForHttpMessageHandler IMockForHttpMessageHandler.TransitionTo(string scenario) - { - this.MockRegistry.TransitionTo(scenario); - return this; - } - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - IMockVerifyForHttpMessageHandler IMockForHttpMessageHandler.Verify - => this; - /// - [global::System.Diagnostics.DebuggerBrowsable(global::System.Diagnostics.DebuggerBrowsableState.Never)] - IMockProtectedVerifyForHttpMessageHandler IMockForHttpMessageHandler.VerifyProtected - => this; - /// - global::Mockolate.Verify.VerificationResult IMockForHttpMessageHandler.VerifySetup(global::Mockolate.Setup.IMethodSetup setup) - => this.MockRegistry.Method(this, setup); - /// - bool IMockForHttpMessageHandler.VerifyThatAllInteractionsAreVerified() - => this.MockRegistry.Interactions.GetUnverifiedInteractions().Count == 0; - /// - bool IMockForHttpMessageHandler.VerifyThatAllSetupsAreUsed() - => this.MockRegistry.GetUnusedSetups(this.MockRegistry.Interactions).Count == 0; - /// - void IMockForHttpMessageHandler.ClearAllInteractions() - => this.MockRegistry.ClearAllInteractions(); - /// - global::Mockolate.Monitor.MockMonitor IMockForHttpMessageHandler.Monitor() - => new global::Mockolate.Monitor.MockMonitor(this.MockRegistry.Interactions, interactions => new VerifyMonitorHttpMessageHandler(new global::Mockolate.MockRegistry(this.MockRegistry, interactions))); - - /// - string global::Mockolate.IMock.ToString() - => "System.Net.Http.HttpMessageHandler mock"; - - /// - public HttpMessageHandler(global::Mockolate.MockRegistry mockRegistry) - : base() - { - this.MockRegistry = mockRegistry; - } - - /// - public HttpMessageHandler(global::Mockolate.MockBehavior behavior) - : this(MockolateCreateRegistryFromBehavior(behavior)) - { - } - - #region System.Net.Http.HttpMessageHandler - - /// - protected override global::System.Net.Http.HttpResponseMessage Send(global::System.Net.Http.HttpRequestMessage request, global::System.Threading.CancellationToken cancellationToken) - { - global::Mockolate.Setup.ReturnMethodSetup? methodSetup = null; - if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) - { - global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send); - 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(request, cancellationToken)) - { - methodSetup = s_methodSetup; - break; - } - } - } - } - if (methodSetup is null) - { - foreach (global::Mockolate.Setup.ReturnMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::System.Net.Http.HttpMessageHandler.Send")) - { - if (s_methodSetup.Matches(request, cancellationToken)) - { - methodSetup = s_methodSetup; - break; - } - } - } - bool hasWrappedResult = false; - global::System.Net.Http.HttpResponseMessage wrappedResult = default!; - if (this.MockRegistry.Behavior.SkipInteractionRecording == false) - { - this.MockolateBuffer_Send.Append("global::System.Net.Http.HttpMessageHandler.Send", request, cancellationToken); - } - try - { - if (!(methodSetup?.SkipBaseClass(this.MockRegistry.Behavior) ?? this.MockRegistry.Behavior.SkipBaseClass)) - { - wrappedResult = base.Send(request, cancellationToken); - hasWrappedResult = true; - } - } - finally - { - methodSetup?.TriggerCallbacks(request, cancellationToken); - } - if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) - { - throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::System.Net.Http.HttpMessageHandler.Send(HttpRequestMessage, CancellationToken)' was invoked without prior setup."); - } - if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) - { - return wrappedResult; - } - return methodSetup?.TryGetReturnValue(request, cancellationToken, out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(global::System.Net.Http.HttpResponseMessage)!, request, cancellationToken); - } - - /// - protected override global::System.Threading.Tasks.Task SendAsync(global::System.Net.Http.HttpRequestMessage request, global::System.Threading.CancellationToken cancellationToken) - { - global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>? methodSetup = null; - if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) - { - global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync); - 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, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> s_methodSetup && s_methodSetup.Matches(request, cancellationToken)) - { - methodSetup = s_methodSetup; - break; - } - } - } - } - if (methodSetup is null) - { - foreach (global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> s_methodSetup in this.MockRegistry.GetMethodSetups, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>>("global::System.Net.Http.HttpMessageHandler.SendAsync")) - { - if (s_methodSetup.Matches(request, cancellationToken)) - { - methodSetup = s_methodSetup; - break; - } - } - } - bool hasWrappedResult = false; - global::System.Threading.Tasks.Task wrappedResult = default!; - if (this.MockRegistry.Behavior.SkipInteractionRecording == false) - { - this.MockolateBuffer_SendAsync.Append("global::System.Net.Http.HttpMessageHandler.SendAsync", request, cancellationToken); - } - try - { - } - finally - { - methodSetup?.TriggerCallbacks(request, cancellationToken); - } - if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) - { - throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::System.Net.Http.HttpMessageHandler.SendAsync(HttpRequestMessage, CancellationToken)' was invoked without prior setup."); - } - if (methodSetup?.HasReturnCallbacks != true && hasWrappedResult) - { - return wrappedResult; - } - return methodSetup?.TryGetReturnValue(request, cancellationToken, out var returnValue) == true ? returnValue : this.MockRegistry.Behavior.DefaultValue.Generate(default(global::System.Threading.Tasks.Task)!, this.MockRegistry.Behavior.DefaultValue.Generate(default(global::System.Net.Http.HttpResponseMessage)!, request, cancellationToken), request, cancellationToken); - } - - /// - protected override void Dispose(bool disposing) - { - global::Mockolate.Setup.VoidMethodSetup? methodSetup = null; - if (string.IsNullOrEmpty(this.MockRegistry.Scenario)) - { - global::Mockolate.Setup.MethodSetup[]? snapshot_methodSetup = this.MockRegistry.GetMethodSetupSnapshot(global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose); - 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.VoidMethodSetup s_methodSetup && s_methodSetup.Matches(disposing)) - { - methodSetup = s_methodSetup; - break; - } - } - } - } - if (methodSetup is null) - { - foreach (global::Mockolate.Setup.VoidMethodSetup s_methodSetup in this.MockRegistry.GetMethodSetups>("global::System.Net.Http.HttpMessageHandler.Dispose")) - { - if (s_methodSetup.Matches(disposing)) - { - methodSetup = s_methodSetup; - break; - } - } - } - bool hasWrappedResult = false; - if (this.MockRegistry.Behavior.SkipInteractionRecording == false) - { - this.MockolateBuffer_Dispose.Append("global::System.Net.Http.HttpMessageHandler.Dispose", disposing); - } - try - { - if (!(methodSetup?.SkipBaseClass(this.MockRegistry.Behavior) ?? this.MockRegistry.Behavior.SkipBaseClass)) - { - base.Dispose(disposing); - hasWrappedResult = true; - } - } - finally - { - methodSetup?.TriggerCallbacks(disposing); - } - if (methodSetup is null && !hasWrappedResult && this.MockRegistry.Behavior.ThrowWhenNotSetup) - { - throw new global::Mockolate.Exceptions.MockNotSetupException("The method 'global::System.Net.Http.HttpMessageHandler.Dispose(bool)' was invoked without prior setup."); - } - } - - #endregion System.Net.Http.HttpMessageHandler - - #region IMockSetupForHttpMessageHandler - - #endregion IMockSetupForHttpMessageHandler - - #region IMockProtectedSetupForHttpMessageHandler - - /// - global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::Mockolate.Parameters.IParameters parameters) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", parameters, "request", "cancellationToken"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, methodSetup); - return methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - global::Mockolate.Setup.ReturnMethodSetup methodSetup; - if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.Literal!, cancellationTokenArg.Literal!); - } - else - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); - } - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) - { - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupWithCallback, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::Mockolate.Parameters.IParameters parameters) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", parameters, "request", "cancellationToken"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, methodSetup); - return methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> methodSetup; - if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.Literal!, cancellationTokenArg.Literal!); - } - else - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); - } - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) - { - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Dispose(global::Mockolate.Parameters.IParameters parameters) - { - var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", parameters, "disposing"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, methodSetup); - return methodSetup; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Dispose(global::Mockolate.ParameterArg? disposing) - { - global::Mockolate.ParameterArg disposingArg = disposing ?? default; - global::Mockolate.Setup.VoidMethodSetup methodSetup; - if (disposingArg.IsLiteral) - { - methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", disposingArg.Literal!); - } - else - { - methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", disposingArg.ToParameterMatch()); - } - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, methodSetup); - return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Dispose(global::System.Func disposing, string disposingExpression) - { - var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(disposing, disposingExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, methodSetup); - return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; - } - - #endregion IMockProtectedSetupForHttpMessageHandler - - #region IMockVerifyForHttpMessageHandler - - #endregion IMockVerifyForHttpMessageHandler - - #region IMockProtectedVerifyForHttpMessageHandler - - /// - global::Mockolate.Verify.VerificationResult IMockProtectedVerifyForHttpMessageHandler.Send(global::Mockolate.Parameters.IParameters parameters) - => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, "global::System.Net.Http.HttpMessageHandler.Send", __i => parameters switch - { - global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2]), - global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("request", __i.Parameter1), ("cancellationToken", __i.Parameter2)]), - _ => true - }, () => $"Send({parameters})"); - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpMessageHandler.Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) - { - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.Literal!, cancellationTokenArg.Literal!, () => $"Send({requestArg}, {cancellationTokenArg})"); - } - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch(), () => $"Send({requestArg}, {cancellationTokenArg})"); - } - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpMessageHandler.Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) - { - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, "global::System.Net.Http.HttpMessageHandler.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch(), () => $"Send({requestExpression}, {cancellationTokenArg})"); - } - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpMessageHandler.Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"Send({requestArg}, {cancellationTokenExpression})"); - } - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpMessageHandler.Send(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) - { - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, "global::System.Net.Http.HttpMessageHandler.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"Send({requestExpression}, {cancellationTokenExpression})"); - } - - /// - global::Mockolate.Verify.VerificationResult IMockProtectedVerifyForHttpMessageHandler.SendAsync(global::Mockolate.Parameters.IParameters parameters) - => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, "global::System.Net.Http.HttpMessageHandler.SendAsync", __i => parameters switch - { - global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1, __i.Parameter2]), - global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("request", __i.Parameter1), ("cancellationToken", __i.Parameter2)]), - _ => true - }, () => $"SendAsync({parameters})"); - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpMessageHandler.SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) - { - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.Literal!, cancellationTokenArg.Literal!, () => $"SendAsync({requestArg}, {cancellationTokenArg})"); - } - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch(), () => $"SendAsync({requestArg}, {cancellationTokenArg})"); - } - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpMessageHandler.SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) - { - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, "global::System.Net.Http.HttpMessageHandler.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch(), () => $"SendAsync({requestExpression}, {cancellationTokenArg})"); - } - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpMessageHandler.SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"SendAsync({requestArg}, {cancellationTokenExpression})"); - } - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpMessageHandler.SendAsync(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) - { - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, "global::System.Net.Http.HttpMessageHandler.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression), () => $"SendAsync({requestExpression}, {cancellationTokenExpression})"); - } - - /// - global::Mockolate.Verify.VerificationResult IMockProtectedVerifyForHttpMessageHandler.Dispose(global::Mockolate.Parameters.IParameters parameters) - => this.MockRegistry.VerifyMethod>(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, "global::System.Net.Http.HttpMessageHandler.Dispose", __i => parameters switch - { - global::Mockolate.Parameters.IParametersMatch m => m.Matches([__i.Parameter1]), - global::Mockolate.Parameters.INamedParametersMatch m => m.Matches([("disposing", __i.Parameter1)]), - _ => true - }, () => $"Dispose({parameters})"); - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpMessageHandler.Dispose(global::Mockolate.ParameterArg? disposing) - { - global::Mockolate.ParameterArg disposingArg = disposing ?? default; - if (disposingArg.IsLiteral) - { - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, "global::System.Net.Http.HttpMessageHandler.Dispose", disposingArg.Literal!, () => $"Dispose({disposingArg})"); - } - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, "global::System.Net.Http.HttpMessageHandler.Dispose", disposingArg.ToParameterMatch(), () => $"Dispose({disposingArg})"); - } - - /// - global::Mockolate.Verify.VerificationResult.IgnoreParameters IMockProtectedVerifyForHttpMessageHandler.Dispose(global::System.Func disposing, string disposingExpression) - { - return this.MockRegistry.VerifyMethod(this, global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, "global::System.Net.Http.HttpMessageHandler.Dispose", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(disposing, disposingExpression), () => $"Dispose({disposingExpression})"); - } - - #endregion IMockProtectedVerifyForHttpMessageHandler - } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class VerifyMonitorHttpMessageHandler(global::Mockolate.MockRegistry mockRegistry) : global::Mockolate.Mock.IMockVerifyForHttpMessageHandler - { - private global::Mockolate.MockRegistry MockRegistry { get; } = mockRegistry; - - #region IMockVerifyForHttpMessageHandler - - #endregion IMockVerifyForHttpMessageHandler - } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class MockInScenarioForHttpMessageHandler : global::Mockolate.Mock.IMockInScenarioForHttpMessageHandler, global::Mockolate.Mock.IMockSetupForHttpMessageHandler, global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler - { - private global::Mockolate.MockRegistry MockRegistry { get; } - private string _scenarioName; - - public MockInScenarioForHttpMessageHandler(global::Mockolate.MockRegistry mockRegistry, string scenario) - { - this.MockRegistry = mockRegistry; - _scenarioName = scenario; - } - - /// - global::Mockolate.Mock.IMockSetupForHttpMessageHandler global::Mockolate.Mock.IMockInScenarioForHttpMessageHandler.Setup - => this; - - /// - global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler global::Mockolate.Mock.IMockInScenarioForHttpMessageHandler.SetupProtected - => this; - - #region IMockSetupForHttpMessageHandler - - #endregion IMockSetupForHttpMessageHandler - - #region IMockProtectedSetupForHttpMessageHandler - - /// - global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::Mockolate.Parameters.IParameters parameters) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", parameters, "request", "cancellationToken"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, _scenarioName, methodSetup); - return methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - global::Mockolate.Setup.ReturnMethodSetup methodSetup; - if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.Literal!, cancellationTokenArg.Literal!); - } - else - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); - } - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, _scenarioName, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) - { - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, _scenarioName, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, _scenarioName, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, _scenarioName, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupWithCallback, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::Mockolate.Parameters.IParameters parameters) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", parameters, "request", "cancellationToken"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, _scenarioName, methodSetup); - return methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> methodSetup; - if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.Literal!, cancellationTokenArg.Literal!); - } - else - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); - } - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, _scenarioName, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) - { - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, _scenarioName, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, _scenarioName, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, _scenarioName, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Dispose(global::Mockolate.Parameters.IParameters parameters) - { - var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", parameters, "disposing"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, _scenarioName, methodSetup); - return methodSetup; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Dispose(global::Mockolate.ParameterArg? disposing) - { - global::Mockolate.ParameterArg disposingArg = disposing ?? default; - global::Mockolate.Setup.VoidMethodSetup methodSetup; - if (disposingArg.IsLiteral) - { - methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", disposingArg.Literal!); - } - else - { - methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", disposingArg.ToParameterMatch()); - } - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, _scenarioName, methodSetup); - return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Dispose(global::System.Func disposing, string disposingExpression) - { - var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(disposing, disposingExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, _scenarioName, methodSetup); - return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; - } - - #endregion IMockProtectedSetupForHttpMessageHandler - } - - /// - /// The Mockolate accessor for a mock of HttpMessageHandler, reached through .Mock on the mocked instance. - /// - /// - /// Groups every operation that acts on the mock rather than on the mocked subject: setups, verifications, event raising, scenarios and monitoring. - /// - internal interface IMockForHttpMessageHandler - { - /// - /// Configures how members of the mock of HttpMessageHandler respond when invoked. - /// - /// - /// Each mocked member is available as a strongly-typed entry on this surface. Chain Returns, ReturnsAsync, Throws, ThrowsAsync or Do to control the response; chain InitializeWith/Register to initialize properties and indexers; chain multiple returns/throws to define a sequence; use .For(n), .Only(n), .Forever(), .When(predicate) to control when a callback runs.
- /// When two setups overlap, the most recently defined one wins. - ///
- IMockSetupForHttpMessageHandler Setup { get; } - - /// - /// Configures how virtual members of the mock of HttpMessageHandler respond when invoked. - /// - /// - /// Only members declared as (or ) on the mocked class appear here. All setup chain operators (Returns, Throws, Do, sequences, .For/.Only/.Forever, ...) work identically to Setup. - /// - IMockProtectedSetupForHttpMessageHandler SetupProtected { get; } - - /// - /// Opens a named scenario scope on the mock of HttpMessageHandler so that additional setups can be registered for that scenario. - /// - /// - /// Scenarios let you define per-state behavior. Setups registered inside the returned IMockInScenarioFor... scope only apply while the mock's current scenario matches ; switch scenarios with TransitionTo. - /// - /// Name of the scenario to enter. Any non-null string acts as a key; the mock starts in an unnamed default scenario. - /// A scoped accessor whose Setup (and SetupProtected, where applicable) register scenario-specific setups. - IMockInScenarioForHttpMessageHandler InScenario(string scenario); - - /// - /// Opens a named scenario scope on the mock of HttpMessageHandler and immediately invokes to register scenario-specific setups. - /// - /// - /// Equivalent to InScenario(scenario) followed by the setup callback, but returns the original IMockFor... accessor so it chains nicely at mock-creation time. - /// - /// Name of the scenario to enter. - /// Callback that receives the scenario-scoped setup surface and registers scenario-specific setups. - /// This accessor, to allow chaining. - IMockForHttpMessageHandler InScenario(string scenario, global::System.Action setup); - - /// - /// Switches the active scenario of the mock of HttpMessageHandler to . - /// - /// - /// After the transition, setups registered via InScenario(string) under that scenario take effect. Scenarios that have no matching setup for a given member fall back to the default (un-scoped) setups. - /// - /// Name of the scenario to transition to. - /// This accessor, to allow chaining. - IMockForHttpMessageHandler TransitionTo(string scenario); - - /// - /// Asserts how often, and in which order, members of the mock of HttpMessageHandler were invoked. - /// - /// - /// Each call to a member here returns a VerificationResult that you terminate with a count assertion: Never(), Once(), Twice(), Exactly(n), AtLeast(n)/AtLeastOnce()/AtLeastTwice(), AtMost(n)/AtMostOnce()/AtMostTwice(), Between(min, max) or Times(predicate).
- /// Use Within(TimeSpan) / WithCancellation(CancellationToken) before the terminator to wait for expected interactions that happen on background threads.
- /// Chain Then(...) to assert an ordered sequence of calls. A failing assertion throws a MockVerificationException. - ///
- IMockVerifyForHttpMessageHandler Verify { get; } - - /// - /// Asserts how often, and in which order, members of the mock of HttpMessageHandler were invoked. - /// - /// - /// Same terminators and modifiers as Verify (Once(), Exactly(n), Within(...), Then(...), ...); applies to members and events instead of public ones. - /// - IMockProtectedVerifyForHttpMessageHandler VerifyProtected { get; } - - /// - /// Verifies how often a specific method setup was matched by actual invocations. - /// - /// - /// Useful when you want to verify "this particular setup was hit N times" without re-stating the matchers. Chain the usual count terminators (Once(), AtLeastOnce(), Exactly(n), ...) on the returned result. - /// - /// The setup previously registered through Setup (typically returned from a Returns(...)/Throws(...) call). - /// A VerificationResult that counts invocations matching the given setup. - global::Mockolate.Verify.VerificationResult VerifySetup(global::Mockolate.Setup.IMethodSetup setup); - - /// - /// Checks whether every recorded interaction on this mock has been observed by at least one Verify call. - /// - /// - /// Useful in test teardown to catch unexpected interactions ("strict verification"): if any recorded call has never been matched by a verification, the method returns . - /// - /// if every recorded interaction was verified at least once; otherwise . - bool VerifyThatAllInteractionsAreVerified(); - - /// - /// Checks whether every registered setup on this mock was matched by at least one actual invocation. - /// - /// - /// Useful to catch unused setups that silently rot as the test subject evolves. - /// - /// if every registered setup was used at least once; otherwise . - bool VerifyThatAllSetupsAreUsed(); - - /// - /// Removes every recorded interaction from this mock while keeping all registered setups intact. - /// - /// - /// Handy when a single test exercises multiple logical phases and you only want to verify the interactions of the latest phase. - /// - void ClearAllInteractions(); - - /// - /// Creates a monitor whose Verify surface is scoped to interactions produced between monitor.Run() and the disposal of its IDisposable scope. - /// - /// - /// The underlying mock keeps recording all interactions as usual - only the monitor's Verify view is scoped. Useful to verify only the interactions produced by a specific block of test code without resetting the mock. - /// - /// A MockMonitor<T> that exposes Verify over the monitored interactions and a Run() method that opens the recording scope. - global::Mockolate.Monitor.MockMonitor Monitor(); - } - - /// - /// Scoped access to setups for a scenario on the mock of HttpMessageHandler. - /// - internal interface IMockInScenarioForHttpMessageHandler - { - /// - /// Set up the mock of HttpMessageHandler within the scenario scope. - /// - IMockSetupForHttpMessageHandler Setup { get; } - - /// - /// Set up protected members of the mock of HttpMessageHandler within the scenario scope. - /// - IMockProtectedSetupForHttpMessageHandler SetupProtected { get; } - } - - /// - /// Set up the mock of HttpMessageHandler. - /// - internal interface IMockSetupForHttpMessageHandler : global::Mockolate.Setup.IMockSetup - { - } - - /// - /// Set up protected members for the mock of HttpMessageHandler. - /// - internal interface IMockProtectedSetupForHttpMessageHandler - { - /// - /// Setup for the method Send(HttpRequestMessage, CancellationToken) 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 Send(global::Mockolate.Parameters.IParameters parameters); - - /// - /// Setup for the method Send(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken); - - /// - /// Setup for the method Send(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = ""); - - /// - /// Setup for the method Send(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); - - /// - /// Setup for the method Send(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts a predicate for , . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer Send(global::System.Func request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); - - /// - /// Setup for the method SendAsync(HttpRequestMessage, CancellationToken) 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, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::Mockolate.Parameters.IParameters parameters); - - /// - /// Setup for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken); - - /// - /// Setup for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = ""); - - /// - /// Setup for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); - - /// - /// Setup for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts a predicate for , . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> SendAsync(global::System.Func request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); - - /// - /// Setup for the method Dispose(bool) 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.IVoidMethodSetupWithCallback Dispose(global::Mockolate.Parameters.IParameters parameters); - - /// - /// Setup for the method Dispose(bool) with the given . - /// - /// - /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] - global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer Dispose(global::Mockolate.ParameterArg? disposing); - - /// - /// Setup for the method Dispose(bool) with the given . - /// - /// - /// This overload accepts a predicate for . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] - global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer Dispose(global::System.Func disposing, [global::System.Runtime.CompilerServices.CallerArgumentExpression("disposing")] string disposingExpression = ""); - - } - - /// - /// Verify interactions with the mock of HttpMessageHandler. - /// - internal interface IMockVerifyForHttpMessageHandler : global::Mockolate.Verify.IMockVerify - { - } - - /// - /// Verify protected interactions with the mock of HttpMessageHandler. - /// - internal interface IMockProtectedVerifyForHttpMessageHandler - { - /// - /// Verify invocations for the method Send(HttpRequestMessage, CancellationToken) 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 Send(global::Mockolate.Parameters.IParameters parameters); - - /// - /// Verify invocations for the method Send(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] - global::Mockolate.Verify.VerificationResult.IgnoreParameters Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken); - - /// - /// Verify invocations for the method Send(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] - global::Mockolate.Verify.VerificationResult.IgnoreParameters Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = ""); - - /// - /// Verify invocations for the method Send(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] - global::Mockolate.Verify.VerificationResult.IgnoreParameters Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); - - /// - /// Verify invocations for the method Send(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts a predicate for , . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] - global::Mockolate.Verify.VerificationResult.IgnoreParameters Send(global::System.Func request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); - - /// - /// Verify invocations for the method SendAsync(HttpRequestMessage, CancellationToken) 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 SendAsync(global::Mockolate.Parameters.IParameters parameters); - - /// - /// Verify invocations for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] - global::Mockolate.Verify.VerificationResult.IgnoreParameters SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken); - - /// - /// Verify invocations for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] - global::Mockolate.Verify.VerificationResult.IgnoreParameters SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = ""); - - /// - /// Verify invocations for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts an It matcher or a direct value for and a predicate for . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(1)] - global::Mockolate.Verify.VerificationResult.IgnoreParameters SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); - - /// - /// Verify invocations for the method SendAsync(HttpRequestMessage, CancellationToken) with the given , . - /// - /// - /// This overload accepts a predicate for , . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] - global::Mockolate.Verify.VerificationResult.IgnoreParameters SendAsync(global::System.Func request, global::System.Func cancellationToken, [global::System.Runtime.CompilerServices.CallerArgumentExpression("request")] string requestExpression = "", [global::System.Runtime.CompilerServices.CallerArgumentExpression("cancellationToken")] string cancellationTokenExpression = ""); - - /// - /// Verify invocations for the method Dispose(bool) 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 Dispose(global::Mockolate.Parameters.IParameters parameters); - - /// - /// Verify invocations for the method Dispose(bool) with the given . - /// - /// - /// This overload accepts an It matcher or a direct value for every parameter. A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(int.MaxValue)] - global::Mockolate.Verify.VerificationResult.IgnoreParameters Dispose(global::Mockolate.ParameterArg? disposing); - - /// - /// Verify invocations for the method Dispose(bool) with the given . - /// - /// - /// This overload accepts a predicate for . A or argument stands for the literal default value. - /// - [global::System.Runtime.CompilerServices.OverloadResolutionPriority(0)] - global::Mockolate.Verify.VerificationResult.IgnoreParameters Dispose(global::System.Func disposing, [global::System.Runtime.CompilerServices.CallerArgumentExpression("disposing")] string disposingExpression = ""); - - } -} -/// -/// Mock extensions for HttpMessageHandler. -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static partial class MockExtensionsForHttpMessageHandler -{ - /// - extension(global::System.Net.Http.HttpMessageHandler mock) - { - /// - /// Gets the mock accessor for HttpMessageHandler - the entry point for configuring setups, verifying interactions and raising events. - /// - /// - /// The accessor is the bridge between the strongly-typed instance of HttpMessageHandler returned by CreateMock(...) and the underlying mock registry where setups and recorded interactions live.
- /// Through it you can:
- ///
- /// Setup - configure how members respond when invoked (Returns, Throws, Do, InitializeWith, ...).
- /// Verify - assert how often (and in which order) members were invoked.
- /// SetupProtected / VerifyProtected / RaiseProtected - target members on class mocks.
- /// InScenario / TransitionTo - scope setups and behavior to a named scenario and switch between scenarios.
- /// Monitor, ClearAllInteractions, VerifyThatAllInteractionsAreVerified, VerifyThatAllSetupsAreUsed - manage recorded interactions.
- /// VerifySetup - verify how often a specific setup matched.
- ///
- ///
- /// The instance is not a Mockolate-generated mock of HttpMessageHandler. - public global::Mockolate.Mock.IMockForHttpMessageHandler Mock - { - get - { - if (mock is global::Mockolate.Mock.IMockForHttpMessageHandler mockInterface) - { - return mockInterface; - } - throw new global::Mockolate.Exceptions.MockException("The subject is no mock."); - } - } - - /// - /// Creates a new mock of HttpMessageHandler with the default MockBehavior. - /// - /// - /// The returned instance is a strongly-typed mock generated at compile time - it implements HttpMessageHandler and exposes the Mockolate surface through .Mock:
- ///
- /// .Mock.Setup configures how members respond (Returns, Throws, Do, InitializeWith, sequences, callbacks).
- /// .Mock.Verify asserts how often and in which order members were invoked.
- ///

- /// With the default behavior, un-configured members return default values (empty collections / strings, completed tasks, otherwise) and base-class implementations are invoked for class mocks. Use one of the overloads that accepts a MockBehavior to customize this (for example to make un-configured calls throw or to skip the base class).
- /// Overloads allow you to additionally pass constructor parameters (for class mocks), apply an initial setup callback before the instance is returned, or combine both. - ///
- /// A new mock instance of HttpMessageHandler. - public static global::System.Net.Http.HttpMessageHandler CreateMock() - => CreateMock(null, null, (object?[]?)null); - - /// - /// Creates a new mock of HttpMessageHandler with the default MockBehavior, applying the given immediately. - /// - /// - /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. - /// - /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. - /// A new mock instance of HttpMessageHandler. - public static global::System.Net.Http.HttpMessageHandler CreateMock(global::System.Action setup) - => CreateMock(null, setup, (object?[]?)null); - - /// - /// Creates a new mock of HttpMessageHandler with the given . - /// - /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. - /// A new mock instance of HttpMessageHandler. - public static global::System.Net.Http.HttpMessageHandler CreateMock(global::Mockolate.MockBehavior mockBehavior) - => CreateMock(mockBehavior, null, (object?[]?)null); - - /// - /// Creates a new mock of HttpMessageHandler with the given , applying the given immediately. - /// - /// - /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. - /// - /// Controls how the mock responds when members are invoked without a matching setup; see MockBehavior. - /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned. - /// A new mock instance of HttpMessageHandler. - public static global::System.Net.Http.HttpMessageHandler CreateMock(global::Mockolate.MockBehavior mockBehavior, global::System.Action setup) - => CreateMock(mockBehavior, setup, (object?[]?)null); - - /// - /// Creates a new mock of HttpMessageHandler using the given , applying the given immediately, using the given . - /// - /// - /// The provided is immediately applied to the mock. Use this overload when you want setups to cover virtual interactions triggered inside the constructor. - /// - /// Controls how the mock responds when members are invoked without a matching setup, or for MockBehavior.Default. - /// Callback that receives the mock's setup surface and registers initial setups before the mock is returned, or to skip. - /// Values forwarded to a matching base-class constructor, or to use the parameterless constructor. - /// A new mock instance of HttpMessageHandler. - private static global::System.Net.Http.HttpMessageHandler CreateMock(global::Mockolate.MockBehavior? mockBehavior, global::System.Action? setup, object?[]? constructorParameters) - { - if (mockBehavior is not null) - { - IMockBehaviorAccess mockBehaviorAccess = (global::Mockolate.IMockBehaviorAccess)mockBehavior; - if (mockBehaviorAccess.TryGet?>(out var additionalSetup)) - { - if (setup is null) - { - setup = additionalSetup; - } - else - { - var originalSetup = setup; - setup = s => { additionalSetup.Invoke(s); originalSetup.Invoke(s); }; - } - } - if (constructorParameters is null && mockBehaviorAccess.TryGetConstructorParameters(out object?[]? parameters)) - { - constructorParameters = parameters; - } - } - - mockBehavior ??= global::Mockolate.MockBehavior.Default; - global::Mockolate.MockRegistry mockRegistry = new global::Mockolate.MockRegistry(mockBehavior, global::Mockolate.Mock.HttpMessageHandler.MemberCount, constructorParameters); - return CreateMockInstance(mockRegistry, constructorParameters, setup); - } - - private static global::System.Net.Http.HttpMessageHandler CreateMockInstance(global::Mockolate.MockRegistry mockRegistry, object?[]? constructorParameters, global::System.Action? setup) - { - if (constructorParameters is null || constructorParameters.Length == 0) - { - global::Mockolate.Mock.HttpMessageHandler.MockRegistryProvider.Value = mockRegistry; - global::Mockolate.MockExtensionsForHttpMessageHandler.MockSetup? setupTarget = null; - if (setup is not null) - { - setupTarget ??= new(mockRegistry); - setup.Invoke(setupTarget); - } - return new global::Mockolate.Mock.HttpMessageHandler(mockRegistry); - } - else if (constructorParameters.Length == 0) - { - global::Mockolate.Mock.HttpMessageHandler.MockRegistryProvider.Value = mockRegistry; - global::Mockolate.MockExtensionsForHttpMessageHandler.MockSetup? setupTarget = null; - if (setup is not null) - { - setupTarget ??= new(mockRegistry); - setup.Invoke(setupTarget); - } - return new global::Mockolate.Mock.HttpMessageHandler(mockRegistry); - } - else - { - throw new global::Mockolate.Exceptions.MockException($"Could not find any constructor for 'System.Net.Http.HttpMessageHandler' that matches the {constructorParameters.Length} given parameters ({string.Join(", ", constructorParameters)})."); - } - } - /// - /// Creates a mock that wraps the given . - /// - /// - /// Public members on the mock forward to unless overridden by a setup; protected members still go through the base-class implementation. All forwarded interactions are recorded and can be verified the same as on a plain mock. - /// - /// The real object whose calls should be forwarded. Must not be . - /// A new mock of HttpMessageHandler that delegates to . - public global::System.Net.Http.HttpMessageHandler Wrapping(global::System.Net.Http.HttpMessageHandler instance) - { - if (mock is global::Mockolate.IMock mockInterface) - { - global::Mockolate.MockRegistry wrappingRegistry = new global::Mockolate.MockRegistry(mockInterface.MockRegistry, instance); - wrappingRegistry = new global::Mockolate.MockRegistry(wrappingRegistry, global::Mockolate.Mock.HttpMessageHandler.CreateFastInteractions(wrappingRegistry.Behavior)); - return CreateMockInstance(wrappingRegistry, mockInterface.MockRegistry.ConstructorParameters, null); - } - throw new global::Mockolate.Exceptions.MockException("The subject is no mock."); - } - - } - - /// - extension(global::Mockolate.MockBehavior behavior) - { - /// - /// Initializes mocks of type with the given . - /// - /// - /// The is applied to the mock before the constructor is executed. Calling Initialize again overlays additional setups on top of any previously registered ones. - /// - /// The mockable type derived from HttpMessageHandler that this setup should apply to. - /// Callback invoked when a new mock of is created. - /// A new MockBehavior with the registered initializer. The original instance is unchanged. - public global::Mockolate.MockBehavior Initialize(global::System.Action setup) - where T : global::System.Net.Http.HttpMessageHandler - { - var behaviorAccess = (global::Mockolate.IMockBehaviorAccess)behavior; - return behaviorAccess.Set(setup); - } - } - internal interface IMockSetupInitializationForHttpMessageHandler : global::Mockolate.Mock.IMockSetupForHttpMessageHandler - { - /// - /// Setup protected members - /// - global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler Protected { get; } - } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal sealed class MockSetup(global::Mockolate.MockRegistry mockRegistry) : global::Mockolate.Mock.IMockSetupForHttpMessageHandler, global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler, IMockSetupInitializationForHttpMessageHandler - { - /// - global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler IMockSetupInitializationForHttpMessageHandler.Protected => this; - private global::Mockolate.MockRegistry MockRegistry { get; } = mockRegistry; - - #region IMockSetupForHttpMessageHandler - - #endregion IMockSetupForHttpMessageHandler - - #region IMockProtectedSetupForHttpMessageHandler - - /// - global::Mockolate.Setup.IReturnMethodSetupWithCallback global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::Mockolate.Parameters.IParameters parameters) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", parameters, "request", "cancellationToken"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, methodSetup); - return methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - global::Mockolate.Setup.ReturnMethodSetup methodSetup; - if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.Literal!, cancellationTokenArg.Literal!); - } - else - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); - } - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) - { - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Send(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Send", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Send, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupWithCallback, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::Mockolate.Parameters.IParameters parameters) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", parameters, "request", "cancellationToken"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, methodSetup); - return methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::Mockolate.ParameterArg? request, global::Mockolate.ParameterArg? cancellationToken) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> methodSetup; - if (requestArg.IsLiteral && cancellationTokenArg.IsLiteral) - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.Literal!, cancellationTokenArg.Literal!); - } - else - { - methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.ToParameterMatch(), cancellationTokenArg.ToParameterMatch()); - } - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::System.Func request, global::Mockolate.ParameterArg? cancellationToken, string requestExpression) - { - global::Mockolate.ParameterArg cancellationTokenArg = cancellationToken ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), cancellationTokenArg.ToParameterMatch()); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::Mockolate.ParameterArg? request, global::System.Func cancellationToken, string cancellationTokenExpression) - { - global::Mockolate.ParameterArg requestArg = request ?? default; - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", requestArg.ToParameterMatch(), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - /// - global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken> global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.SendAsync(global::System.Func request, global::System.Func cancellationToken, string requestExpression, string cancellationTokenExpression) - { - var methodSetup = new global::Mockolate.Setup.ReturnMethodSetup, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.SendAsync", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(request, requestExpression), (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(cancellationToken, cancellationTokenExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_SendAsync, methodSetup); - return (global::Mockolate.Setup.IReturnMethodSetupParameterIgnorer, global::System.Net.Http.HttpRequestMessage, global::System.Threading.CancellationToken>)methodSetup; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupWithCallback global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Dispose(global::Mockolate.Parameters.IParameters parameters) - { - var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameters(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", parameters, "disposing"); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, methodSetup); - return methodSetup; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Dispose(global::Mockolate.ParameterArg? disposing) - { - global::Mockolate.ParameterArg disposingArg = disposing ?? default; - global::Mockolate.Setup.VoidMethodSetup methodSetup; - if (disposingArg.IsLiteral) - { - methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithLiteralValues(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", disposingArg.Literal!); - } - else - { - methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", disposingArg.ToParameterMatch()); - } - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, methodSetup); - return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; - } - - /// - global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer global::Mockolate.Mock.IMockProtectedSetupForHttpMessageHandler.Dispose(global::System.Func disposing, string disposingExpression) - { - var methodSetup = new global::Mockolate.Setup.VoidMethodSetup.WithParameterCollection(MockRegistry, "global::System.Net.Http.HttpMessageHandler.Dispose", (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.Satisfies(disposing, disposingExpression)); - this.MockRegistry.SetupMethod(global::Mockolate.Mock.HttpMessageHandler.MemberId_Dispose, methodSetup); - return (global::Mockolate.Setup.IVoidMethodSetupParameterIgnorer)methodSetup; - } - - #endregion IMockProtectedSetupForHttpMessageHandler - } -} - -#nullable disable annotations diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.g.cs deleted file mode 100644 index 3944360b..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/Mock.g.cs +++ /dev/null @@ -1,135 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable -/// -/// Create new mocks by calling the static T.CreateMock() method on your type T. -/// -/// -/// You can also provide a MockBehavior parameter to customize how the mock should behave in certain scenarios.
-/// If your type is a class without a default constructor, you can provide constructor parameters by passing an object?[]? to the corresponding CreateMock(...) overload. -///
-[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static partial class Mock -{ - /// - /// This interface should never be used. If it is, this is an indication that the Mockolate source generator did not run correctly or that the used type is not mockable. - /// - /// - /// The source generator creates overloads with correct return values. - /// - internal interface IMockGenerationDidNotRun {} - - /// - /// Create a new mock of with the default MockBehavior. - /// - /// Type to mock, which can be an interface or a class. - /// - /// Any interface type can be used for mocking, but for classes, only abstract and virtual members can be mocked. - /// - extension(T _) - { - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior = null) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior, object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - } - - extension(global::Mockolate.Mock.IMockGenerationDidNotRun _) - { - /// - /// Fallback Implementing that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Additional interface the mock should implement. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete Implementing overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public global::Mockolate.Mock.IMockGenerationDidNotRun Implementing() where TInterface : class - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(TInterface)}' is not mockable or the source generator did not run correctly."); - } - } - -} - -/// -/// Adapts an IParameter (non-generic) to -/// IParameterMatch<T> so that covariant parameter -/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> -/// slot) can still be invoked at setup/verify time. Only allocated when the direct -/// IParameterMatch<T> cast fails. Shared by every -/// generated mock file. -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch -{ - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); -} -#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/MockBehaviorExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/MockBehaviorExtensions.g.cs deleted file mode 100644 index 3e895b59..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/MockBehaviorExtensions.g.cs +++ /dev/null @@ -1,301 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable annotations - -/// -/// Extensions for MockBehavior. -/// -internal static partial class Mock -{ - private static readonly global::Mockolate.MockBehavior _default; - - static Mock() - { - _default = new global::Mockolate.MockBehavior(new DefaultValueGenerator()); - } - - extension(global::Mockolate.MockBehavior) - { - /// - /// The default MockBehavior - the starting point for configuring a mock. - /// - /// - /// Un-configured members return the generator-provided default value (empty strings/collections, completed - /// Tasks, otherwise), base-class - /// implementations run for class mocks, and every invocation is recorded for later verification. - /// - /// Chain SkippingBaseClass(), ThrowingWhenNotSetup(), SkippingInteractionRecording(), - /// WithDefaultValueFor<T>(...) or UseConstructorParametersFor<T>(...) to derive - /// a customized MockBehavior; because it is a , - /// each call returns a new instance and this shared default stays unchanged. - /// - public static global::Mockolate.MockBehavior Default => _default; - } - - /// - /// Defines a factory for creating default values for a specified type. - /// - public interface IDefaultValueFactory - { - /// - /// Determines whether the specified can be created by this factory. - /// - bool IsMatch(global::System.Type type); - - /// - /// Creates a new instance of the specified type. - /// - object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, object?[] parameters); - } - - /// - /// A IDefaultValueFactory that returns a specified for the given type - /// parameter . - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal class TypedDefaultValueFactory(T value) : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(T); - - /// - public object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - => value; - } - /// - /// A IDefaultValueFactory that returns an empty HttpResponseMessage with the specified - /// . - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class HttpResponseMessageFactory(global::System.Net.HttpStatusCode statusCode) : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Net.Http.HttpResponseMessage); - - /// - public object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - => new global::System.Net.Http.HttpResponseMessage(statusCode) { Content = new global::System.Net.Http.StringContent(string.Empty) }; - } - - /// - /// Provides default values for common types used in mocking scenarios. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private class DefaultValueGenerator : IDefaultValueGenerator - { - private static readonly global::System.Collections.Concurrent.ConcurrentQueue _factories = new([ - new TypedDefaultValueFactory(""), - new HttpResponseMessageFactory(global::System.Net.HttpStatusCode.NotImplemented), - new CancellableTaskFactory(), - #if NET8_0_OR_GREATER - new CancellableValueTaskFactory(), - #endif - new TypedDefaultValueFactory(global::System.Threading.CancellationToken.None), - new TypedDefaultValueFactory(global::System.Array.Empty()), - ]); - - /// - public object? GenerateValue(global::System.Type type, params object?[] parameters) - { - if (TryGenerate(type, parameters, out object? value)) - { - return value; - } - - return null; - } - - /// - /// Registers a to provide default values for a specific type. - /// - public static void Register(IDefaultValueFactory defaultValueFactory) - => _factories.Enqueue(defaultValueFactory); - - /// - /// Tries to generate a default value for the specified type. - /// - protected virtual bool TryGenerate(global::System.Type type, object?[] parameters, out object? value) - { - IDefaultValueFactory? matchingFactory = global::System.Linq.Enumerable.FirstOrDefault(_factories, Predicate); - if (matchingFactory is not null) - { - value = matchingFactory.Create(type, this, parameters); - return true; - } - - value = null; - return false; - - bool Predicate(global::Mockolate.Mock.IDefaultValueFactory f) - => f.IsMatch(type); - } - - private static bool HasCanceledCancellationToken(object?[] parameters, out global::System.Threading.CancellationToken cancellationToken) - { - global::System.Threading.CancellationToken parameter = global::System.Linq.Enumerable.FirstOrDefault(global::System.Linq.Enumerable.OfType(parameters)); - if (parameter.IsCancellationRequested) - { - cancellationToken = parameter; - return true; - } - - cancellationToken = global::System.Threading.CancellationToken.None; - return false; - } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CancellableTaskFactory : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Threading.Tasks.Task); - - /// - public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - { - if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) - { - return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.Task.CompletedTask; - } - } - #if NET8_0_OR_GREATER - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CancellableValueTaskFactory : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Threading.Tasks.ValueTask); - - /// - public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - { - if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) - { - return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.ValueTask.CompletedTask; - } - } - #endif - } -} - -/// -/// Extensions on IDefaultValueGenerator -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static class DefaultValueGeneratorExtensions -{ - /// - /// Adds a generic Generate method for specific types. - /// - extension(IDefaultValueGenerator generator) - { - /// - /// Generates a Task of , with - /// the for context. - /// - public global::System.Threading.Tasks.Task Generate(global::System.Threading.Tasks.Task nullValue, T value, params object?[] parameters) - { - global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( - global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; - if (cancellationToken.IsCancellationRequested) - { - return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.Task.FromResult(value); - } - -#if NET8_0_OR_GREATER - /// - /// Generates a ValueTask of , with - /// the for context. - /// - public global::System.Threading.Tasks.ValueTask Generate(global::System.Threading.Tasks.ValueTask nullValue, T value, params object?[] parameters) - { - global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( - global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; - if (cancellationToken.IsCancellationRequested) - { - return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.ValueTask.FromResult(value); - } -#endif - - /// - /// Generates an empty enumerable of , with - /// the for context. - /// - public global::System.Collections.Generic.IEnumerable Generate(global::System.Collections.Generic.IEnumerable nullValue, params object?[] parameters) - => global::System.Array.Empty(); - - /// - /// Generates an empty enumerable of , with - /// the for context. - /// - public global::System.Collections.Generic.List Generate(global::System.Collections.Generic.List nullValue, params object?[] parameters) - => new global::System.Collections.Generic.List(); - - /// - /// Generates an empty array of , with - /// the for context. - /// - public T[] Generate(T[] nullValue, params object?[] parameters) - => global::System.Array.Empty(); - - /// - /// Generates an empty two-dimensional array of , with - /// the for context. - /// - public T[,] Generate(T[,] nullValue, params object?[] parameters) - => new T[,] { }; - - /// - /// Generates an empty three-dimensional array of , with - /// the for context. - /// - public T[,,] Generate(T[,,] nullValue, params object?[] parameters) - => new T[,,] { }; - - /// - /// Generates an empty four-dimensional array of , with - /// the for context. - /// - public T[,,,] Generate(T[,,,] nullValue, params object?[] parameters) - => new T[,,,] { }; - - /// - /// Generates a default value of type , with - /// the for context. - /// - public T Generate(T nullValue, params object?[] parameters) - { - if (generator.GenerateValue(typeof(T), parameters) is T value) - { - return value; - } - - return nullValue; - } - } -} - -#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/ParameterArg.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/ParameterArg.g.cs deleted file mode 100644 index 284fbf66..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/HttpClient_CanBeCreated_Unions/ParameterArg.g.cs +++ /dev/null @@ -1,126 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -#nullable enable - -namespace Mockolate -{ - /// - /// A setup or verify argument that is either an It matcher - /// (IParameter<T>) or a literal value of type . - /// - /// - /// Both case types convert implicitly, so Setup.Method(42) and Setup.Method(It.IsAny<int>()) - /// bind to the same overload. A instance stands for the literal default(T). - /// - [global::System.Runtime.CompilerServices.Union] - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal readonly struct ParameterArg - { - private const byte MatcherTag = 1; - private const byte LiteralTag = 2; - - private readonly global::Mockolate.Parameters.IParameter? _matcher; - private readonly T? _literal; - private readonly byte _tag; - - /// - /// Creates the matcher case. - /// - public ParameterArg(global::Mockolate.Parameters.IParameter matcher) - { - _matcher = matcher; - _literal = default; - _tag = MatcherTag; - } - - /// - /// Creates the literal value case. - /// - public ParameterArg(T? literal) - { - _matcher = null; - _literal = literal; - _tag = LiteralTag; - } - - /// - /// The contained matcher or literal value, boxed. Part of the union pattern; the generated mocks use the - /// typed accessors instead. - /// - public object? Value => _tag switch - { - MatcherTag => _matcher, - LiteralTag => _literal, - _ => null, - }; - - /// - /// unless this is the instance. - /// - public bool HasValue => _tag != 0; - - /// - /// when the argument is a literal value (including the instance). - /// - public bool IsLiteral => _tag != MatcherTag; - - /// - /// The literal value; default(T) for the matcher case and the instance. - /// - public T? Literal => _literal; - - /// - /// Gets the matcher, when this is the matcher case. - /// - public bool TryGetValue(out global::Mockolate.Parameters.IParameter? matcher) - { - matcher = _matcher; - return _tag == MatcherTag; - } - - /// - /// Gets the literal value, when this is the literal case. - /// - public bool TryGetValue(out T? literal) - { - literal = _literal; - return _tag == LiteralTag; - } - - /// - /// The IParameterMatch<T> for this argument: the matcher itself, - /// or an equality match for the literal value. - /// - public global::Mockolate.Parameters.IParameterMatch ToParameterMatch() - { - if (_tag != MatcherTag) - { - return (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(_literal!); - } - - if (_matcher is null) - { - return (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsNull("null"); - } - - return _matcher is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new global::Mockolate.CovariantParameterAdapter(_matcher); - } - - /// - public override string ToString() => _tag switch - { - MatcherTag => _matcher?.ToString() ?? "null", - _ => _literal?.ToString() ?? "null", - }; - } -} -#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated/Mock.g.cs deleted file mode 100644 index 3944360b..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated/Mock.g.cs +++ /dev/null @@ -1,135 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable -/// -/// Create new mocks by calling the static T.CreateMock() method on your type T. -/// -/// -/// You can also provide a MockBehavior parameter to customize how the mock should behave in certain scenarios.
-/// If your type is a class without a default constructor, you can provide constructor parameters by passing an object?[]? to the corresponding CreateMock(...) overload. -///
-[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static partial class Mock -{ - /// - /// This interface should never be used. If it is, this is an indication that the Mockolate source generator did not run correctly or that the used type is not mockable. - /// - /// - /// The source generator creates overloads with correct return values. - /// - internal interface IMockGenerationDidNotRun {} - - /// - /// Create a new mock of with the default MockBehavior. - /// - /// Type to mock, which can be an interface or a class. - /// - /// Any interface type can be used for mocking, but for classes, only abstract and virtual members can be mocked. - /// - extension(T _) - { - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior = null) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior, object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - } - - extension(global::Mockolate.Mock.IMockGenerationDidNotRun _) - { - /// - /// Fallback Implementing that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Additional interface the mock should implement. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete Implementing overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public global::Mockolate.Mock.IMockGenerationDidNotRun Implementing() where TInterface : class - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(TInterface)}' is not mockable or the source generator did not run correctly."); - } - } - -} - -/// -/// Adapts an IParameter (non-generic) to -/// IParameterMatch<T> so that covariant parameter -/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> -/// slot) can still be invoked at setup/verify time. Only allocated when the direct -/// IParameterMatch<T> cast fails. Shared by every -/// generated mock file. -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch -{ - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); -} -#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated/MockBehaviorExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated/MockBehaviorExtensions.g.cs deleted file mode 100644 index 888d2c2c..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated/MockBehaviorExtensions.g.cs +++ /dev/null @@ -1,285 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable annotations - -/// -/// Extensions for MockBehavior. -/// -internal static partial class Mock -{ - private static readonly global::Mockolate.MockBehavior _default; - - static Mock() - { - _default = new global::Mockolate.MockBehavior(new DefaultValueGenerator()); - } - - extension(global::Mockolate.MockBehavior) - { - /// - /// The default MockBehavior - the starting point for configuring a mock. - /// - /// - /// Un-configured members return the generator-provided default value (empty strings/collections, completed - /// Tasks, otherwise), base-class - /// implementations run for class mocks, and every invocation is recorded for later verification. - /// - /// Chain SkippingBaseClass(), ThrowingWhenNotSetup(), SkippingInteractionRecording(), - /// WithDefaultValueFor<T>(...) or UseConstructorParametersFor<T>(...) to derive - /// a customized MockBehavior; because it is a , - /// each call returns a new instance and this shared default stays unchanged. - /// - public static global::Mockolate.MockBehavior Default => _default; - } - - /// - /// Defines a factory for creating default values for a specified type. - /// - public interface IDefaultValueFactory - { - /// - /// Determines whether the specified can be created by this factory. - /// - bool IsMatch(global::System.Type type); - - /// - /// Creates a new instance of the specified type. - /// - object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, object?[] parameters); - } - - /// - /// A IDefaultValueFactory that returns a specified for the given type - /// parameter . - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal class TypedDefaultValueFactory(T value) : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(T); - - /// - public object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - => value; - } - - /// - /// Provides default values for common types used in mocking scenarios. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private class DefaultValueGenerator : IDefaultValueGenerator - { - private static readonly global::System.Collections.Concurrent.ConcurrentQueue _factories = new([ - new TypedDefaultValueFactory(""), - new CancellableTaskFactory(), - #if NET8_0_OR_GREATER - new CancellableValueTaskFactory(), - #endif - new TypedDefaultValueFactory(global::System.Threading.CancellationToken.None), - new TypedDefaultValueFactory(global::System.Array.Empty()), - ]); - - /// - public object? GenerateValue(global::System.Type type, params object?[] parameters) - { - if (TryGenerate(type, parameters, out object? value)) - { - return value; - } - - return null; - } - - /// - /// Registers a to provide default values for a specific type. - /// - public static void Register(IDefaultValueFactory defaultValueFactory) - => _factories.Enqueue(defaultValueFactory); - - /// - /// Tries to generate a default value for the specified type. - /// - protected virtual bool TryGenerate(global::System.Type type, object?[] parameters, out object? value) - { - IDefaultValueFactory? matchingFactory = global::System.Linq.Enumerable.FirstOrDefault(_factories, Predicate); - if (matchingFactory is not null) - { - value = matchingFactory.Create(type, this, parameters); - return true; - } - - value = null; - return false; - - bool Predicate(global::Mockolate.Mock.IDefaultValueFactory f) - => f.IsMatch(type); - } - - private static bool HasCanceledCancellationToken(object?[] parameters, out global::System.Threading.CancellationToken cancellationToken) - { - global::System.Threading.CancellationToken parameter = global::System.Linq.Enumerable.FirstOrDefault(global::System.Linq.Enumerable.OfType(parameters)); - if (parameter.IsCancellationRequested) - { - cancellationToken = parameter; - return true; - } - - cancellationToken = global::System.Threading.CancellationToken.None; - return false; - } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CancellableTaskFactory : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Threading.Tasks.Task); - - /// - public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - { - if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) - { - return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.Task.CompletedTask; - } - } - #if NET8_0_OR_GREATER - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CancellableValueTaskFactory : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Threading.Tasks.ValueTask); - - /// - public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - { - if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) - { - return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.ValueTask.CompletedTask; - } - } - #endif - } -} - -/// -/// Extensions on IDefaultValueGenerator -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static class DefaultValueGeneratorExtensions -{ - /// - /// Adds a generic Generate method for specific types. - /// - extension(IDefaultValueGenerator generator) - { - /// - /// Generates a Task of , with - /// the for context. - /// - public global::System.Threading.Tasks.Task Generate(global::System.Threading.Tasks.Task nullValue, T value, params object?[] parameters) - { - global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( - global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; - if (cancellationToken.IsCancellationRequested) - { - return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.Task.FromResult(value); - } - -#if NET8_0_OR_GREATER - /// - /// Generates a ValueTask of , with - /// the for context. - /// - public global::System.Threading.Tasks.ValueTask Generate(global::System.Threading.Tasks.ValueTask nullValue, T value, params object?[] parameters) - { - global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( - global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; - if (cancellationToken.IsCancellationRequested) - { - return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.ValueTask.FromResult(value); - } -#endif - - /// - /// Generates an empty enumerable of , with - /// the for context. - /// - public global::System.Collections.Generic.IEnumerable Generate(global::System.Collections.Generic.IEnumerable nullValue, params object?[] parameters) - => global::System.Array.Empty(); - - /// - /// Generates an empty enumerable of , with - /// the for context. - /// - public global::System.Collections.Generic.List Generate(global::System.Collections.Generic.List nullValue, params object?[] parameters) - => new global::System.Collections.Generic.List(); - - /// - /// Generates an empty array of , with - /// the for context. - /// - public T[] Generate(T[] nullValue, params object?[] parameters) - => global::System.Array.Empty(); - - /// - /// Generates an empty two-dimensional array of , with - /// the for context. - /// - public T[,] Generate(T[,] nullValue, params object?[] parameters) - => new T[,] { }; - - /// - /// Generates an empty three-dimensional array of , with - /// the for context. - /// - public T[,,] Generate(T[,,] nullValue, params object?[] parameters) - => new T[,,] { }; - - /// - /// Generates an empty four-dimensional array of , with - /// the for context. - /// - public T[,,,] Generate(T[,,,] nullValue, params object?[] parameters) - => new T[,,,] { }; - - /// - /// Generates a default value of type , with - /// the for context. - /// - public T Generate(T nullValue, params object?[] parameters) - { - if (generator.GenerateValue(typeof(T), parameters) is T value) - { - return value; - } - - return nullValue; - } - } -} - -#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated/_shared.txt b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated/_shared.txt new file mode 100644 index 00000000..1ce1e618 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated/_shared.txt @@ -0,0 +1,2 @@ +Mock.g.cs|Mock.g.cs +MockBehaviorExtensions.g.cs|MockBehaviorExtensions.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.g.cs deleted file mode 100644 index 3944360b..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/Mock.g.cs +++ /dev/null @@ -1,135 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable -/// -/// Create new mocks by calling the static T.CreateMock() method on your type T. -/// -/// -/// You can also provide a MockBehavior parameter to customize how the mock should behave in certain scenarios.
-/// If your type is a class without a default constructor, you can provide constructor parameters by passing an object?[]? to the corresponding CreateMock(...) overload. -///
-[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static partial class Mock -{ - /// - /// This interface should never be used. If it is, this is an indication that the Mockolate source generator did not run correctly or that the used type is not mockable. - /// - /// - /// The source generator creates overloads with correct return values. - /// - internal interface IMockGenerationDidNotRun {} - - /// - /// Create a new mock of with the default MockBehavior. - /// - /// Type to mock, which can be an interface or a class. - /// - /// Any interface type can be used for mocking, but for classes, only abstract and virtual members can be mocked. - /// - extension(T _) - { - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior = null) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior, object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - } - - extension(global::Mockolate.Mock.IMockGenerationDidNotRun _) - { - /// - /// Fallback Implementing that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Additional interface the mock should implement. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete Implementing overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public global::Mockolate.Mock.IMockGenerationDidNotRun Implementing() where TInterface : class - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(TInterface)}' is not mockable or the source generator did not run correctly."); - } - } - -} - -/// -/// Adapts an IParameter (non-generic) to -/// IParameterMatch<T> so that covariant parameter -/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> -/// slot) can still be invoked at setup/verify time. Only allocated when the direct -/// IParameterMatch<T> cast fails. Shared by every -/// generated mock file. -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch -{ - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); -} -#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/MockBehaviorExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/MockBehaviorExtensions.g.cs deleted file mode 100644 index 888d2c2c..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/MockBehaviorExtensions.g.cs +++ /dev/null @@ -1,285 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable annotations - -/// -/// Extensions for MockBehavior. -/// -internal static partial class Mock -{ - private static readonly global::Mockolate.MockBehavior _default; - - static Mock() - { - _default = new global::Mockolate.MockBehavior(new DefaultValueGenerator()); - } - - extension(global::Mockolate.MockBehavior) - { - /// - /// The default MockBehavior - the starting point for configuring a mock. - /// - /// - /// Un-configured members return the generator-provided default value (empty strings/collections, completed - /// Tasks, otherwise), base-class - /// implementations run for class mocks, and every invocation is recorded for later verification. - /// - /// Chain SkippingBaseClass(), ThrowingWhenNotSetup(), SkippingInteractionRecording(), - /// WithDefaultValueFor<T>(...) or UseConstructorParametersFor<T>(...) to derive - /// a customized MockBehavior; because it is a , - /// each call returns a new instance and this shared default stays unchanged. - /// - public static global::Mockolate.MockBehavior Default => _default; - } - - /// - /// Defines a factory for creating default values for a specified type. - /// - public interface IDefaultValueFactory - { - /// - /// Determines whether the specified can be created by this factory. - /// - bool IsMatch(global::System.Type type); - - /// - /// Creates a new instance of the specified type. - /// - object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, object?[] parameters); - } - - /// - /// A IDefaultValueFactory that returns a specified for the given type - /// parameter . - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal class TypedDefaultValueFactory(T value) : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(T); - - /// - public object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - => value; - } - - /// - /// Provides default values for common types used in mocking scenarios. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private class DefaultValueGenerator : IDefaultValueGenerator - { - private static readonly global::System.Collections.Concurrent.ConcurrentQueue _factories = new([ - new TypedDefaultValueFactory(""), - new CancellableTaskFactory(), - #if NET8_0_OR_GREATER - new CancellableValueTaskFactory(), - #endif - new TypedDefaultValueFactory(global::System.Threading.CancellationToken.None), - new TypedDefaultValueFactory(global::System.Array.Empty()), - ]); - - /// - public object? GenerateValue(global::System.Type type, params object?[] parameters) - { - if (TryGenerate(type, parameters, out object? value)) - { - return value; - } - - return null; - } - - /// - /// Registers a to provide default values for a specific type. - /// - public static void Register(IDefaultValueFactory defaultValueFactory) - => _factories.Enqueue(defaultValueFactory); - - /// - /// Tries to generate a default value for the specified type. - /// - protected virtual bool TryGenerate(global::System.Type type, object?[] parameters, out object? value) - { - IDefaultValueFactory? matchingFactory = global::System.Linq.Enumerable.FirstOrDefault(_factories, Predicate); - if (matchingFactory is not null) - { - value = matchingFactory.Create(type, this, parameters); - return true; - } - - value = null; - return false; - - bool Predicate(global::Mockolate.Mock.IDefaultValueFactory f) - => f.IsMatch(type); - } - - private static bool HasCanceledCancellationToken(object?[] parameters, out global::System.Threading.CancellationToken cancellationToken) - { - global::System.Threading.CancellationToken parameter = global::System.Linq.Enumerable.FirstOrDefault(global::System.Linq.Enumerable.OfType(parameters)); - if (parameter.IsCancellationRequested) - { - cancellationToken = parameter; - return true; - } - - cancellationToken = global::System.Threading.CancellationToken.None; - return false; - } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CancellableTaskFactory : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Threading.Tasks.Task); - - /// - public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - { - if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) - { - return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.Task.CompletedTask; - } - } - #if NET8_0_OR_GREATER - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CancellableValueTaskFactory : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Threading.Tasks.ValueTask); - - /// - public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - { - if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) - { - return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.ValueTask.CompletedTask; - } - } - #endif - } -} - -/// -/// Extensions on IDefaultValueGenerator -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static class DefaultValueGeneratorExtensions -{ - /// - /// Adds a generic Generate method for specific types. - /// - extension(IDefaultValueGenerator generator) - { - /// - /// Generates a Task of , with - /// the for context. - /// - public global::System.Threading.Tasks.Task Generate(global::System.Threading.Tasks.Task nullValue, T value, params object?[] parameters) - { - global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( - global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; - if (cancellationToken.IsCancellationRequested) - { - return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.Task.FromResult(value); - } - -#if NET8_0_OR_GREATER - /// - /// Generates a ValueTask of , with - /// the for context. - /// - public global::System.Threading.Tasks.ValueTask Generate(global::System.Threading.Tasks.ValueTask nullValue, T value, params object?[] parameters) - { - global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( - global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; - if (cancellationToken.IsCancellationRequested) - { - return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.ValueTask.FromResult(value); - } -#endif - - /// - /// Generates an empty enumerable of , with - /// the for context. - /// - public global::System.Collections.Generic.IEnumerable Generate(global::System.Collections.Generic.IEnumerable nullValue, params object?[] parameters) - => global::System.Array.Empty(); - - /// - /// Generates an empty enumerable of , with - /// the for context. - /// - public global::System.Collections.Generic.List Generate(global::System.Collections.Generic.List nullValue, params object?[] parameters) - => new global::System.Collections.Generic.List(); - - /// - /// Generates an empty array of , with - /// the for context. - /// - public T[] Generate(T[] nullValue, params object?[] parameters) - => global::System.Array.Empty(); - - /// - /// Generates an empty two-dimensional array of , with - /// the for context. - /// - public T[,] Generate(T[,] nullValue, params object?[] parameters) - => new T[,] { }; - - /// - /// Generates an empty three-dimensional array of , with - /// the for context. - /// - public T[,,] Generate(T[,,] nullValue, params object?[] parameters) - => new T[,,] { }; - - /// - /// Generates an empty four-dimensional array of , with - /// the for context. - /// - public T[,,,] Generate(T[,,,] nullValue, params object?[] parameters) - => new T[,,,] { }; - - /// - /// Generates a default value of type , with - /// the for context. - /// - public T Generate(T nullValue, params object?[] parameters) - { - if (generator.GenerateValue(typeof(T), parameters) is T value) - { - return value; - } - - return nullValue; - } - } -} - -#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/ParameterArg.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/ParameterArg.g.cs deleted file mode 100644 index 284fbf66..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/ParameterArg.g.cs +++ /dev/null @@ -1,126 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -#nullable enable - -namespace Mockolate -{ - /// - /// A setup or verify argument that is either an It matcher - /// (IParameter<T>) or a literal value of type . - /// - /// - /// Both case types convert implicitly, so Setup.Method(42) and Setup.Method(It.IsAny<int>()) - /// bind to the same overload. A instance stands for the literal default(T). - /// - [global::System.Runtime.CompilerServices.Union] - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal readonly struct ParameterArg - { - private const byte MatcherTag = 1; - private const byte LiteralTag = 2; - - private readonly global::Mockolate.Parameters.IParameter? _matcher; - private readonly T? _literal; - private readonly byte _tag; - - /// - /// Creates the matcher case. - /// - public ParameterArg(global::Mockolate.Parameters.IParameter matcher) - { - _matcher = matcher; - _literal = default; - _tag = MatcherTag; - } - - /// - /// Creates the literal value case. - /// - public ParameterArg(T? literal) - { - _matcher = null; - _literal = literal; - _tag = LiteralTag; - } - - /// - /// The contained matcher or literal value, boxed. Part of the union pattern; the generated mocks use the - /// typed accessors instead. - /// - public object? Value => _tag switch - { - MatcherTag => _matcher, - LiteralTag => _literal, - _ => null, - }; - - /// - /// unless this is the instance. - /// - public bool HasValue => _tag != 0; - - /// - /// when the argument is a literal value (including the instance). - /// - public bool IsLiteral => _tag != MatcherTag; - - /// - /// The literal value; default(T) for the matcher case and the instance. - /// - public T? Literal => _literal; - - /// - /// Gets the matcher, when this is the matcher case. - /// - public bool TryGetValue(out global::Mockolate.Parameters.IParameter? matcher) - { - matcher = _matcher; - return _tag == MatcherTag; - } - - /// - /// Gets the literal value, when this is the literal case. - /// - public bool TryGetValue(out T? literal) - { - literal = _literal; - return _tag == LiteralTag; - } - - /// - /// The IParameterMatch<T> for this argument: the matcher itself, - /// or an equality match for the literal value. - /// - public global::Mockolate.Parameters.IParameterMatch ToParameterMatch() - { - if (_tag != MatcherTag) - { - return (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(_literal!); - } - - if (_matcher is null) - { - return (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsNull("null"); - } - - return _matcher is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new global::Mockolate.CovariantParameterAdapter(_matcher); - } - - /// - public override string ToString() => _tag switch - { - MatcherTag => _matcher?.ToString() ?? "null", - _ => _literal?.ToString() ?? "null", - }; - } -} -#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/_shared.txt b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/_shared.txt new file mode 100644 index 00000000..b02bd8b2 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/KeywordEdgeCases_CanBeCreated_Unions/_shared.txt @@ -0,0 +1,3 @@ +Mock.g.cs|Mock.g.cs +MockBehaviorExtensions.g.cs|MockBehaviorExtensions.g.cs +ParameterArg.g.cs|ParameterArg.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/RefStructConsumer_CanBeCreated/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/RefStructConsumer_CanBeCreated/Mock.g.cs deleted file mode 100644 index 3944360b..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/RefStructConsumer_CanBeCreated/Mock.g.cs +++ /dev/null @@ -1,135 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable -/// -/// Create new mocks by calling the static T.CreateMock() method on your type T. -/// -/// -/// You can also provide a MockBehavior parameter to customize how the mock should behave in certain scenarios.
-/// If your type is a class without a default constructor, you can provide constructor parameters by passing an object?[]? to the corresponding CreateMock(...) overload. -///
-[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static partial class Mock -{ - /// - /// This interface should never be used. If it is, this is an indication that the Mockolate source generator did not run correctly or that the used type is not mockable. - /// - /// - /// The source generator creates overloads with correct return values. - /// - internal interface IMockGenerationDidNotRun {} - - /// - /// Create a new mock of with the default MockBehavior. - /// - /// Type to mock, which can be an interface or a class. - /// - /// Any interface type can be used for mocking, but for classes, only abstract and virtual members can be mocked. - /// - extension(T _) - { - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior = null) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior, object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - } - - extension(global::Mockolate.Mock.IMockGenerationDidNotRun _) - { - /// - /// Fallback Implementing that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Additional interface the mock should implement. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete Implementing overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public global::Mockolate.Mock.IMockGenerationDidNotRun Implementing() where TInterface : class - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(TInterface)}' is not mockable or the source generator did not run correctly."); - } - } - -} - -/// -/// Adapts an IParameter (non-generic) to -/// IParameterMatch<T> so that covariant parameter -/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> -/// slot) can still be invoked at setup/verify time. Only allocated when the direct -/// IParameterMatch<T> cast fails. Shared by every -/// generated mock file. -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch -{ - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); -} -#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/RefStructConsumer_CanBeCreated/MockBehaviorExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/RefStructConsumer_CanBeCreated/MockBehaviorExtensions.g.cs deleted file mode 100644 index 888d2c2c..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/RefStructConsumer_CanBeCreated/MockBehaviorExtensions.g.cs +++ /dev/null @@ -1,285 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable annotations - -/// -/// Extensions for MockBehavior. -/// -internal static partial class Mock -{ - private static readonly global::Mockolate.MockBehavior _default; - - static Mock() - { - _default = new global::Mockolate.MockBehavior(new DefaultValueGenerator()); - } - - extension(global::Mockolate.MockBehavior) - { - /// - /// The default MockBehavior - the starting point for configuring a mock. - /// - /// - /// Un-configured members return the generator-provided default value (empty strings/collections, completed - /// Tasks, otherwise), base-class - /// implementations run for class mocks, and every invocation is recorded for later verification. - /// - /// Chain SkippingBaseClass(), ThrowingWhenNotSetup(), SkippingInteractionRecording(), - /// WithDefaultValueFor<T>(...) or UseConstructorParametersFor<T>(...) to derive - /// a customized MockBehavior; because it is a , - /// each call returns a new instance and this shared default stays unchanged. - /// - public static global::Mockolate.MockBehavior Default => _default; - } - - /// - /// Defines a factory for creating default values for a specified type. - /// - public interface IDefaultValueFactory - { - /// - /// Determines whether the specified can be created by this factory. - /// - bool IsMatch(global::System.Type type); - - /// - /// Creates a new instance of the specified type. - /// - object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, object?[] parameters); - } - - /// - /// A IDefaultValueFactory that returns a specified for the given type - /// parameter . - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal class TypedDefaultValueFactory(T value) : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(T); - - /// - public object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - => value; - } - - /// - /// Provides default values for common types used in mocking scenarios. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private class DefaultValueGenerator : IDefaultValueGenerator - { - private static readonly global::System.Collections.Concurrent.ConcurrentQueue _factories = new([ - new TypedDefaultValueFactory(""), - new CancellableTaskFactory(), - #if NET8_0_OR_GREATER - new CancellableValueTaskFactory(), - #endif - new TypedDefaultValueFactory(global::System.Threading.CancellationToken.None), - new TypedDefaultValueFactory(global::System.Array.Empty()), - ]); - - /// - public object? GenerateValue(global::System.Type type, params object?[] parameters) - { - if (TryGenerate(type, parameters, out object? value)) - { - return value; - } - - return null; - } - - /// - /// Registers a to provide default values for a specific type. - /// - public static void Register(IDefaultValueFactory defaultValueFactory) - => _factories.Enqueue(defaultValueFactory); - - /// - /// Tries to generate a default value for the specified type. - /// - protected virtual bool TryGenerate(global::System.Type type, object?[] parameters, out object? value) - { - IDefaultValueFactory? matchingFactory = global::System.Linq.Enumerable.FirstOrDefault(_factories, Predicate); - if (matchingFactory is not null) - { - value = matchingFactory.Create(type, this, parameters); - return true; - } - - value = null; - return false; - - bool Predicate(global::Mockolate.Mock.IDefaultValueFactory f) - => f.IsMatch(type); - } - - private static bool HasCanceledCancellationToken(object?[] parameters, out global::System.Threading.CancellationToken cancellationToken) - { - global::System.Threading.CancellationToken parameter = global::System.Linq.Enumerable.FirstOrDefault(global::System.Linq.Enumerable.OfType(parameters)); - if (parameter.IsCancellationRequested) - { - cancellationToken = parameter; - return true; - } - - cancellationToken = global::System.Threading.CancellationToken.None; - return false; - } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CancellableTaskFactory : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Threading.Tasks.Task); - - /// - public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - { - if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) - { - return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.Task.CompletedTask; - } - } - #if NET8_0_OR_GREATER - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CancellableValueTaskFactory : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Threading.Tasks.ValueTask); - - /// - public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - { - if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) - { - return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.ValueTask.CompletedTask; - } - } - #endif - } -} - -/// -/// Extensions on IDefaultValueGenerator -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static class DefaultValueGeneratorExtensions -{ - /// - /// Adds a generic Generate method for specific types. - /// - extension(IDefaultValueGenerator generator) - { - /// - /// Generates a Task of , with - /// the for context. - /// - public global::System.Threading.Tasks.Task Generate(global::System.Threading.Tasks.Task nullValue, T value, params object?[] parameters) - { - global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( - global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; - if (cancellationToken.IsCancellationRequested) - { - return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.Task.FromResult(value); - } - -#if NET8_0_OR_GREATER - /// - /// Generates a ValueTask of , with - /// the for context. - /// - public global::System.Threading.Tasks.ValueTask Generate(global::System.Threading.Tasks.ValueTask nullValue, T value, params object?[] parameters) - { - global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( - global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; - if (cancellationToken.IsCancellationRequested) - { - return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.ValueTask.FromResult(value); - } -#endif - - /// - /// Generates an empty enumerable of , with - /// the for context. - /// - public global::System.Collections.Generic.IEnumerable Generate(global::System.Collections.Generic.IEnumerable nullValue, params object?[] parameters) - => global::System.Array.Empty(); - - /// - /// Generates an empty enumerable of , with - /// the for context. - /// - public global::System.Collections.Generic.List Generate(global::System.Collections.Generic.List nullValue, params object?[] parameters) - => new global::System.Collections.Generic.List(); - - /// - /// Generates an empty array of , with - /// the for context. - /// - public T[] Generate(T[] nullValue, params object?[] parameters) - => global::System.Array.Empty(); - - /// - /// Generates an empty two-dimensional array of , with - /// the for context. - /// - public T[,] Generate(T[,] nullValue, params object?[] parameters) - => new T[,] { }; - - /// - /// Generates an empty three-dimensional array of , with - /// the for context. - /// - public T[,,] Generate(T[,,] nullValue, params object?[] parameters) - => new T[,,] { }; - - /// - /// Generates an empty four-dimensional array of , with - /// the for context. - /// - public T[,,,] Generate(T[,,,] nullValue, params object?[] parameters) - => new T[,,,] { }; - - /// - /// Generates a default value of type , with - /// the for context. - /// - public T Generate(T nullValue, params object?[] parameters) - { - if (generator.GenerateValue(typeof(T), parameters) is T value) - { - return value; - } - - return nullValue; - } - } -} - -#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/RefStructConsumer_CanBeCreated/_shared.txt b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/RefStructConsumer_CanBeCreated/_shared.txt new file mode 100644 index 00000000..5c71c0fe --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/RefStructConsumer_CanBeCreated/_shared.txt @@ -0,0 +1,3 @@ +IndexerSetups.g.cs|IndexerSetups.854c2a72.g.cs +Mock.g.cs|Mock.g.cs +MockBehaviorExtensions.g.cs|MockBehaviorExtensions.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/StaticAbstractMembers_CanBeCreated/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/StaticAbstractMembers_CanBeCreated/Mock.g.cs deleted file mode 100644 index 3944360b..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/StaticAbstractMembers_CanBeCreated/Mock.g.cs +++ /dev/null @@ -1,135 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable -/// -/// Create new mocks by calling the static T.CreateMock() method on your type T. -/// -/// -/// You can also provide a MockBehavior parameter to customize how the mock should behave in certain scenarios.
-/// If your type is a class without a default constructor, you can provide constructor parameters by passing an object?[]? to the corresponding CreateMock(...) overload. -///
-[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static partial class Mock -{ - /// - /// This interface should never be used. If it is, this is an indication that the Mockolate source generator did not run correctly or that the used type is not mockable. - /// - /// - /// The source generator creates overloads with correct return values. - /// - internal interface IMockGenerationDidNotRun {} - - /// - /// Create a new mock of with the default MockBehavior. - /// - /// Type to mock, which can be an interface or a class. - /// - /// Any interface type can be used for mocking, but for classes, only abstract and virtual members can be mocked. - /// - extension(T _) - { - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior = null) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior, object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - } - - extension(global::Mockolate.Mock.IMockGenerationDidNotRun _) - { - /// - /// Fallback Implementing that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Additional interface the mock should implement. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete Implementing overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public global::Mockolate.Mock.IMockGenerationDidNotRun Implementing() where TInterface : class - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(TInterface)}' is not mockable or the source generator did not run correctly."); - } - } - -} - -/// -/// Adapts an IParameter (non-generic) to -/// IParameterMatch<T> so that covariant parameter -/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> -/// slot) can still be invoked at setup/verify time. Only allocated when the direct -/// IParameterMatch<T> cast fails. Shared by every -/// generated mock file. -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch -{ - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); -} -#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/StaticAbstractMembers_CanBeCreated/MockBehaviorExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/StaticAbstractMembers_CanBeCreated/MockBehaviorExtensions.g.cs deleted file mode 100644 index 888d2c2c..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/StaticAbstractMembers_CanBeCreated/MockBehaviorExtensions.g.cs +++ /dev/null @@ -1,285 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable annotations - -/// -/// Extensions for MockBehavior. -/// -internal static partial class Mock -{ - private static readonly global::Mockolate.MockBehavior _default; - - static Mock() - { - _default = new global::Mockolate.MockBehavior(new DefaultValueGenerator()); - } - - extension(global::Mockolate.MockBehavior) - { - /// - /// The default MockBehavior - the starting point for configuring a mock. - /// - /// - /// Un-configured members return the generator-provided default value (empty strings/collections, completed - /// Tasks, otherwise), base-class - /// implementations run for class mocks, and every invocation is recorded for later verification. - /// - /// Chain SkippingBaseClass(), ThrowingWhenNotSetup(), SkippingInteractionRecording(), - /// WithDefaultValueFor<T>(...) or UseConstructorParametersFor<T>(...) to derive - /// a customized MockBehavior; because it is a , - /// each call returns a new instance and this shared default stays unchanged. - /// - public static global::Mockolate.MockBehavior Default => _default; - } - - /// - /// Defines a factory for creating default values for a specified type. - /// - public interface IDefaultValueFactory - { - /// - /// Determines whether the specified can be created by this factory. - /// - bool IsMatch(global::System.Type type); - - /// - /// Creates a new instance of the specified type. - /// - object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, object?[] parameters); - } - - /// - /// A IDefaultValueFactory that returns a specified for the given type - /// parameter . - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal class TypedDefaultValueFactory(T value) : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(T); - - /// - public object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - => value; - } - - /// - /// Provides default values for common types used in mocking scenarios. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private class DefaultValueGenerator : IDefaultValueGenerator - { - private static readonly global::System.Collections.Concurrent.ConcurrentQueue _factories = new([ - new TypedDefaultValueFactory(""), - new CancellableTaskFactory(), - #if NET8_0_OR_GREATER - new CancellableValueTaskFactory(), - #endif - new TypedDefaultValueFactory(global::System.Threading.CancellationToken.None), - new TypedDefaultValueFactory(global::System.Array.Empty()), - ]); - - /// - public object? GenerateValue(global::System.Type type, params object?[] parameters) - { - if (TryGenerate(type, parameters, out object? value)) - { - return value; - } - - return null; - } - - /// - /// Registers a to provide default values for a specific type. - /// - public static void Register(IDefaultValueFactory defaultValueFactory) - => _factories.Enqueue(defaultValueFactory); - - /// - /// Tries to generate a default value for the specified type. - /// - protected virtual bool TryGenerate(global::System.Type type, object?[] parameters, out object? value) - { - IDefaultValueFactory? matchingFactory = global::System.Linq.Enumerable.FirstOrDefault(_factories, Predicate); - if (matchingFactory is not null) - { - value = matchingFactory.Create(type, this, parameters); - return true; - } - - value = null; - return false; - - bool Predicate(global::Mockolate.Mock.IDefaultValueFactory f) - => f.IsMatch(type); - } - - private static bool HasCanceledCancellationToken(object?[] parameters, out global::System.Threading.CancellationToken cancellationToken) - { - global::System.Threading.CancellationToken parameter = global::System.Linq.Enumerable.FirstOrDefault(global::System.Linq.Enumerable.OfType(parameters)); - if (parameter.IsCancellationRequested) - { - cancellationToken = parameter; - return true; - } - - cancellationToken = global::System.Threading.CancellationToken.None; - return false; - } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CancellableTaskFactory : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Threading.Tasks.Task); - - /// - public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - { - if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) - { - return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.Task.CompletedTask; - } - } - #if NET8_0_OR_GREATER - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CancellableValueTaskFactory : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Threading.Tasks.ValueTask); - - /// - public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - { - if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) - { - return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.ValueTask.CompletedTask; - } - } - #endif - } -} - -/// -/// Extensions on IDefaultValueGenerator -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static class DefaultValueGeneratorExtensions -{ - /// - /// Adds a generic Generate method for specific types. - /// - extension(IDefaultValueGenerator generator) - { - /// - /// Generates a Task of , with - /// the for context. - /// - public global::System.Threading.Tasks.Task Generate(global::System.Threading.Tasks.Task nullValue, T value, params object?[] parameters) - { - global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( - global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; - if (cancellationToken.IsCancellationRequested) - { - return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.Task.FromResult(value); - } - -#if NET8_0_OR_GREATER - /// - /// Generates a ValueTask of , with - /// the for context. - /// - public global::System.Threading.Tasks.ValueTask Generate(global::System.Threading.Tasks.ValueTask nullValue, T value, params object?[] parameters) - { - global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( - global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; - if (cancellationToken.IsCancellationRequested) - { - return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.ValueTask.FromResult(value); - } -#endif - - /// - /// Generates an empty enumerable of , with - /// the for context. - /// - public global::System.Collections.Generic.IEnumerable Generate(global::System.Collections.Generic.IEnumerable nullValue, params object?[] parameters) - => global::System.Array.Empty(); - - /// - /// Generates an empty enumerable of , with - /// the for context. - /// - public global::System.Collections.Generic.List Generate(global::System.Collections.Generic.List nullValue, params object?[] parameters) - => new global::System.Collections.Generic.List(); - - /// - /// Generates an empty array of , with - /// the for context. - /// - public T[] Generate(T[] nullValue, params object?[] parameters) - => global::System.Array.Empty(); - - /// - /// Generates an empty two-dimensional array of , with - /// the for context. - /// - public T[,] Generate(T[,] nullValue, params object?[] parameters) - => new T[,] { }; - - /// - /// Generates an empty three-dimensional array of , with - /// the for context. - /// - public T[,,] Generate(T[,,] nullValue, params object?[] parameters) - => new T[,,] { }; - - /// - /// Generates an empty four-dimensional array of , with - /// the for context. - /// - public T[,,,] Generate(T[,,,] nullValue, params object?[] parameters) - => new T[,,,] { }; - - /// - /// Generates a default value of type , with - /// the for context. - /// - public T Generate(T nullValue, params object?[] parameters) - { - if (generator.GenerateValue(typeof(T), parameters) is T value) - { - return value; - } - - return nullValue; - } - } -} - -#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/StaticAbstractMembers_CanBeCreated/_shared.txt b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/StaticAbstractMembers_CanBeCreated/_shared.txt new file mode 100644 index 00000000..1ce1e618 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/StaticAbstractMembers_CanBeCreated/_shared.txt @@ -0,0 +1,2 @@ +Mock.g.cs|Mock.g.cs +MockBehaviorExtensions.g.cs|MockBehaviorExtensions.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/IndexerSetups.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/IndexerSetups.g.cs deleted file mode 100644 index e2e703fc..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/IndexerSetups.g.cs +++ /dev/null @@ -1,1055 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -#nullable enable - -namespace Mockolate.Setup -{ - /// - /// Sets up a indexer getter for , , , and . - /// - internal interface IIndexerGetterSetup - { - /// - /// Registers a to be invoked whenever the indexer's getter is accessed. - /// - IIndexerGetterSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Transitions the scenario to the given whenever the indexer is read. - /// - IIndexerGetterSetupParallelCallbackBuilder TransitionTo(string scenario); - } - - /// - /// Sets up a indexer getter for , , , and with callback support for the parameters. - /// - internal interface IIndexerGetterSetupWithCallback : global::Mockolate.Setup.IIndexerGetterSetup - { - /// - /// Registers a to be invoked whenever the indexer's getter is accessed. - /// - /// - /// The callback receives the parameters of the indexer. - /// - IIndexerGetterSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Registers a to be invoked whenever the indexer's getter is accessed. - /// - /// - /// The callback receives the parameters of the indexer and the value of the indexer as last parameter. - /// - IIndexerGetterSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Registers a to be invoked whenever the indexer's getter is accessed. - /// - /// - /// The callback receives an incrementing access counter as first parameter, the parameters of the indexer and the value of the indexer as last parameter. - /// - IIndexerGetterSetupCallbackBuilder Do(global::System.Action callback); - } - - /// - /// Sets up a indexer setter for , , , and . - /// - internal interface IIndexerSetterSetup - { - /// - /// Registers a to be invoked whenever the indexer's setter is accessed. - /// - IIndexerSetterSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Registers a to be invoked whenever the indexer's setter is accessed. - /// - /// - /// The callback receives the value the indexer is set to as single parameter. - /// - IIndexerSetterSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Transitions the scenario to the given whenever the indexer is written to. - /// - IIndexerSetterSetupParallelCallbackBuilder TransitionTo(string scenario); - } - - /// - /// Sets up a indexer setter for , , , and with callback support for the parameters. - /// - internal interface IIndexerSetterSetupWithCallback : global::Mockolate.Setup.IIndexerSetterSetup - { - /// - /// Registers a to be invoked whenever the indexer's setter is accessed. - /// - /// - /// The callback receives the parameters of the indexer and the value the indexer is set to as last parameter. - /// - IIndexerSetterSetupCallbackBuilder Do(global::System.Action callback); - - /// - /// Registers a to be invoked whenever the indexer's setter is accessed. - /// - /// - /// The callback receives an incrementing access counter as first parameter, the parameters of the indexer and the value the indexer is set to as last parameter. - /// - IIndexerSetterSetupCallbackBuilder Do(global::System.Action callback); - } - - /// - /// Sets up a indexer for , , , and . - /// - internal interface IIndexerSetup - { - /// - /// Sets up callbacks on the getter. - /// - IIndexerGetterSetupWithCallback OnGet { get; } - - /// - /// Sets up callbacks on the setter. - /// - IIndexerSetterSetupWithCallback OnSet { get; } - - /// - /// Overrides SkipBaseClass for this indexer only. - /// - /// - /// If not specified, use SkipBaseClass. - /// - global::Mockolate.Setup.IIndexerSetup SkippingBaseClass(bool skipBaseClass = true); - - /// - /// Initializes the indexer with the given . - /// - global::Mockolate.Setup.IIndexerSetup InitializeWith(TValue value); - - /// - /// Registers the for this indexer. - /// - IIndexerSetupReturnBuilder Returns(TValue returnValue); - - /// - /// Registers a to setup the return value for this indexer. - /// - IIndexerSetupReturnBuilder Returns(global::System.Func callback); - - /// - /// Registers an to throw when the indexer is read. - /// - IIndexerSetupReturnBuilder Throws() - where TException : global::System.Exception, new(); - - /// - /// Registers an to throw when the indexer is read. - /// - IIndexerSetupReturnBuilder Throws(global::System.Exception exception); - - /// - /// Registers a that will calculate the exception to throw when the indexer is read. - /// - IIndexerSetupReturnBuilder Throws(global::System.Func callback); - } - - /// - /// Sets up a indexer for , , , and with callback support for the parameters. - /// - internal interface IIndexerSetupWithCallback : global::Mockolate.Setup.IIndexerSetup - { - /// - /// Initializes the indexer according to the given . - /// - global::Mockolate.Setup.IIndexerSetup InitializeWith(global::System.Func valueGenerator); - - /// - /// Registers a to setup the return value for this indexer. - /// - /// - /// The callback receives the parameters of the indexer. - /// - IIndexerSetupReturnBuilder Returns(global::System.Func callback); - - /// - /// Registers a to setup the return value for this indexer. - /// - /// - /// The callback receives the parameters of the indexer and the value of the indexer as last parameter. - /// - IIndexerSetupReturnBuilder Returns(global::System.Func callback); - - /// - /// Registers a that will calculate the exception to throw when the indexer is read. - /// - /// - /// The callback receives the parameters of the indexer. - /// - IIndexerSetupReturnBuilder Throws(global::System.Func callback); - - /// - /// Registers a that will calculate the exception to throw when the indexer is read. - /// - /// - /// The callback receives the parameters of the indexer and the value of the indexer as last parameter. - /// - IIndexerSetupReturnBuilder Throws(global::System.Func callback); - } - - /// - /// Sets up a getter callback for a indexer for , , , and . - /// - internal interface IIndexerGetterSetupCallbackBuilder : IIndexerGetterSetupParallelCallbackBuilder - { - /// - /// Runs the callback in parallel to the other callbacks. - /// - IIndexerGetterSetupParallelCallbackBuilder InParallel(); - } - - /// - /// Sets up a parallel getter callback for a indexer for , , , and . - /// - internal interface IIndexerGetterSetupParallelCallbackBuilder : IIndexerGetterSetupCallbackWhenBuilder - { - /// - /// Limits the callback to only execute for indexer accesses where the predicate returns true. - /// - /// - /// Provides a zero-based counter indicating how many times the indexer has been accessed so far. - /// - IIndexerGetterSetupCallbackWhenBuilder When(global::System.Func predicate); - } - - /// - /// Sets up a when getter callback for a indexer for , , , and . - /// - internal interface IIndexerGetterSetupCallbackWhenBuilder : global::Mockolate.Setup.IIndexerSetupWithCallback - { - /// - /// Repeats the callback for the given number of . - /// - /// - /// The number of times is only counted for actual executions (IIndexerGetterSetupParallelCallbackBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). - /// - IIndexerGetterSetupCallbackWhenBuilder For(int times); - - /// - /// Deactivates the callback after the given number of . - /// - /// - /// The number of times is only counted for actual executions (IIndexerGetterSetupParallelCallbackBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IIndexerSetup Only(int times); - } - - /// - /// Sets up a setter callback for a indexer for , , , and . - /// - internal interface IIndexerSetterSetupCallbackBuilder : IIndexerSetterSetupParallelCallbackBuilder - { - /// - /// Runs the callback in parallel to the other callbacks. - /// - IIndexerSetterSetupParallelCallbackBuilder InParallel(); - } - - /// - /// Sets up a parallel setter callback for a indexer for , , , and . - /// - internal interface IIndexerSetterSetupParallelCallbackBuilder : IIndexerSetterSetupCallbackWhenBuilder - { - /// - /// Limits the callback to only execute for indexer accesses where the predicate returns true. - /// - /// - /// Provides a zero-based counter indicating how many times the indexer has been accessed so far. - /// - IIndexerSetterSetupCallbackWhenBuilder When(global::System.Func predicate); - } - - /// - /// Sets up a when setter callback for a indexer for , , , and . - /// - internal interface IIndexerSetterSetupCallbackWhenBuilder : global::Mockolate.Setup.IIndexerSetupWithCallback - { - /// - /// Repeats the callback for the given number of . - /// - /// - /// The number of times is only counted for actual executions (IIndexerSetterSetupParallelCallbackBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). - /// - IIndexerSetterSetupCallbackWhenBuilder For(int times); - - /// - /// Deactivates the callback after the given number of . - /// - /// - /// The number of times is only counted for actual executions (IIndexerSetterSetupParallelCallbackBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IIndexerSetup Only(int times); - } - - /// - /// Sets up a return/throw callback for a indexer for , , , and . - /// - internal interface IIndexerSetupReturnBuilder : IIndexerSetupReturnWhenBuilder - { - /// - /// Limits the return/throw callback to only execute for indexer accesses where the predicate returns true. - /// - /// - /// Provides a zero-based counter indicating how many times the indexer has been accessed so far. - /// - IIndexerSetupReturnWhenBuilder When(global::System.Func predicate); - } - - /// - /// Sets up a when return/throw callback for a indexer for , , , and . - /// - internal interface IIndexerSetupReturnWhenBuilder : global::Mockolate.Setup.IIndexerSetupWithCallback - { - /// - /// Repeats the return/throw callback for the given number of . - /// - /// - /// The number of times is only counted for actual executions (IIndexerSetupReturnBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). - /// - IIndexerSetupReturnWhenBuilder For(int times); - - /// - /// Deactivates the return/throw after the given number of . - /// - /// - /// The number of times is only counted for actual executions (IIndexerSetupReturnBuilder<TValue, T1, T2, T3, T4, T5>.When(Func<int, bool>) evaluates to ). - /// - global::Mockolate.Setup.IIndexerSetup Only(int times); - } - - /// - /// Sets up a indexer for , , , and . - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal class IndexerSetup(global::Mockolate.MockRegistry mockRegistry, global::Mockolate.Parameters.IParameterMatch parameter1, global::Mockolate.Parameters.IParameterMatch parameter2, global::Mockolate.Parameters.IParameterMatch parameter3, global::Mockolate.Parameters.IParameterMatch parameter4, global::Mockolate.Parameters.IParameterMatch parameter5) : global::Mockolate.Setup.IndexerSetup(mockRegistry), - global::Mockolate.Setup.IIndexerSetupWithCallback, - global::Mockolate.Setup.IIndexerGetterSetupCallbackBuilder, - global::Mockolate.Setup.IIndexerSetterSetupCallbackBuilder, - global::Mockolate.Setup.IIndexerSetupReturnBuilder, - global::Mockolate.Setup.IIndexerGetterSetupWithCallback, - global::Mockolate.Setup.IIndexerSetterSetupWithCallback - { - private Callbacks>? _getterCallbacks; - private Callbacks>? _setterCallbacks; - private Callbacks>? _returnCallbacks; - private bool? _skipBaseClass; - private global::System.Func? _initialization; - - /// - public global::Mockolate.Setup.IIndexerSetup SkippingBaseClass(bool skipBaseClass = true) - { - _skipBaseClass = skipBaseClass; - return this; - } - - /// - public global::Mockolate.Setup.IIndexerSetupWithCallback InitializeWith(TValue value) - { - if (_initialization is not null) - { - throw new global::Mockolate.Exceptions.MockException("The indexer is already initialized. You cannot initialize it twice."); - } - - _initialization = (_, _, _, _, _) => value; - return this; - } - - global::Mockolate.Setup.IIndexerSetup global::Mockolate.Setup.IIndexerSetup.InitializeWith(TValue value) - => InitializeWith(value); - - /// - public global::Mockolate.Setup.IIndexerSetup InitializeWith(global::System.Func valueGenerator) - { - if (_initialization is not null) - { - throw new global::Mockolate.Exceptions.MockException("The indexer is already initialized. You cannot initialize it twice."); - } - - _initialization = valueGenerator; - return this; - } - - /// - public IIndexerGetterSetupWithCallback OnGet - => this; - - /// - IIndexerGetterSetupCallbackBuilder IIndexerGetterSetup.Do(global::System.Action callback) - { - Callback>? currentCallback = new((_, _, _, _, _, _, _) => callback()); - _getterCallbacks = _getterCallbacks.Register(currentCallback); - return this; - } - - /// - IIndexerGetterSetupCallbackBuilder IIndexerGetterSetupWithCallback.Do(global::System.Action callback) - { - Callback>? currentCallback = new((_, p1, p2, p3, p4, p5, _) => callback(p1, p2, p3, p4, p5)); - _getterCallbacks = _getterCallbacks.Register(currentCallback); - return this; - } - - /// - IIndexerGetterSetupCallbackBuilder IIndexerGetterSetupWithCallback.Do(global::System.Action callback) - { - Callback>? currentCallback = new((_, p1, p2, p3, p4, p5, v) => callback(p1, p2, p3, p4, p5, v)); - _getterCallbacks = _getterCallbacks.Register(currentCallback); - return this; - } - - /// - IIndexerGetterSetupCallbackBuilder IIndexerGetterSetupWithCallback.Do(global::System.Action callback) - { - Callback>? currentCallback = new(callback); - _getterCallbacks = _getterCallbacks.Register(currentCallback); - return this; - } - - IIndexerGetterSetupParallelCallbackBuilder IIndexerGetterSetup.TransitionTo(string scenario) - { - Callback>? currentCallback = new((_, _, _, _, _, _, _) => TransitionScenario(scenario)); - currentCallback.InParallel(); - _getterCallbacks = _getterCallbacks.Register(currentCallback); - return this; - } - - /// - public IIndexerSetterSetupWithCallback OnSet - => this; - - /// - IIndexerSetterSetupCallbackBuilder IIndexerSetterSetup.Do(global::System.Action callback) - { - Callback>? currentCallback = new((_, _, _, _, _, _, _) => callback()); - _setterCallbacks = _setterCallbacks.Register(currentCallback); - return this; - } - - /// - IIndexerSetterSetupCallbackBuilder IIndexerSetterSetup.Do(global::System.Action callback) - { - Callback>? currentCallback = new((_, _, _, _, _, _, v) => callback(v)); - _setterCallbacks = _setterCallbacks.Register(currentCallback); - return this; - } - - /// - IIndexerSetterSetupCallbackBuilder IIndexerSetterSetupWithCallback.Do(global::System.Action callback) - { - Callback>? currentCallback = new((_, p1, p2, p3, p4, p5, v) => callback(p1, p2, p3, p4, p5, v)); - _setterCallbacks = _setterCallbacks.Register(currentCallback); - return this; - } - - /// - IIndexerSetterSetupCallbackBuilder IIndexerSetterSetupWithCallback.Do(global::System.Action callback) - { - Callback>? currentCallback = new(callback); - _setterCallbacks = _setterCallbacks.Register(currentCallback); - return this; - } - - IIndexerSetterSetupParallelCallbackBuilder IIndexerSetterSetup.TransitionTo(string scenario) - { - Callback>? currentCallback = new((_, _, _, _, _, _, _) => TransitionScenario(scenario)); - currentCallback.InParallel(); - _setterCallbacks = _setterCallbacks.Register(currentCallback); - return this; - } - - /// - public IIndexerSetupReturnBuilder Returns(TValue returnValue) - { - var currentCallback = new Callback>((_, _, _, _, _, _, _) => returnValue); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - public IIndexerSetupReturnBuilder Returns(global::System.Func callback) - { - var currentCallback = new Callback>((_, _, _, _, _, _, _) => callback()); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - public IIndexerSetupReturnBuilder Returns(global::System.Func callback) - { - var currentCallback = new Callback>((_, p1, p2, p3, p4, p5, _) => callback(p1, p2, p3, p4, p5)); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - public IIndexerSetupReturnBuilder Returns(global::System.Func callback) - { - var currentCallback = new Callback>((_, v, p1, p2, p3, p4, p5) => callback(v, p1, p2, p3, p4, p5)); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - public IIndexerSetupReturnBuilder Throws() - where TException : global::System.Exception, new() - { - var currentCallback = new Callback>((_, _, _, _, _, _, _) => throw new TException()); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - public IIndexerSetupReturnBuilder Throws(global::System.Exception exception) - { - var currentCallback = new Callback>((_, _, _, _, _, _, _) => throw exception); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - public IIndexerSetupReturnBuilder Throws(global::System.Func callback) - { - var currentCallback = new Callback>((_, _, _, _, _, _, _) => throw callback()); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - public IIndexerSetupReturnBuilder Throws(global::System.Func callback) - { - var currentCallback = new Callback>((_, p1, p2, p3, p4, p5, _) => throw callback(p1, p2, p3, p4, p5)); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - public IIndexerSetupReturnBuilder Throws(global::System.Func callback) - { - var currentCallback = new Callback>((_, p1, p2, p3, p4, p5, v) => throw callback(p1, p2, p3, p4, p5, v)); - _returnCallbacks = _returnCallbacks.Register(currentCallback); - return this; - } - - /// - IIndexerGetterSetupCallbackWhenBuilder IIndexerGetterSetupParallelCallbackBuilder.When(global::System.Func predicate) - { - _getterCallbacks?.Active?.When(predicate); - return this; - } - - /// - IIndexerGetterSetupParallelCallbackBuilder IIndexerGetterSetupCallbackBuilder.InParallel() - { - _getterCallbacks?.Active?.InParallel(); - return this; - } - - /// - IIndexerGetterSetupCallbackWhenBuilder IIndexerGetterSetupCallbackWhenBuilder.For(int times) - { - _getterCallbacks?.Active?.For(times); - return this; - } - - /// - global::Mockolate.Setup.IIndexerSetup IIndexerGetterSetupCallbackWhenBuilder.Only(int times) - { - _getterCallbacks?.Active?.Only(times); - return this; - } - - /// - IIndexerSetterSetupCallbackWhenBuilder IIndexerSetterSetupParallelCallbackBuilder.When(global::System.Func predicate) - { - _setterCallbacks?.Active?.When(predicate); - return this; - } - - /// - IIndexerSetterSetupParallelCallbackBuilder IIndexerSetterSetupCallbackBuilder.InParallel() - { - _setterCallbacks?.Active?.InParallel(); - return this; - } - - /// - IIndexerSetterSetupCallbackWhenBuilder IIndexerSetterSetupCallbackWhenBuilder.For(int times) - { - _setterCallbacks?.Active?.For(times); - return this; - } - - /// - global::Mockolate.Setup.IIndexerSetup IIndexerSetterSetupCallbackWhenBuilder.Only(int times) - { - _setterCallbacks?.Active?.Only(times); - return this; - } - - /// - IIndexerSetupReturnWhenBuilder IIndexerSetupReturnBuilder.When(global::System.Func predicate) - { - _returnCallbacks?.Active?.When(predicate); - return this; - } - - /// - IIndexerSetupReturnWhenBuilder IIndexerSetupReturnWhenBuilder.For(int times) - { - _returnCallbacks?.Active?.For(times); - return this; - } - - /// - global::Mockolate.Setup.IIndexerSetup IIndexerSetupReturnWhenBuilder.Only(int times) - { - _returnCallbacks?.Active?.Only(times); - return this; - } - - /// - /// Check if the setup matches the specified parameter values. - /// - public virtual bool Matches(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5) - { - if (!parameter1.Matches(p1) || !parameter2.Matches(p2) || !parameter3.Matches(p3) || !parameter4.Matches(p4) || !parameter5.Matches(p5)) - { - return false; - } - - parameter1.InvokeCallbacks(p1); - parameter2.InvokeCallbacks(p2); - parameter3.InvokeCallbacks(p3); - parameter4.InvokeCallbacks(p4); - parameter5.InvokeCallbacks(p5); - return true; - } - - /// - /// Check if the setup matches the specified parameter values. - /// - public virtual bool Matches(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, TValue value) - => Matches(p1, p2, p3, p4, p5); - - /// - protected override bool MatchesAccess(global::Mockolate.Interactions.IndexerAccess access) - { - if (access is global::Mockolate.Interactions.IndexerGetterAccess getter) - { - return Matches(getter.Parameter1, getter.Parameter2, getter.Parameter3, getter.Parameter4, getter.Parameter5); - } - - if (access is global::Mockolate.Interactions.IndexerSetterAccess setter) - { - return Matches(setter.Parameter1, setter.Parameter2, setter.Parameter3, setter.Parameter4, setter.Parameter5, setter.TypedValue); - } - - return false; - } - - /// - public override bool? SkipBaseClass() - => _skipBaseClass; - - /// - public override TResult GetResult(global::Mockolate.Interactions.IndexerAccess access, global::Mockolate.MockBehavior behavior, TResult baseValue) - { - if (!TryExtractParameters(access, out T1 p1, out T2 p2, out T3 p3, out T4 p4, out T5 p5)) - { - return baseValue; - } - - TValue currentValue = TryCast(baseValue, out TValue casted, behavior) ? casted : default!; - currentValue = ExecuteGetterCallbacks(p1, p2, p3, p4, p5, currentValue); - currentValue = ExecuteReturnCallbacks(p1, p2, p3, p4, p5, currentValue); - access.StoreValue(currentValue); - return TryCast(currentValue, out TResult result, behavior) ? result : baseValue; - } - - /// - public override TResult GetResult(global::Mockolate.Interactions.IndexerAccess access, global::Mockolate.MockBehavior behavior) - { - if (!TryExtractParameters(access, out T1 p1, out T2 p2, out T3 p3, out T4 p4, out T5 p5)) - { - return behavior.DefaultValue.Generate(default(TResult)!); - } - - TValue currentValue; - if (access.TryFindStoredValue(out TValue existing)) - { - currentValue = existing; - } - else if (_initialization is not null) - { - currentValue = _initialization.Invoke(p1, p2, p3, p4, p5); - } - else - { - currentValue = TryCast(behavior.DefaultValue.Generate(default(TValue)!), out TValue casted, behavior) ? casted : default!; - } - - currentValue = ExecuteGetterCallbacks(p1, p2, p3, p4, p5, currentValue); - currentValue = ExecuteReturnCallbacks(p1, p2, p3, p4, p5, currentValue); - access.StoreValue(currentValue); - return TryCast(currentValue, out TResult result, behavior) ? result : behavior.DefaultValue.Generate(default(TResult)!); - } - - /// - public override TResult GetResult(global::Mockolate.Interactions.IndexerAccess access, global::Mockolate.MockBehavior behavior, global::System.Func defaultValueGenerator) - { - if (!TryExtractParameters(access, out T1 p1, out T2 p2, out T3 p3, out T4 p4, out T5 p5)) - { - return defaultValueGenerator(); - } - - TValue currentValue; - if (access.TryFindStoredValue(out TValue existing)) - { - currentValue = existing; - } - else if (_initialization is not null) - { - currentValue = _initialization.Invoke(p1, p2, p3, p4, p5); - } - else - { - currentValue = TryCast(defaultValueGenerator(), out TValue casted, behavior) ? casted : default!; - } - - currentValue = ExecuteGetterCallbacks(p1, p2, p3, p4, p5, currentValue); - currentValue = ExecuteReturnCallbacks(p1, p2, p3, p4, p5, currentValue); - access.StoreValue(currentValue); - return TryCast(currentValue, out TResult result, behavior) ? result : defaultValueGenerator(); - } - - /// - public override void SetResult(global::Mockolate.Interactions.IndexerAccess access, global::Mockolate.MockBehavior behavior, TResult value) - { - access.StoreValue(value); - if (!TryExtractParameters(access, out T1 p1, out T2 p2, out T3 p3, out T4 p4, out T5 p5)) - { - return; - } - - if (!TryCast(value, out TValue resultValue, behavior)) - { - return; - } - - if (_setterCallbacks is not null) - { - bool wasInvoked = false; - int currentSetterCallbacksIndex = _setterCallbacks.CurrentIndex; - for (int i = 0; i < _setterCallbacks.Count; i++) - { - Callback> setterCallback = - _setterCallbacks[(currentSetterCallbacksIndex + i) % _setterCallbacks.Count]; - if (setterCallback.Invoke(wasInvoked, ref _setterCallbacks.CurrentIndex, (p1, p2, p3, p4, p5, resultValue), - static (count, @delegate, state) => @delegate(count, state.p1, state.p2, state.p3, state.p4, state.p5, state.resultValue))) - { - wasInvoked = true; - } - } - } - } - - private TValue ExecuteGetterCallbacks(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, TValue currentValue) - { - if (_getterCallbacks is not null) - { - bool wasInvoked = false; - int currentGetterCallbacksIndex = _getterCallbacks.CurrentIndex; - for (int i = 0; i < _getterCallbacks.Count; i++) - { - Callback> getterCallback = - _getterCallbacks[(currentGetterCallbacksIndex + i) % _getterCallbacks.Count]; - if (getterCallback.Invoke(wasInvoked, ref _getterCallbacks.CurrentIndex, (p1, p2, p3, p4, p5, currentValue), - static (count, @delegate, state) => @delegate(count, state.p1, state.p2, state.p3, state.p4, state.p5, state.currentValue))) - { - wasInvoked = true; - } - } - } - - return currentValue; - } - - private TValue ExecuteReturnCallbacks(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, TValue currentValue) - { - if (_returnCallbacks is not null) - { - foreach (Callback> _ in _returnCallbacks) - { - Callback> returnCallback = - _returnCallbacks[_returnCallbacks.CurrentIndex % _returnCallbacks.Count]; - if (returnCallback.Invoke(ref _returnCallbacks.CurrentIndex, (p1, p2, p3, p4, p5, currentValue), - static (count, @delegate, state) => @delegate(count, state.p1, state.p2, state.p3, state.p4, state.p5, state.currentValue), - out TValue? newValue)) - { - return newValue!; - } - } - } - - return currentValue; - } - - private static bool TryExtractParameters(global::Mockolate.Interactions.IndexerAccess access, out T1 p1, out T2 p2, out T3 p3, out T4 p4, out T5 p5) - { - if (access is global::Mockolate.Interactions.IndexerGetterAccess getter) - { - p1 = getter.Parameter1; - p2 = getter.Parameter2; - p3 = getter.Parameter3; - p4 = getter.Parameter4; - p5 = getter.Parameter5; - return true; - } - - if (access is global::Mockolate.Interactions.IndexerSetterAccess setter) - { - p1 = setter.Parameter1; - p2 = setter.Parameter2; - p3 = setter.Parameter3; - p4 = setter.Parameter4; - p5 = setter.Parameter5; - return true; - } - - p1 = default!; - p2 = default!; - p3 = default!; - p4 = default!; - p5 = default!; - return false; - } - - /// - public override string ToString() - => $"{FormatType(typeof(TValue))} this[{parameter1}, {parameter2}, {parameter3}, {parameter4}, {parameter5}]"; - - } - -} - -namespace Mockolate -{ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal static class IndexerSetupExtensions - { - - /// - /// Extensions for indexer getter callback setups with 5 parameters. - /// - extension(Mockolate.Setup.IIndexerGetterSetupCallbackWhenBuilder setup) - { - /// - /// Executes the callback only once. - /// - public global::Mockolate.Setup.IIndexerSetup OnlyOnce() - => setup.Only(1); - } - - /// - /// Extensions for indexer setter callback setups with 5 parameters. - /// - extension(Mockolate.Setup.IIndexerSetterSetupCallbackWhenBuilder setup) - { - /// - /// Executes the callback only once. - /// - public global::Mockolate.Setup.IIndexerSetup OnlyOnce() - => setup.Only(1); - } - - /// - /// Extensions for indexer setups with 5 parameters. - /// - extension(Mockolate.Setup.IIndexerSetupReturnWhenBuilder setup) - { - /// - /// Returns/throws forever. - /// - public void Forever() - { - setup.For(int.MaxValue); - } - - /// - /// Uses the return value only once. - /// - public global::Mockolate.Setup.IIndexerSetup OnlyOnce() - => setup.Only(1); - } - } -} -namespace Mockolate.Interactions -{ - /// - /// An access of an indexer getter with 5 typed parameters. - /// - [global::System.Diagnostics.DebuggerDisplay("{ToString()}")] - internal class IndexerGetterAccess(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5) - : global::Mockolate.Interactions.IndexerAccess - { - /// - /// The value of parameter 1. - /// - public T1 Parameter1 { get; } = parameter1; - /// - /// The value of parameter 2. - /// - public T2 Parameter2 { get; } = parameter2; - /// - /// The value of parameter 3. - /// - public T3 Parameter3 { get; } = parameter3; - /// - /// The value of parameter 4. - /// - public T4 Parameter4 { get; } = parameter4; - /// - /// The value of parameter 5. - /// - public T5 Parameter5 { get; } = parameter5; - /// - public override int ParameterCount => 5; - /// - public override object? GetParameterValueAt(int index) - => index switch - { - 0 => Parameter1, - 1 => Parameter2, - 2 => Parameter3, - 3 => Parameter4, - 4 => Parameter5, - _ => null, - }; - /// - protected override global::Mockolate.Setup.IndexerValueStorage? TraverseStorage(global::Mockolate.Setup.IndexerValueStorage? storage, bool createMissing) - { - global::Mockolate.Setup.IndexerValueStorage? s = storage; - if (s is null) - { - return null; - } - s = createMissing ? s.GetOrAddChildDispatch(Parameter1) : s.GetChildDispatch(Parameter1); - if (s is null) - { - return null; - } - s = createMissing ? s.GetOrAddChildDispatch(Parameter2) : s.GetChildDispatch(Parameter2); - if (s is null) - { - return null; - } - s = createMissing ? s.GetOrAddChildDispatch(Parameter3) : s.GetChildDispatch(Parameter3); - if (s is null) - { - return null; - } - s = createMissing ? s.GetOrAddChildDispatch(Parameter4) : s.GetChildDispatch(Parameter4); - if (s is null) - { - return null; - } - return createMissing ? s.GetOrAddChildDispatch(Parameter5) : s.GetChildDispatch(Parameter5); - } - /// - public override string ToString() - => $"get indexer [{Parameter1?.ToString() ?? "null"}, {Parameter2?.ToString() ?? "null"}, {Parameter3?.ToString() ?? "null"}, {Parameter4?.ToString() ?? "null"}, {Parameter5?.ToString() ?? "null"}]"; - } - /// - /// An access of an indexer setter with 5 typed parameters. - /// - [global::System.Diagnostics.DebuggerDisplay("{ToString()}")] - internal class IndexerSetterAccess(T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, TValue value) - : global::Mockolate.Interactions.IndexerAccess - { - /// - /// The value of parameter 1. - /// - public T1 Parameter1 { get; } = parameter1; - /// - /// The value of parameter 2. - /// - public T2 Parameter2 { get; } = parameter2; - /// - /// The value of parameter 3. - /// - public T3 Parameter3 { get; } = parameter3; - /// - /// The value of parameter 4. - /// - public T4 Parameter4 { get; } = parameter4; - /// - /// The value of parameter 5. - /// - public T5 Parameter5 { get; } = parameter5; - /// - /// The typed value the indexer was being set to. - /// - public TValue TypedValue { get; } = value; - /// - public override int ParameterCount => 5; - /// - public override object? GetParameterValueAt(int index) - => index switch - { - 0 => Parameter1, - 1 => Parameter2, - 2 => Parameter3, - 3 => Parameter4, - 4 => Parameter5, - _ => null, - }; - /// - protected override global::Mockolate.Setup.IndexerValueStorage? TraverseStorage(global::Mockolate.Setup.IndexerValueStorage? storage, bool createMissing) - { - global::Mockolate.Setup.IndexerValueStorage? s = storage; - if (s is null) - { - return null; - } - s = createMissing ? s.GetOrAddChildDispatch(Parameter1) : s.GetChildDispatch(Parameter1); - if (s is null) - { - return null; - } - s = createMissing ? s.GetOrAddChildDispatch(Parameter2) : s.GetChildDispatch(Parameter2); - if (s is null) - { - return null; - } - s = createMissing ? s.GetOrAddChildDispatch(Parameter3) : s.GetChildDispatch(Parameter3); - if (s is null) - { - return null; - } - s = createMissing ? s.GetOrAddChildDispatch(Parameter4) : s.GetChildDispatch(Parameter4); - if (s is null) - { - return null; - } - return createMissing ? s.GetOrAddChildDispatch(Parameter5) : s.GetChildDispatch(Parameter5); - } - /// - public override string ToString() - => $"set indexer [{Parameter1?.ToString() ?? "null"}, {Parameter2?.ToString() ?? "null"}, {Parameter3?.ToString() ?? "null"}, {Parameter4?.ToString() ?? "null"}, {Parameter5?.ToString() ?? "null"}] to {TypedValue?.ToString() ?? "null"}"; - } -} - -#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/Mock.g.cs deleted file mode 100644 index 3944360b..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/Mock.g.cs +++ /dev/null @@ -1,135 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable -/// -/// Create new mocks by calling the static T.CreateMock() method on your type T. -/// -/// -/// You can also provide a MockBehavior parameter to customize how the mock should behave in certain scenarios.
-/// If your type is a class without a default constructor, you can provide constructor parameters by passing an object?[]? to the corresponding CreateMock(...) overload. -///
-[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static partial class Mock -{ - /// - /// This interface should never be used. If it is, this is an indication that the Mockolate source generator did not run correctly or that the used type is not mockable. - /// - /// - /// The source generator creates overloads with correct return values. - /// - internal interface IMockGenerationDidNotRun {} - - /// - /// Create a new mock of with the default MockBehavior. - /// - /// Type to mock, which can be an interface or a class. - /// - /// Any interface type can be used for mocking, but for classes, only abstract and virtual members can be mocked. - /// - extension(T _) - { - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior = null) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(global::Mockolate.MockBehavior? mockBehavior, object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - - /// - /// Fallback CreateMock that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Ignored; reserved for the generator-emitted overload. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete CreateMock overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public static global::Mockolate.Mock.IMockGenerationDidNotRun CreateMock(object?[]? constructorParameters) - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(T)}' is not mockable or the source generator did not run correctly."); - } - } - - extension(global::Mockolate.Mock.IMockGenerationDidNotRun _) - { - /// - /// Fallback Implementing that is only resolved when the Mockolate source generator did not run or when - /// is not mockable. Calling it always throws a MockException. - /// - /// Additional interface the mock should implement. - /// This method never returns - it always throws. - /// - /// The source generator emits a concrete Implementing overload per mockable type with the same shape. - /// If you see this fallback resolved in your IDE, the generator did not run for ; - /// run a clean build (for example dotnet clean && dotnet build) and verify that the type is mockable. - /// - /// Always thrown: the source generator did not run or is not mockable. - public global::Mockolate.Mock.IMockGenerationDidNotRun Implementing() where TInterface : class - { - throw new global::Mockolate.Exceptions.MockException($"This method should not be called directly. Either '{typeof(TInterface)}' is not mockable or the source generator did not run correctly."); - } - } - -} - -/// -/// Adapts an IParameter (non-generic) to -/// IParameterMatch<T> so that covariant parameter -/// references (e.g. an IParameter<Derived> passed through an IParameter<Base> -/// slot) can still be invoked at setup/verify time. Only allocated when the direct -/// IParameterMatch<T> cast fails. Shared by every -/// generated mock file. -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal sealed class CovariantParameterAdapter(global::Mockolate.Parameters.IParameter inner) : global::Mockolate.Parameters.IParameterMatch -{ - public bool Matches(T value) => inner.Matches(value); - public void InvokeCallbacks(T value) => inner.InvokeCallbacks(value); - public override string? ToString() => inner.ToString(); - - public static global::Mockolate.Parameters.IParameterMatch Wrap(global::Mockolate.Parameters.IParameter parameter) - => parameter is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new CovariantParameterAdapter(parameter); -} -#nullable disable diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/MockBehaviorExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/MockBehaviorExtensions.g.cs deleted file mode 100644 index 888d2c2c..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/MockBehaviorExtensions.g.cs +++ /dev/null @@ -1,285 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -namespace Mockolate; - -#nullable enable annotations - -/// -/// Extensions for MockBehavior. -/// -internal static partial class Mock -{ - private static readonly global::Mockolate.MockBehavior _default; - - static Mock() - { - _default = new global::Mockolate.MockBehavior(new DefaultValueGenerator()); - } - - extension(global::Mockolate.MockBehavior) - { - /// - /// The default MockBehavior - the starting point for configuring a mock. - /// - /// - /// Un-configured members return the generator-provided default value (empty strings/collections, completed - /// Tasks, otherwise), base-class - /// implementations run for class mocks, and every invocation is recorded for later verification. - /// - /// Chain SkippingBaseClass(), ThrowingWhenNotSetup(), SkippingInteractionRecording(), - /// WithDefaultValueFor<T>(...) or UseConstructorParametersFor<T>(...) to derive - /// a customized MockBehavior; because it is a , - /// each call returns a new instance and this shared default stays unchanged. - /// - public static global::Mockolate.MockBehavior Default => _default; - } - - /// - /// Defines a factory for creating default values for a specified type. - /// - public interface IDefaultValueFactory - { - /// - /// Determines whether the specified can be created by this factory. - /// - bool IsMatch(global::System.Type type); - - /// - /// Creates a new instance of the specified type. - /// - object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, object?[] parameters); - } - - /// - /// A IDefaultValueFactory that returns a specified for the given type - /// parameter . - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal class TypedDefaultValueFactory(T value) : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(T); - - /// - public object? Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - => value; - } - - /// - /// Provides default values for common types used in mocking scenarios. - /// - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private class DefaultValueGenerator : IDefaultValueGenerator - { - private static readonly global::System.Collections.Concurrent.ConcurrentQueue _factories = new([ - new TypedDefaultValueFactory(""), - new CancellableTaskFactory(), - #if NET8_0_OR_GREATER - new CancellableValueTaskFactory(), - #endif - new TypedDefaultValueFactory(global::System.Threading.CancellationToken.None), - new TypedDefaultValueFactory(global::System.Array.Empty()), - ]); - - /// - public object? GenerateValue(global::System.Type type, params object?[] parameters) - { - if (TryGenerate(type, parameters, out object? value)) - { - return value; - } - - return null; - } - - /// - /// Registers a to provide default values for a specific type. - /// - public static void Register(IDefaultValueFactory defaultValueFactory) - => _factories.Enqueue(defaultValueFactory); - - /// - /// Tries to generate a default value for the specified type. - /// - protected virtual bool TryGenerate(global::System.Type type, object?[] parameters, out object? value) - { - IDefaultValueFactory? matchingFactory = global::System.Linq.Enumerable.FirstOrDefault(_factories, Predicate); - if (matchingFactory is not null) - { - value = matchingFactory.Create(type, this, parameters); - return true; - } - - value = null; - return false; - - bool Predicate(global::Mockolate.Mock.IDefaultValueFactory f) - => f.IsMatch(type); - } - - private static bool HasCanceledCancellationToken(object?[] parameters, out global::System.Threading.CancellationToken cancellationToken) - { - global::System.Threading.CancellationToken parameter = global::System.Linq.Enumerable.FirstOrDefault(global::System.Linq.Enumerable.OfType(parameters)); - if (parameter.IsCancellationRequested) - { - cancellationToken = parameter; - return true; - } - - cancellationToken = global::System.Threading.CancellationToken.None; - return false; - } - - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CancellableTaskFactory : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Threading.Tasks.Task); - - /// - public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - { - if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) - { - return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.Task.CompletedTask; - } - } - #if NET8_0_OR_GREATER - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - private sealed class CancellableValueTaskFactory : IDefaultValueFactory - { - /// - public bool IsMatch(global::System.Type type) - => type == typeof(global::System.Threading.Tasks.ValueTask); - - /// - public object Create(global::System.Type type, IDefaultValueGenerator defaultValueGenerator, params object?[] parameters) - { - if (HasCanceledCancellationToken(parameters, out global::System.Threading.CancellationToken cancellationToken)) - { - return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.ValueTask.CompletedTask; - } - } - #endif - } -} - -/// -/// Extensions on IDefaultValueGenerator -/// -[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] -internal static class DefaultValueGeneratorExtensions -{ - /// - /// Adds a generic Generate method for specific types. - /// - extension(IDefaultValueGenerator generator) - { - /// - /// Generates a Task of , with - /// the for context. - /// - public global::System.Threading.Tasks.Task Generate(global::System.Threading.Tasks.Task nullValue, T value, params object?[] parameters) - { - global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( - global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; - if (cancellationToken.IsCancellationRequested) - { - return global::System.Threading.Tasks.Task.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.Task.FromResult(value); - } - -#if NET8_0_OR_GREATER - /// - /// Generates a ValueTask of , with - /// the for context. - /// - public global::System.Threading.Tasks.ValueTask Generate(global::System.Threading.Tasks.ValueTask nullValue, T value, params object?[] parameters) - { - global::System.Threading.CancellationToken cancellationToken = global::System.Linq.Enumerable.FirstOrDefault( - global::System.Linq.Enumerable.OfType(parameters)) ?? global::System.Threading.CancellationToken.None; - if (cancellationToken.IsCancellationRequested) - { - return global::System.Threading.Tasks.ValueTask.FromCanceled(cancellationToken); - } - - return global::System.Threading.Tasks.ValueTask.FromResult(value); - } -#endif - - /// - /// Generates an empty enumerable of , with - /// the for context. - /// - public global::System.Collections.Generic.IEnumerable Generate(global::System.Collections.Generic.IEnumerable nullValue, params object?[] parameters) - => global::System.Array.Empty(); - - /// - /// Generates an empty enumerable of , with - /// the for context. - /// - public global::System.Collections.Generic.List Generate(global::System.Collections.Generic.List nullValue, params object?[] parameters) - => new global::System.Collections.Generic.List(); - - /// - /// Generates an empty array of , with - /// the for context. - /// - public T[] Generate(T[] nullValue, params object?[] parameters) - => global::System.Array.Empty(); - - /// - /// Generates an empty two-dimensional array of , with - /// the for context. - /// - public T[,] Generate(T[,] nullValue, params object?[] parameters) - => new T[,] { }; - - /// - /// Generates an empty three-dimensional array of , with - /// the for context. - /// - public T[,,] Generate(T[,,] nullValue, params object?[] parameters) - => new T[,,] { }; - - /// - /// Generates an empty four-dimensional array of , with - /// the for context. - /// - public T[,,,] Generate(T[,,,] nullValue, params object?[] parameters) - => new T[,,,] { }; - - /// - /// Generates a default value of type , with - /// the for context. - /// - public T Generate(T nullValue, params object?[] parameters) - { - if (generator.GenerateValue(typeof(T), parameters) is T value) - { - return value; - } - - return nullValue; - } - } -} - -#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/ParameterArg.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/ParameterArg.g.cs deleted file mode 100644 index 284fbf66..00000000 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/ParameterArg.g.cs +++ /dev/null @@ -1,126 +0,0 @@ -//---------------------- -// -// This code was generated by the Mockolate source generator. -// -// Changes to this file may cause incorrect behavior and -// will be lost if the code is regenerated! -// -//---------------------- - -#nullable enable - -namespace Mockolate -{ - /// - /// A setup or verify argument that is either an It matcher - /// (IParameter<T>) or a literal value of type . - /// - /// - /// Both case types convert implicitly, so Setup.Method(42) and Setup.Method(It.IsAny<int>()) - /// bind to the same overload. A instance stands for the literal default(T). - /// - [global::System.Runtime.CompilerServices.Union] - [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal readonly struct ParameterArg - { - private const byte MatcherTag = 1; - private const byte LiteralTag = 2; - - private readonly global::Mockolate.Parameters.IParameter? _matcher; - private readonly T? _literal; - private readonly byte _tag; - - /// - /// Creates the matcher case. - /// - public ParameterArg(global::Mockolate.Parameters.IParameter matcher) - { - _matcher = matcher; - _literal = default; - _tag = MatcherTag; - } - - /// - /// Creates the literal value case. - /// - public ParameterArg(T? literal) - { - _matcher = null; - _literal = literal; - _tag = LiteralTag; - } - - /// - /// The contained matcher or literal value, boxed. Part of the union pattern; the generated mocks use the - /// typed accessors instead. - /// - public object? Value => _tag switch - { - MatcherTag => _matcher, - LiteralTag => _literal, - _ => null, - }; - - /// - /// unless this is the instance. - /// - public bool HasValue => _tag != 0; - - /// - /// when the argument is a literal value (including the instance). - /// - public bool IsLiteral => _tag != MatcherTag; - - /// - /// The literal value; default(T) for the matcher case and the instance. - /// - public T? Literal => _literal; - - /// - /// Gets the matcher, when this is the matcher case. - /// - public bool TryGetValue(out global::Mockolate.Parameters.IParameter? matcher) - { - matcher = _matcher; - return _tag == MatcherTag; - } - - /// - /// Gets the literal value, when this is the literal case. - /// - public bool TryGetValue(out T? literal) - { - literal = _literal; - return _tag == LiteralTag; - } - - /// - /// The IParameterMatch<T> for this argument: the matcher itself, - /// or an equality match for the literal value. - /// - public global::Mockolate.Parameters.IParameterMatch ToParameterMatch() - { - if (_tag != MatcherTag) - { - return (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsValue(_literal!); - } - - if (_matcher is null) - { - return (global::Mockolate.Parameters.IParameterMatch)global::Mockolate.It.IsNull("null"); - } - - return _matcher is global::Mockolate.Parameters.IParameterMatch direct - ? direct - : new global::Mockolate.CovariantParameterAdapter(_matcher); - } - - /// - public override string ToString() => _tag switch - { - MatcherTag => _matcher?.ToString() ?? "null", - _ => _literal?.ToString() ?? "null", - }; - } -} -#nullable disable \ No newline at end of file diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/_shared.txt b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/_shared.txt new file mode 100644 index 00000000..279eee42 --- /dev/null +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/UnionIndexers_CanBeCreated_Unions/_shared.txt @@ -0,0 +1,4 @@ +IndexerSetups.g.cs|IndexerSetups.854c2a72.g.cs +Mock.g.cs|Mock.g.cs +MockBehaviorExtensions.g.cs|MockBehaviorExtensions.g.cs +ParameterArg.g.cs|ParameterArg.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/ActionFunc.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/ActionFunc.g.cs similarity index 100% rename from Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/ActionFunc.g.cs rename to Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/ActionFunc.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/RefStructConsumer_CanBeCreated/IndexerSetups.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/IndexerSetups.854c2a72.g.cs similarity index 100% rename from Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/RefStructConsumer_CanBeCreated/IndexerSetups.g.cs rename to Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/IndexerSetups.854c2a72.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/IndexerSetups.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/IndexerSetups.d958f396.g.cs similarity index 100% rename from Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/IndexerSetups.g.cs rename to Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/IndexerSetups.d958f396.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/MethodSetups.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/MethodSetups.0483b407.g.cs similarity index 100% rename from Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/MethodSetups.g.cs rename to Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/MethodSetups.0483b407.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated/MethodSetups.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/MethodSetups.3d601ff0.g.cs similarity index 100% rename from Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated/MethodSetups.g.cs rename to Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/MethodSetups.3d601ff0.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/Mock.ComprehensiveAbstractClass.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/Mock.ComprehensiveAbstractClass.g.cs similarity index 100% rename from Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/Mock.ComprehensiveAbstractClass.g.cs rename to Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/Mock.ComprehensiveAbstractClass.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/Mock.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/Mock.g.cs similarity index 100% rename from Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/Mock.g.cs rename to Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/Mock.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/MockBehaviorExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/MockBehaviorExtensions.g.cs similarity index 100% rename from Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/BaseClass_WithMultipleAdditionalInterfaces_CanBeCreated/MockBehaviorExtensions.g.cs rename to Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/MockBehaviorExtensions.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/ParameterArg.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/ParameterArg.g.cs similarity index 100% rename from Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated_Unions/ParameterArg.g.cs rename to Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/ParameterArg.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated/ReturnsThrowsAsyncExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/ReturnsThrowsAsyncExtensions.d2d185ae.g.cs similarity index 100% rename from Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveDelegate_CanBeCreated/ReturnsThrowsAsyncExtensions.g.cs rename to Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/ReturnsThrowsAsyncExtensions.d2d185ae.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/ReturnsThrowsAsyncExtensions.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/ReturnsThrowsAsyncExtensions.dd90b829.g.cs similarity index 100% rename from Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/ComprehensiveInterface_CanBeCreated/ReturnsThrowsAsyncExtensions.g.cs rename to Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/ReturnsThrowsAsyncExtensions.dd90b829.g.cs diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotAcceptance.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotAcceptance.cs index 7f114219..7b963282 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotAcceptance.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotAcceptance.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; + namespace Mockolate.SourceGenerators.Tests.Snapshot; public sealed class MockGenerationSnapshotAcceptance @@ -9,12 +11,13 @@ public sealed class MockGenerationSnapshotAcceptance [Fact(Explicit = true)] public void AcceptSnapshotChanges() { + Dictionary> scenarios = new(); foreach (var scenario in MockGenerationSnapshotTests.Scenarios) { var result = MockGenerationSnapshotTests.RunGenerator(scenario); - var generated = - MockGenerationSnapshotTests.NormalizeSources(result); - SnapshotStorage.SetExpected(scenario.Name, generated); + scenarios[scenario.Name] = MockGenerationSnapshotTests.NormalizeSources(result); } + + SnapshotStorage.SetExpected(scenarios); } } diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotTests.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotTests.cs index f6525585..1c47a7fa 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotTests.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotTests.cs @@ -13,7 +13,8 @@ namespace Mockolate.SourceGenerators.Tests.Snapshot; /// Tests/Mockolate.Tests/GeneratorCoverage source files as input, so the /// example types remain the single source of truth for "every special case in the /// source generator". The full set of generated .g.cs files is diffed against -/// Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/<scenario>/. +/// Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/<scenario>/; files identical across +/// scenarios are stored once under Expected/_Shared/ and listed in the scenario's _shared.txt. /// When a scenario fails because the change was intentional, run /// . ///
@@ -120,14 +121,6 @@ await That(SnapshotStorage.StripConfigSpecificLines(generated[fileName])) """, [], UnionMode: true), - new( - "HttpClient_CanBeCreated_Unions", - [], - """ - System.Net.Http.HttpClient sut = System.Net.Http.HttpClient.CreateMock(); - """, - [typeof(HttpClient), typeof(HttpStatusCode),], - UnionMode: true), new( "KeywordEdgeCases_CanBeCreated_Unions", ["IKeywordEdgeCases.cs",], diff --git a/Tests/Mockolate.SourceGenerators.Tests/TestHelpers/SnapshotStorage.cs b/Tests/Mockolate.SourceGenerators.Tests/TestHelpers/SnapshotStorage.cs index 7cdf192a..43093c6c 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/TestHelpers/SnapshotStorage.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/TestHelpers/SnapshotStorage.cs @@ -2,12 +2,22 @@ using System.IO; using System.Linq; using System.Runtime.CompilerServices; +using System.Security.Cryptography; +using System.Text; using System.Text.RegularExpressions; namespace Mockolate.SourceGenerators.Tests.TestHelpers; +/// +/// Stores the expected generator output per scenario under Snapshot/Expected/<scenario>/. +/// Files whose content is identical across scenarios (e.g. Mock.g.cs) are stored once under +/// Snapshot/Expected/_Shared/ and referenced from a _shared.txt manifest per scenario. +/// public static partial class SnapshotStorage { + private const string SharedFolderName = "_Shared"; + private const string ManifestFileName = "_shared.txt"; + [GeneratedRegex(@"[ \t]*\[global::System\.Diagnostics\.DebuggerNonUserCode\]\r?\n?")] private static partial Regex DebuggerNonUserCodeRegex { get; } @@ -26,25 +36,82 @@ public static IReadOnlyDictionary GetExpected(string scenario) foreach (var file in Directory.GetFiles(folder).OrderBy(f => f, StringComparer.Ordinal)) { - var content = File.ReadAllText(file).Replace("\r\n", "\n"); - result[Path.GetFileName(file)] = content; + if (Path.GetFileName(file) == ManifestFileName) continue; + + result[Path.GetFileName(file)] = ReadNormalized(file); + } + + var manifest = Path.Combine(folder, ManifestFileName); + if (File.Exists(manifest)) + { + foreach (var line in File.ReadAllLines(manifest)) + { + var separator = line.IndexOf('|'); + if (separator <= 0) continue; + + var fileName = line.Substring(0, separator); + var sharedName = line.Substring(separator + 1); + result[fileName] = ReadNormalized(Path.Combine(ExpectedFolder(SharedFolderName), sharedName)); + } } return result; } - public static void SetExpected(string scenario, IReadOnlyDictionary sources) + public static void SetExpected(IReadOnlyDictionary> scenarios) { - var folder = ExpectedFolder(scenario); - if (Directory.Exists(folder)) Directory.Delete(folder, true); + Dictionary<(string FileName, string Content), int> useCounts = new(); + Dictionary> normalized = new(); + foreach (var scenario in scenarios) + { + Dictionary files = new(); + foreach (var source in scenario.Value) + { + var content = StripConfigSpecificLines(source.Value.Replace("\r\n", "\n")); + files[source.Key] = content; + useCounts.TryGetValue((source.Key, content), out var count); + useCounts[(source.Key, content)] = count + 1; + } + + normalized[scenario.Key] = files; + } - Directory.CreateDirectory(folder); - foreach (var source in sources) + // A (name, content) pair used by more than one scenario is stored once in _Shared; when several + // distinct contents of the same name are shared, a short content hash keeps them apart. + Dictionary<(string FileName, string Content), string> sharedNames = new(); + foreach (var group in useCounts.Where(x => x.Value > 1).GroupBy(x => x.Key.FileName)) { - var content = StripConfigSpecificLines(source.Value - .Replace("\r\n", "\n") - .Replace("\n", Environment.NewLine)); - File.WriteAllText(Path.Combine(folder, source.Key), content); + var variants = group.Select(x => x.Key).OrderBy(x => x.Content, StringComparer.Ordinal).ToList(); + foreach (var variant in variants) + sharedNames[variant] = variants.Count == 1 + ? variant.FileName + : InsertHash(variant.FileName, variant.Content); + } + + var expectedRoot = Path.GetDirectoryName(ExpectedFolder(SharedFolderName))!; + if (Directory.Exists(expectedRoot)) Directory.Delete(expectedRoot, true); + + foreach (var shared in sharedNames) + WriteNormalized(Path.Combine(ExpectedFolder(SharedFolderName), shared.Value), shared.Key.Content); + + foreach (var scenario in normalized) + { + var folder = ExpectedFolder(scenario.Key); + List manifest = new(); + foreach (var file in scenario.Value) + { + if (sharedNames.TryGetValue((file.Key, file.Value), out var sharedName)) + manifest.Add($"{file.Key}|{sharedName}"); + else + WriteNormalized(Path.Combine(folder, file.Key), file.Value); + } + + if (manifest.Count > 0) + { + Directory.CreateDirectory(folder); + manifest.Sort(StringComparer.Ordinal); + File.WriteAllLines(Path.Combine(folder, ManifestFileName), manifest); + } } } @@ -58,6 +125,23 @@ public static void SetExpected(string scenario, IReadOnlyDictionary DebuggerNonUserCodeRegex.Replace(content, string.Empty); + private static string ReadNormalized(string file) => + File.ReadAllText(file).Replace("\r\n", "\n"); + + private static void WriteNormalized(string path, string content) + { + Directory.CreateDirectory(Path.GetDirectoryName(path)!); + File.WriteAllText(path, content.Replace("\n", Environment.NewLine)); + } + + private static string InsertHash(string fileName, string content) + { + var hash = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(content))) + .Substring(0, 8).ToLowerInvariant(); + var dot = fileName.IndexOf('.'); + return dot < 0 ? $"{fileName}.{hash}" : $"{fileName.Substring(0, dot)}.{hash}{fileName.Substring(dot)}"; + } + private static string ExpectedFolder(string scenario) => CombinedPaths("Tests", "Mockolate.SourceGenerators.Tests", "Snapshot", "Expected", scenario); From b1cf2c78fdcce56682b89c1e45012d80376f6644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Sat, 5 Sep 2026 18:31:33 +0200 Subject: [PATCH 13/14] fix: treat the default ParameterArg as the literal default in Value The default instance is the literal case everywhere else (IsLiteral, Literal, ToParameterMatch); Value returned null instead of the boxed default(T) for value types. --- .../Sources/Sources.ParameterArg.cs | 5 ++--- .../Snapshot/Expected/_Shared/ParameterArg.g.cs | 5 ++--- Tests/Mockolate.Tests/ParameterArgTests.cs | 1 + 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.ParameterArg.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.ParameterArg.cs index 03394762..3a3e75fa 100644 --- a/Source/Mockolate.SourceGenerators/Sources/Sources.ParameterArg.cs +++ b/Source/Mockolate.SourceGenerators/Sources/Sources.ParameterArg.cs @@ -130,13 +130,12 @@ public ParameterArg(T? literal) /// /// The contained matcher or literal value, boxed. Part of the union pattern; the generated mocks use the - /// typed accessors instead. + /// typed accessors instead. The instance is the literal default(T). /// public object? Value => _tag switch { MatcherTag => _matcher, - LiteralTag => _literal, - _ => null, + _ => _literal, }; /// diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/ParameterArg.g.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/ParameterArg.g.cs index 284fbf66..fba27797 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/ParameterArg.g.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/Expected/_Shared/ParameterArg.g.cs @@ -52,13 +52,12 @@ public ParameterArg(T? literal) /// /// The contained matcher or literal value, boxed. Part of the union pattern; the generated mocks use the - /// typed accessors instead. + /// typed accessors instead. The instance is the literal default(T). /// public object? Value => _tag switch { MatcherTag => _matcher, - LiteralTag => _literal, - _ => null, + _ => _literal, }; /// diff --git a/Tests/Mockolate.Tests/ParameterArgTests.cs b/Tests/Mockolate.Tests/ParameterArgTests.cs index 701de692..8065a593 100644 --- a/Tests/Mockolate.Tests/ParameterArgTests.cs +++ b/Tests/Mockolate.Tests/ParameterArgTests.cs @@ -92,6 +92,7 @@ public async Task Default_ForValueType_ShouldBeTheLiteralDefaultValue() await That(sut.HasValue).IsFalse(); await That(sut.IsLiteral).IsTrue(); await That(sut.Literal).IsEqualTo(0); + await That(sut.Value).IsEqualTo(0); await That(sut.ToParameterMatch().Matches(0)).IsTrue(); await That(sut.ToParameterMatch().Matches(1)).IsFalse(); } From bee4f4082d9144fbdecb9a1554104f7c93ce399a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Sat, 5 Sep 2026 18:31:33 +0200 Subject: [PATCH 14/14] fix: collect generator coverage reliably by moving the tests to xunit v2 The coverlet VSTest collector cannot reliably read the coverage hits of xunit.v3 out-of-process runs (intermittent EndOfStreamException at session end), which silently dropped the whole Mockolate.SourceGenerators coverage from the SonarCloud quality gate. xunit v2 runs in-process in the testhost, where the collector works (reproduced and verified locally in Release). The snapshot acceptance test is gated by the MOCKOLATE_ACCEPT_SNAPSHOTS environment variable instead of the v3-only Explicit flag, and the snapshot test helpers use tabs like the rest of the repository. --- .../Entities/TypeIsFormattableTests.cs | 12 +- .../Mockolate.SourceGenerators.Tests.csproj | 7 +- .../MockGenerationSnapshotAcceptance.cs | 33 ++- .../TestHelpers/SnapshotStorage.cs | 270 +++++++++--------- 4 files changed, 164 insertions(+), 158 deletions(-) diff --git a/Tests/Mockolate.SourceGenerators.Tests/Entities/TypeIsFormattableTests.cs b/Tests/Mockolate.SourceGenerators.Tests/Entities/TypeIsFormattableTests.cs index f7b1af16..907550a7 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Entities/TypeIsFormattableTests.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Entities/TypeIsFormattableTests.cs @@ -12,18 +12,18 @@ public class TypeIsFormattableTests public async Task WhenSymbolIsObject_ShouldNotReportFormattable() { const string source = "public class Holder { public object Value; }"; - SyntaxTree tree = CSharpSyntaxTree.ParseText(source, cancellationToken: TestContext.Current.CancellationToken); + SyntaxTree tree = CSharpSyntaxTree.ParseText(source); CSharpCompilation compilation = CSharpCompilation.Create( "TestAssembly", [tree,], [MetadataReference.CreateFromFile(typeof(object).Assembly.Location),], new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); SemanticModel model = compilation.GetSemanticModel(tree); - FieldDeclarationSyntax declaration = tree.GetRoot(TestContext.Current.CancellationToken).DescendantNodes() + FieldDeclarationSyntax declaration = tree.GetRoot().DescendantNodes() .OfType() .First(); VariableDeclaratorSyntax variable = declaration.Declaration.Variables.Single(); - IFieldSymbol fieldSymbol = (IFieldSymbol)model.GetDeclaredSymbol(variable, TestContext.Current.CancellationToken)!; + IFieldSymbol fieldSymbol = (IFieldSymbol)model.GetDeclaredSymbol(variable)!; Type type = Type.From(fieldSymbol.Type); @@ -43,7 +43,7 @@ public class Holder public IFormattable Value; } """; - SyntaxTree tree = CSharpSyntaxTree.ParseText(source, cancellationToken: TestContext.Current.CancellationToken); + SyntaxTree tree = CSharpSyntaxTree.ParseText(source); CSharpCompilation compilation = CSharpCompilation.Create( "TestAssembly", [tree,], @@ -53,11 +53,11 @@ public class Holder ], new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); SemanticModel model = compilation.GetSemanticModel(tree); - FieldDeclarationSyntax declaration = tree.GetRoot(TestContext.Current.CancellationToken).DescendantNodes() + FieldDeclarationSyntax declaration = tree.GetRoot().DescendantNodes() .OfType() .First(); VariableDeclaratorSyntax variable = declaration.Declaration.Variables.Single(); - IFieldSymbol fieldSymbol = (IFieldSymbol)model.GetDeclaredSymbol(variable, TestContext.Current.CancellationToken)!; + IFieldSymbol fieldSymbol = (IFieldSymbol)model.GetDeclaredSymbol(variable)!; ITypeSymbol typeSymbol = fieldSymbol.Type; Type type = Type.From(typeSymbol); diff --git a/Tests/Mockolate.SourceGenerators.Tests/Mockolate.SourceGenerators.Tests.csproj b/Tests/Mockolate.SourceGenerators.Tests/Mockolate.SourceGenerators.Tests.csproj index d377d436..fa06d67e 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Mockolate.SourceGenerators.Tests.csproj +++ b/Tests/Mockolate.SourceGenerators.Tests/Mockolate.SourceGenerators.Tests.csproj @@ -11,10 +11,9 @@ - - - - + diff --git a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotAcceptance.cs b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotAcceptance.cs index 7b963282..c1547c1b 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotAcceptance.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/Snapshot/MockGenerationSnapshotAcceptance.cs @@ -5,19 +5,26 @@ namespace Mockolate.SourceGenerators.Tests.Snapshot; public sealed class MockGenerationSnapshotAcceptance { /// - /// Execute this test to overwrite the expected snapshot files for - /// with the current generator output. + /// Set the environment variable MOCKOLATE_ACCEPT_SNAPSHOTS to true and execute this test to + /// overwrite the expected snapshot files for with the current + /// generator output. Without the variable the test is a no-op (xunit v2 has no explicit tests). /// - [Fact(Explicit = true)] - public void AcceptSnapshotChanges() - { - Dictionary> scenarios = new(); - foreach (var scenario in MockGenerationSnapshotTests.Scenarios) - { - var result = MockGenerationSnapshotTests.RunGenerator(scenario); - scenarios[scenario.Name] = MockGenerationSnapshotTests.NormalizeSources(result); - } + [Fact] + public void AcceptSnapshotChanges() + { + if (!string.Equals(Environment.GetEnvironmentVariable("MOCKOLATE_ACCEPT_SNAPSHOTS"), "true", + StringComparison.OrdinalIgnoreCase)) + { + return; + } - SnapshotStorage.SetExpected(scenarios); - } + Dictionary> scenarios = new(); + foreach (var scenario in MockGenerationSnapshotTests.Scenarios) + { + var result = MockGenerationSnapshotTests.RunGenerator(scenario); + scenarios[scenario.Name] = MockGenerationSnapshotTests.NormalizeSources(result); + } + + SnapshotStorage.SetExpected(scenarios); + } } diff --git a/Tests/Mockolate.SourceGenerators.Tests/TestHelpers/SnapshotStorage.cs b/Tests/Mockolate.SourceGenerators.Tests/TestHelpers/SnapshotStorage.cs index 43093c6c..769b3c6c 100644 --- a/Tests/Mockolate.SourceGenerators.Tests/TestHelpers/SnapshotStorage.cs +++ b/Tests/Mockolate.SourceGenerators.Tests/TestHelpers/SnapshotStorage.cs @@ -15,139 +15,139 @@ namespace Mockolate.SourceGenerators.Tests.TestHelpers; /// public static partial class SnapshotStorage { - private const string SharedFolderName = "_Shared"; - private const string ManifestFileName = "_shared.txt"; - - [GeneratedRegex(@"[ \t]*\[global::System\.Diagnostics\.DebuggerNonUserCode\]\r?\n?")] - private static partial Regex DebuggerNonUserCodeRegex { get; } - - public static string ReadCoverageFile(string coverageFileName) - { - var path = CombinedPaths("Tests", "Mockolate.Tests", "GeneratorCoverage", - coverageFileName); - return File.ReadAllText(path); - } - - public static IReadOnlyDictionary GetExpected(string scenario) - { - var folder = ExpectedFolder(scenario); - Dictionary result = new(); - if (!Directory.Exists(folder)) return result; - - foreach (var file in Directory.GetFiles(folder).OrderBy(f => f, StringComparer.Ordinal)) - { - if (Path.GetFileName(file) == ManifestFileName) continue; - - result[Path.GetFileName(file)] = ReadNormalized(file); - } - - var manifest = Path.Combine(folder, ManifestFileName); - if (File.Exists(manifest)) - { - foreach (var line in File.ReadAllLines(manifest)) - { - var separator = line.IndexOf('|'); - if (separator <= 0) continue; - - var fileName = line.Substring(0, separator); - var sharedName = line.Substring(separator + 1); - result[fileName] = ReadNormalized(Path.Combine(ExpectedFolder(SharedFolderName), sharedName)); - } - } - - return result; - } - - public static void SetExpected(IReadOnlyDictionary> scenarios) - { - Dictionary<(string FileName, string Content), int> useCounts = new(); - Dictionary> normalized = new(); - foreach (var scenario in scenarios) - { - Dictionary files = new(); - foreach (var source in scenario.Value) - { - var content = StripConfigSpecificLines(source.Value.Replace("\r\n", "\n")); - files[source.Key] = content; - useCounts.TryGetValue((source.Key, content), out var count); - useCounts[(source.Key, content)] = count + 1; - } - - normalized[scenario.Key] = files; - } - - // A (name, content) pair used by more than one scenario is stored once in _Shared; when several - // distinct contents of the same name are shared, a short content hash keeps them apart. - Dictionary<(string FileName, string Content), string> sharedNames = new(); - foreach (var group in useCounts.Where(x => x.Value > 1).GroupBy(x => x.Key.FileName)) - { - var variants = group.Select(x => x.Key).OrderBy(x => x.Content, StringComparer.Ordinal).ToList(); - foreach (var variant in variants) - sharedNames[variant] = variants.Count == 1 - ? variant.FileName - : InsertHash(variant.FileName, variant.Content); - } - - var expectedRoot = Path.GetDirectoryName(ExpectedFolder(SharedFolderName))!; - if (Directory.Exists(expectedRoot)) Directory.Delete(expectedRoot, true); - - foreach (var shared in sharedNames) - WriteNormalized(Path.Combine(ExpectedFolder(SharedFolderName), shared.Value), shared.Key.Content); - - foreach (var scenario in normalized) - { - var folder = ExpectedFolder(scenario.Key); - List manifest = new(); - foreach (var file in scenario.Value) - { - if (sharedNames.TryGetValue((file.Key, file.Value), out var sharedName)) - manifest.Add($"{file.Key}|{sharedName}"); - else - WriteNormalized(Path.Combine(folder, file.Key), file.Value); - } - - if (manifest.Count > 0) - { - Directory.CreateDirectory(folder); - manifest.Sort(StringComparer.Ordinal); - File.WriteAllLines(Path.Combine(folder, ManifestFileName), manifest); - } - } - } - - /// - /// The source generator gates `[DebuggerNonUserCode]` behind `#if !DEBUG`, so its output - /// depends on whether the generator dll was built in Debug or Release. Strip those tokens - /// on both sides so the snapshot test passes regardless of the build configuration used to - /// produce the generator. The attribute appears either on its own indented line or inline - /// directly after an opening brace, so the pattern allows optional leading tabs/spaces. - /// - internal static string StripConfigSpecificLines(string content) - => DebuggerNonUserCodeRegex.Replace(content, string.Empty); - - private static string ReadNormalized(string file) => - File.ReadAllText(file).Replace("\r\n", "\n"); - - private static void WriteNormalized(string path, string content) - { - Directory.CreateDirectory(Path.GetDirectoryName(path)!); - File.WriteAllText(path, content.Replace("\n", Environment.NewLine)); - } - - private static string InsertHash(string fileName, string content) - { - var hash = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(content))) - .Substring(0, 8).ToLowerInvariant(); - var dot = fileName.IndexOf('.'); - return dot < 0 ? $"{fileName}.{hash}" : $"{fileName.Substring(0, dot)}.{hash}{fileName.Substring(dot)}"; - } - - private static string ExpectedFolder(string scenario) => - CombinedPaths("Tests", "Mockolate.SourceGenerators.Tests", "Snapshot", "Expected", scenario); - - private static string CombinedPaths(params string[] paths) => - Path.GetFullPath(Path.Combine(paths.Prepend(GetSolutionDirectory()).ToArray())); - - private static string GetSolutionDirectory([CallerFilePath] string path = "") => - Path.Combine(Path.GetDirectoryName(path)!, "..", "..", ".."); + private const string SharedFolderName = "_Shared"; + private const string ManifestFileName = "_shared.txt"; + + [GeneratedRegex(@"[ \t]*\[global::System\.Diagnostics\.DebuggerNonUserCode\]\r?\n?")] + private static partial Regex DebuggerNonUserCodeRegex { get; } + + public static string ReadCoverageFile(string coverageFileName) + { + string path = CombinedPaths("Tests", "Mockolate.Tests", "GeneratorCoverage", + coverageFileName); + return File.ReadAllText(path); + } + + public static IReadOnlyDictionary GetExpected(string scenario) + { + string folder = ExpectedFolder(scenario); + Dictionary result = new(); + if (!Directory.Exists(folder)) return result; + + foreach (string file in Directory.GetFiles(folder).OrderBy(f => f, StringComparer.Ordinal)) + { + if (Path.GetFileName(file) == ManifestFileName) continue; + + result[Path.GetFileName(file)] = ReadNormalized(file); + } + + string manifest = Path.Combine(folder, ManifestFileName); + if (File.Exists(manifest)) + { + foreach (string line in File.ReadAllLines(manifest)) + { + int separator = line.IndexOf('|'); + if (separator <= 0) continue; + + string fileName = line.Substring(0, separator); + string sharedName = line.Substring(separator + 1); + result[fileName] = ReadNormalized(Path.Combine(ExpectedFolder(SharedFolderName), sharedName)); + } + } + + return result; + } + + public static void SetExpected(IReadOnlyDictionary> scenarios) + { + Dictionary<(string FileName, string Content), int> useCounts = new(); + Dictionary> normalized = new(); + foreach (var scenario in scenarios) + { + Dictionary files = new(); + foreach (var source in scenario.Value) + { + string content = StripConfigSpecificLines(source.Value.Replace("\r\n", "\n")); + files[source.Key] = content; + useCounts.TryGetValue((source.Key, content), out int count); + useCounts[(source.Key, content)] = count + 1; + } + + normalized[scenario.Key] = files; + } + + // A (name, content) pair used by more than one scenario is stored once in _Shared; when several + // distinct contents of the same name are shared, a short content hash keeps them apart. + Dictionary<(string FileName, string Content), string> sharedNames = new(); + foreach (var group in useCounts.Where(x => x.Value > 1).GroupBy(x => x.Key.FileName)) + { + var variants = group.Select(x => x.Key).OrderBy(x => x.Content, StringComparer.Ordinal).ToList(); + foreach (var variant in variants) + sharedNames[variant] = variants.Count == 1 + ? variant.FileName + : InsertHash(variant.FileName, variant.Content); + } + + string expectedRoot = Path.GetDirectoryName(ExpectedFolder(SharedFolderName))!; + if (Directory.Exists(expectedRoot)) Directory.Delete(expectedRoot, true); + + foreach (var shared in sharedNames) + WriteNormalized(Path.Combine(ExpectedFolder(SharedFolderName), shared.Value), shared.Key.Content); + + foreach (var scenario in normalized) + { + string folder = ExpectedFolder(scenario.Key); + List manifest = new(); + foreach (var file in scenario.Value) + { + if (sharedNames.TryGetValue((file.Key, file.Value), out string? sharedName)) + manifest.Add($"{file.Key}|{sharedName}"); + else + WriteNormalized(Path.Combine(folder, file.Key), file.Value); + } + + if (manifest.Count > 0) + { + Directory.CreateDirectory(folder); + manifest.Sort(StringComparer.Ordinal); + File.WriteAllLines(Path.Combine(folder, ManifestFileName), manifest); + } + } + } + + /// + /// The source generator gates `[DebuggerNonUserCode]` behind `#if !DEBUG`, so its output + /// depends on whether the generator dll was built in Debug or Release. Strip those tokens + /// on both sides so the snapshot test passes regardless of the build configuration used to + /// produce the generator. The attribute appears either on its own indented line or inline + /// directly after an opening brace, so the pattern allows optional leading tabs/spaces. + /// + internal static string StripConfigSpecificLines(string content) + => DebuggerNonUserCodeRegex.Replace(content, string.Empty); + + private static string ReadNormalized(string file) => + File.ReadAllText(file).Replace("\r\n", "\n"); + + private static void WriteNormalized(string path, string content) + { + Directory.CreateDirectory(Path.GetDirectoryName(path)!); + File.WriteAllText(path, content.Replace("\n", Environment.NewLine)); + } + + private static string InsertHash(string fileName, string content) + { + string hash = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(content))) + .Substring(0, 8).ToLowerInvariant(); + int dot = fileName.IndexOf('.'); + return dot < 0 ? $"{fileName}.{hash}" : $"{fileName.Substring(0, dot)}.{hash}{fileName.Substring(dot)}"; + } + + private static string ExpectedFolder(string scenario) => + CombinedPaths("Tests", "Mockolate.SourceGenerators.Tests", "Snapshot", "Expected", scenario); + + private static string CombinedPaths(params string[] paths) => + Path.GetFullPath(Path.Combine(paths.Prepend(GetSolutionDirectory()).ToArray())); + + private static string GetSolutionDirectory([CallerFilePath] string path = "") => + Path.Combine(Path.GetDirectoryName(path)!, "..", "..", ".."); }