public async Task WhenItemDoesNotExists_ShouldThrowKeyNotFoundException() { // Arrange var cabId = _fixture.Create <Id <Cab> >(); var dbContext = new DispatchingDbContextBuilder() .Build(); // Act using (dbContext) { var sut = new CabRepository(dbContext, _domainModelMapper, _persistenceModelMapper); Func <Task> act = async() => await sut.Get(cabId); // Assert act.Should().Throw <KeyNotFoundException>(); } }
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)); } }