public void GivenInvalidVacancyIdString_ThenVacancyNotFound(string vacancyId) { var mediator = new ApprenticeshipApplicationMediatorBuilder().Build(); var response = mediator.Apply(Guid.NewGuid(), vacancyId); response.AssertCode(ApprenticeshipApplicationMediatorCodes.Apply.VacancyNotFound, false); }
public void Ok() { var apprenticeshipApplicationProvider = new Mock <IApprenticeshipApplicationProvider>(); apprenticeshipApplicationProvider.Setup(p => p.CreateApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)) .Returns(new ApprenticeshipApplicationViewModelBuilder().WithVacancyStatus(VacancyStatuses.Live).Build()); var mediator = new ApprenticeshipApplicationMediatorBuilder().With(apprenticeshipApplicationProvider).Build(); var response = mediator.Apply(Guid.NewGuid(), ValidVacancyId.ToString()); response.AssertCode(ApprenticeshipApplicationMediatorCodes.Apply.Ok, true); }
public void OfflineVacancy() { var apprenticeshipApplicationProvider = new Mock <IApprenticeshipApplicationProvider>(); apprenticeshipApplicationProvider.Setup(p => p.CreateApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)) .Returns(new ApprenticeshipApplicationViewModelBuilder().ApplyViaEmployerWebsite(true).Build()); var mediator = new ApprenticeshipApplicationMediatorBuilder().With(apprenticeshipApplicationProvider).Build(); var response = mediator.Apply(Guid.NewGuid(), ValidVacancyId.ToString()); response.AssertCode(ApprenticeshipApplicationMediatorCodes.Apply.OfflineVacancy, false); }
public void HasError() { var apprenticeshipApplicationProvider = new Mock <IApprenticeshipApplicationProvider>(); apprenticeshipApplicationProvider.Setup( p => p.CreateApplicationViewModel(It.IsAny <Guid>(), InvalidVacancyId)) .Returns(new ApprenticeshipApplicationViewModel("Vacancy has error")); var mediator = new ApprenticeshipApplicationMediatorBuilder().With(apprenticeshipApplicationProvider).Build(); var response = mediator.Apply(Guid.NewGuid(), InvalidVacancyId.ToString()); response.AssertCode(ApprenticeshipApplicationMediatorCodes.Apply.HasError, false); }
public void VacancyExpired() { var apprenticeshipApplicationProvider = new Mock <IApprenticeshipApplicationProvider>(); apprenticeshipApplicationProvider.Setup(p => p.CreateApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)) .Returns( new ApprenticeshipApplicationViewModelBuilder().WithVacancyStatus(VacancyStatuses.Expired).Build()); var mediator = new ApprenticeshipApplicationMediatorBuilder().With(apprenticeshipApplicationProvider).Build(); var response = mediator.Apply(Guid.NewGuid(), ValidVacancyId.ToString()); response.AssertMessage(ApprenticeshipApplicationMediatorCodes.Apply.VacancyNotFound, MyApplicationsPageMessages.ApprenticeshipNoLongerAvailable, UserMessageLevel.Warning, false); }
public void IncorrectState() { var apprenticeshipApplicationProvider = new Mock <IApprenticeshipApplicationProvider>(); apprenticeshipApplicationProvider.Setup(p => p.CreateApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)) .Returns( new ApprenticeshipApplicationViewModelBuilder().WithStatus(ApplicationStatuses.Submitted).Build()); var mediator = new ApprenticeshipApplicationMediatorBuilder().With(apprenticeshipApplicationProvider).Build(); var response = mediator.Apply(Guid.NewGuid(), ValidVacancyId.ToString()); response.AssertMessage(ApprenticeshipApplicationMediatorCodes.Apply.IncorrectState, MyApplicationsPageMessages.ApplicationInIncorrectState, UserMessageLevel.Info, false); }
public void CreateWhenApplicationNotFound() { var apprenticeshipApplicationProvider = new Mock <IApprenticeshipApplicationProvider>(); apprenticeshipApplicationProvider.Setup(p => p.GetApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)) .Returns( new ApprenticeshipApplicationViewModelBuilder().HasError( ApplicationViewModelStatus.ApplicationNotFound, MyApplicationsPageMessages.ApplicationNotFound) .Build()); apprenticeshipApplicationProvider.Setup(p => p.CreateApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId)) .Returns(new ApprenticeshipApplicationViewModelBuilder().WithVacancyStatus(VacancyStatuses.Live).Build()); var mediator = new ApprenticeshipApplicationMediatorBuilder().With(apprenticeshipApplicationProvider).Build(); var response = mediator.Apply(Guid.NewGuid(), ValidVacancyId.ToString()); response.AssertCode(ApprenticeshipApplicationMediatorCodes.Apply.Ok, true); apprenticeshipApplicationProvider.Verify(p => p.GetApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId), Times.Once); apprenticeshipApplicationProvider.Verify( p => p.CreateApplicationViewModel(It.IsAny <Guid>(), ValidVacancyId), Times.Once); }