public void TestTextNull() { var obj = new ComplexTypeTestTableWithNull(); // Set Default Value for Tests. obj.Text = null; // Test Add var inserted = Database.AddObject(obj); Assert.IsTrue(inserted, "DatabaseTypeTests: Could not insert object in Text (Null) Test."); Assert.IsTrue(obj.IsPersisted, "DatabaseTypeTests: Inserted Object in Text (Null) Test doesn't have Persisted Flag set."); // Test Read var objRetrieved = Database.FindObjectByKey<ComplexTypeTestTableWithNull>(obj.PrimaryKey); Assert.IsNotNull(objRetrieved, "DatabaseTypeTests: Could not retrieve object (ID {0}) in Text (Null) Test.", obj.PrimaryKey); Assert.AreEqual(obj.Text, objRetrieved.Text, "DatabaseTypeTests: in Text (Null) Insterted Value and Retrieved Value should be Equal."); // Test Save obj.Text = new string(Enumerable.Range(0, 65534).Select(i => 'z').Concat(new [] { '@' }).ToArray()); var saved = Database.SaveObject(obj); Assert.IsTrue(saved, "DatabaseTypeTests: Could not save objet in Text (Null) Test."); Assert.IsFalse(obj.Dirty, "DatabaseTypeTests: Saved Object in Text (Null) Test still have Dirty Flag set."); // Test Re-Read var objReRetrieved = Database.FindObjectByKey<ComplexTypeTestTableWithNull>(obj.PrimaryKey); Assert.IsNotNull(objReRetrieved, "DatabaseTypeTests: Could not retrieve object (ID {0}) in Text (Null) Test.", obj.PrimaryKey); Assert.AreEqual(obj.Text, objReRetrieved.Text, "DatabaseTypeTests: in Text (Null) Saved Value and Retrieved Value should be Equal."); // Test Re-Save obj.Text = "a"; var reSaved = Database.SaveObject(obj); Assert.IsTrue(reSaved, "DatabaseTypeTests: Could not Re-Save objet in Text (Null) Test."); Assert.IsFalse(obj.Dirty, "DatabaseTypeTests: Re-Saved Object in Text (Null) Test still have Dirty Flag set."); // Test Re-Re-Read var objReReRetrieved = Database.FindObjectByKey<ComplexTypeTestTableWithNull>(obj.PrimaryKey); Assert.IsNotNull(objReReRetrieved, "DatabaseTypeTests: Could not retrieve object (ID {0}) in Text (Null) Test.", obj.PrimaryKey); Assert.AreEqual(obj.Text, objReReRetrieved.Text, "DatabaseTypeTests: in Text (Null) Saved Value and Retrieved Value should be Equal."); }
public void TestFloatNull() { var obj = new ComplexTypeTestTableWithNull(); // Set Default Value for Tests. obj.Float = float.MinValue; // Test Add var inserted = Database.AddObject(obj); Assert.IsTrue(inserted, "DatabaseTypeTests: Could not insert object in Float (Null) Test."); Assert.IsTrue(obj.IsPersisted, "DatabaseTypeTests: Inserted Object in Float (Null) Test doesn't have Persisted Flag set."); // Test Read var objRetrieved = Database.FindObjectByKey<ComplexTypeTestTableWithNull>(obj.PrimaryKey); Assert.IsNotNull(objRetrieved, "DatabaseTypeTests: Could not retrieve object (ID {0}) in Float (Null) Test.", obj.PrimaryKey); Assert.AreEqual(obj.Float, objRetrieved.Float, "DatabaseTypeTests: in Float (Null) Insterted Value and Retrieved Value should be Equal."); // Test Save obj.Float = float.MaxValue; var saved = Database.SaveObject(obj); Assert.IsTrue(saved, "DatabaseTypeTests: Could not save objet in Float (Null) Test."); Assert.IsFalse(obj.Dirty, "DatabaseTypeTests: Saved Object in Float (Null) Test still have Dirty Flag set."); // Test Re-Read var objReRetrieved = Database.FindObjectByKey<ComplexTypeTestTableWithNull>(obj.PrimaryKey); Assert.IsNotNull(objReRetrieved, "DatabaseTypeTests: Could not retrieve object (ID {0}) in Float (Null) Test.", obj.PrimaryKey); Assert.AreEqual(obj.Float, objReRetrieved.Float, "DatabaseTypeTests: in Float (Null) Saved Value and Retrieved Value should be Equal."); // Test Re-Save obj.Float = (float)0.1; var reSaved = Database.SaveObject(obj); Assert.IsTrue(reSaved, "DatabaseTypeTests: Could not Re-Save objet in Float (Null) Test."); Assert.IsFalse(obj.Dirty, "DatabaseTypeTests: Re-Saved Object in Float (Null) Test still have Dirty Flag set."); // Test Re-Re-Read var objReReRetrieved = Database.FindObjectByKey<ComplexTypeTestTableWithNull>(obj.PrimaryKey); Assert.IsNotNull(objReReRetrieved, "DatabaseTypeTests: Could not retrieve object (ID {0}) in Float (Null) Test.", obj.PrimaryKey); Assert.AreEqual(obj.Float, objReReRetrieved.Float, "DatabaseTypeTests: in Float (Null) Saved Value and Retrieved Value should be Equal."); }
public void TestDateTimeNull() { var obj = new ComplexTypeTestTableWithNull(); // Set Default Value for Tests. obj.DateTime = new DateTime(DateTime.MaxValue.Year, DateTime.MaxValue.Month, DateTime.MaxValue.Day, DateTime.MaxValue.Hour, DateTime.MaxValue.Minute, DateTime.MaxValue.Second); // Test Add var inserted = Database.AddObject(obj); Assert.IsTrue(inserted, "DatabaseTypeTests: Could not insert object in DateTime (Null) Test."); Assert.IsTrue(obj.IsPersisted, "DatabaseTypeTests: Inserted Object in DateTime (Null) Test doesn't have Persisted Flag set."); // Test Read var objRetrieved = Database.FindObjectByKey<ComplexTypeTestTableWithNull>(obj.PrimaryKey); Assert.IsNotNull(objRetrieved, "DatabaseTypeTests: Could not retrieve object (ID {0}) in DateTime (Null) Test.", obj.PrimaryKey); Assert.AreEqual(obj.DateTime, objRetrieved.DateTime, "DatabaseTypeTests: in DateTime (Null) Insterted Value and Retrieved Value should be Equal."); // Test Save obj.DateTime = DateTime.MinValue; var saved = Database.SaveObject(obj); Assert.IsTrue(saved, "DatabaseTypeTests: Could not save objet in DateTime (Null) Test."); Assert.IsFalse(obj.Dirty, "DatabaseTypeTests: Saved Object in DateTime (Null) Test still have Dirty Flag set."); // Test Re-Read var objReRetrieved = Database.FindObjectByKey<ComplexTypeTestTableWithNull>(obj.PrimaryKey); Assert.IsNotNull(objReRetrieved, "DatabaseTypeTests: Could not retrieve object (ID {0}) in DateTime (Null) Test.", obj.PrimaryKey); Assert.AreEqual(obj.DateTime, objReRetrieved.DateTime, "DatabaseTypeTests: in DateTime (Null) Saved Value and Retrieved Value should be Equal."); // Test Re-Save obj.DateTime = default(DateTime); var reSaved = Database.SaveObject(obj); Assert.IsTrue(reSaved, "DatabaseTypeTests: Could not Re-Save objet in DateTime (Null) Test."); Assert.IsFalse(obj.Dirty, "DatabaseTypeTests: Re-Saved Object in DateTime (Null) Test still have Dirty Flag set."); // Test Re-Re-Read var objReReRetrieved = Database.FindObjectByKey<ComplexTypeTestTableWithNull>(obj.PrimaryKey); Assert.IsNotNull(objReReRetrieved, "DatabaseTypeTests: Could not retrieve object (ID {0}) in DateTime (Null) Test.", obj.PrimaryKey); Assert.AreEqual(obj.DateTime, objReReRetrieved.DateTime, "DatabaseTypeTests: in DateTime (Null) Saved Value and Retrieved Value should be Equal."); }