예제 #1
0
        public void AcceptSubmitValidationError()
        {
            var postedViewModel = new ApprenticeshipApplicationPreviewViewModel
            {
                AcceptSubmit = false
            };

            var viewModel = new ApprenticeshipApplicationPreviewViewModel
            {
                Candidate     = new ApprenticeshipCandidateViewModel(),
                VacancyDetail = new ApprenticeshipVacancyDetailViewModel
                {
                    VacancyStatus = VacancyStatuses.Live
                },
                Status = ApplicationStatuses.Draft
            };

            ApprenticeshipApplicationProvider.Setup(
                p => p.GetApplicationPreviewViewModel(It.IsAny <Guid>(), It.IsAny <int>())).Returns(viewModel);
            ApprenticeshipApplicationProvider.Setup(p => p.SubmitApplication(It.IsAny <Guid>(), It.IsAny <int>()))
            .Returns(viewModel);

            var response = Mediator.Submit(Guid.NewGuid(), ValidVacancyId, postedViewModel);

            response.AssertValidationResult(ApprenticeshipApplicationMediatorCodes.Submit.AcceptSubmitValidationError);
        }
예제 #2
0
        public void GetApplicationViewModelError()
        {
            var postedViewModel = new ApprenticeshipApplicationPreviewViewModel
            {
                AcceptSubmit = true
            };

            var savedViewModel = new ApprenticeshipApplicationPreviewViewModel
            {
                Candidate     = new ApprenticeshipCandidateViewModel(),
                VacancyDetail = new ApprenticeshipVacancyDetailViewModel
                {
                    VacancyStatus = VacancyStatuses.Live
                }
            };
            var submittedApplicationViewModel = new ApprenticeshipApplicationViewModel
            {
                Candidate        = new ApprenticeshipCandidateViewModel(),
                VacancyDetail    = new ApprenticeshipVacancyDetailViewModel(),
                ViewModelStatus  = ApplicationViewModelStatus.Error,
                ViewModelMessage = "An error message"
            };

            ApprenticeshipApplicationProvider.Setup(
                p => p.GetApplicationPreviewViewModel(It.IsAny <Guid>(), It.IsAny <int>())).Returns(savedViewModel);
            ApprenticeshipApplicationProvider.Setup(p => p.SubmitApplication(It.IsAny <Guid>(), It.IsAny <int>()))
            .Returns(submittedApplicationViewModel);

            var response = Mediator.Submit(Guid.NewGuid(), ValidVacancyId, postedViewModel);

            response.AssertMessage(ApprenticeshipApplicationMediatorCodes.Submit.Error,
                                   ApplicationPageMessages.SubmitApplicationFailed, UserMessageLevel.Warning, false, true);
        }
