public async Task When_RemovedCalledAndUserStillHasSkillsInTheBasket_ThenReturnViewWithHasMoreSkills()
        {
            _sessionService.GetUserSession().ReturnsForAnyArgs(new UserSession
            {
                SkillsToRemove = new HashSet <UsSkill>
                {
                    new UsSkill("1", "test")
                },
                Skills = new HashSet <UsSkill>
                {
                    new UsSkill("1", "test")
                }
            });


            var controller = new RemovedController(_compositeSettings, _sessionService);

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

            result.Model.As <RemovedCompositeViewModel>().HasRemainingSkills.Should().BeTrue();
            result.Model.As <RemovedCompositeViewModel>().Skills.Count.Should().Be(1);
        }
        public async Task When_RemovedPostedTo_Then_SkillsRemoved()
        {
            _sessionService.GetUserSession().ReturnsForAnyArgs(new UserSession
            {
                SkillsToRemove = new HashSet <UsSkill>
                {
                    new UsSkill("1", "test")
                },
                Skills = new HashSet <UsSkill>
                {
                    new UsSkill("1", "test")
                }
            });


            var controller = new RemovedController(_compositeSettings, _sessionService);

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

            var formDictionary = new Dictionary <string, StringValues>
            {
                { "1--test1", "test" }
            };

            var formCollection = new FormCollection(formDictionary);

            await controller.Body(formCollection);

            await _sessionService.Received()
            .UpdateUserSessionAsync(Arg.Is <UserSession>(x =>
                                                         x.CurrentPage == CompositeViewModel.PageId.Removed.Value && x.SkillsToRemove.Count == 1 && x.Skills.Count == 0));
        }
        public async Task When_RemovedCalled_TrackTrackPageInUserSession()
        {
            var controller = new RemovedController(_compositeSettings, _sessionService);

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

            await _sessionService.Received()
            .UpdateUserSessionAsync(Arg.Is <UserSession>(x =>
                                                         x.CurrentPage == CompositeViewModel.PageId.Removed.Value));
        }
        public async Task When_ConfirmRemoveCalled_ReturnView()
        {
            var controller = new RemovedController(_compositeSettings, _sessionService);

            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_RemovedPostedToAndFormIsEmpty_Then_RedirectToSkillsBasket()
        {
            var controller = new RemovedController(_compositeSettings, _sessionService);

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

            var formDictionary = new Dictionary <string, StringValues>
            {
            };

            var formCollection = new FormCollection(formDictionary);

            await controller.Body(formCollection);

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

            result.Should().NotBeNull();
            result.Should().BeOfType <RedirectResult>();
            result.Url.Should().Be($"~/{CompositeViewModel.PageId.RemoveSkills}?errors=true");
        }
        public async Task When_RemovedPostedTo_ReturnRedirect()
        {
            var controller = new RemovedController(_compositeSettings, _sessionService);

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

            var formDictionary = new Dictionary <string, StringValues>
            {
                { "test--test1", "test" }
            };

            var formCollection = new FormCollection(formDictionary);

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

            result.Should().NotBeNull();
            result.Should().BeOfType <RedirectResult>();
            result.Url.Should().Be($"~/{CompositeViewModel.PageId.Removed}");
        }