Exemple #1
0
        public void EditTest()
        {
            Area v = new Area();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.AreaName = "AyD9qo";
                v.ParentId = AddParent();
                context.Set <Area>().Add(v);
                context.SaveChanges();
            }

            PartialViewResult rv = (PartialViewResult)_controller.Edit(v.ID.ToString());

            Assert.IsInstanceOfType(rv.Model, typeof(AreaVM));

            AreaVM vm = rv.Model as AreaVM;

            vm.Wtm.DC = new DataContext(_seed, DBTypeEnum.Memory);
            v         = new Area();
            v.ID      = vm.Entity.ID;

            v.AreaName = "bLt4Lg7Ll";
            vm.Entity  = v;
            vm.FC      = new Dictionary <string, object>();

            vm.FC.Add("Entity.AreaName", "");
            vm.FC.Add("Entity.ParentId", "");
            _controller.Edit(vm);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data = context.Set <Area>().Find(v.ID);

                Assert.AreEqual(data.AreaName, "bLt4Lg7Ll");
            }
        }