public async Task WhenData_ShouldMapToDomainModel() { // Arrange var dbContext = new DispatchingDbContextBuilder(_fixture.Create <string>()) .WithCustomerLocation(_location) .WithCab(_nearestCabId, _distance) .Build(); // Act using (dbContext) { var sut = new CabRepository(dbContext, _domainModelMapper, _persistenceModelMapper); await sut.GetNearestAvailableCab(_location); // Assert _persistenceModelMapper .Received(1) .Map(Arg.Is(dbContext.Cabs.Single())); } }
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 WhenLocation_ShouldReturnResultFromPersistenceModelMapper() { // Arrange var dbContext = new DispatchingDbContextBuilder() .WithCustomerLocation(_location) .WithCab(_nearestCabId, _distance) .Build(); var expected = _fixture.Create <Cab>(); _persistenceModelMapper .Map(Arg.Any <PersistenceModel.Cab>()) .Returns(expected); // Act using (dbContext) { var sut = new CabRepository(dbContext, _domainModelMapper, _persistenceModelMapper); var actual = await sut.GetNearestAvailableCab(_location); // Assert actual.Should().Be(expected); } }