예제 #3
0
        public void IncorrectState()
        {
            var postedViewModel = new ApprenticeshipApplicationPreviewViewModel
            {
                AcceptSubmit = true
            };

            var viewModel = new ApprenticeshipApplicationPreviewViewModel
            {
                Candidate     = new ApprenticeshipCandidateViewModel(),
                VacancyDetail = new ApprenticeshipVacancyDetailViewModel
                {
                    VacancyStatus = VacancyStatuses.Live
                },
                ViewModelStatus = ApplicationViewModelStatus.ApplicationInIncorrectState
            };

            ApprenticeshipApplicationProvider.Setup(
                p => p.GetApplicationPreviewViewModel(It.IsAny <Guid>(), It.IsAny <int>())).Returns(viewModel);
            ApprenticeshipApplicationProvider.Setup(p => p.SubmitApplication(It.IsAny <Guid>(), It.IsAny <int>()))
            .Returns(viewModel);

            var response = Mediator.Submit(Guid.NewGuid(), ValidVacancyId, postedViewModel);

            response.AssertMessage(ApprenticeshipApplicationMediatorCodes.Submit.IncorrectState,
                                   MyApplicationsPageMessages.ApplicationInIncorrectState, UserMessageLevel.Info, false);
        }
        public void OfflineVacancy()
        {
            var viewModel = new ApprenticeshipApplicationViewModel
            {
                Candidate     = new ApprenticeshipCandidateViewModel(),
                VacancyDetail = new ApprenticeshipVacancyDetailViewModel()
            };

            ApprenticeshipApplicationProvider.Setup(p => p.GetApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId))
            .Returns(new ApprenticeshipApplicationViewModel
            {
                Status        = ApplicationStatuses.Draft,
                VacancyDetail = new ApprenticeshipVacancyDetailViewModel
                {
                    ApplyViaEmployerWebsite = true
                }
            });
            ApprenticeshipApplicationProvider.Setup(
                p =>
                p.PatchApplicationViewModel(It.IsAny <Guid>(), It.IsAny <ApprenticeshipApplicationViewModel>(),
                                            It.IsAny <ApprenticeshipApplicationViewModel>()))
            .Returns <Guid, ApprenticeshipApplicationViewModel, ApprenticeshipApplicationViewModel>(
                (cid, svm, vm) => vm);
            ApprenticeshipApplicationProvider.Setup(p => p.SubmitApplication(It.IsAny <Guid>(), It.IsAny <int>()))
            .Returns(viewModel);

            var response = Mediator.PreviewAndSubmit(Guid.NewGuid(), ValidVacancyId, viewModel);

            response.AssertCode(ApprenticeshipApplicationMediatorCodes.PreviewAndSubmit.OfflineVacancy, false);
        }
예제 #5
0
        public void ShouldIncrementSavedVacancyCount(int savedAndDraftCount)
        {
            // Arrange.
            var viewModel = new SavedVacancyViewModel();

            ApprenticeshipApplicationProvider
            .Setup(mock => mock.SaveVacancy(_testCandidateId, TestVacancyId))
            .Returns(viewModel);

            UserDataProvider
            .Setup(mock => mock.Get(UserDataItemNames.SavedAndDraftCount))
            .Returns(savedAndDraftCount.ToString(CultureInfo.InvariantCulture));

            // Act.
            var response = Mediator.SaveVacancy(_testCandidateId, TestVacancyId);

            // Assert.
            UserDataProvider.Verify(mock => mock.Get(UserDataItemNames.SavedAndDraftCount), Times.Once);
            UserDataProvider.Verify(
                mock =>
                mock.Push(UserDataItemNames.SavedAndDraftCount,
                          (savedAndDraftCount + 1).ToString(CultureInfo.InvariantCulture)), Times.Once);

            response.AssertCode(ApprenticeshipApplicationMediatorCodes.SaveVacancy.Ok, true);
            response.ViewModel.Should().Be(viewModel);
        }
