public void FailValidationEducationLongerThan15Char() { var viewModel = new TraineeshipApplicationViewModel { Candidate = new TraineeshipCandidateViewModel { MonitoringInformation = new MonitoringInformationViewModel(), HasQualifications = true, Qualifications = new List <QualificationsViewModel> { new QualificationsViewModel { Grade = "Grade is Longer than 15 chars", QualificationType = "QUAL", Year = "2012" } } } }; TraineeshipApplicationProvider.Setup(p => p.GetApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)) .Returns(viewModel); TraineeshipApplicationProvider.Setup( p => p.PatchApplicationViewModel(It.IsAny <Guid>(), It.IsAny <TraineeshipApplicationViewModel>(), It.IsAny <TraineeshipApplicationViewModel>())) .Returns <Guid, TraineeshipApplicationViewModel, TraineeshipApplicationViewModel>((cid, svm, vm) => vm); var response = Mediator.Submit(Guid.NewGuid(), ValidVacancyId, viewModel); response.AssertValidationResult(TraineeshipApplicationMediatorCodes.Submit.ValidationError, true, false); }
public void SubmitApplicationError() { var viewModel = new TraineeshipApplicationViewModel { Candidate = new TraineeshipCandidateViewModel(), VacancyDetail = new TraineeshipVacancyDetailViewModel(), ViewModelStatus = ApplicationViewModelStatus.Error }; TraineeshipApplicationProvider.Setup(p => p.GetApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)) .Returns(new TraineeshipApplicationViewModel { ViewModelStatus = ApplicationViewModelStatus.Error }); TraineeshipApplicationProvider.Setup( p => p.PatchApplicationViewModel(It.IsAny <Guid>(), It.IsAny <TraineeshipApplicationViewModel>(), It.IsAny <TraineeshipApplicationViewModel>())) .Returns <Guid, TraineeshipApplicationViewModel, TraineeshipApplicationViewModel>((cid, svm, vm) => vm); TraineeshipApplicationProvider.Setup( p => p.SubmitApplication(It.IsAny <Guid>(), It.IsAny <int>(), It.IsAny <TraineeshipApplicationViewModel>())) .Returns <Guid, int, TraineeshipApplicationViewModel>((cid, vid, vm) => vm); var response = Mediator.Submit(Guid.NewGuid(), ValidVacancyId, viewModel); response.AssertMessage(TraineeshipApplicationMediatorCodes.Submit.Error, ApplicationPageMessages.SubmitApplicationFailed, UserMessageLevel.Warning, true, true); }
public void FailValidation() { var viewModel = new TraineeshipApplicationViewModel { Candidate = new TraineeshipCandidateViewModel { MonitoringInformation = new MonitoringInformationViewModel { AnythingWeCanDoToSupportYourInterview = new string('X', 9999) } } }; TraineeshipApplicationProvider.Setup(p => p.GetApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)) .Returns(viewModel); TraineeshipApplicationProvider.Setup( p => p.PatchApplicationViewModel(It.IsAny <Guid>(), It.IsAny <TraineeshipApplicationViewModel>(), It.IsAny <TraineeshipApplicationViewModel>())) .Returns <Guid, TraineeshipApplicationViewModel, TraineeshipApplicationViewModel>((cid, svm, vm) => vm); var response = Mediator.Submit(Guid.NewGuid(), ValidVacancyId, viewModel); response.AssertValidationResult(TraineeshipApplicationMediatorCodes.Submit.ValidationError, true, false); }
public void IncorrectState() { var viewModel = new TraineeshipApplicationViewModel { Candidate = new TraineeshipCandidateViewModel(), VacancyDetail = new TraineeshipVacancyDetailViewModel(), ViewModelStatus = ApplicationViewModelStatus.ApplicationInIncorrectState }; TraineeshipApplicationProvider.Setup(p => p.GetApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)) .Returns(new TraineeshipApplicationViewModel { ViewModelStatus = ApplicationViewModelStatus.ApplicationInIncorrectState }); TraineeshipApplicationProvider.Setup( p => p.PatchApplicationViewModel(It.IsAny <Guid>(), It.IsAny <TraineeshipApplicationViewModel>(), It.IsAny <TraineeshipApplicationViewModel>())) .Returns <Guid, TraineeshipApplicationViewModel, TraineeshipApplicationViewModel>((cid, svm, vm) => vm); TraineeshipApplicationProvider.Setup( p => p.SubmitApplication(It.IsAny <Guid>(), It.IsAny <int>(), It.IsAny <TraineeshipApplicationViewModel>())) .Returns <Guid, int, TraineeshipApplicationViewModel>((cid, vid, vm) => vm); var response = Mediator.Submit(Guid.NewGuid(), ValidVacancyId, viewModel); response.AssertCode(TraineeshipApplicationMediatorCodes.Submit.IncorrectState, false); }
public void Ok() { TraineeshipApplicationProvider.Setup(p => p.GetApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)).Returns(new TraineeshipApplicationViewModel()); var response = Mediator.Apply(Guid.NewGuid(), ValidVacancyId.ToString()); response.AssertCode(TraineeshipApplicationMediatorCodes.Apply.Ok, true); }
public void HasError() { TraineeshipApplicationProvider.Setup(p => p.GetApplicationViewModel(It.IsAny <Guid>(), InvalidVacancyId)).Returns(new TraineeshipApplicationViewModel("Vacancy not found")); var response = Mediator.Apply(Guid.NewGuid(), InvalidVacancyId.ToString()); response.AssertCode(TraineeshipApplicationMediatorCodes.Apply.HasError, false); }
public void Ok() { TraineeshipApplicationProvider.Setup(p => p.GetWhatHappensNextViewModel(It.IsAny <Guid>(), It.IsAny <int>())).Returns(new WhatHappensNextViewModel()); var response = Mediator.WhatHappensNext(_someCandidateId, SomeVacancyId.ToString(), VacancyReference, VacancyTitle); response.AssertCode(TraineeshipApplicationMediatorCodes.WhatHappensNext.Ok, true); }
public void VacancyNotFound() { TraineeshipApplicationProvider.Setup(p => p.GetWhatHappensNextViewModel(It.IsAny <Guid>(), It.IsAny <int>())).Returns(new WhatHappensNextViewModel { Status = ApplicationStatuses.ExpiredOrWithdrawn }); var response = Mediator.WhatHappensNext(_someCandidateId, SomeVacancyId.ToString(), VacancyReference, VacancyTitle); response.AssertCode(TraineeshipApplicationMediatorCodes.WhatHappensNext.VacancyNotFound, false); }
public void GetApplicationViewModelError() { var getApplicationViewModel = new TraineeshipApplicationViewModelBuilder().WithMessage(ApplicationPageMessages.SubmitApplicationFailed).Build(); TraineeshipApplicationProvider.Setup(p => p.GetApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)).Returns(getApplicationViewModel); var viewModel = new TraineeshipApplicationViewModelBuilder().Build(); var response = Mediator.Submit(Guid.NewGuid(), ValidVacancyId, viewModel); response.AssertMessage(TraineeshipApplicationMediatorCodes.Submit.Error, ApplicationPageMessages.SubmitApplicationFailed, UserMessageLevel.Warning, true, true); }
public void HasError() { TraineeshipApplicationProvider.Setup(p => p.GetWhatHappensNextViewModel(It.IsAny <Guid>(), It.IsAny <int>())) .Returns(new WhatHappensNextTraineeshipViewModel("Has Error")); var response = Mediator.WhatHappensNext(_someCandidateId, SomeVacancyId.ToString(CultureInfo.InvariantCulture), VacancyReference, VacancyTitle); response.AssertCode(TraineeshipApplicationMediatorCodes.WhatHappensNext.Ok, true); var viewModel = response.ViewModel; viewModel.VacancyReference.Should().Be(VacancyReference); viewModel.VacancyTitle.Should().Be(VacancyTitle); }
public void OkIsJavascript() { var viewModel = new TraineeshipApplicationViewModel { Candidate = new TraineeshipCandidateViewModel(), VacancyDetail = new VacancyDetailViewModel(), IsJavascript = true }; TraineeshipApplicationProvider.Setup(p => p.GetApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)).Returns(new TraineeshipApplicationViewModel()); TraineeshipApplicationProvider.Setup(p => p.PatchApplicationViewModel(It.IsAny <Guid>(), It.IsAny <TraineeshipApplicationViewModel>(), It.IsAny <TraineeshipApplicationViewModel>())).Returns <Guid, TraineeshipApplicationViewModel, TraineeshipApplicationViewModel>((cid, svm, vm) => vm); TraineeshipApplicationProvider.Setup(p => p.SubmitApplication(It.IsAny <Guid>(), It.IsAny <int>(), It.IsAny <TraineeshipApplicationViewModel>())).Returns <Guid, int, TraineeshipApplicationViewModel>((cid, vid, vm) => vm); var response = Mediator.Submit(Guid.NewGuid(), ValidVacancyId, viewModel); response.AssertCode(TraineeshipApplicationMediatorCodes.Submit.Ok, false, true); }