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); }
public void UpdateACat() { ConsoleTitleUtil.ShowTestTitle("UpdateCat"); TCat cat = TCat.findById(2); Assert.AreEqual("国际新闻", cat.Name); cat.Name = "这里不是新闻"; cat.update(); TCat newcat = TCat.findById(cat.Id); Assert.AreEqual("这里不是新闻", newcat.Name); }