public void UpdateMultipleSimpleEntities()
        {
            // Arrange
            const int expectedId1 = 10;
            const int expectedId2 = 10;

            FakeDbContext          dbContext        = new FakeDbContext();
            SimpleEntityRepository entityRepository = new SimpleEntityRepository(dbContext);

            SimpleEntity simpleEntity1 = new SimpleEntity {
                Id = expectedId1
            };
            SimpleEntity simpleEntity2 = new SimpleEntity {
                Id = expectedId2
            };

            // Act
            entityRepository.Update(simpleEntity1);
            entityRepository.Update(simpleEntity2);

            // Assert
            Assert.IsNotNull(entityRepository.DbContext);
            Assert.AreEqual(1, entityRepository.DbContext.ChangeTracker.Entries().Count());
            Assert.AreEqual(EntityState.Modified, entityRepository.DbContext.FindEntity(simpleEntity1.Id).State);
            Assert.AreEqual(EntityState.Modified, entityRepository.DbContext.FindEntity(simpleEntity2.Id).State);
        }
        public void InsertSimpleEntityFollowedByAnUpdate()
        {
            // Arrange
            const string updatedValue = "Updated Value";

            FakeDbContext          dbContext        = new FakeDbContext();
            SimpleEntityRepository entityRepository = new SimpleEntityRepository(dbContext);

            SimpleEntity simpleEntity = new SimpleEntity {
                Id = 1, SomeProperty = "Initial value"
            };

            // Act
            entityRepository.Insert(simpleEntity);

            simpleEntity.SomeProperty = updatedValue;
            entityRepository.Update(simpleEntity);

            // Assert
            Assert.IsNotNull(entityRepository.DbContext);
            Assert.AreEqual(1, entityRepository.DbContext.ChangeTracker.Entries().Count());

            // Ensure the entity in cache is still at a state of 'Added' but has the updated properties
            DbEntityEntry entry = entityRepository.DbContext.ChangeTracker.Entries().ToList()[0];

            Assert.AreEqual(EntityState.Added, entry.State);
            Assert.AreEqual(updatedValue, ((SimpleEntity)entry.Entity).SomeProperty);
        }