public void Repository_CreatesAndReadsRoutesAndWarehouses() { var firstUow = new ConnectedUnitOfWork(); var origin = new Warehouse { City = "Gotham City", State = "New Jersey" }; var destination = new Warehouse { City = "Metropolis", State = "New Jersey" }; firstUow.BeginTransaction(IsolationLevel.ReadUncommitted); origin = firstUow.WarehouseRepository.Create(origin); destination = firstUow.WarehouseRepository.Create(destination); var route = new Route { OriginId = origin.Id, DestinationId = destination.Id, Distance = 1000 }; route = firstUow.RouteRepository.Create(route); var secondUow = new ConnectedUnitOfWork(); secondUow.BeginTransaction(IsolationLevel.ReadUncommitted); var routeFromDatabase = secondUow.RouteRepository.ReadOne(route.Id); Assert.Equal(route.Id, routeFromDatabase.Id); Assert.Equal(origin.Id, routeFromDatabase.OriginId); Assert.Equal(route.Distance, routeFromDatabase.Distance); Assert.Equal(destination.Id, routeFromDatabase.DestinationId); secondUow.RollbackTransaction(); firstUow.RollbackTransaction(); }
private double RunConnectedRepositoryReadMethod(int readsCount) { using (var uow = new ConnectedUnitOfWork()) { uow.BeginTransaction(IsolationLevel.ReadUncommitted); var sw = new Stopwatch(); sw.Start(); for (var i = 0; i < readsCount; i++) { var entity = uow.WarehouseRepository.ReadOne(1); } sw.Stop(); var averageTime = (double)sw.ElapsedMilliseconds / ReadSampleSize; return(averageTime); } }
private double RunConnectedRepositoryWriteMethod(List <Warehouse> warehousesToInsert) { using (var uow = new ConnectedUnitOfWork()) { uow.BeginTransaction(IsolationLevel.ReadUncommitted); var sw = new Stopwatch(); sw.Start(); foreach (var warehouse in warehousesToInsert) { uow.WarehouseRepository.Create(warehouse); } sw.Stop(); uow.RollbackTransaction(); var averageTime = (double)sw.ElapsedMilliseconds / WriteSampleSize; return(averageTime); } }