public void ShouldFindControllerActivateAndExecuteItUsingIoC() { var router = FakeRouter.Create(typeof(ICustomController).GetClass().As <IRenderingController>()); var a = new ControllerExecutionManager(new CustomApplication(), router); IResult rezult = a.ExecuteController(this.CreateContext(a.Application)); rezult.Content.BodyAsString.Should().Be("Something!"); }
public void ShouldFindControllerActivateAndExecuteIt() { var router = FakeRouter.Create(typeof(CustomController).GetClass().As <IRenderingController>()); var a = new ControllerExecutionManager(new Application(ApplicationMode.Prod, Environment.CurrentDirectory, null), router); IResult rezult = a.ExecuteController(this.CreateContext(a.Application)); rezult.Content.BodyAsString.Should().Be("Something!"); }
public void ShouldExecuteControllerWithRenderingChildController() { var router = FakeRouter.Create(typeof(ParentController).GetClass().As <IRenderingController>()); var a = new ControllerExecutionManager(new Application(ApplicationMode.Prod, Environment.CurrentDirectory, null), router); IResult rezult = a.ExecuteController(this.CreateContext(a.Application)); rezult.Content.BodyAsString.Should().Be("Parent Begin->ChildController<- End"); }
public void ShouldNotHaveExceptionOnClazzNotFound() { var router = FakeRouter.Create(typeof(ICustomController).GetClass().As <IRenderingController>()); var a = new ControllerExecutionManager(new Application(ApplicationMode.Prod, Environment.CurrentDirectory, null), router); IResult rezult = a.ExecuteController(this.CreateContext(a.Application)); rezult.Content.BodyAsString.Should().Be("Page Not Found"); }
public void ShouldExecuteControllerNotFoundNotPossibleController() { var router = FakeRouter.Create(Class.GetClass <INotPossibleController>()); var a = new ControllerExecutionManager(new Application(ApplicationMode.Prod, Environment.CurrentDirectory, null), router); IResult rezult = a.ExecuteController(this.CreateContext(a.Application)); rezult.Content.BodyAsString.Should().Be("Page Not Found"); }
public void ShouldExecuteControllerWithNonRenderingController() { CountingNonRenderingController.Count = 0; SubCountingNonRenderingController.Count = 0; var router = FakeRouter.Create(typeof(CustomControllerWithNonRenderingChild).GetClass().As <IRenderingController>()); var a = new ControllerExecutionManager(new Application(ApplicationMode.Prod, Environment.CurrentDirectory, null), router); IResult rezult = a.ExecuteController(this.CreateContext(a.Application)); rezult.Content.BodyAsString.Should().Be("Something!"); CountingNonRenderingController.Count.Should().Be(1); SubCountingNonRenderingController.Count.Should().Be(1); }
public void ShouldExecuteControllerAndHaveLogging() { var router = FakeRouter.Create(typeof(ParentController).GetClass().As <IRenderingController>()); var application = new CustomApplication(); var inMemoryLogger = new InMemoryLogger(LogLevels.Always); application.SetInstance <ILogger>(x => inMemoryLogger); var a = new ControllerExecutionManager(application, router); IResult rezult = a.ExecuteController(this.CreateContext(a.Application, inMemoryLogger)); rezult.Content.BodyAsString.Should().Be("Parent Begin->ChildController<- End"); inMemoryLogger.Messages.Length.Should().BeGreaterThan(0); }
public void ShouldExecuteControllerWithHandler() { { var klazz = Class.GetClass <CustomController>(); var fakeRouteData = new FakeRouteData <IRenderingController>( klazz, (x, y, z) => ((CustomController)(x)).View(y, z, 1)); var router = FakeRouter.CreateData(fakeRouteData); var a = new ControllerExecutionManager(new Application(ApplicationMode.Prod, Environment.CurrentDirectory, null), router); IResult rezult = a.ExecuteController(this.CreateContext(a.Application)); rezult.Content.BodyAsString.Should().Be("Number i: 1"); } { var klazz = Class.GetClass <CustomController>(); var fakeRouteData = new FakeRouteData <IRenderingController>( klazz, (x, y, z) => ((CustomController)(x)).View(y, z, 2)); var router = FakeRouter.CreateData(fakeRouteData); var a = new ControllerExecutionManager(new Application(ApplicationMode.Prod, Environment.CurrentDirectory, null), router); IResult rezult = a.ExecuteController(this.CreateContext(a.Application)); rezult.Content.BodyAsString.Should().Be("Number i: 2"); } }