示例#1
0
        public async Task Then_Confirm_Remove_Employer_Model_Is_Loaded(
            Domain.Models.Opportunity opportunity,
            IEmployerService employerService,
            EmployerController sut,
            [Frozen] RemoveEmployerDto dto
            )
        {
            //Arrange
            employerService.GetConfirmDeleteEmployerOpportunityAsync(Arg.Any <int>(), Arg.Any <string>()).Returns(dto);

            //Act
            var result = await sut.ConfirmDeleteAsync(opportunity.Id) as ViewResult;

            //Assert
            var viewModel = result?.Model as RemoveEmployerViewModel;

            viewModel.Should().NotBeNull();
            viewModel?.OpportunityId.Should().Be(opportunity.Id);
            viewModel?.ConfirmDeleteText.Should()
            .Be($"Confirm you want to delete {dto.OpportunityCount} opportunities created for {dto.EmployerName}");

            viewModel?.ConfirmDeleteText.Should()
            .NotBe($"Confirm you want to delete {dto.OpportunityCount} opportunity created for {dto.EmployerName}");

            viewModel?.WarningDeleteText.Should().Be("This cannot be undone.");
            viewModel?.EmployerCount.Should().Be(dto.EmployerCount);
        }
示例#2
0
        public async Task Then_Confirm_Remove_Employer_Model_Is_Loaded_With_No_Employer(
            Domain.Models.Opportunity opportunity,
            IEmployerService employerService,
            EmployerController sut,
            [Frozen] RemoveEmployerDto dto
            )
        {
            //Arrange
            dto.OpportunityCount = 1;
            dto.EmployerCount    = 1;

            employerService.GetConfirmDeleteEmployerOpportunityAsync(Arg.Any <int>(), Arg.Any <string>()).Returns(dto);

            //Act
            var result = await sut.ConfirmDeleteAsync(opportunity.Id) as ViewResult;

            //Assert
            var viewModel = result.GetViewModel <RemoveEmployerViewModel>();

            viewModel.OpportunityId.Should().Be(opportunity.Id);
            viewModel.ConfirmDeleteText.Should()
            .Be($"Confirm you want to delete {dto.OpportunityCount} opportunity created for {dto.EmployerName}");
            viewModel.WarningDeleteText.Should().Be("This cannot be undone and will mean you have no more employers with saved opportunities.");
            viewModel.SubmitActionText.Should().Be("Confirm and finish");
            viewModel.EmployerCount.Should().Be(dto.EmployerCount);
        }
        public async Task <IActionResult> ConfirmDeleteAsync(int opportunityId)
        {
            var dto = await _employerService.GetConfirmDeleteEmployerOpportunityAsync(opportunityId,
                                                                                      HttpContext.User.GetUserName());

            var viewModel = new RemoveEmployerViewModel
            {
                OpportunityId    = opportunityId,
                OpportunityCount = dto.OpportunityCount,
                EmployerName     = dto.EmployerName,
                EmployerCount    = dto.EmployerCount
            };

            return(View("ConfirmDelete", viewModel));
        }
示例#4
0
        public async Task Then_Result_Is_Not_Null(
            Domain.Models.Opportunity opportunity,
            IEmployerService employerService,
            EmployerController sut,
            [Frozen] RemoveEmployerDto dto)
        {
            //Arrange
            employerService.GetConfirmDeleteEmployerOpportunityAsync(Arg.Any <int>(), Arg.Any <string>()).Returns(dto);

            //Act
            var result = await sut.ConfirmDeleteAsync(opportunity.Id) as ViewResult;

            //Assert
            result.Should().NotBeNull();
        }