コード例 #1
0
        public void DeleteTest()
        {
            PaintMapEntity v = new PaintMapEntity();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.Img  = "UoG";
                v.Sort = 70;
                context.Set <PaintMapEntity>().Add(v);
                context.SaveChanges();
            }

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

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

            PaintMapEntityVM vm = rv.Model as PaintMapEntityVM;

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

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                Assert.AreEqual(context.Set <PaintMapEntity>().Count(), 0);
            }
        }
コード例 #2
0
 public ActionResult Edit(PaintMapEntityVM 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));
         }
     }
 }
コード例 #3
0
        public void EditTest()
        {
            PaintMapEntity v = new PaintMapEntity();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.Img  = "UoG";
                v.Sort = 70;
                context.Set <PaintMapEntity>().Add(v);
                context.SaveChanges();
            }

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

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

            PaintMapEntityVM vm = rv.Model as PaintMapEntityVM;

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

            v.Img     = "GHW50BY8";
            v.Sort    = 23;
            vm.Entity = v;
            vm.FC     = new Dictionary <string, object>();

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

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

                Assert.AreEqual(data.Img, "GHW50BY8");
                Assert.AreEqual(data.Sort, 23);
                Assert.AreEqual(data.UpdateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.UpdateTime.Value).Seconds < 10);
            }
        }
コード例 #4
0
        public void CreateTest()
        {
            PartialViewResult rv = (PartialViewResult)_controller.Create();

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

            PaintMapEntityVM vm = rv.Model as PaintMapEntityVM;
            PaintMapEntity   v  = new PaintMapEntity();

            v.Img     = "UoG";
            v.Sort    = 70;
            vm.Entity = v;
            _controller.Create(vm);

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

                Assert.AreEqual(data.Img, "UoG");
                Assert.AreEqual(data.Sort, 70);
                Assert.AreEqual(data.CreateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.CreateTime.Value).Seconds < 10);
            }
        }