public void Update_Sets_Entity_State_as_Modified()
            {
                var entity = new TestTable(Value);

                _sut.Update(entity);

                Assert.AreEqual(EntityState.Modified, GetEntityState(entity));
            }
            public void Add_Adds_New_Entity_In_Context()
            {
                var entity = new TestTable(Value);

                _sut.Add(entity);

                Assert.AreEqual(EntityState.Added, GetEntityState(entity));
            }
            private TestTable SavesEntity()
            {
                var entity = new TestTable(Value);

                SetEntityState(entity, EntityState.Added);

                _sut.Commit();

                return entity;
            }
            public void Rollback_Detaches_All_Added_Entities()
            {
                var entity = new TestTable(Value);

                SetEntityState(entity, EntityState.Added);

                Assert.AreEqual(EntityState.Added, GetEntityState(entity));

                _sut.Rollback();

                Assert.AreEqual(EntityState.Detached, GetEntityState(entity));
            }
Exemplo n.º 5
0
            public void Commit_Saves_Context_Into_Database()
            {
                var entity = new TestTable(Value);

                SetEntityState(entity, EntityState.Added);

                Assert.AreEqual(0, entity.Id);

                _sut.Commit();

                Assert.AreNotEqual(0, entity.Id);
            }
 protected void SetEntityState(TestTable entity, EntityState newState)
 {
     TestEntities.Entry(entity).State = newState;
 }
 protected EntityState GetEntityState(TestTable entity)
 {
     return(TestEntities.Entry(entity).State);
 }