public void TrainingCourseChanges()
        {
            var candidateId = Guid.NewGuid();
            var traineeshipApplicationProvider = new TraineeshipApplicationProviderBuilder().Build();
            var savedTraineeshipViewModel      = new TraineeshipApplicationViewModelBuilder().Build();

            var trainingCourses = new List <TrainingCourseViewModel>
            {
                new TrainingCourseViewModelBuilder()
                .WithProvider("Provider")
                .Build()
            };

            var monitoringInformationViewModel = new Fixture().Build <MonitoringInformationViewModel>().Create();

            var traineeshipViewModel = new TraineeshipApplicationViewModelBuilder()
                                       .WithTrainingCourses(trainingCourses)
                                       .WithMonitoringInformation(monitoringInformationViewModel)
                                       .Build();

            var viewModel = traineeshipApplicationProvider
                            .PatchApplicationViewModel(candidateId, savedTraineeshipViewModel, traineeshipViewModel);

            viewModel.Should().NotBeNull();
            viewModel.ViewModelMessage.Should().BeNull();
            viewModel.HasError().Should().BeFalse();
            viewModel.Candidate.HasTrainingCourses.Should().BeTrue();
            viewModel.Candidate.TrainingCourses.Should().Equal(trainingCourses);
        }
        public void ShouldPatchMonitoringInformation()
        {
            // Arrange.
            var candidateId = Guid.NewGuid();
            var traineeshipApplicationProvider = new TraineeshipApplicationProviderBuilder().Build();
            var savedViewModel = new TraineeshipApplicationViewModelBuilder().Build();

            var monitoringInformationViewModel = new Fixture()
                                                 .Build <MonitoringInformationViewModel>()
                                                 .Create();

            var submittedViewModel = new TraineeshipApplicationViewModelBuilder()
                                     .WithMonitoringInformation(monitoringInformationViewModel)
                                     .Build();

            // Act.
            var patchedViewModel = traineeshipApplicationProvider
                                   .PatchApplicationViewModel(candidateId, savedViewModel, submittedViewModel);

            patchedViewModel.Should().NotBeNull();
            patchedViewModel.ViewModelMessage.Should().BeNull();
            patchedViewModel.HasError().Should().BeFalse();

            // Assert.
            patchedViewModel.Candidate.MonitoringInformation.Should().Be(monitoringInformationViewModel);
        }
        public void ShouldPatchRequiresSupportForInterview(
            bool isJavascript,
            bool requiresSupportForInterview,
            string anythingWeCanDoToSupportYourInterview,
            string expectedAythingWeCanDoToSupportYourInterview)
        {
            // Arrange.
            var candidateId = Guid.NewGuid();
            var traineeshipApplicationProvider = new TraineeshipApplicationProviderBuilder().Build();
            var savedModel = new TraineeshipApplicationViewModelBuilder().Build();

            var submittedModel = new TraineeshipApplicationViewModelBuilder()
                                 .IsJavascript(isJavascript)
                                 .WithMonitoringInformation(new MonitoringInformationViewModel
            {
                RequiresSupportForInterview           = requiresSupportForInterview,
                AnythingWeCanDoToSupportYourInterview = anythingWeCanDoToSupportYourInterview
            })
                                 .Build();

            // Act.
            var patchedViewModel = traineeshipApplicationProvider
                                   .PatchApplicationViewModel(candidateId, savedModel, submittedModel);

            patchedViewModel.Should().NotBeNull();
            patchedViewModel.ViewModelMessage.Should().BeNull();
            patchedViewModel.HasError().Should().BeFalse();

            // Assert.
            patchedViewModel.Candidate.MonitoringInformation.AnythingWeCanDoToSupportYourInterview
            .Should().Be(expectedAythingWeCanDoToSupportYourInterview);
        }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        public void NullSavedViewModel()
        {
            var candidateId = Guid.NewGuid();
            var traineeshipApplicationProvider = new TraineeshipApplicationProviderBuilder().Build();

            var traineeshipViewModel = new TraineeshipApplicationViewModelBuilder().Build();

            var viewModel = traineeshipApplicationProvider.PatchApplicationViewModel(candidateId, null, traineeshipViewModel);

            viewModel.Should().NotBeNull();
            viewModel.ViewModelMessage.Should().Be(ApplicationPageMessages.SubmitApplicationFailed);
            viewModel.HasError().Should().BeTrue();
        }
Exemplo n.º 6
0
        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();
        }
Exemplo n.º 7
0
        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();
        }
Exemplo n.º 8
0
        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();
        }
Exemplo n.º 9
0
        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();
        }
Exemplo n.º 10
0
        public void WorkExperienceChanges()
        {
            var candidateId = Guid.NewGuid();
            var traineeshipApplicationProvider = new TraineeshipApplicationProviderBuilder().Build();

            var savedTraineeshipViewModel = new TraineeshipApplicationViewModelBuilder().Build();
            var workExperience            = new List <WorkExperienceViewModel> {
                new WorkExperienceViewModelBuilder().WithDescription("Work").WithEmployer("Employer").Build()
            };
            var traineeshipViewModel = new TraineeshipApplicationViewModelBuilder().WithWorkExperience(workExperience).Build();

            var viewModel = traineeshipApplicationProvider.PatchApplicationViewModel(candidateId, savedTraineeshipViewModel, traineeshipViewModel);

            viewModel.Should().NotBeNull();
            viewModel.ViewModelMessage.Should().BeNull();
            viewModel.HasError().Should().BeFalse();
            viewModel.Candidate.HasWorkExperience.Should().BeTrue();
            viewModel.Candidate.WorkExperience.Should().Equal(workExperience);
        }
Exemplo n.º 11
0
        public void QualificationChanges()
        {
            var candidateId = Guid.NewGuid();
            var traineeshipApplicationProvider = new TraineeshipApplicationProviderBuilder().Build();

            var savedTraineeshipViewModel = new TraineeshipApplicationViewModelBuilder().Build();
            var qualifications            = new List <QualificationsViewModel> {
                new QualificationsViewModelBuilder().WithSubject("Maths").WithGrade("C").WithYear("2015").Build()
            };
            var traineeshipViewModel = new TraineeshipApplicationViewModelBuilder().WithQualifications(qualifications).Build();

            var viewModel = traineeshipApplicationProvider.PatchApplicationViewModel(candidateId, savedTraineeshipViewModel, traineeshipViewModel);

            viewModel.Should().NotBeNull();
            viewModel.ViewModelMessage.Should().BeNull();
            viewModel.HasError().Should().BeFalse();
            viewModel.Candidate.HasQualifications.Should().BeTrue();
            viewModel.Candidate.Qualifications.Should().Equal(qualifications);
        }