Пример #1
0
        public void WhenLatitude_ShouldMapLatitude()
        {
            // Arrange
            var actual = new PersistenceModel.Cab();

            // Act
            _sut.Apply(_itemToMap, actual);

            // Assert
            actual.Latitude.Should().Be(_itemToMap.CurrentLocation.Latitude);
        }
Пример #2
0
        public void WhenId_ShouldMapId()
        {
            // Arrange
            var actual = new PersistenceModel.Cab();

            // Act
            _sut.Apply(_itemToMap, actual);

            // Assert
            actual.Id.Should().Be(_itemToMap.Id.ToGuid());
        }
Пример #3
0
        public async Task Initialize()
        {
            _databaseName = _fixture.Create <string>();

            // Arrange
            _cab       = _fixture.Create <Cab>();
            _mappedCab = _fixture.Create <PersistenceModel.Cab>();

            var persistenceModelMapper = Substitute.For <IMapToDomainModel <PersistenceModel.Cab, Cab> >();
            var domainModelMapper      = CreateDomainModelMapper(_mappedCab);

            // Act
            using (var dbContext = CreateDbContext())
            {
                var sut = new CabRepository(dbContext, domainModelMapper, persistenceModelMapper);
                await sut.Update(_cab);
            }
        }
Пример #4
0
        public DispatchingDbContextBuilder WithCab(Guid cabId, decimal distance)
        {
            var cab = new PersistenceModel.Cab
            {
                Id        = cabId,
                Latitude  = _fixture.Create <decimal>(),
                Longitude = _fixture.Create <decimal>()
            };

            _dbContext.Cabs.Add(cab);

            _dbContext.Distances.Add(new PersistenceModel.Distance
            {
                Id            = _fixture.Create <Guid>(),
                Kilometers    = distance,
                ToLongitude   = _location.Longitude,
                ToLatitude    = _location.Latitude,
                FromLatitude  = cab.Latitude,
                FromLongitude = cab.Longitude
            });

            return(this);
        }
Пример #5
0
        private IMapToPersistenceModel <Cab, PersistenceModel.Cab> CreateDomainModelMapper(PersistenceModel.Cab cab)
        {
            var mapper = Substitute.For <IMapToPersistenceModel <Cab, PersistenceModel.Cab> >();

            mapper
            .CreateNew()
            .Returns(cab);

            return(mapper);
        }
Пример #6
0
 private DispatchingDbContext CreateDbContext(PersistenceModel.Cab cab)
 {
     return(new DispatchingDbContextBuilder(_databaseName)
            .WithCab(cab)
            .Build());
 }
Пример #7
0
 public DispatchingDbContextBuilder WithCab(PersistenceModel.Cab cab)
 {
     _dbContext.Cabs.Add(cab);
     return(this);
 }