예제 #6
0
        public void ValidationError()
        {
            var viewModel = new ApprenticeshipApplicationViewModel
            {
                Candidate = new ApprenticeshipCandidateViewModel
                {
                    Education = new EducationViewModel
                    {
                        FromYear = "1066"
                    }
                },
                VacancyDetail = new ApprenticeshipVacancyDetailViewModel()
            };

            ApprenticeshipApplicationProvider.Setup(p => p.GetApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId))
            .Returns(new ApprenticeshipApplicationViewModel
            {
                Status        = ApplicationStatuses.Draft,
                VacancyDetail = new ApprenticeshipVacancyDetailViewModel()
            });
            ApprenticeshipApplicationProvider.Setup(
                p =>
                p.PatchApplicationViewModel(It.IsAny <Guid>(), It.IsAny <ApprenticeshipApplicationViewModel>(),
                                            It.IsAny <ApprenticeshipApplicationViewModel>()))
            .Returns <Guid, ApprenticeshipApplicationViewModel, ApprenticeshipApplicationViewModel>(
                (cid, svm, vm) => vm);

            var response = Mediator.Save(Guid.NewGuid(), ValidVacancyId, viewModel);

            response.AssertValidationResult(ApprenticeshipApplicationMediatorCodes.Save.ValidationError);
        }
        public void ValidationError()
        {
            var viewModel = new ApprenticeshipApplicationViewModel
            {
                Candidate = new ApprenticeshipCandidateViewModel
                {
                    AboutYou = new AboutYouViewModel()
                },
                VacancyDetail = new ApprenticeshipVacancyDetailViewModel()
            };

            ApprenticeshipApplicationProvider.Setup(p => p.GetApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId))
            .Returns(new ApprenticeshipApplicationViewModel
            {
                Status        = ApplicationStatuses.Draft,
                VacancyDetail = new ApprenticeshipVacancyDetailViewModel
                {
                    VacancyStatus = VacancyStatuses.Live
                }
            });
            ApprenticeshipApplicationProvider.Setup(
                p =>
                p.PatchApplicationViewModel(It.IsAny <Guid>(), It.IsAny <ApprenticeshipApplicationViewModel>(),
                                            It.IsAny <ApprenticeshipApplicationViewModel>()))
            .Returns <Guid, ApprenticeshipApplicationViewModel, ApprenticeshipApplicationViewModel>(
                (cid, svm, vm) => vm);

            var response = Mediator.PreviewAndSubmit(Guid.NewGuid(), ValidVacancyId, viewModel);

            response.AssertValidationResult(ApprenticeshipApplicationMediatorCodes.PreviewAndSubmit.ValidationError);
        }
예제 #8
0
        public void Ok()
        {
            var postedViewModel = new ApprenticeshipApplicationPreviewViewModel
            {
                AcceptSubmit = true
            };

            var viewModel = new ApprenticeshipApplicationPreviewViewModel
            {
                Candidate     = new ApprenticeshipCandidateViewModel(),
                VacancyDetail = new ApprenticeshipVacancyDetailViewModel
                {
                    VacancyStatus = VacancyStatuses.Live
                }
            };

            ApprenticeshipApplicationProvider.Setup(
                p => p.GetApplicationPreviewViewModel(It.IsAny <Guid>(), It.IsAny <int>())).Returns(viewModel);
            ApprenticeshipApplicationProvider.Setup(p => p.CreateApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId))
            .Returns(new ApprenticeshipApplicationViewModel());
            ApprenticeshipApplicationProvider.Setup(
                p =>
                p.PatchApplicationViewModel(It.IsAny <Guid>(), It.IsAny <ApprenticeshipApplicationViewModel>(),
                                            It.IsAny <ApprenticeshipApplicationViewModel>()))
            .Returns <Guid, ApprenticeshipApplicationViewModel, ApprenticeshipApplicationViewModel>(
                (cid, svm, vm) => vm);
            ApprenticeshipApplicationProvider.Setup(p => p.SubmitApplication(It.IsAny <Guid>(), It.IsAny <int>()))
            .Returns(viewModel);

            var response = Mediator.Submit(Guid.NewGuid(), ValidVacancyId, postedViewModel);

            response.AssertCode(ApprenticeshipApplicationMediatorCodes.Submit.Ok, false, true);
        }
예제 #9
0
        public void ValidationError()
        {
            var postedViewModel = new ApprenticeshipApplicationPreviewViewModel
            {
                AcceptSubmit = true
            };

            var viewModel = new ApprenticeshipApplicationPreviewViewModel
            {
                Candidate = new ApprenticeshipCandidateViewModel
                {
                    Education = new EducationViewModel
                    {
                        NameOfMostRecentSchoolCollege = "A School",
                        FromYear = "0",
                        ToYear   = "0"
                    }
                },
                VacancyDetail = new ApprenticeshipVacancyDetailViewModel
                {
                    VacancyStatus = VacancyStatuses.Live
                },
                ViewModelStatus = ApplicationViewModelStatus.Error
            };

            ApprenticeshipApplicationProvider.Setup(
                p => p.GetApplicationPreviewViewModel(It.IsAny <Guid>(), It.IsAny <int>())).Returns(viewModel);
            ApprenticeshipApplicationProvider.Setup(p => p.SubmitApplication(It.IsAny <Guid>(), It.IsAny <int>()))
            .Returns(viewModel);

            var response = Mediator.Submit(Guid.NewGuid(), ValidVacancyId, postedViewModel);

            response.AssertValidationResult(ApprenticeshipApplicationMediatorCodes.Submit.ValidationError);
        }
