public void UT_Constraints() { string _testid = DateTime.Now.Ticks.ToString(); bool _constraint; for (int c = 0; c < UT0__utils.DBConnections.Length; c++) { //Console.WriteLine("UT_Constraints: {0}", DBConnectionsupport.GetDBServerType(UT0__utils.DBConnections[c]).ToString()); UT0__utils.DBConnections[c].Open(); UT0__utils.DBConnections[c].Transaction.Begin(); DO_User _user = new DO_User(UT0__utils.DBConnections[c]); _user.Fields.Login = _testid; _user.Fields.Password = _testid; _user.insObject(false, out _constraint); Assert.IsFalse(_constraint, "there should be no constraint problems"); _user.clrObject(); _user.Fields.Login = _testid; _user.Fields.Password = _testid; _user.insObject(false, out _constraint); Assert.IsTrue(_constraint, "constraint problems expected and not found"); _user.Dispose(); _user = null; UT0__utils.DBConnections[c].Transaction.Rollback(); UT0__utils.DBConnections[c].Transaction.Terminate(); UT0__utils.DBConnections[c].Close(); } }
public void UT_hasChanges() { string _testid = DateTime.Now.Ticks.ToString(); bool _constraint; long _iduser; DO_User _user = new DO_User(); _user.Connection.Open(); _user.Connection.Transaction.Begin(); Assert.IsFalse(_user.Fields.hasChanges, "unexpected changes, object just instantiated and no changes have been made"); _user.Fields.Login = _testid; _user.Fields.Password = _testid; Assert.IsTrue(_user.Fields.hasChanges, "expected changes, changes have been made over object"); _iduser = _user.insObject(true, out _constraint); Assert.IsFalse(_user.Fields.hasChanges, "unexpected changes, object state commited (insert) over data base"); _user.Fields.Login = _testid; _user.Fields.Password = _testid; Assert.IsFalse(_user.Fields.hasChanges, "unexpected changes, no real changes have been made"); _user.Fields.Password = string.Empty; Assert.IsTrue(_user.Fields.hasChanges, "expected changes, real changes have been made"); _user.updObject(false, out _constraint); Assert.IsFalse(_user.Fields.hasChanges, "unexpected changes, object state commited (update) over data base"); _user.clrObject(); Assert.IsTrue(_user.Fields.hasChanges, "expected changes, object state cleared"); _user.getObject_byLogin(_testid); Assert.IsFalse(_user.Fields.hasChanges, "unexpected changes, object state sinchronized (select) with data base"); _user.delObject(); Assert.IsTrue(_user.Fields.hasChanges, "expected changes, object erased (delete on data base)"); _user.Connection.Transaction.Rollback(); _user.Connection.Transaction.Terminate(); _user.Connection.Close(); _user.Dispose(); _user = null; }