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); }
public async Task Given_an_invalid_SearchAvailabilityRQ_checkout_greeter_than_checkin_Response_with_errors() { var request = Fixture.Build <SearchAvailabilityRq>() .With(p => p.CheckIn, DateTime.UtcNow) .With(p => p.CheckOut, DateTime.UtcNow.AddDays(-2)) .Create(); var validator = new SearchAvailabilityRqValidator(); var sut = new JccHubPropertiesService( validator, SupplierConnectorManagerMock.Object, ConnectorsConfiguration, logStorageMock.Object); var actual = await sut.SearchAvailability(request); Assert.False(actual.Success); Assert.NotEmpty(actual.Errors); }
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); }
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>())); }