예제 #10
0
        public void ErrorGettingApplicationViewModel()
        {
            var postedViewModel = new ApprenticeshipApplicationPreviewViewModel
            {
                AcceptSubmit = true
            };

            var viewModel = new ApprenticeshipApplicationPreviewViewModel
            {
                Candidate     = new ApprenticeshipCandidateViewModel(),
                VacancyDetail = new ApprenticeshipVacancyDetailViewModel()
            };

            ApprenticeshipApplicationProvider.Setup(
                p => p.GetApplicationPreviewViewModel(It.IsAny <Guid>(), It.IsAny <int>())).Returns(viewModel);
            ApprenticeshipApplicationProvider.Setup(p => p.CreateApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId))
            .Returns(new ApprenticeshipApplicationViewModel(MyApplicationsPageMessages.ApplicationNotFound,
                                                            ApplicationViewModelStatus.ApplicationNotFound));
            ApprenticeshipApplicationProvider.Setup(
                p =>
                p.PatchApplicationViewModel(It.IsAny <Guid>(), It.IsAny <ApprenticeshipApplicationViewModel>(),
                                            It.IsAny <ApprenticeshipApplicationViewModel>()))
            .Returns <Guid, ApprenticeshipApplicationViewModel, ApprenticeshipApplicationViewModel>(
                (cid, svm, vm) => vm);
            ApprenticeshipApplicationProvider.Setup(p => p.SubmitApplication(It.IsAny <Guid>(), It.IsAny <int>()))
            .Returns(viewModel);

            var response = Mediator.Submit(Guid.NewGuid(), ValidVacancyId, postedViewModel);

            response.AssertCode(ApprenticeshipApplicationMediatorCodes.Submit.VacancyNotFound, false);
        }
예제 #11
0
        public void HasError()
        {
            ApprenticeshipApplicationProvider.Setup(p => p.GetOrCreateApplicationViewModel(It.IsAny <Guid>(), InvalidVacancyId)).Returns(new ApprenticeshipApplicationViewModel("Vacancy not found"));

            var response = Mediator.Resume(Guid.NewGuid(), InvalidVacancyId);

            response.AssertMessage(ApprenticeshipApplicationMediatorCodes.Resume.HasError, "Vacancy not found", UserMessageLevel.Warning, false);
        }
예제 #12
0
        public void HasError()
        {
            ApprenticeshipApplicationProvider.Setup(p => p.GetOrCreateApplicationViewModel(It.IsAny <Guid>(), InvalidVacancyId)).Returns(new ApprenticeshipApplicationViewModel("Vacancy not found"));

            var response = Mediator.Preview(Guid.NewGuid(), InvalidVacancyId);

            response.AssertCode(ApprenticeshipApplicationMediatorCodes.Preview.HasError, false);
        }
예제 #13
0
        public void Ok()
        {
            ApprenticeshipApplicationProvider.Setup(p => p.GetApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId))
            .Returns(new ApprenticeshipApplicationViewModelBuilder().WithVacancyStatus(VacancyStatuses.Live).Build);

            var response = Mediator.Resume(Guid.NewGuid(), ValidVacancyId);

            response.AssertCode(ApprenticeshipApplicationMediatorCodes.Resume.Ok, false, true);
        }
예제 #14
0
        public void IfModelHasError_PopulateVacancyTitleAndVacancyReferenceInTheModel()
        {
            ApprenticeshipApplicationProvider.Setup(p => p.GetWhatHappensNextViewModel(_someCandidateId, SomeVacancyId)).Returns(new WhatHappensNextViewModel(SomeErrorMessage));

            var response = Mediator.WhatHappensNext(_someCandidateId, SomeVacancyId.ToString(), VacancyReference, VacancyTitle);

            response.AssertCode(ApprenticeshipApplicationMediatorCodes.WhatHappensNext.Ok, true);
            response.ViewModel.VacancyTitle     = VacancyTitle;
            response.ViewModel.VacancyReference = VacancyReference;
        }
