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

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.OrderRemark = "6od";
                context.Set <ship_pop_sum>().Add(v);
                context.SaveChanges();
            }

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

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

            ship_pop_sumVM vm = rv.Model as ship_pop_sumVM;

            v    = new ship_pop_sum();
            v.ID = vm.Entity.ID;

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

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

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data = context.Set <ship_pop_sum>().FirstOrDefault();

                Assert.AreEqual(data.OrderRemark, "xq2r");
            }
        }
Exemple #2
0
        public void DeleteTest()
        {
            ship_pop_sum v = new ship_pop_sum();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.OrderRemark = "6od";
                context.Set <ship_pop_sum>().Add(v);
                context.SaveChanges();
            }

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

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

            ship_pop_sumVM vm = rv.Model as ship_pop_sumVM;

            v         = new ship_pop_sum();
            v.ID      = vm.Entity.ID;
            vm.Entity = v;
            _controller.Delete(v.ID.ToString(), null);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                Assert.AreEqual(context.Set <ship_pop_sum>().Count(), 0);
            }
        }
 public ActionResult Edit(ship_pop_sumVM vm)
 {
     if (!ModelState.IsValid)
     {
         return(PartialView(vm));
     }
     else
     {
         vm.DoEdit();
         if (!ModelState.IsValid)
         {
             vm.DoReInit();
             return(PartialView(vm));
         }
         else
         {
             return(FFResult().CloseDialog().RefreshGridRow(vm.Entity.ID));
         }
     }
 }
 public ActionResult DoCreate(ship_pop_sumVM vm)
 {
     if (!ModelState.IsValid)
     {
         return(PartialView(vm));
     }
     else
     {
         vm.DoAdd();
         if (!ModelState.IsValid)
         {
             vm.DoReInit();
             return(PartialView(vm));
         }
         else
         {
             return(FFResult().CloseDialog().RefreshGrid());
         }
     }
 }
Exemple #5
0
        public void CreateTest()
        {
            PartialViewResult rv = (PartialViewResult)_controller.Create();

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

            ship_pop_sumVM vm = rv.Model as ship_pop_sumVM;
            ship_pop_sum   v  = new ship_pop_sum();

            v.OrderRemark = "6od";
            vm.Entity     = v;
            _controller.Create(vm);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data = context.Set <ship_pop_sum>().FirstOrDefault();

                Assert.AreEqual(data.OrderRemark, "6od");
            }
        }