예제 #1
0
        public void GivenInvalidVacancyIdString_ThenVacancyNotFound(string vacancyId)
        {
            var mediator = new ApprenticeshipApplicationMediatorBuilder().Build();
            var response = mediator.Apply(Guid.NewGuid(), vacancyId);

            response.AssertCode(ApprenticeshipApplicationMediatorCodes.Apply.VacancyNotFound, false);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        public void Ok()
        {
            var candidateId = Guid.NewGuid();
            var apprenticeshipApplicationProvider = new Mock <IApprenticeshipApplicationProvider>();

            apprenticeshipApplicationProvider.Setup(p => p.GetApplicationViewModel(candidateId, ValidVacancyId))
            .Returns(new ApprenticeshipApplicationViewModelBuilder().WithVacancyStatus(VacancyStatuses.Live).Build());
            var mediator =
                new ApprenticeshipApplicationMediatorBuilder().With(apprenticeshipApplicationProvider).Build();

            var response = mediator.View(candidateId, ValidVacancyId);

            response.AssertCode(ApprenticeshipApplicationMediatorCodes.View.Ok, true);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        public void VacancyNotFound()
        {
            var viewModel =
                new ApprenticeshipApplicationViewModelBuilder().WithStatus(ApplicationStatuses.ExpiredOrWithdrawn)
                .Build();
            var apprenticeshipApplicationProvider = new Mock <IApprenticeshipApplicationProvider>();

            apprenticeshipApplicationProvider.Setup(p => p.GetApplicationViewModel(It.IsAny <Guid>(), It.IsAny <int>()))
            .Returns(viewModel);
            var mediator =
                new ApprenticeshipApplicationMediatorBuilder().With(apprenticeshipApplicationProvider).Build();

            var response = mediator.View(Guid.NewGuid(), ValidVacancyId);

            //Should still be able to view the application even if the vacancy is not available
            response.AssertCode(ApprenticeshipApplicationMediatorCodes.View.Ok, true);
        }
예제 #9
0
        public void ApplicationNotFound()
        {
            var viewModel =
                new ApprenticeshipApplicationViewModelBuilder().HasError(
                    ApplicationViewModelStatus.ApplicationNotFound, MyApplicationsPageMessages.ApplicationNotFound)
                .Build();
            var apprenticeshipApplicationProvider = new Mock <IApprenticeshipApplicationProvider>();

            apprenticeshipApplicationProvider.Setup(p => p.GetApplicationViewModel(It.IsAny <Guid>(), It.IsAny <int>()))
            .Returns(viewModel);
            var mediator =
                new ApprenticeshipApplicationMediatorBuilder().With(apprenticeshipApplicationProvider).Build();

            var response = mediator.View(Guid.NewGuid(), ValidVacancyId);

            //Should still be able to view the application even if the vacancy is not available
            response.AssertMessage(ApprenticeshipApplicationMediatorCodes.View.ApplicationNotFound,
                                   ApplicationPageMessages.ViewApplicationFailed, UserMessageLevel.Warning, true);
        }
예제 #10
0
        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);
        }