예제 #15
0
        public void VacancyNotFound()
        {
            ApprenticeshipApplicationProvider.Setup(p => p.GetOrCreateApplicationViewModel(It.IsAny <Guid>(), InvalidVacancyId)).Returns(new ApprenticeshipApplicationViewModel {
                Status = ApplicationStatuses.ExpiredOrWithdrawn, VacancyDetail = new VacancyDetailViewModel()
            });

            var response = Mediator.Preview(Guid.NewGuid(), InvalidVacancyId);

            response.AssertCode(ApprenticeshipApplicationMediatorCodes.Preview.VacancyNotFound, false);
        }
예제 #16
0
        public void IncorrectState()
        {
            ApprenticeshipApplicationProvider.Setup(p => p.GetApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId))
            .Returns(new ApprenticeshipApplicationViewModelBuilder().WithStatus(ApplicationStatuses.Submitted).Build);

            var response = Mediator.Resume(Guid.NewGuid(), ValidVacancyId);

            response.AssertMessage(ApprenticeshipApplicationMediatorCodes.Resume.IncorrectState,
                                   MyApplicationsPageMessages.ApplicationInIncorrectState, UserMessageLevel.Info, false);
        }
예제 #17
0
        public void ExpiredOrWithdrawnVacancyReturnsAVacancyNotFound()
        {
            ApprenticeshipApplicationProvider.Setup(p => p.GetWhatHappensNextViewModel(_someCandidateId, SomeVacancyId)).Returns(new WhatHappensNextViewModel
            {
                Status = ApplicationStatuses.ExpiredOrWithdrawn
            });

            var response = Mediator.WhatHappensNext(_someCandidateId, SomeVacancyId.ToString(), VacancyReference, VacancyTitle);

            response.Code.Should().Be(ApprenticeshipApplicationMediatorCodes.WhatHappensNext.VacancyNotFound);
        }
예제 #18
0
        public void ApplicationExpired()
        {
            ApprenticeshipApplicationProvider.Setup(p => p.GetOrCreateApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)).Returns(new ApprenticeshipApplicationViewModel
            {
                Status = ApplicationStatuses.ExpiredOrWithdrawn
            });

            var response = Mediator.Resume(Guid.NewGuid(), ValidVacancyId);

            response.AssertMessage(ApprenticeshipApplicationMediatorCodes.Resume.HasError, MyApplicationsPageMessages.ApprenticeshipNoLongerAvailable, UserMessageLevel.Warning, false);
        }
예제 #19
0
        public void Ok()
        {
            ApprenticeshipApplicationProvider.Setup(p => p.GetWhatHappensNextViewModel(_someCandidateId, SomeVacancyId)).Returns(new WhatHappensNextViewModel
            {
                VacancyStatus = VacancyStatuses.Live
            });

            var response = Mediator.WhatHappensNext(_someCandidateId, SomeVacancyId.ToString(), VacancyReference, VacancyTitle);

            response.AssertCode(ApprenticeshipApplicationMediatorCodes.WhatHappensNext.Ok, true);
        }
예제 #20
0
        public void SetUp()
        {
            _logService           = new Mock <ILogService>();
            _candidateService     = new Mock <ICandidateService>();
            _configurationManager = new Mock <IConfigurationManager>();

            _configurationManager.Setup(cm => cm.GetCloudAppSetting <int>("UnsuccessfulApplicationsToShowTraineeshipsPrompt"))
            .Returns(UnsuccessfulApplications);

            _apprenticeshipApplicationProvider = new ApprenticeshipApplicationProvider(null, _candidateService.Object,
                                                                                       null, _configurationManager.Object, _logService.Object);
        }
