public void TestListLoadByTitle() { new Sql("delete from gentest").Execute(); GenTest genTest = new GenTest { Title = "mike1" }; genTest.Save(); genTest = new GenTest { Title = "mike1" }; genTest.Save(); genTest = new GenTest { Title = "mike2" }; genTest.Save(); var genTests = GenTestList.LoadByTitle("mike"); Assert.AreEqual(0, genTests.Count); var genTests2 = GenTestList.LoadByTitle("mike1"); Assert.AreEqual(2, genTests2.Count); }
public static void TestID() { var g = new GenTest(); g.GenTestID = 5; Assert.AreEqual(5, g.ID); }
public void TestCacheIDsecond() { int id = GetGenTestID(); var obj2 = GenTest.Load(new Sql("select gentestid, bodytexthtml as mike from gentest where gentestid=", id)); var obj1 = GenTest.LoadID(id); Assert.IsTrue(obj1.GetFieldNames().Join(",") != obj2.GetFieldNames().Join(","), "Fields match and should not match"); }
public void TestSaveNew() { GenTest genTest = new GenTest(); genTest.Title = "mike"; genTest.Save(); Assert.AreEqual("mike", genTest.Title); }
public void TestLoadChildrenPartFour() { var g = GenTest.Load(new Sql("where 1=1 order by GenTestID")); g.Title = "Green"; g.ReloadFromDatabase(); Assert.AreEqual("Blue", g.Title); }
public void TestCacheIDsame() { int id = GetGenTestID(); var obj3 = GenTest.Load(new Sql("select * from gentest where gentestid=", id)); var obj1 = GenTest.LoadID(id); Assert.IsTrue(obj1.GetFieldNames().Join(",") == obj3.GetFieldNames().Join(","), "Fields should match"); Assert.IsTrue(object.ReferenceEquals(obj1, obj3), "Objects should be same"); }
public void TestLoadChildrenPartTwo() { var g = GenTest.Load(new Sql("where 1=1 order by GenTestID")); g.Title = "Blue"; g.Save(); g.Title = "Green"; Assert.AreEqual("Green", g.Title); }
public static void TestLoadFk() { var g = new GenTest(); g.GenTestID = 5; var expectedValue = ""; var actualValue = ""; Assert.AreEqual(expectedValue, actualValue); }
public void TestLoadByTitle() { GenTest g = new GenTest(); g.Title = "mike"; g.Save(); var genTest = GenTest.LoadByTitle("mike"); Assert.AreEqual("mike", genTest.Title); }
public void TestCacheIDAreEqual() { int id = GetGenTestID(); var obj1 = GenTest.LoadID(id); var obj2 = GenTest.Load(new Sql("select gentestid, bodytexthtml as mike from gentest where gentestid=", id)); var obj3 = GenTest.Load(new Sql("select * from gentest where gentestid=", id)); var obj4 = GenTest.Load(new Sql("select gentestid, bodytexthtml as mike from gentest where gentestid=", id)); Assert.IsTrue(object.ReferenceEquals(obj1, obj3), "Objects should be same"); Assert.IsTrue(object.ReferenceEquals(obj2, obj4), "Objects should be same"); Assert.IsFalse(object.ReferenceEquals(obj1, obj4), "Objects should be not same"); }
protected ActionResult ProcessForm(Models.GenTest record) { try { if (record == null) { record = new GenTest(); //check for deleted, or null, create a new one } record.UpdateFromRequest(); // read subform or related checkboxes here eg record.Lines.UpdateFromRequest(); //ifsubform: record.example.UpdateFromRequest(); Validate(record); if (ModelState.IsValid) { Save(record, record.IsNewRecord); Web.InfoMessage += "Gen Test " + record.GetName() + " saved."; } } catch (UserErrorException e) { ModelState.AddModelError("Record", e.Message); } if (!ModelState.IsValid) { // invalid so redisplay form with validation message(s) return(View("GenTestEdit", new EditViewModel() { GenTest = record })); } else if (Web.Request["SaveAndRefreshButton"] != null) { return(RedirectToEdit(record.ID)); } else if (Web.Request["DuplicateButton"] != null) { var newRecord = new Models.GenTest(); newRecord.UpdateFrom(record); newRecord.Save(); Web.InfoMessage += "Copy of Gen Test " + record.GetName() + " created. You are now editing the new copy."; return(RedirectToEdit(newRecord.ID)); } else { return(RedirectToReturnPage()); } }
// NOTE: executes on work thread. DO NOT do any UI work here. Pass the test // results through e.Result. private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; GenTest test = new GenTest(); test.RetainOutput = IsOutputRetained; // should be okay to read from work thread List <GenTest.GenTestResults> results = test.Run(worker); if (worker.CancellationPending) { e.Cancel = true; } else { e.Result = results; } }
public void TestLoadChildrenPartThree() { var g = GenTest.Load(new Sql("where 1=1 order by GenTestID")); Assert.AreEqual("Green", g.Title); }