public async Task Then_The_Employer_Reservation_Is_Returned_By_Id()
        {
            //Arrange
            _cacheReservationRepository
            .Setup(r => r.GetEmployerReservation(It.IsAny <Guid>()))
            .ReturnsAsync(_cachedReservation);

            var command = new GetCachedReservationQuery
            {
                Id = _cachedReservation.Id
            };

            //Act
            var actual = await _handler.Handle(command, new CancellationToken());

            //Assert
            Assert.AreEqual(_cachedReservation.Id, actual.Id);
            Assert.AreEqual(_cachedReservation.TrainingDate, actual.TrainingDate);
            Assert.AreEqual(_cachedReservation.CohortRef, actual.CohortRef);
            Assert.AreEqual(_cachedReservation.IsEmptyCohortFromSelect, actual.IsEmptyCohortFromSelect);
            Assert.AreEqual(_cachedReservation.UkPrn, actual.UkPrn);

            _cacheReservationRepository.Verify(r => r.GetEmployerReservation(command.Id), Times.Once);
            _cacheReservationRepository.Verify(r => r.GetProviderReservation(It.IsAny <Guid>(), It.IsAny <uint>()), Times.Never);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Review(ReservationsRouteModel routeModel)
        {
            GetCachedReservationResult cachedReservation;

            try
            {
                var query = new GetCachedReservationQuery
                {
                    Id = routeModel.Id.GetValueOrDefault()
                };

                cachedReservation = await _mediator.Send(query);
            }
            catch (ValidationException e)
            {
                var errors = new StringBuilder();
                errors.AppendLine();
                foreach (var member in e.ValidationResult.MemberNames)
                {
                    errors.AppendLine(member);
                }

                _logger.LogWarning($"Validation Error when reviewing a reservation: {errors}");

                return(RedirectToRoute(RouteNames.Error500));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.Message);
                return(RedirectToRoute(RouteNames.Error500));
            }

            routeModel.FromReview = true;

            var viewModel = new ReviewViewModel(
                routeModel,
                cachedReservation.TrainingDate,
                cachedReservation.CourseDescription,
                cachedReservation.AccountLegalEntityName,
                cachedReservation.AccountLegalEntityPublicHashedId);

            return(View(viewModel.ViewName, viewModel));
        }