public void WhichShouldNotResolveControllerFilterLogicWithControllerConstructionFunction() { MyApplication .StartsFrom <DefaultStartup>() .WithServices(services => services .AddTransient <IInjectedService, InjectedService>()); var injectedService = new InjectedService(); MyPipeline .Configuration() .ShouldMap("/Pipeline/Action?controller=true") .To <PipelineController>(c => c.Action()) .Which(() => new PipelineController(injectedService)) .ShouldReturn() .Ok() .AndAlso() .ShouldPassForThe <PipelineController>(controller => { Assert.Same(injectedService, controller.Service); Assert.Null(controller.Data); }); MyApplication.StartsFrom <DefaultStartup>(); }
public void WithServicesDirectlyShouldWorkCorrectly() { var service = new InjectedService(); var anotherService = new AnotherInjectedService(); MyViewComponent <MultipleServicesComponent> .Instance() .WithDependencies(service, anotherService) .InvokedWith(c => c.Invoke()) .ShouldReturn() .View() .ShouldPassForThe <MultipleServicesComponent>(viewComponent => { Assert.Same(service, viewComponent.InjectedService); Assert.Same(anotherService, viewComponent.AnotherService); }); }
public void WithServicesDirectlyShouldWorkCorrectly() { var service = new InjectedService(); var anotherService = new AnotherInjectedService(); MyViewComponent<MultipleServicesComponent> .Instance() .WithServices(service, anotherService) .InvokedWith(c => c.Invoke()) .ShouldReturn() .View() .ShouldPassForThe<MultipleServicesComponent>(viewComponent => { Assert.Same(service, viewComponent.InjectedService); Assert.Same(anotherService, viewComponent.AnotherService); }); }
public SampleController(InjectedService service) { this.service = service; }
public ClassWithManyCtors() { TestString = InjectedService.GetStringFromService(); }
public ClassUsingInjectedPropertyInsideCtor(string textToAppend) { TestString = InjectedService.GetStringFromService() + textToAppend; }
public ClassNotConfigurableInheritingFromBase() { TestString = InjectedService.GetStringFromService() + " appended from subclass"; }