예제 #21
0
        public void VacancyExpired()
        {
            ApprenticeshipApplicationProvider.Setup(p => p.GetOrCreateApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)).Returns(new ApprenticeshipApplicationViewModel
            {
                VacancyDetail = new VacancyDetailViewModel
                {
                    VacancyStatus = VacancyStatuses.Expired
                }
            });

            var response = Mediator.Apply(Guid.NewGuid(), ValidVacancyId.ToString());

            response.AssertCode(ApprenticeshipApplicationMediatorCodes.Apply.VacancyNotFound, false);
        }
예제 #22
0
        public void Ok()
        {
            ApprenticeshipApplicationProvider.Setup(p => p.GetOrCreateApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)).Returns(new ApprenticeshipApplicationViewModel
            {
                VacancyDetail = new VacancyDetailViewModel
                {
                    VacancyStatus = VacancyStatuses.Live
                }
            });

            var response = Mediator.Preview(Guid.NewGuid(), ValidVacancyId);

            response.AssertCode(ApprenticeshipApplicationMediatorCodes.Preview.Ok, true);
        }
예제 #23
0
        public void HasError()
        {
            var viewModel = new ApprenticeshipApplicationViewModel
            {
                Candidate     = new ApprenticeshipCandidateViewModel(),
                VacancyDetail = new VacancyDetailViewModel()
            };

            ApprenticeshipApplicationProvider.Setup(p => p.GetOrCreateApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)).Returns(new ApprenticeshipApplicationViewModel("Has Error"));

            var response = Mediator.AutoSave(Guid.NewGuid(), ValidVacancyId, viewModel);

            response.AssertCode(ApprenticeshipApplicationMediatorCodes.AutoSave.HasError, true);
        }
예제 #24
0
        public void OfflineVacancy()
        {
            ApprenticeshipApplicationProvider.Setup(p => p.GetOrCreateApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)).Returns(new ApprenticeshipApplicationViewModel
            {
                VacancyDetail = new VacancyDetailViewModel
                {
                    ApplyViaEmployerWebsite = true
                }
            });

            var response = Mediator.Preview(Guid.NewGuid(), ValidVacancyId);

            response.AssertCode(ApprenticeshipApplicationMediatorCodes.Preview.OfflineVacancy, false);
        }
예제 #25
0
        public void Error()
        {
            var viewModel = new ApprenticeshipApplicationViewModel
            {
                Candidate     = new ApprenticeshipCandidateViewModel(),
                VacancyDetail = new ApprenticeshipVacancyDetailViewModel()
            };

            ApprenticeshipApplicationProvider.Setup(p => p.GetApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)).Returns(new ApprenticeshipApplicationViewModel("Has Error"));

            var response = Mediator.Save(Guid.NewGuid(), ValidVacancyId, viewModel);

            response.AssertMessage(ApprenticeshipApplicationMediatorCodes.Save.Error, ApplicationPageMessages.SaveFailed, UserMessageLevel.Warning, true);
        }
예제 #26
0
        public void VacancyNotFound()
        {
            var viewModel = new ApprenticeshipApplicationViewModel
            {
                Candidate     = new ApprenticeshipCandidateViewModel(),
                VacancyDetail = new VacancyDetailViewModel()
            };

            ApprenticeshipApplicationProvider.Setup(p => p.GetOrCreateApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)).Returns(new ApprenticeshipApplicationViewModel {
                Status = ApplicationStatuses.ExpiredOrWithdrawn
            });

            var response = Mediator.AutoSave(Guid.NewGuid(), ValidVacancyId, viewModel);

            response.AssertCode(ApprenticeshipApplicationMediatorCodes.AutoSave.VacancyNotFound, true);
        }
