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>();
        }
コード例 #2
0
        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);
            });
        }
コード例 #3
0
        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);
                });
        }
コード例 #4
0
 public SampleController(InjectedService service)
 {
     this.service = service;
 }
コード例 #5
0
 public ClassWithManyCtors()
 {
     TestString = InjectedService.GetStringFromService();
 }
コード例 #6
0
 public ClassUsingInjectedPropertyInsideCtor(string textToAppend)
 {
     TestString = InjectedService.GetStringFromService() + textToAppend;
 }
コード例 #7
0
 public ClassNotConfigurableInheritingFromBase()
 {
     TestString = InjectedService.GetStringFromService() + " appended from subclass";
 }