Esempio n. 1
0
        public void WhenBodyTopCalled_ReturnHtml()
        {
            var controller = new WorkedController(_compositeSettings, _sessionService, _dysacService, _dysacServiceSetings);
            var result     = controller.BodyTop() as ViewResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <ViewResult>();
            result.ViewName.Should().BeNull();
        }
Esempio n. 2
0
        public void WhenHeadCalled_ReturnHtml()
        {
            var controller = new WorkedController(_compositeSettings, _sessionService, _dysacService, _dysacServiceSetings);

            controller.ControllerContext.HttpContext = new DefaultHttpContext();
            var result = controller.Head() as ViewResult;
            var vm     = result.ViewData.Model as HeadViewModel;

            result.Should().NotBeNull();
            result.Should().BeOfType <ViewResult>();
            result.ViewName.Should().BeNull();
        }
Esempio n. 3
0
        public async Task WhenPostBodyCalledWithNo_SetOriginToDysac()
        {
            var controller = new WorkedController(_compositeSettings, _sessionService, _dysacService, _dysacServiceSetings);

            controller.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext()
            };

            await controller.Body(WorkedBefore.No);

            await _dysacService.Received().InitiateDysacOnly();
        }
Esempio n. 4
0
        public async Task WhenBodyCalled_ReturnHtml()
        {
            var controller = new WorkedController(_compositeSettings, _sessionService, _dysacService, _dysacServiceSetings);

            controller.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext()
            };
            var result = await controller.Body() as ViewResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <ViewResult>();
            result.ViewName.Should().BeNull();
        }
Esempio n. 5
0
        public async Task When_VisitingTheWorkedPageWithoutACookie_Then_CreateCookie()
        {
            var controller = new WorkedController(_compositeSettings, _sessionService, _dysacService, _dysacServiceSetings);

            controller.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext()
            };
            controller.HttpContext.Request.QueryString = QueryString.Create(".matchSkill-session", "Abc123");

            await controller.Body();

            await _sessionService.Received(1).CreateUserSession(Arg.Any <CreateSessionRequest>());
        }
Esempio n. 6
0
        public async Task When_VisitingTheWorkedPageWithACookie_Then_CookieIsUpdatedAndCurrentPageIsSetToWorked()
        {
            var controller = new WorkedController(_compositeSettings, _sessionService, _dysacService, _dysacServiceSetings);

            controller.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext()
            };
            controller.HttpContext.Request.QueryString = QueryString.Create(".dfc-session", "Abc123");

            await controller.Body();

            await _sessionService.Received().CreateUserSession(Arg.Is <CreateSessionRequest>(x => x.CurrentPage == CompositeViewModel.PageId.Worked.Value));
        }
Esempio n. 7
0
        public async Task WhenPostBodyCalledWithNo_ReturnHtml()
        {
            var controller = new WorkedController(_compositeSettings, _sessionService, _dysacService, _dysacServiceSetings);

            controller.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext()
            };

            var result = await controller.Body(WorkedBefore.No) as RedirectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <RedirectResult>();
            result.Url.Should().Be("http://dysacurl");
        }
Esempio n. 8
0
        public async Task WhenPostBodyCalledWithYes_ReturnHtml()
        {
            var controller = new WorkedController(_compositeSettings, _sessionService, _dysacService, _dysacServiceSetings);

            controller.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext()
            };

            var result = await controller.Body(WorkedBefore.Yes) as RedirectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <RedirectResult>();
            result.Url.Should().Be($"~/{CompositeViewModel.PageId.Route}");
        }
Esempio n. 9
0
        public async Task When_PostingBackToTheWorkedPage_Then_UpdateSessionWithWorkedPageChoice()
        {
            var controller = new WorkedController(_compositeSettings, _sessionService, _dysacService, _dysacServiceSetings);

            controller.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext()
            };
            controller.HttpContext.Request.QueryString = QueryString.Create(".matchSkill-session", "Abc123");

            await controller.Body(WorkedBefore.Yes);

            await _sessionService.Received().UpdateUserSessionAsync(Arg.Is <UserSession>(x =>
                                                                                         x.UserHasWorkedBefore == true));
        }