Пример #1
0
        public void DeleteTest()
        {
            inv_record v = new inv_record();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.InvID = AddInv();
                v.Qty   = 69;
                context.Set <inv_record>().Add(v);
                context.SaveChanges();
            }

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

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

            inv_recordVM vm = rv.Model as inv_recordVM;

            v         = new inv_record();
            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 <inv_record>().Count(), 0);
            }
        }
Пример #2
0
 public ActionResult Create(inv_recordVM vm)
 {
     if (!ModelState.IsValid)
     {
         return(PartialView(vm));
     }
     else
     {
         vm.DoAdd();
         if (!ModelState.IsValid)
         {
             vm.DoReInit();
             return(PartialView(vm));
         }
         else
         {
             return(FFResult().CloseDialog().RefreshGrid());
         }
     }
 }
Пример #3
0
        public void CreateTest()
        {
            PartialViewResult rv = (PartialViewResult)_controller.Create();

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

            inv_recordVM vm = rv.Model as inv_recordVM;
            inv_record   v  = new inv_record();

            v.InvID   = AddInv();
            v.Qty     = 69;
            vm.Entity = v;
            _controller.Create(vm);

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

                Assert.AreEqual(data.Qty, 69);
            }
        }
Пример #4
0
        public void EditTest()
        {
            inv_record v = new inv_record();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.InvID = AddInv();
                v.Qty   = 69;
                context.Set <inv_record>().Add(v);
                context.SaveChanges();
            }

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

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

            inv_recordVM vm = rv.Model as inv_recordVM;

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

            v.Qty     = 38;
            vm.Entity = v;
            vm.FC     = new Dictionary <string, object>();

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

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

                Assert.AreEqual(data.Qty, 38);
            }
        }