public async Task WhenLocation_ShouldReturnNearestCab() { // Arrange var dbContext = new DispatchingDbContextBuilder() .WithCustomerLocation(_location) .WithCab(_nearestCabId, _distance) .WithCab(_fixture.Create <Guid>(), _distance + _fixture.Create <decimal>()) .Build(); // Act using (dbContext) { var sut = new CabRepository(dbContext, _domainModelMapper, _persistenceModelMapper); await sut.GetNearestAvailableCab(_location); // Assert _persistenceModelMapper .Received(1) .Map(Arg.Is <PersistenceModel.Cab>(x => x.Id == _nearestCabId)); } }
public async Task WhenItemExists_ShouldMapEntityIntoDomainModel() { // Arrange var cab = _fixture.Create <PersistenceModel.Cab>(); var cabId = new Id <Cab>(cab.Id); var dbContext = new DispatchingDbContextBuilder() .WithCab(cab) .Build(); // Act using (dbContext) { var sut = new CabRepository(dbContext, _domainModelMapper, _persistenceModelMapper); await sut.Get(cabId); // Assert _persistenceModelMapper .Received(1) .Map(Arg.Is <PersistenceModel.Cab>(x => x.Id == cab.Id)); } }
public async Task WhenUtrechtCentraalExists_ShouldMapLocation() { // Arrange var location = _fixture.Create <PersistenceModel.Location>(); location.Name = "Utrecht Centraal"; using (_context) { _context.Locations.Add(location); _context.SaveChanges(); // Act var sut = new LocationRepository(_context, _persistenceModelMapper); await sut.GetTrainStationLocation(); // Assert _persistenceModelMapper .Received(1) .Map(Arg.Is(location)); } }