Exemplo n.º 1
0
        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!");
        }
Exemplo n.º 2
0
        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!");
        }
Exemplo n.º 3
0
        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");
        }
Exemplo n.º 4
0
        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");
        }
Exemplo n.º 5
0
        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");
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
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");
     }
 }