public void DefaultIsDirtyCollection() { int id = -1; DefaultTest entity = new DefaultTest(); try { using (esTransactionScope scope = new esTransactionScope()) { // Create test record entity = new DefaultTest(); entity.DefaultNotNullBool = true; entity.DefaultNotNullInt = -1; entity.Save(); // Get the ID of the newly saved object id = entity.TestId.Value; DefaultTestCollection coll = new DefaultTestCollection(); Assert.IsTrue(coll.LoadAll()); Assert.AreEqual(true, coll[0].DefaultNotNullBool.Value); Assert.AreEqual(-1, coll[0].DefaultNotNullInt.Value); Assert.IsFalse(coll[0].es.IsDirty, "Load Dirty"); Assert.AreEqual(0, coll[0].es.ModifiedColumns.Count, "Load Count"); coll[0].DefaultNotNullBool = false; Assert.AreEqual(1, coll[0].es.ModifiedColumns.Count, "Bool Count"); Assert.IsTrue(coll[0].es.IsDirty, "Bool Dirty"); coll = new DefaultTestCollection(); Assert.IsTrue(coll.LoadAll()); Assert.AreEqual(true, coll[0].DefaultNotNullBool.Value); Assert.AreEqual(-1, coll[0].DefaultNotNullInt.Value); coll[0].DefaultNotNullInt = 0; Assert.AreEqual(1, coll[0].es.ModifiedColumns.Count, "Int Count"); Assert.IsTrue(coll[0].es.IsDirty, "Int Dirty"); } } finally { // Clean up entity = new DefaultTest(); if (entity.LoadByPrimaryKey(id)) { entity.MarkAsDeleted(); entity.Save(); } } }
public void DefaultNotNullOnInsert() { int id = -1; DefaultTest entity = new DefaultTest(); try { using (esTransactionScope scope = new esTransactionScope()) { // Create test record entity = new DefaultTest(); entity.Save(); // Get the ID of the newly saved object id = entity.TestId.Value; // Check default value was set on insert entity = new DefaultTest(); Assert.IsTrue(entity.LoadByPrimaryKey(id)); Assert.AreEqual(0, entity.DefaultNotNullInt.Value); Assert.AreEqual(false, entity.DefaultNotNullBool.Value); } } finally { // Clean up entity = new DefaultTest(); if (entity.LoadByPrimaryKey(id)) { entity.MarkAsDeleted(); entity.Save(); } } }