public void Initialize()
        {
            _databaseName = _fixture.Create <string>();

            _dbContext = new DispatchingReadDbContextBuilder(_databaseName)
                         .Build();

            _sut = new CabRideRepository(_dbContext, Substitute.For <IApply <CabRide> >());
        }
Esempio n. 2
0
        public void WhenNoDbContext_ShouldThrowArgumentNullException()
        {
            // Arrange
            DispatchingReadDbContext dbContext = null;

            // Act
            Action act = () => new CabRideRepository(dbContext, _mapper);

            // Assert
            act.Should().Throw <ArgumentNullException>();
        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
        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());
        }
Esempio n. 5
0
        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>();
        }
Esempio n. 6
0
        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> >());
        }
Esempio n. 7
0
 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
 }
Esempio n. 9
0
 public DispatchingReadDbContextBuilder(string databaseName)
 {
     _dbContext = new InMemoryDispatchingDbContext(databaseName);
 }
Esempio n. 10
0
 protected abstract void Apply(DispatchingReadDbContext dispatchingDbContext);
Esempio n. 11
0
 protected override void Apply(DispatchingReadDbContext dispatchingDbContext)
 {
 }