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(); }
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(); }
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(); }
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(); }
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>()); }
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)); }
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"); }
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}"); }
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)); }