public void EditTest() { PlayerState v = new PlayerState(); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { v.LevelExp = 44; v.MaxLifeTime = 69; v.CurrentLife = 52; v.Energy = 93; v.Money = 7; v.Gold = 55; context.Set <PlayerState>().Add(v); context.SaveChanges(); } PartialViewResult rv = (PartialViewResult)_controller.Edit(v.ID.ToString()); Assert.IsInstanceOfType(rv.Model, typeof(PlayerStateVM)); PlayerStateVM vm = rv.Model as PlayerStateVM; v = new PlayerState(); v.ID = vm.Entity.ID; v.LevelExp = 72; v.MaxLifeTime = 88; v.CurrentLife = 5; v.Energy = 87; v.Money = 16; v.Gold = 40; vm.Entity = v; vm.FC = new Dictionary <string, object>(); vm.FC.Add("Entity.LevelExp", ""); vm.FC.Add("Entity.MaxLifeTime", ""); vm.FC.Add("Entity.CurrentLife", ""); vm.FC.Add("Entity.Energy", ""); vm.FC.Add("Entity.Money", ""); vm.FC.Add("Entity.Gold", ""); _controller.Edit(vm); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { var data = context.Set <PlayerState>().FirstOrDefault(); Assert.AreEqual(data.LevelExp, 72); Assert.AreEqual(data.MaxLifeTime, 88); Assert.AreEqual(data.CurrentLife, 5); Assert.AreEqual(data.Energy, 87); Assert.AreEqual(data.Money, 16); Assert.AreEqual(data.Gold, 40); Assert.AreEqual(data.UpdateBy, "user"); Assert.IsTrue(DateTime.Now.Subtract(data.UpdateTime.Value).Seconds < 10); } }