Пример #1
0
		public void TestBooleanNonNull()
		{
			var obj = new ComplexTypeTestTable();
			// Set Value that should not be null
			obj.String = string.Empty;
			obj.Text = string.Empty;
			obj.DateTime = DateTime.Now;
			
			// Set Default Value for Tests.
			obj.Bool = false;
			
			// Test Add
			var inserted = Database.AddObject(obj);
			Assert.IsTrue(inserted, "DatabaseTypeTests: Could not insert object in Boolean (NonNull) Test.");
			Assert.IsTrue(obj.IsPersisted, "DatabaseTypeTests: Inserted Object in Boolean (NonNull) Test doesn't have Persisted Flag set.");
			
			// Test Read
			var objRetrieved = Database.FindObjectByKey<ComplexTypeTestTable>(obj.PrimaryKey);
			Assert.IsNotNull(objRetrieved, "DatabaseTypeTests: Could not retrieve object (ID {0}) in Boolean (NonNull) Test.", obj.PrimaryKey);
			Assert.AreEqual(obj.Bool, objRetrieved.Bool, "DatabaseTypeTests: in Boolean (NonNull) Insterted Value and Retrieved Value should be Equal.");
			
			// Test Save
			obj.Bool = true;
			var saved = Database.SaveObject(obj);
			Assert.IsTrue(saved, "DatabaseTypeTests: Could not save objet in Boolean (NonNull) Test.");
			Assert.IsFalse(obj.Dirty, "DatabaseTypeTests: Saved Object in Boolean (NonNull) Test still have Dirty Flag set.");
			
			// Test Re-Read
			var objReRetrieved = Database.FindObjectByKey<ComplexTypeTestTable>(obj.PrimaryKey);
			Assert.IsNotNull(objReRetrieved, "DatabaseTypeTests: Could not retrieve object (ID {0}) in Boolean (NonNull) Test.", obj.PrimaryKey);
			Assert.AreEqual(obj.Bool, objReRetrieved.Bool, "DatabaseTypeTests: in Boolean (NonNull) Saved Value and Retrieved Value should be Equal.");
		}
Пример #2
0
		public void TestTextNonNull()
		{
			var obj = new ComplexTypeTestTable();
			// Set Value that should not be null
			obj.String = string.Empty;
			obj.Text = string.Empty;
			obj.DateTime = DateTime.Now;
			
			// Set Default Value for Tests.
			obj.Text = "a";
			
			// Test Add
			var inserted = Database.AddObject(obj);
			Assert.IsTrue(inserted, "DatabaseTypeTests: Could not insert object in Text (NonNull) Test.");
			Assert.IsTrue(obj.IsPersisted, "DatabaseTypeTests: Inserted Object in Text (NonNull) Test doesn't have Persisted Flag set.");
			
			// Test Read
			var objRetrieved = Database.FindObjectByKey<ComplexTypeTestTable>(obj.PrimaryKey);
			Assert.IsNotNull(objRetrieved, "DatabaseTypeTests: Could not retrieve object (ID {0}) in Text (NonNull) Test.", obj.PrimaryKey);
			Assert.AreEqual(obj.Text, objRetrieved.Text, "DatabaseTypeTests: in Text (NonNull) 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 (NonNull) Test.");
			Assert.IsFalse(obj.Dirty, "DatabaseTypeTests: Saved Object in Text (NonNull) Test still have Dirty Flag set.");
			
			// Test Re-Read
			var objReRetrieved = Database.FindObjectByKey<ComplexTypeTestTable>(obj.PrimaryKey);
			Assert.IsNotNull(objReRetrieved, "DatabaseTypeTests: Could not retrieve object (ID {0}) in Text (NonNull) Test.", obj.PrimaryKey);
			Assert.AreEqual(obj.Text, objReRetrieved.Text, "DatabaseTypeTests: in Text (NonNull) Saved Value and Retrieved Value should be Equal.");
			
			// Test Re-Save
			obj.Text = string.Empty;
			var reSaved = Database.SaveObject(obj);
			Assert.IsTrue(reSaved, "DatabaseTypeTests: Could not Re-Save objet in Text (NonNull) Test.");
			Assert.IsFalse(obj.Dirty, "DatabaseTypeTests: Re-Saved Object in Text (NonNull) Test still have Dirty Flag set.");
			
			// Test Re-Re-Read
			var objReReRetrieved = Database.FindObjectByKey<ComplexTypeTestTable>(obj.PrimaryKey);
			Assert.IsNotNull(objReReRetrieved, "DatabaseTypeTests: Could not retrieve object (ID {0}) in Text (NonNull) Test.", obj.PrimaryKey);
			Assert.AreEqual(obj.Text, objReReRetrieved.Text, "DatabaseTypeTests: in Text (NonNull) Saved Value and Retrieved Value should be Equal.");
		}
Пример #3
0
		public void TestDateTimeNonNull()
		{
			var obj = new ComplexTypeTestTable();
			// Set Value that should not be null
			obj.String = string.Empty;
			obj.Text = string.Empty;
			obj.DateTime = DateTime.Now;
			
			// 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 (NonNull) Test.");
			Assert.IsTrue(obj.IsPersisted, "DatabaseTypeTests: Inserted Object in DateTime (NonNull) Test doesn't have Persisted Flag set.");
			
			// Test Read
			var objRetrieved = Database.FindObjectByKey<ComplexTypeTestTable>(obj.PrimaryKey);
			Assert.IsNotNull(objRetrieved, "DatabaseTypeTests: Could not retrieve object (ID {0}) in DateTime (NonNull) Test.", obj.PrimaryKey);
			Assert.AreEqual(obj.DateTime, objRetrieved.DateTime, "DatabaseTypeTests: in DateTime (NonNull) 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 (NonNull) Test.");
			Assert.IsFalse(obj.Dirty, "DatabaseTypeTests: Saved Object in DateTime (NonNull) Test still have Dirty Flag set.");
			
			// Test Re-Read
			var objReRetrieved = Database.FindObjectByKey<ComplexTypeTestTable>(obj.PrimaryKey);
			Assert.IsNotNull(objReRetrieved, "DatabaseTypeTests: Could not retrieve object (ID {0}) in DateTime (NonNull) Test.", obj.PrimaryKey);
			Assert.AreEqual(obj.DateTime, objReRetrieved.DateTime, "DatabaseTypeTests: in DateTime (NonNull) 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 (NonNull) Test.");
			Assert.IsFalse(obj.Dirty, "DatabaseTypeTests: Re-Saved Object in DateTime (NonNull) Test still have Dirty Flag set.");
			
			// Test Re-Re-Read
			var objReReRetrieved = Database.FindObjectByKey<ComplexTypeTestTable>(obj.PrimaryKey);
			Assert.IsNotNull(objReReRetrieved, "DatabaseTypeTests: Could not retrieve object (ID {0}) in DateTime (NonNull) Test.", obj.PrimaryKey);
			Assert.AreEqual(obj.DateTime, objReReRetrieved.DateTime, "DatabaseTypeTests: in DateTime (NonNull) Saved Value and Retrieved Value should be Equal.");
		}