Exemple #1
0
        public void Arrange()
        {
            _query = new GetReservationQuery {
                Id = _expectedReservationId
            };
            _validator = new Mock <IValidator <GetReservationQuery> >();
            _validator.Setup(x => x.ValidateAsync(It.IsAny <GetReservationQuery>()))
            .ReturnsAsync(new ValidationResult {
                ValidationDictionary = new Dictionary <string, string>()
            });
            _cancellationToken = new CancellationToken();
            _service           = new Mock <IAccountReservationService>();
            var reservation = new Reservation(Guid.Empty, 12345, DateTime.UtcNow, 1, "TestName");

            _service.Setup(x => x.GetReservation(_expectedReservationId)).ReturnsAsync(reservation);

            _handler = new GetReservationQueryHandler(_validator.Object, _service.Object);
        }
Exemple #2
0
        public void Arrange()
        {
            _validator = new Mock <IValidator <IReservationQuery> >();
            _validator.Setup(x => x.ValidateAsync(It.Is <GetReservationQuery>(c =>
                                                                              c.Id.Equals(_expectedReservationId))))
            .ReturnsAsync(new ValidationResult());

            _response = new GetReservationResponse
            {
                Id                     = _expectedReservationId,
                StartDate              = _expectedStartDate,
                ExpiryDate             = _expectedExpiryDate,
                AccountLegalEntityId   = ExpectedLegalEntityId,
                AccountLegalEntityName = ExpectedLegalEntityName,
                ProviderId             = ExpectedProviderId
            };


            _apiClient = new Mock <IApiClient>();
            _apiClient.Setup(x =>
                             x.Get <GetReservationResponse>(
                                 It.Is <ReservationApiRequest>(c =>
                                                               c.GetUrl.Equals(
                                                                   $"{ExpectedBaseUrl}api/reservations/{_expectedReservationId}"))))
            .ReturnsAsync(_response);

            _options = new Mock <IOptions <ReservationsApiConfiguration> >();
            _options.Setup(x => x.Value.Url).Returns(ExpectedBaseUrl);

            _reservationAuthorisationService = new Mock <IReservationAuthorisationService>();
            _reservationAuthorisationService.Setup(s =>
                                                   s.ProviderReservationAccessAllowed(It.IsAny <uint>(), It.IsAny <GetReservationResponse>()))
            .ReturnsAsync(true);

            _handler = new GetReservationQueryHandler(_validator.Object, _apiClient.Object, _options.Object, _reservationAuthorisationService.Object);
        }