예제 #1
0
        public void BatchDeleteTest()
        {
            ship_pop v1 = new ship_pop();
            ship_pop v2 = new ship_pop();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.UserID   = AddUser();
                v1.PopID    = AddPop();
                v1.OrderQty = 38;
                v2.UserID   = v1.UserID;
                v2.PopID    = v1.PopID;
                v2.OrderQty = 97;
                context.Set <ship_pop>().Add(v1);
                context.Set <ship_pop>().Add(v2);
                context.SaveChanges();
            }

            PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new string[] { v1.ID.ToString(), v2.ID.ToString() });

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

            ship_popBatchVM vm = rv.Model as ship_popBatchVM;

            vm.Ids = new string[] { v1.ID.ToString(), v2.ID.ToString() };
            _controller.DoBatchDelete(vm, null);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                Assert.AreEqual(context.Set <ship_pop>().Count(), 0);
            }
        }
예제 #2
0
        public void DeleteTest()
        {
            ship_pop v = new ship_pop();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.UserID   = AddUser();
                v.PopID    = AddPop();
                v.OrderQty = 38;
                context.Set <ship_pop>().Add(v);
                context.SaveChanges();
            }

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

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

            ship_popVM vm = rv.Model as ship_popVM;

            v         = new ship_pop();
            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>().Count(), 0);
            }
        }
예제 #3
0
        public void DetailsTest()
        {
            ship_pop v = new ship_pop();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.UserID   = AddUser();
                v.PopID    = AddPop();
                v.OrderQty = 38;
                context.Set <ship_pop>().Add(v);
                context.SaveChanges();
            }
            PartialViewResult rv = (PartialViewResult)_controller.Details(v.ID.ToString());

            Assert.IsInstanceOfType(rv.Model, typeof(IBaseCRUDVM <TopBasePoco>));
            Assert.AreEqual(v.ID, (rv.Model as IBaseCRUDVM <TopBasePoco>).Entity.GetID());
        }
예제 #4
0
        public void EditTest()
        {
            ship_pop v = new ship_pop();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.UserID   = AddUser();
                v.PopID    = AddPop();
                v.OrderQty = 38;
                context.Set <ship_pop>().Add(v);
                context.SaveChanges();
            }

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

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

            ship_popVM vm = rv.Model as ship_popVM;

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

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

            vm.FC.Add("Entity.UserID", "");
            vm.FC.Add("Entity.PopID", "");
            vm.FC.Add("Entity.OrderQty", "");
            _controller.Edit(vm);

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

                Assert.AreEqual(data.OrderQty, 97);
                Assert.AreEqual(data.UpdateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.UpdateTime.Value).Seconds < 10);
            }
        }
예제 #5
0
        public void CreateTest()
        {
            PartialViewResult rv = (PartialViewResult)_controller.Create();

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

            ship_popVM vm = rv.Model as ship_popVM;
            ship_pop   v  = new ship_pop();

            v.UserID   = AddUser();
            v.PopID    = AddPop();
            v.OrderQty = 38;
            vm.Entity  = v;
            _controller.Create(vm);

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

                Assert.AreEqual(data.OrderQty, 38);
                Assert.AreEqual(data.CreateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.CreateTime.Value).Seconds < 10);
            }
        }