public void WhenIGetTheApplicationViewModel_IfIveAlreadyAppliedForTheApprenticeship_IGetAViewModelWithError() { var candidateService = new Mock <ICandidateService>(); candidateService.Setup(cs => cs.GetTraineeshipApplication(It.IsAny <Guid>(), It.IsAny <int>())).Returns(new TraineeshipApplicationDetail()); var traineeshipApplicationProvider = new TraineeshipApplicationProviderBuilder().With(candidateService).Build(); var traineeshipApplicationViewModel = traineeshipApplicationProvider.GetApplicationViewModel(Guid.NewGuid(), 1); traineeshipApplicationViewModel.HasError().Should().BeTrue(); }
public void Error() { var candidateId = Guid.NewGuid(); var candidateService = new Mock <ICandidateService>(); candidateService.Setup(cs => cs.GetTraineeshipApplication(candidateId, ValidVacancyId)).Returns((TraineeshipApplicationDetail)null); candidateService.Setup(cs => cs.CreateTraineeshipApplication(candidateId, ValidVacancyId)).Throws(new Exception()); var traineeshipApplicationProvider = new TraineeshipApplicationProviderBuilder().With(candidateService).Build(); var viewModel = traineeshipApplicationProvider.GetApplicationViewModel(candidateId, ValidVacancyId); viewModel.Should().NotBeNull(); viewModel.ViewModelStatus.Should().Be(ApplicationViewModelStatus.Error); viewModel.ViewModelMessage.Should().Be(MyApplicationsPageMessages.CreateOrRetrieveApplicationFailed); viewModel.HasError().Should().BeTrue(); }
public void CreateApplicationReturnsNull() { var candidateId = Guid.NewGuid(); var candidateService = new Mock <ICandidateService>(); candidateService.Setup(cs => cs.GetTraineeshipApplication(candidateId, ValidVacancyId)).Returns((TraineeshipApplicationDetail)null); candidateService.Setup(cs => cs.CreateTraineeshipApplication(candidateId, ValidVacancyId)).Returns((TraineeshipApplicationDetail)null); var traineeshipVacancyProvider = new Mock <ITraineeshipVacancyProvider>(); traineeshipVacancyProvider.Setup(p => p.GetVacancyDetailViewModel(candidateId, ValidVacancyId)).Returns((TraineeshipVacancyDetailViewModel)null); var traineeshipApplicationProvider = new TraineeshipApplicationProviderBuilder().With(candidateService).With(traineeshipVacancyProvider).Build(); var viewModel = traineeshipApplicationProvider.GetApplicationViewModel(candidateId, ValidVacancyId); viewModel.Should().NotBeNull(); viewModel.ViewModelMessage.Should().Be(MyApplicationsPageMessages.TraineeshipNoLongerAvailable); viewModel.HasError().Should().BeTrue(); }
public void Ok() { var candidateId = Guid.NewGuid(); var traineeshipVacancyProvider = new Mock <ITraineeshipVacancyProvider>(); traineeshipVacancyProvider.Setup(p => p.GetVacancyDetailViewModel(candidateId, ValidVacancyId)).Returns(new TraineeshipVacancyDetailViewModel()); var candidateService = new Mock <ICandidateService>(); candidateService.Setup(cs => cs.GetTraineeshipApplication(candidateId, ValidVacancyId)).Returns((TraineeshipApplicationDetail)null); candidateService.Setup(cs => cs.CreateTraineeshipApplication(candidateId, ValidVacancyId)).Returns(new TraineeshipApplicationDetail()); var traineeshipApplicationProvider = new TraineeshipApplicationProviderBuilder().With(candidateService).With(traineeshipVacancyProvider).Build(); var viewModel = traineeshipApplicationProvider.GetApplicationViewModel(candidateId, ValidVacancyId); viewModel.Should().NotBeNull(); viewModel.ViewModelMessage.Should().BeNullOrEmpty(); viewModel.HasError().Should().BeFalse(); }
public void PatchWithVacancyDetail_VacancyHasError() { var candidateId = Guid.NewGuid(); var apprenticeshipVacancyDetailProvider = new Mock <ITraineeshipVacancyDetailProvider>(); apprenticeshipVacancyDetailProvider.Setup(p => p.GetVacancyDetailViewModel(candidateId, ValidVacancyId)).Returns(new VacancyDetailViewModel(ApprenticeshipVacancyDetailPageMessages.GetVacancyDetailFailed)); var candidateService = new Mock <ICandidateService>(); candidateService.Setup(cs => cs.GetTraineeshipApplication(candidateId, ValidVacancyId)).Returns((TraineeshipApplicationDetail)null); candidateService.Setup(cs => cs.CreateTraineeshipApplication(candidateId, ValidVacancyId)).Returns(new TraineeshipApplicationDetail()); var traineeshipApplicationProvider = new TraineeshipApplicationProviderBuilder().With(candidateService).With(apprenticeshipVacancyDetailProvider).Build(); var viewModel = traineeshipApplicationProvider.GetApplicationViewModel(candidateId, ValidVacancyId); viewModel.Should().NotBeNull(); viewModel.ViewModelMessage.Should().Be(ApprenticeshipVacancyDetailPageMessages.GetVacancyDetailFailed); viewModel.HasError().Should().BeTrue(); }