public void InterceptedServiceShouldBeIntercepted() { var interceptor = A.Fake <IInterceptor <IServiceWithoutDependencies> >(); IServiceWithoutDependencies original = null; IServiceWithoutDependencies decorated = null; A.CallTo( () => interceptor.Intercept( A <ServiceRequest> .Ignored, A <Func <IServiceWithoutDependencies> > .Ignored)) .ReturnsLazily( (ServiceRequest req, Func <IServiceWithoutDependencies> svc) => { original = svc(); decorated = A.Fake <IServiceWithoutDependencies>(); return(decorated); }); var registry = new Registry() .Define <IServiceWithoutDependencies>().Singleton().As <ServiceWithoutDependencies>() .Intercept <IServiceWithoutDependencies>().With(interceptor); using (var container = registry.CreateContainer()) { var service = container.GetService <IServiceWithoutDependencies>(); Assert.Same(decorated, service); Assert.IsType <ServiceWithoutDependencies>(original); } }
public ServiceWithDependencies(IServiceWithoutDependencies dependency) { SomeDependency = dependency; }
public ServiceWithDependencies(IServiceWithoutDependencies dependency) { Dependency = dependency; }
public ServiceWithDependencies(IServiceWithoutDependencies dependency, string message) : this(dependency) { Message = message; }
public ServiceWithMultipleDependencies(IServiceWithoutDependencies dependency1, IServiceWithDependencies dependency2) { Dependency1 = dependency1; Dependency2 = dependency2; }