public void GetCat() { ConsoleTitleUtil.ShowTestTitle("GetCat"); TCat cat = TCat.findById(20); Assert.AreEqual("国际新闻20", cat.Name); Console.WriteLine("\n读取 TCat{{Id:{0},Name:{1}}} code:{2} \n", cat.Id, cat.Name, cat.GetHashCode()); }
public void UpdateCat() { ConsoleTitleUtil.ShowTestTitle("UpdateCat"); TCat cat = TCat.findById(10); Console.WriteLine("\n读取 TCat{{Id:{0},Name:{1}}} code:{2} \n", cat.Id, cat.Name, cat.GetHashCode()); Assert.AreEqual("国内新闻10", cat.Name); cat.Name = "糊播新闻10"; db.update(cat); Console.WriteLine("\n更新 TCat{{Id:{0},Name:{1}}} code:{2} \n", cat.Id, cat.Name, cat.GetHashCode()); cat = TCat.findById(10); Console.WriteLine("\n重新读取 TCat{{Id:{0},Name:{1}}} code:{2} \n", cat.Id, cat.Name, cat.GetHashCode()); Assert.AreEqual("糊播新闻10", cat.Name); // Id 不可以修改 //------------------------------------------------ cat.Id = 101; cat.update(); TCat newCat = TCat.findById(101); Assert.IsNull(newCat); }