public class Foo { public string GetName() { return nameof(Foo); } }
public class Interceptor : IInterceptor
{
public bool Invoked { get; private set; }
public object Invoke(IInvocationInfo invocationInfo)
{
this.Invoked = true;
return invocationInfo.Proceed();
}
}
// Directly register a class as service type and implementing type
container.Register<Foo>();
var interceptor = new Interceptor();
container.Intercept(sr => sr.ServiceType == typeof(Foo), _ => interceptor);
var foo = container.GetInstance<Foo>();
foo.GetName();
// Assertion fails
Assert.True(interceptor.Invoked);