コード例 #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 void BatchDeleteTest()
        {
            inv_record v1 = new inv_record();
            inv_record v2 = new inv_record();

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

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

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

            inv_recordBatchVM vm = rv.Model as inv_recordBatchVM;

            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 <inv_record>().Count(), 0);
            }
        }
コード例 #3
0
        public void DetailsTest()
        {
            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.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 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);
            }
        }
コード例 #5
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);
            }
        }