Esempio n. 1
0
        public async Task Given_an_invalid_SearchAvailabilityRQ_Response_with_errors()
        {
            var request = Fixture.Build <SearchAvailabilityRq>()
                          .With(p => p.CheckIn, DateTime.UtcNow)
                          .With(p => p.CheckOut, DateTime.UtcNow.AddDays(-1))
                          .Create();

            var resonseValidator = Fixture
                                   .Build <ResponseValidator>()
                                   .With(p => p.IsValid, false)
                                   .Create();

            SearchAvalibilityRqValidatorMock
            .Setup(p => p.Validate(request))
            .Returns(resonseValidator);

            var sut = new JccHubPropertiesService(
                SearchAvalibilityRqValidatorMock.Object,
                SupplierConnectorManagerMock.Object,
                ConnectorsConfiguration,
                logStorageMock.Object);

            var actual = await sut.SearchAvailability(request);

            SearchAvalibilityRqValidatorMock.Verify(p => p.Validate(request));

            Assert.False(actual.Success);
            Assert.NotEmpty(actual.Errors);
        }
Esempio n. 2
0
        public async Task Given_an_valid_SearchAvailabilityRQ_Response_without_errors()
        {
            var request          = Fixture.Create <SearchAvailabilityRq>();
            var resonseValidator = GetValidResponseValidator();

            SearchAvalibilityRqValidatorMock
            .Setup(p => p.Validate(request))
            .Returns(resonseValidator);


            var sut = new JccHubPropertiesService(
                SearchAvalibilityRqValidatorMock.Object,
                SupplierConnectorManagerMock.Object,
                ConnectorsConfiguration,
                logStorageMock.Object);

            var actual = await sut.SearchAvailability(request);

            SearchAvalibilityRqValidatorMock.Verify(p => p.Validate(request));

            Assert.True(actual.Success);
            Assert.Empty(actual.Errors);
        }
Esempio n. 3
0
        public async Task Verify_is_using_ISupplierConnectorManager_to_returns_ISupplierConnectorsAsync()
        {
            var supplierConnectors = Fixture.CreateMany <ConcreteSupplierConector>();
            var request            = Fixture.Create <SearchAvailabilityRq>();
            var resonseValidator   = GetValidResponseValidator();

            SupplierConnectorManagerMock
            .Setup(p => p.GetSupplierConnectors(It.IsAny <ConnectorsConfiguration>()))
            .Returns(Task.FromResult((IEnumerable <ISupplierConnector>)supplierConnectors));

            SearchAvalibilityRqValidatorMock
            .Setup(p => p.Validate(request))
            .Returns(resonseValidator);

            var sut = new JccHubPropertiesService(
                SearchAvalibilityRqValidatorMock.Object,
                SupplierConnectorManagerMock.Object,
                ConnectorsConfiguration,
                logStorageMock.Object);

            var actual = await sut.SearchAvailability(request);

            SupplierConnectorManagerMock.Verify(p => p.GetSupplierConnectors(It.IsAny <ConnectorsConfiguration>()));
        }