public void testModelContextModelObjectUpdateAndRead() { ModelContext.beginTrans(); try { Assert.AreEqual(ModelContext.CurrentDBUtils.GetHashCode(), DBUtils.Current().GetHashCode(), "Expected same connection"); Assert.AreEqual(true, ModelContext.CurrentDBUtils.inTrans, "Expected connection to be in transaction"); Employee e = ModelContext.Current.loadModelObject <Employee>(1); e.PrAddress = "nikoy theofanous 3a, nicosia - testObjectRead"; ModelContext.Current.saveModelObject(e); e = ModelContext.Current.loadModelObject <Employee>(1); Assert.AreEqual(e.PrAddress, "nikoy theofanous 3a, nicosia - testObjectRead"); e = EmployeeDataUtils.findOne("address=?", "nikoy theofanous 3a, nicosia - testObjectRead"); Assert.IsNotNull(e); Assert.AreEqual(e.PrAddress, "nikoy theofanous 3a, nicosia - testObjectRead"); } finally { ModelContext.rollbackTrans(); } Employee e2 = EmployeeDataUtils.findOne("address=?", "nikoy theofanous 3a, nicosia - testObjectRead"); Assert.IsNull(e2); }
public void testModelObjectUpdateReadWithDataUtils() { DBUtils.Current().beginTrans(); try { Employee e = EmployeeDataUtils.findByKey(1); e.PrAddress = "nikoy theofanous 3a, nicosia - testObjectRead"; EmployeeDataUtils.saveEmployee(e); e = EmployeeDataUtils.findByKey(1); Assert.AreEqual(e.PrAddress, "nikoy theofanous 3a, nicosia - testObjectRead"); e = EmployeeDataUtils.findOne("address=?", "nikoy theofanous 3a, nicosia - testObjectRead"); Assert.IsNotNull(e); Assert.AreEqual(e.PrAddress, "nikoy theofanous 3a, nicosia - testObjectRead"); } finally { DBUtils.Current().rollbackTrans(); } Employee e2 = EmployeeDataUtils.findOne("address=?", "nikoy theofanous 3a, nicosia - testObjectRead"); Assert.IsNull(e2); }