Innovabit.DotNet.Interceptors.Testing 2.0.119

dotnet add package Innovabit.DotNet.Interceptors.Testing --version 2.0.119
                    
NuGet\Install-Package Innovabit.DotNet.Interceptors.Testing -Version 2.0.119
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Innovabit.DotNet.Interceptors.Testing" Version="2.0.119" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Innovabit.DotNet.Interceptors.Testing" Version="2.0.119" />
                    
Directory.Packages.props
<PackageReference Include="Innovabit.DotNet.Interceptors.Testing" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Innovabit.DotNet.Interceptors.Testing --version 2.0.119
                    
#r "nuget: Innovabit.DotNet.Interceptors.Testing, 2.0.119"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Innovabit.DotNet.Interceptors.Testing@2.0.119
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Innovabit.DotNet.Interceptors.Testing&version=2.0.119
                    
Install as a Cake Addin
#tool nuget:?package=Innovabit.DotNet.Interceptors.Testing&version=2.0.119
                    
Install as a Cake Tool

Innovabit.DotNet.Interceptors.Testing

Test helpers for interceptors built on Innovabit.DotNet.Interceptors.Abstractions. Framework-agnostic: it pulls in no test framework, so it works with xUnit, NUnit or MSTest.

These are the two things this repository's own ~1800 tests do, packaged up.

Driving an interceptor directly

FakeInvocation is an IInvocation you construct by hand, so CanIntercept and the three ProcessInterception* methods can be called without a proxy, a container, or the service under test. Proceed() runs the delegate you hand it — that is the intercepted method — and the harness counts the calls.

var invocation = FakeInvocation.For<Sample>(
    nameof(Sample.ChargeAsync),
    [order],
    call => call.ReturnValue = Task.FromException<int>(new TimeoutException()));

await Assert.ThrowsAsync<TimeoutException>(() => interceptor.ProcessInterceptionAsync<int>(invocation));

Assert.Equal(3, invocation.ProceedCount);   // it retried twice

That is the whole point: a retry, a circuit breaker or a cache is about how many times the method is reached and with what, which a fake invocation answers directly and a real call does not.

Exercising a real pipeline

InterceptorHarness builds a container with one intercepted service in it, for the questions a fake invocation cannot answer — ordering, several interceptors together, and whether an attribute survives the trip through a real Castle proxy.

using var harness = InterceptorHarness.For<IOrderService, OrderService>(
    builder => builder.AddRetry().AddTimeout());

await harness.Get<IOrderService>().PlaceAsync(order);

Resolution happens inside a scope the harness owns and scope validation is on, so a scoped interceptor behaves as it does in an application — and a lifetime mistake surfaces in the test rather than in production. ForClass<T>() does the same for a service with no interface, and Build(services) wraps a collection you assembled yourself.

Describe() returns the pipeline report, which is what to assert on when the test is about ordering rather than behaviour:

Assert.Equal(
    [typeof(RetryInterceptor), typeof(TimeoutInterceptor)],
    harness.Describe().Interceptors.Select(interceptor => interceptor.InterceptorType));

Part of

The Innovabit.DotNet.Interceptors suite — github.com/Innovabit/dotnet-interceptors.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.119 53 11/14/2026
2.0.118 100 11/7/2026
2.0.117 113 10/31/2026
2.0.116 100 10/26/2026
2.0.115 114 10/17/2026
2.0.114 100 10/10/2026
2.0.113 105 10/3/2026
2.0.112 108 9/28/2026
2.0.111 98 9/28/2026
2.0.110 101 9/27/2026
2.0.109 102 9/26/2026
2.0.108 98 9/26/2026
2.0.107 102 9/26/2026
2.0.106 115 9/25/2026
2.0.105 104 9/25/2026