public void ShouldReturnFailedValidationIfTheViewModelIsNotCorrect()
        {
            const int vacancyReferenceNumber = 1;
            var       vacancy = VacancyMediatorTestHelper.GetValidVacancyViewModel(vacancyReferenceNumber);

            vacancy.VacancyRequirementsProspectsViewModel.DesiredQualifications = @"<script> </script>"; // Make the vacancy invalid

            var mediator = new VacancyMediatorBuilder().Build();

            var result = mediator.UpdateVacancy(vacancy.VacancyRequirementsProspectsViewModel);

            result.AssertValidationResult(VacancyMediatorCodes.UpdateVacancy.FailedValidation);
        }
        public void ShouldReturnFailedValidationIfTheViewModelIsNotCorrect()
        {
            const int vacancyReferenceNumber = 1;
            var       vacancy = VacancyMediatorTestHelper.GetValidVacancyViewModel(vacancyReferenceNumber);

            vacancy.TrainingDetailsViewModel.ContactName = @"<script> </script>"; // Make the vacancy invalid

            var mediator = new VacancyMediatorBuilder().Build();

            var result = mediator.UpdateVacancy(vacancy.TrainingDetailsViewModel);

            result.AssertValidationResult(VacancyMediatorCodes.UpdateVacancy.FailedValidation);
        }
        public void ShouldReturnFailedValidationIfTheViewModelIsNotCorrect()
        {
            const int vacancyReferenceNumber = 1;
            var       vacancy = VacancyMediatorTestHelper.GetValidVacancyViewModel(vacancyReferenceNumber);

            vacancy.NewVacancyViewModel.Title = null; // Make the vacancy invalid

            var mediator = new VacancyMediatorBuilder().Build();

            var result = mediator.UpdateVacancy(vacancy.NewVacancyViewModel);

            result.AssertValidationResult(VacancyMediatorCodes.UpdateVacancy.FailedValidation);
        }
        public void ShouldReturnInvalidVacancyIfTheVacancyIsNotAvailableToQA()
        {
            const int vacancyReferenceNumber = 1;
            var       provider       = new Mock <IVacancyQAProvider>();
            var       vacancy        = VacancyMediatorTestHelper.GetValidVacancyViewModel(vacancyReferenceNumber);
            var       qaActionResult = new QAActionResult <VacancyRequirementsProspectsViewModel>(QAActionResultCode.InvalidVacancy);

            provider.Setup(p => p.UpdateVacancyWithComments(vacancy.VacancyRequirementsProspectsViewModel)).Returns(qaActionResult);

            var mediator = new VacancyMediatorBuilder().With(provider).Build();

            var result = mediator.UpdateVacancy(vacancy.VacancyRequirementsProspectsViewModel);

            result.AssertMessage(VacancyMediatorCodes.UpdateVacancy.InvalidVacancy, VacancyViewModelMessages.InvalidVacancy, UserMessageLevel.Error);
        }
Exemplo n.º 5
0
        public void UpdateVacancyWithAVacancyThatDontAcceptsWarningsWithWarningsShouldNotUpdateVacancy()
        {
            var vacancyProvider = new Mock <IVacancyQAProvider>();

            var mediator  = new VacancyMediatorBuilder().With(vacancyProvider).Build();
            var viewModel = GetValidVacancySummaryViewModel(1);

            viewModel.VacancyDatesViewModel.ClosingDate = new DateViewModel(DateTime.UtcNow.AddDays(10));
            viewModel.AcceptWarnings = false;

            var result = mediator.UpdateVacancy(viewModel);

            result.AssertValidationResult(VacancyMediatorCodes.UpdateVacancy.FailedValidation);
            vacancyProvider.Verify(vp => vp.UpdateVacancyWithComments(viewModel), Times.Never);
        }
        public void ShouldReturnOkIsThereIsNotAnyIssue()
        {
            const int vacancyReferenceNumber = 1;
            var       provider       = new Mock <IVacancyQAProvider>();
            var       vacancy        = VacancyMediatorTestHelper.GetValidVacancyViewModel(vacancyReferenceNumber);
            var       qaActionResult = new QAActionResult <VacancyRequirementsProspectsViewModel>(QAActionResultCode.Ok, vacancy.VacancyRequirementsProspectsViewModel);

            provider.Setup(p => p.UpdateVacancyWithComments(vacancy.VacancyRequirementsProspectsViewModel)).Returns(qaActionResult);

            var mediator = new VacancyMediatorBuilder().With(provider).Build();

            var result = mediator.UpdateVacancy(vacancy.VacancyRequirementsProspectsViewModel);

            result.AssertCodeAndMessage(VacancyMediatorCodes.UpdateVacancy.Ok);
            result.ViewModel.ShouldBeEquivalentTo(vacancy.VacancyRequirementsProspectsViewModel);
        }
Exemplo n.º 7
0
        public void UpdateVacancyWithAVacancyThatAcceptsWarningsWithWarningsShouldUpdateVacancy()
        {
            var vacancyProvider = new Mock <IVacancyQAProvider>();

            var mediator  = new VacancyMediatorBuilder().With(vacancyProvider).Build();
            var viewModel = GetValidVacancySummaryViewModel(1);

            viewModel.VacancyDatesViewModel.ClosingDate = new DateViewModel(DateTime.UtcNow.AddDays(10));
            viewModel.AcceptWarnings = true;

            vacancyProvider.Setup(vp => vp.UpdateVacancyWithComments(viewModel))
            .Returns(new QAActionResult <FurtherVacancyDetailsViewModel>(QAActionResultCode.Ok,
                                                                         new FurtherVacancyDetailsViewModel()));

            var result = mediator.UpdateVacancy(viewModel);

            result.AssertCodeAndMessage(VacancyMediatorCodes.UpdateVacancy.Ok);
            vacancyProvider.Verify(vp => vp.UpdateVacancyWithComments(viewModel));
        }
Exemplo n.º 8
0
        public void UpdateVacancyWillNotUpdateVacancyIfViewModelIsNotValid()
        {
            var vacancyProvider = new Mock <IVacancyQAProvider>();

            var mediator  = new VacancyMediatorBuilder().With(vacancyProvider).Build();
            var viewModel = new FurtherVacancyDetailsViewModel
            {
                VacancyDatesViewModel = new VacancyDatesViewModel
                {
                    ClosingDate       = new DateViewModel(DateTime.UtcNow),
                    PossibleStartDate = new DateViewModel(DateTime.UtcNow)
                },
                Wage = new WageViewModel()
                {
                    Type = WageType.ApprenticeshipMinimum, Classification = WageClassification.ApprenticeshipMinimum, Amount = null, AmountLowerBound = null, AmountUpperBound = null, Text = null, Unit = WageUnit.NotApplicable, HoursPerWeek = null
                }
            };

            var result = mediator.UpdateVacancy(viewModel);

            result.AssertValidationResult(VacancyMediatorCodes.UpdateVacancy.FailedValidation);
            vacancyProvider.Verify(vp => vp.UpdateVacancyWithComments(viewModel), Times.Never);
        }