public void TreePersist_Update_WithFieldsDifferentTypeOfChildren_ShouldEqualWhenLoaded() { try { var con = SetupTables(); ITransaction transaction = CreateTransaction(con); int id = 35; ITreeTestRootEntity rootEntity = CreateFullObjectTree(id, TYPE_FIELD); rootEntity.Persist(transaction); transaction.Commit(); transaction = CreateTransaction(con); ITreeTestRootEntity loadedEntity = new TreeTestRootEntityFields(); LoadEntityWithId(transaction, loadedEntity, id); loadedEntity.Name = "changed-name"; loadedEntity.Status = EntityStatus.Modified; loadedEntity.One2OneEntity.Name = "changed-one2one"; loadedEntity.One2OneEntity.Status = EntityStatus.Modified; IEnumerator <ITreeTestOne2ManyEntity> enumerator = loadedEntity.One2ManyEntities.GetEnumerator(); enumerator.MoveNext(); ITreeTestOne2ManyEntity one2ManyEntity = enumerator.Current; one2ManyEntity.Name = "changed-one2many"; one2ManyEntity.Status = EntityStatus.Modified; loadedEntity.Persist(transaction); ITreeTestRootEntity reLoadedEntity = new TreeTestRootEntityFields(); LoadEntityWithId(transaction, reLoadedEntity, id); con.Close(); bool compareResult = CompareEntities(loadedEntity, reLoadedEntity); Assert.IsTrue(compareResult); } catch (System.Exception e) { LogManager.GetLogger(typeof(DbGateTreePersistTests)).Fatal("Exception during test", e); Assert.Fail(e.Message); } }
public void TreePersist_Delete_WithFieldsDifferentTypeOfChildren_ShouldEqualWhenLoaded() { try { var con = SetupTables(); ITransaction transaction = CreateTransaction(con); int id = 35; ITreeTestRootEntity rootEntity = CreateFullObjectTree(id, TYPE_FIELD); rootEntity.Persist(transaction); transaction.Commit(); transaction = CreateTransaction(con); ITreeTestRootEntity loadedEntity = new TreeTestRootEntityFields(); LoadEntityWithId(transaction, loadedEntity, id); loadedEntity.Name = "changed-name"; loadedEntity.Status = EntityStatus.Deleted; loadedEntity.Persist(transaction); ITreeTestRootEntity reLoadedEntity = new TreeTestRootEntityFields(); bool loaded = LoadEntityWithId(transaction, reLoadedEntity, id); bool existsOne2one = ExistsOne2ManyChild(transaction, id); bool existsOne2many = ExistsOne2ManyChild(transaction, id); transaction.Close(); Assert.IsFalse(loaded); Assert.IsFalse(existsOne2one); Assert.IsFalse(existsOne2many); } catch (System.Exception e) { LogManager.GetLogger(typeof(DbGateTreePersistTests)).Fatal("Exception during test", e); Assert.Fail(e.Message); } }