コード例 #1
0
        public void BatchDeleteTest()
        {
            InOutDepot v1 = new InOutDepot();
            InOutDepot v2 = new InOutDepot();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.IODID    = "M5DrJo0E";
                v1.IODType  = SCMSupplyChain.Model.IODType.出库;
                v1.DepotsID = AddDepots();
                v1.IODDesc  = "hkLS0";
                v2.IODID    = "vZ3";
                v2.IODType  = SCMSupplyChain.Model.IODType.入库;
                v2.DepotsID = v1.DepotsID;
                v2.IODDesc  = "jC0Ed1aTh";
                context.Set <InOutDepot>().Add(v1);
                context.Set <InOutDepot>().Add(v2);
                context.SaveChanges();
            }

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

            Assert.IsInstanceOfType(rv, typeof(OkObjectResult));

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data1 = context.Set <InOutDepot>().Find(v1.ID);
                var data2 = context.Set <InOutDepot>().Find(v2.ID);
                Assert.AreEqual(data1.IsValid, false);
                Assert.AreEqual(data2.IsValid, false);
            }

            rv = _controller.BatchDelete(new string[] {});
            Assert.IsInstanceOfType(rv, typeof(OkResult));
        }
コード例 #2
0
        public void CreateTest()
        {
            InOutDepotVM vm = _controller.Wtm.CreateVM <InOutDepotVM>();
            InOutDepot   v  = new InOutDepot();

            v.IODID    = "M5DrJo0E";
            v.IODType  = SCMSupplyChain.Model.IODType.出库;
            v.DepotsID = AddDepots();
            v.IODDesc  = "hkLS0";
            vm.Entity  = v;
            var rv = _controller.Add(vm);

            Assert.IsInstanceOfType(rv, typeof(OkObjectResult));

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data = context.Set <InOutDepot>().Find(v.ID);

                Assert.AreEqual(data.IODID, "M5DrJo0E");
                Assert.AreEqual(data.IODType, SCMSupplyChain.Model.IODType.出库);
                Assert.AreEqual(data.IODDesc, "hkLS0");
                Assert.AreEqual(data.CreateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.CreateTime.Value).Seconds < 10);
            }
        }
コード例 #3
0
        public void GetTest()
        {
            InOutDepot v = new InOutDepot();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.IODID    = "M5DrJo0E";
                v.IODType  = SCMSupplyChain.Model.IODType.出库;
                v.DepotsID = AddDepots();
                v.IODDesc  = "hkLS0";
                context.Set <InOutDepot>().Add(v);
                context.SaveChanges();
            }
            var rv = _controller.Get(v.ID.ToString());

            Assert.IsNotNull(rv);
        }
コード例 #4
0
        public void EditTest()
        {
            InOutDepot v = new InOutDepot();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.IODID    = "M5DrJo0E";
                v.IODType  = SCMSupplyChain.Model.IODType.出库;
                v.DepotsID = AddDepots();
                v.IODDesc  = "hkLS0";
                context.Set <InOutDepot>().Add(v);
                context.SaveChanges();
            }

            InOutDepotVM vm    = _controller.Wtm.CreateVM <InOutDepotVM>();
            var          oldID = v.ID;

            v    = new InOutDepot();
            v.ID = oldID;

            v.IODID   = "vZ3";
            v.IODType = SCMSupplyChain.Model.IODType.入库;
            v.IODDesc = "jC0Ed1aTh";
            vm.Entity = v;
            vm.FC     = new Dictionary <string, object>();

            vm.FC.Add("Entity.IODID", "");
            vm.FC.Add("Entity.IODType", "");
            vm.FC.Add("Entity.DepotsID", "");
            vm.FC.Add("Entity.IODDesc", "");
            var rv = _controller.Edit(vm);

            Assert.IsInstanceOfType(rv, typeof(OkObjectResult));

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data = context.Set <InOutDepot>().Find(v.ID);

                Assert.AreEqual(data.IODID, "vZ3");
                Assert.AreEqual(data.IODType, SCMSupplyChain.Model.IODType.入库);
                Assert.AreEqual(data.IODDesc, "jC0Ed1aTh");
                Assert.AreEqual(data.UpdateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.UpdateTime.Value).Seconds < 10);
            }
        }