예제 #27
0
        public void VacancyNotFound()
        {
            var viewModel = new ApprenticeshipApplicationViewModel
            {
                Candidate     = new ApprenticeshipCandidateViewModel(),
                VacancyDetail = new VacancyDetailViewModel(),
                Status        = ApplicationStatuses.ExpiredOrWithdrawn
            };

            ApprenticeshipApplicationProvider.Setup(p => p.GetApplicationViewModel(It.IsAny <Guid>(), It.IsAny <int>())).Returns(viewModel);
            ApprenticeshipApplicationProvider.Setup(p => p.SubmitApplication(It.IsAny <Guid>(), It.IsAny <int>())).Returns(viewModel);

            var response = Mediator.Submit(Guid.NewGuid(), ValidVacancyId);

            response.AssertCode(ApprenticeshipApplicationMediatorCodes.Submit.VacancyNotFound, false);
        }
예제 #28
0
        public void Error()
        {
            var viewModel = new ApprenticeshipApplicationViewModel
            {
                Candidate     = new ApprenticeshipCandidateViewModel(),
                VacancyDetail = new VacancyDetailViewModel()
            };

            ApprenticeshipApplicationProvider.Setup(p => p.GetOrCreateApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)).Returns(new ApprenticeshipApplicationViewModel("Has error")
            {
                Status = ApplicationStatuses.Draft
            });

            var response = Mediator.PreviewAndSubmit(Guid.NewGuid(), ValidVacancyId, viewModel);

            response.AssertMessage(ApprenticeshipApplicationMediatorCodes.PreviewAndSubmit.Error, ApplicationPageMessages.PreviewFailed, UserMessageLevel.Warning, true);
        }
예제 #29
0
        public void AlreadySubmitted()
        {
            var viewModel = new ApprenticeshipApplicationViewModel
            {
                Candidate     = new ApprenticeshipCandidateViewModel(),
                VacancyDetail = new ApprenticeshipVacancyDetailViewModel()
            };

            ApprenticeshipApplicationProvider.Setup(p => p.GetApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)).Returns(new ApprenticeshipApplicationViewModel {
                Status = ApplicationStatuses.Submitted, VacancyDetail = new ApprenticeshipVacancyDetailViewModel()
            });
            ApprenticeshipApplicationProvider.Setup(p => p.PatchApplicationViewModel(It.IsAny <Guid>(), It.IsAny <ApprenticeshipApplicationViewModel>(), It.IsAny <ApprenticeshipApplicationViewModel>())).Returns <Guid, ApprenticeshipApplicationViewModel, ApprenticeshipApplicationViewModel>((cid, svm, vm) => vm);

            var response = Mediator.Save(Guid.NewGuid(), ValidVacancyId, viewModel);

            response.AssertMessage(ApprenticeshipApplicationMediatorCodes.Save.IncorrectState, MyApplicationsPageMessages.ApplicationInIncorrectState, UserMessageLevel.Info, false);
        }
예제 #30
0
        public void OkDateUpdated()
        {
            var viewModel = new ApprenticeshipApplicationViewModel
            {
                Candidate     = new ApprenticeshipCandidateViewModel(),
                VacancyDetail = new VacancyDetailViewModel(),
                DateUpdated   = new DateTime(2015, 01, 31)
            };

            ApprenticeshipApplicationProvider.Setup(p => p.GetOrCreateApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)).Returns(viewModel);
            ApprenticeshipApplicationProvider.Setup(p => p.PatchApplicationViewModel(It.IsAny <Guid>(), It.IsAny <ApprenticeshipApplicationViewModel>(), It.IsAny <ApprenticeshipApplicationViewModel>())).Returns <Guid, ApprenticeshipApplicationViewModel, ApprenticeshipApplicationViewModel>((cid, svm, vm) => vm);
            ApprenticeshipApplicationProvider.Setup(p => p.SubmitApplication(It.IsAny <Guid>(), It.IsAny <int>())).Returns(viewModel);

            var response = Mediator.AutoSave(Guid.NewGuid(), ValidVacancyId, viewModel);

            response.AssertCode(ApprenticeshipApplicationMediatorCodes.AutoSave.Ok, true);
            response.ViewModel.DateTimeMessage.Should().Be("12:00:00 AM on 31/1/2015");
        }