コード例 #1
0
        public async Task WhenBodyCalledAndSessionIdIsInvalid_RedirectToHome()
        {
            var controller = new ReloadController(_compositeSettings, _sessionService, _dysacServiceSetings, _dysacService);

            controller.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext()
            };
            controller.HttpContext.Request.Query = new QueryCollection(new Dictionary <string, StringValues>()
            {
                { "sessionId", "123" }
            });

            _dysacService.LoadExistingDysacOnlyAssessment(Arg.Any <string>()).ReturnsForAnyArgs(
                new DysacServiceResponse()
            {
                ResponseCode = DysacReturnCode.Error
            });
            _sessionService.Reload(Arg.Any <string>()).ReturnsNullForAnyArgs();

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

            result.Should().NotBeNull();
            result.Should().BeOfType <RedirectResult>();
            result.Url.Should().Be("~/home?errors=true");
        }
コード例 #2
0
        public async Task WhenPostCalledWithEmptyString_RedirectToHomeWithError()
        {
            var controller = new ReloadController(_compositeSettings, _sessionService, _dysacServiceSetings, _dysacService);

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

            result.Should().NotBeNull();
            result.Should().BeOfType <RedirectResult>();
            result.Url.Should().Be("~/home?errors=true");
        }
コード例 #3
0
        public async Task WhenBodyCalledWithEmptyString_RedirectToHome()
        {
            var controller = new ReloadController(_compositeSettings, _sessionService, _dysacServiceSetings, _dysacService);

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

            result.Should().NotBeNull();
            result.Should().BeOfType <RedirectResult>();
            result.Url.Should().Be("~/");
        }
コード例 #4
0
        public async Task WhenPostCalledAndSessionIdIsInvalid_RedirectToHomeWithErrors()
        {
            var controller = new ReloadController(_compositeSettings, _sessionService, _dysacServiceSetings, _dysacService);

            controller.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext()
            };
            controller.HttpContext.Request.Query = new QueryCollection(new Dictionary <string, StringValues>()
            {
                { "sessionId", "123" }
            });

            _sessionService.Reload(Arg.Any <string>()).ReturnsNullForAnyArgs();
            _dysacService.LoadExistingDysacOnlyAssessment(Arg.Any <string>()).ReturnsForAnyArgs(
                new DysacServiceResponse()
            {
                ResponseCode = DysacReturnCode.Ok
            });
            var result = await controller.Body("123") as RedirectResult;
        }
コード例 #5
0
        public async Task WhenBodyCalledAndSessionIdIsValid_RedirectToUsersLastPage()
        {
            var controller = new ReloadController(_compositeSettings, _sessionService, _dysacServiceSetings, _dysacService);

            controller.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext()
            };
            controller.HttpContext.Request.Query = new QueryCollection(new Dictionary <string, StringValues>()
            {
                { "sessionId", "123" }
            });
            _sessionService.Reload(Arg.Any <string>()).ReturnsForAnyArgs(new UserSession()
            {
                CurrentPage = CompositeViewModel.PageId.Matches.Value
            });
            var result = await controller.Body() as RedirectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <RedirectResult>();
            result.Url.Should().Be($"~/{CompositeViewModel.PageId.Matches}");
        }
コード例 #6
0
        public async Task WhenBodyCalledAndSessionIdIsDysacAndSkillsSessionAndLastPageIsRouteWithOption2Selected_RedirectToDysac()
        {
            var controller = new ReloadController(_compositeSettings, _sessionService, _dysacServiceSetings, _dysacService);

            controller.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext()
            };
            controller.HttpContext.Request.Query = new QueryCollection(new Dictionary <string, StringValues>()
            {
                { "sessionId", "123" }
            });
            _sessionService.Reload(Arg.Any <string>()).ReturnsForAnyArgs(new UserSession()
            {
                CurrentPage         = CompositeViewModel.PageId.Route.Value,
                UserHasWorkedBefore = true,
                RouteIncludesDysac  = true
            });
            var result = await controller.Body() as RedirectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <RedirectResult>();
            result.Url.Should().Be("DysacRoute");
        }