Exemple #1
0
        public async Task Then_It_Returns_The_ViewModel(
            ReservationsRouteModel routeModel,
            GetReservationResult mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Frozen] Mock <IOptions <ReservationsWebConfiguration> > mockConfig,
            ReservationsController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(It.IsAny <GetReservationQuery>(), CancellationToken.None))
            .ReturnsAsync(mediatorResult);

            var result = await controller.Completed(routeModel);

            var viewResult = result.Should().BeOfType <ViewResult>().Subject;
            var model      = viewResult.Model.Should().BeOfType <CompletedViewModel>().Subject;

            viewResult.ViewName.Should().Be(ViewNames.ProviderCompleted);

            model.AccountLegalEntityName.Should().Be(mediatorResult.AccountLegalEntityName);
            model.TrainingDateDescription.Should().Be(new TrainingDateModel
            {
                StartDate = mediatorResult.StartDate,
                EndDate   = mediatorResult.ExpiryDate
            }.GetGDSDateString());
            model.CourseDescription.Should().Be(mediatorResult.Course.CourseDescription);
            model.StartDate.Should().Be(mediatorResult.StartDate);
            model.CourseId.Should().Be(mediatorResult.Course.Id);
            model.UkPrn.Should().Be(mediatorResult.UkPrn);
            model.CohortRef.Should().Be(routeModel.CohortReference);
        }
Exemple #2
0
        public void Then_Sets_CourseDescription(
            GetReservationResult getReservationResult)
        {
            var viewModel = new DeleteViewModel(getReservationResult);

            viewModel.CourseDescription.Should().Be(getReservationResult.Course.CourseDescription);
        }
Exemple #3
0
        public void Then_Sets_AccountLegalEntityName(
            GetReservationResult getReservationResult)
        {
            var viewModel = new DeleteViewModel(getReservationResult);

            viewModel.AccountLegalEntityName.Should().Be(getReservationResult.AccountLegalEntityName);
        }
Exemple #4
0
        public void Then_Sets_ReservationId(
            GetReservationResult getReservationResult)
        {
            var viewModel = new DeleteViewModel(getReservationResult);

            viewModel.Id.Should().Be(getReservationResult.ReservationId);
        }
        public async Task And_Has_Ukprn_And_ReservationId_And_Not_CohortRef_Then_Redirects_To_AddApprentice_With_Reservation_Details(
            ReservationsRouteModel routeModel,
            SelectReservationViewModel viewModel,
            GetReservationResult reservationResult,
            string addApprenticeUrl,
            [Frozen] Mock <IExternalUrlHelper> mockUrlHelper,
            [Frozen] Mock <IMediator> mockMediator,
            SelectReservationsController controller)
        {
            routeModel.CohortReference = string.Empty;
            viewModel.CohortReference  = string.Empty;
            mockMediator.Setup(x => x.Send(It.Is <GetReservationQuery>(c => c.Id.Equals(viewModel.SelectedReservationId)),
                                           It.IsAny <CancellationToken>()))
            .ReturnsAsync(reservationResult);
            mockUrlHelper
            .Setup(helper => helper.GenerateAddApprenticeUrl(viewModel.SelectedReservationId.Value,
                                                             routeModel.AccountLegalEntityPublicHashedId, reservationResult.Course.Id, routeModel.UkPrn.Value,
                                                             reservationResult.StartDate, viewModel.CohortReference, routeModel.EmployerAccountId,
                                                             true, string.Empty, viewModel.JourneyData))
            .Returns(addApprenticeUrl);

            var result = await controller.PostSelectReservation(routeModel, viewModel) as RedirectResult;

            result.Url.Should().Be(addApprenticeUrl);
        }
Exemple #6
0
        public void And_Course_Null_Then_Sets_CourseDescription_Null(
            GetReservationResult getReservationResult)
        {
            getReservationResult.Course = null;

            var viewModel = new DeleteViewModel(getReservationResult);

            viewModel.CourseDescription.Should().Be("Unknown");
        }
Exemple #7
0
 public DeleteViewModel(GetReservationResult queryResult)
 {
     Id = queryResult.ReservationId;
     StartDateDescription = new TrainingDateModel
     {
         StartDate = queryResult.StartDate,
         EndDate   = queryResult.ExpiryDate
     }.GetGDSDateString();
     AccountLegalEntityName = queryResult.AccountLegalEntityName;
     CourseDescription      = queryResult.Course?.CourseDescription ??
                              new Course(null, null, 0).CourseDescription;
 }
Exemple #8
0
        public void Then_Sets_StartDateDescription(
            GetReservationResult getReservationResult)
        {
            var expectedDateDescription = new TrainingDateModel
            {
                StartDate = getReservationResult.StartDate,
                EndDate   = getReservationResult.ExpiryDate
            }.GetGDSDateString();

            var viewModel = new DeleteViewModel(getReservationResult);

            viewModel.StartDateDescription.Should().Be(expectedDateDescription);
        }
Exemple #9
0
        public async Task Then_It_Calls_Mediator_To_Get_Reservation(
            ReservationsRouteModel routeModel,
            GetReservationResult mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            ReservationsController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(It.IsAny <GetReservationQuery>(), CancellationToken.None))
            .ReturnsAsync(mediatorResult);

            await controller.Completed(routeModel);

            mockMediator.Verify(mediator => mediator.Send(It.Is <GetReservationQuery>(query => query.Id == routeModel.Id), CancellationToken.None));
        }
        public async Task Then_Sets_Reservation_Details_On_ViewModel(
            ReservationsRouteModel routeModel,
            GetReservationResult getReservationResult,
            [Frozen] Mock <IMediator> mockMediator,
            ManageReservationsController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.IsAny <GetReservationQuery>(),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(getReservationResult);

            var result = await controller.Delete(routeModel);

            var viewModel = result.Should().BeOfType <ViewResult>()
                            .Which.Model.Should().BeOfType <DeleteViewModel>().Subject;

            viewModel.Should().BeEquivalentTo(new DeleteViewModel(getReservationResult));
        }
Exemple #11
0
        public async Task And_No_UkPrn_Then_It_Uses_Employer_View_And_Uses_Provider_Id_If_Not_Null(
            ReservationsRouteModel routeModel,
            GetReservationResult mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Frozen] Mock <IOptions <ReservationsWebConfiguration> > configuration,
            ReservationsController controller)
        {
            routeModel.UkPrn     = null;
            mediatorResult.UkPrn = null;
            mockMediator
            .Setup(mediator => mediator.Send(It.IsAny <GetReservationQuery>(), CancellationToken.None))
            .ReturnsAsync(mediatorResult);

            var result = await controller.Completed(routeModel);

            var viewResult = result.Should().BeOfType <ViewResult>().Subject;

            viewResult.ViewName.Should().Be(ViewNames.EmployerCompleted);
            var model = viewResult.Model.Should().BeOfType <CompletedViewModel>().Subject;

            model.UkPrn.Should().Be(routeModel.ProviderId);
        }