public void WhenISelectAllTheSingleIntKeyEntitiesUsingEntityFramework()
 {
     using (var dbContext = new EfDbContext(_testContext.DatabaseConnection, _compiledModel, false))
     {
         _testContext.QueriedEntities.AddRange(dbContext.BenchmarkEntities);
     }
 }
 public void WhenISelectAllTheSingleIntKeyEntitiesThatIPreviouslyInsertedUsingEntityFramework()
 {
     foreach (var entity in _testContext.LocalEntities.OfType<SimpleBenchmarkEntity>())
     {
         using (var dbContext = new EfDbContext(_testContext.DatabaseConnection, _compiledModel, false))
         {
             _testContext.QueriedEntities.Add(dbContext.BenchmarkEntities.AsNoTracking().Single(queriedEntity => queriedEntity.Id == entity.Id));
         }
     }
 }
 public void WhenIDeleteAllTheInsertedSingleIntKeyEntitiesUsingEntityFramework()
 {
     foreach (var entity in _testContext.LocalEntities.OfType<SimpleBenchmarkEntity>())
     {
         using (var dbContext = new EfDbContext(_testContext.DatabaseConnection, _compiledModel, false))
         {
             dbContext.BenchmarkEntities.Attach(entity);
             dbContext.BenchmarkEntities.Remove(entity);
             dbContext.SaveChanges();
         }
     }
 }
        public void WhenIInsertSingleIntKeyEntitiesUsingEntityFramework(int entitiesCount)
        {
            for (var entityIndex = 1; entityIndex <= entitiesCount; entityIndex++)
            {
                var generatedEntity = this.GenerateSimpleBenchmarkEntity(entityIndex);
                using (var dbContext = new EfDbContext(_testContext.DatabaseConnection, _compiledModel, false))
                {
                    dbContext.BenchmarkEntities.Add(generatedEntity);
                    dbContext.SaveChanges();
                }

                Assert.Greater(generatedEntity.Id, 1); // the seed starts from 2 in the db to avoid confusion with the number of rows modified
                _testContext.LocalEntities.Add(generatedEntity);
            }
        }
        public void WhenIUpdateAllTheSingleIntKeyEntitiesThatIPreviouslyInsertedUsingEntityFramework()
        {
            var entityCount = _testContext.LocalEntities.Count;

            for (var entityIndex = 0; entityIndex < _testContext.LocalEntities.Count; entityIndex++)
            {
                var oldEntity = _testContext.LocalEntities[entityIndex] as SimpleBenchmarkEntity;
                var newEntity = new SimpleBenchmarkEntity();
                newEntity.Id = oldEntity.Id;

                using (var dbContext = new EfDbContext(_testContext.DatabaseConnection, _compiledModel, false))
                {
                    dbContext.BenchmarkEntities.Attach(newEntity);
                    this.GenerateSimpleBenchmarkEntity(entityCount++, newEntity);
                    dbContext.SaveChanges();
                }
                _testContext.LocalEntities[entityIndex] = newEntity;
            }
        }