public async Task WhenNotified_ShouldAddItemToCache() { _addressRepository.GetByUserId(0).ReturnsForAnyArgs(new List <Address> { AddressFake.Valid() }); await _handler.Handle(_notification, CancellationToken.None); _cacheDbRepository.ReceivedWithAnyArgs(1).AddItemToCache(null, Arg.Any <List <UserAddress> >()); }
public AddressCreatedEventCacheHandlerTests() { var logger = Substitute.For <ILogger <AddressCreatedEventCacheHandler> >(); _cacheDbRepository = Substitute.For <ICacheDbRepository>(); _addressRepository = Substitute.For <IAddressRepository>(); _handler = new AddressCreatedEventCacheHandler(logger, _cacheDbRepository, _addressRepository); _notification = new AddressCreatedEvent(AddressFake.Valid()); }
public async Task Should_CallGoogleMapsApiOKAsync() { var connector = new GoogleMapsConnector(_configuration); var location = await connector.GetLocationAsync(AddressFake.GetAddress()); Assert.NotNull(location); Assert.True(location.Latitude != 0); Assert.True(location.Longitude != 0); }
public async Task Should_NotChangeAddressAsync() { _addressRepository.SaveAsync(Arg.Any <IAddress>()) .Returns(AddressFake.GetAddress()); _driverRepository.HasDriverAsync(Arg.Any <int>()) .Returns(false); var response = await _handler.Handle(GetRequest(), CancellationToken.None); Assert.True(response.HasMessages); }
public async Task Should_GetAddressAsync() { _addressRepository.GetByDriverIdAsync(Arg.Any <int>()) .Returns(new IAddress[] { AddressFake.GetAddress(), AddressFake.GetAddress() }); var response = await _handler.Handle(GetRequest(), CancellationToken.None); Assert.False(response.HasMessages); Assert.NotNull(response.Value); var result = (IEnumerable <IAddress>)response.Value; Assert.True(result.Any()); }
public void ShouldRequireValidSkills() { var entity = new Developer(_faker.Random.Long(), _faker.Person.Email, _faker.Person.FullName, null, 0, ContactFake.Build(), AddressFake.Build(), null, null); var validation = entity.Validate(); validation.Should().BeFalse(); entity.Errors.Should().NotBeNullOrEmpty(); entity.Errors.Should().Contain("Skills is required"); }