public void Then_Throws_Exception_If_Reservation_Not_Found_In_Cache(CacheReservationCourseCommand command) { var expectedException = new CachedReservationNotFoundException(command.Id); _mockCacheRepository.Setup(r => r.GetProviderReservation(It.IsAny <Guid>(), It.IsAny <uint>())) .ThrowsAsync(expectedException); var exception = Assert.ThrowsAsync <CachedReservationNotFoundException>(() => _commandHandler.Handle(command, CancellationToken.None)); Assert.AreEqual(expectedException, exception); }
public async Task And_CachedReservationNotFoundException_And_Has_Ukprn_Then_Redirects_To_ProviderIndex( ReservationsRouteModel routeModel, PostReviewViewModel viewModel, CachedReservationNotFoundException notFoundException, [Frozen] Mock <IMediator> mockMediator, ReservationsController controller) { mockMediator.Setup(x => x.Send(It.IsAny <CreateReservationCommand>(), It.IsAny <CancellationToken>())) .ThrowsAsync(notFoundException); var actual = await controller.PostReview(routeModel, viewModel); actual.Should().NotBeNull(); var redirectToRouteResult = actual as RedirectToRouteResult; redirectToRouteResult.Should().NotBeNull(); redirectToRouteResult?.RouteName.Should().Be(RouteNames.ProviderIndex); }
public async Task And_CachedReservationNotFoundException_And_Has_Ukprn_Then_Redirect_To_ProviderIndex( ReservationsRouteModel routeModel, TrainingDateModel trainingDateModel, ApprenticeshipTrainingFormModel formModel, CachedReservationNotFoundException notFoundException) { formModel.StartDate = JsonConvert.SerializeObject(trainingDateModel); formModel.SelectedCourseId = _course.Id; _mediator .Setup(mediator => mediator.Send(It.IsAny <GetCachedReservationQuery>(), It.IsAny <CancellationToken>())) .ThrowsAsync(notFoundException); var actual = await _controller.PostApprenticeshipTraining(routeModel, formModel) as RedirectToRouteResult; actual.Should().NotBeNull(); actual.RouteName.Should().Be(RouteNames.ProviderIndex); }
public async Task And_CachedReservationNotFoundException_And_No_Ukprn_Then_Redirects_To_EmployerIndex( ReservationsRouteModel routeModel, PostReviewViewModel viewModel, CachedReservationNotFoundException notFoundException, [Frozen] Mock <IMediator> mockMediator, ReservationsController controller) { routeModel.UkPrn = null; var claim = new Claim(EmployerClaims.IdamsUserIdClaimTypeIdentifier, Guid.NewGuid().ToString()); controller.HttpContext.User = new ClaimsPrincipal(new ClaimsIdentity(new[] { claim })); viewModel.Reserve = true; mockMediator.Setup(x => x.Send(It.IsAny <CreateReservationCommand>(), It.IsAny <CancellationToken>())) .ThrowsAsync(notFoundException); var actual = await controller.PostReview(routeModel, viewModel); actual.Should().NotBeNull(); var redirectToRouteResult = actual as RedirectToRouteResult; redirectToRouteResult.Should().NotBeNull(); redirectToRouteResult?.RouteName.Should().Be(RouteNames.EmployerIndex); }