public void Initialize() { _databaseName = _fixture.Create <string>(); _dbContext = new DispatchingReadDbContextBuilder(_databaseName) .Build(); _sut = new CabRideRepository(_dbContext, Substitute.For <IApply <CabRide> >()); }
public void WhenNoDbContext_ShouldThrowArgumentNullException() { // Arrange DispatchingReadDbContext dbContext = null; // Act Action act = () => new CabRideRepository(dbContext, _mapper); // Assert act.Should().Throw <ArgumentNullException>(); }
public async Task WhenCabRideTableDoesNotContainRows_ShouldNotReturnCabRides() { // Arrange _dbContext = new DispatchingReadDbContextBuilder(_databaseName) .Build(); // Act var sut = new CabRideRepository(_dbContext, _mapper); var actual = await sut.GetAll(); // Assert actual.Should().BeEmpty(); }
public async Task WhenCabRidesTableContainsRows_ShouldReturnCabRides() { // Arrange _dbContext = new DispatchingReadDbContextBuilder(_databaseName) .WithCabRide(_fixture.Create <CabRide>()) .WithCabRide(_fixture.Create <CabRide>()) .Build(); // Act var sut = new CabRideRepository(_dbContext, _mapper); var actual = await sut.GetAll(); // Assert actual.Count().Should().Be(_dbContext.CabRides.Count()); }
public void Initialize() { _databaseName = _fixture.Create <string>(); _dbContext = new DispatchingReadDbContextBuilder(_databaseName) .WithCabRide(_fixture.Create <CabRide>()) .WithCabRide(_fixture.Create <CabRide>()) .Build(); // Bootstrap var serviceProvider = new ServiceCollection() .UseDispatchingReadModel(_fixture.Create <string>()) .AddTransient((s) => _dbContext) .BuildServiceProvider(); _sut = serviceProvider.GetService <ICabRideRepository>(); }
public void Initialize() { _databaseName = _fixture.Create <string>(); // Save a cabride in the database _cabRide = _fixture.Create <CabRide>(); using var dbContext = new DispatchingReadDbContextBuilder(_databaseName) .WithCabRide(_cabRide) .Build(); // Simulate another connection to that database _dbContext = new DispatchingReadDbContextBuilder(_databaseName) .Build(); _cabRide.CustomerId = _fixture.Create <Guid>(); _cabRide.TimeOfArrival = _fixture.Create <DateTime>(); _sut = new CabRideRepository(_dbContext, Substitute.For <IApply <CabRide> >()); }
public void Initialize() { _mapper = Substitute.For <IApply <CabRide> >(); _dbContext = new InMemoryDispatchingDbContext(_fixture.Create <string>()); }
protected override void Apply(DispatchingReadDbContext dispatchingDbContext) { // This case doesn't need any read data }
public DispatchingReadDbContextBuilder(string databaseName) { _dbContext = new InMemoryDispatchingDbContext(databaseName); }
protected abstract void Apply(DispatchingReadDbContext dispatchingDbContext);
protected override void Apply(DispatchingReadDbContext dispatchingDbContext) { }