public void Version_PersistTwice_WithVersionColumnEntity_ShouldNotThrowException() { try { var con = SetupTables(); ITransaction transaction = CreateTransaction(con); int id = 35; VersionColumnTestRootEntity entity = new VersionColumnTestRootEntity(); entity.IdCol = id; entity.Name = "Org-Name"; entity.Persist(transaction); transaction.Commit(); transaction = CreateTransaction(con); entity.Persist(transaction); transaction.Commit(); con.Close(); } catch (System.Exception e) { LogManager.GetLogger(typeof(DbGateVersionTest)).Fatal(e.Message, e); Assert.Fail(e.Message); } }
public void Version_RootUpdateFromAnotherTransaction_WithVersionColumnEntity_ShouldThrowException() { var con = SetupTables(); ITransaction transaction = CreateTransaction(con); VersionColumnTestRootEntity entity = null; try { int id = 55; entity = new VersionColumnTestRootEntity(); entity.IdCol = id; entity.Name = "Org-Name"; entity.Persist(transaction); transaction.Commit(); transaction = CreateTransaction(con); VersionColumnTestRootEntity loadedEntity = new VersionColumnTestRootEntity(); LoadWithVersionColumnEntityWithId(transaction, loadedEntity, id); loadedEntity.Name = "New Name"; loadedEntity.Persist(transaction); transaction.Commit(); } catch (System.Exception e) { LogManager.GetLogger(typeof(DbGateVersionTest)).Fatal(e.Message, e); Assert.Fail(e.Message); } transaction = CreateTransaction(con); entity.Name = "New Name2";; Assert.Throws <PersistException>(() => entity.Persist(transaction)); transaction.Commit(); con.Close(); }
public void Version_One2manyChildUpdateFromAnotherTransaction_WithVersionColumnEntity_ShouldThrowException() { var con = SetupTables(); ITransaction transaction = CreateTransaction(con); VersionColumnTestRootEntity entity = null; try { int id = 55; entity = new VersionColumnTestRootEntity(); entity.IdCol = id; entity.Name = "Org-Name"; VersionColumnTestOne2ManyEntity one2ManyEntityOrg = new VersionColumnTestOne2ManyEntity(); one2ManyEntityOrg.Name = "One2Many"; one2ManyEntityOrg.IndexNo = 1; entity.One2ManyEntities.Add(one2ManyEntityOrg); entity.Persist(transaction); transaction.Commit(); transaction = CreateTransaction(con); VersionColumnTestRootEntity loadedEntity = new VersionColumnTestRootEntity(); LoadWithVersionColumnEntityWithId(transaction, loadedEntity, id); IEnumerator <VersionColumnTestOne2ManyEntity> loadedEnumerator = loadedEntity.One2ManyEntities.GetEnumerator(); loadedEnumerator.MoveNext(); VersionColumnTestOne2ManyEntity loadedOne2ManyEntity = loadedEnumerator.Current; loadedOne2ManyEntity.Name = "Modified One2Many"; loadedEntity.Persist(transaction); transaction.Commit(); } catch (System.Exception e) { LogManager.GetLogger(typeof(DbGateVersionTest)).Fatal(e.Message, e); Assert.Fail(e.Message); } transaction = CreateTransaction(con); IEnumerator <VersionColumnTestOne2ManyEntity> orgEnumerator = entity.One2ManyEntities.GetEnumerator(); orgEnumerator.MoveNext(); VersionColumnTestOne2ManyEntity orgOne2ManyEntity = orgEnumerator.Current; orgOne2ManyEntity.Name = "Modified2 One2Many"; Assert.Throws <PersistException>(() => entity.Persist(transaction)); transaction.Commit(); con.Close(); }