Esempio n. 1
0
        public void DeleteTest()
        {
            EnterpriserYearYield v = new EnterpriserYearYield();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.YearYieldValue = 87;
                context.Set <EnterpriserYearYield>().Add(v);
                context.SaveChanges();
            }

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

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

            EnterpriserYearYieldVM vm = rv.Model as EnterpriserYearYieldVM;

            v         = new EnterpriserYearYield();
            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 <EnterpriserYearYield>().Count(), 0);
            }
        }
 public ActionResult Edit(EnterpriserYearYieldVM 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));
         }
     }
 }
Esempio n. 3
0
        public void CreateTest()
        {
            PartialViewResult rv = (PartialViewResult)_controller.Create();

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

            EnterpriserYearYieldVM vm = rv.Model as EnterpriserYearYieldVM;
            EnterpriserYearYield   v  = new EnterpriserYearYield();

            v.YearYieldValue = 87;
            vm.Entity        = v;
            _controller.Create(vm);

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

                Assert.AreEqual(data.YearYieldValue, 87);
                Assert.AreEqual(data.CreateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.CreateTime.Value).Seconds < 10);
            }
        }
Esempio n. 4
0
        public void EditTest()
        {
            EnterpriserYearYield v = new EnterpriserYearYield();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.YearYieldValue = 87;
                context.Set <EnterpriserYearYield>().Add(v);
                context.SaveChanges();
            }

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

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

            EnterpriserYearYieldVM vm = rv.Model as EnterpriserYearYieldVM;

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

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

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

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

                Assert.AreEqual(data.YearYieldValue, 13);
                Assert.AreEqual(data.UpdateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.UpdateTime.Value).Seconds < 10);
            }
        }