public void TestWhereFunctionOfDbObjectModel() { var list = UniquePerson.Where(CK.K["Name"] == "Tom").Select(); Assert.AreEqual(1, list.Count); Assert.AreEqual(1, list[0].Id); }
public void TestUniqueValidate() { var u = new UniquePerson { Name = "test" }; var vh = new ValidateHandler(); vh.ValidateObject(u); Assert.IsTrue(vh.IsValid); u.Name = "Tom"; vh = new ValidateHandler(); vh.ValidateObject(u); Assert.IsFalse(vh.IsValid); Assert.AreEqual("Invalid Field Name Should be UNIQUED.", vh.ErrorMessages["Name"]); // smart validate var p = DbEntry.GetObject <UniquePerson>(1); var n = ConsoleMessageLogRecorder.Count; Assert.IsTrue(p.IsValid()); Assert.AreEqual(n + 1, ConsoleMessageLogRecorder.Count); p.Name = "Jerry"; Assert.IsFalse(p.IsValid()); Assert.AreEqual(n + 2, ConsoleMessageLogRecorder.Count); }