public void BatchDeleteTest()
        {
            TeacherMajorManager v1 = new TeacherMajorManager();
            TeacherMajorManager v2 = new TeacherMajorManager();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.ID        = 72;
                v1.HonorId   = AddHonor();
                v1.TeacherId = AddTeacher();
                v2.ID        = 6;
                v2.HonorId   = v1.HonorId;
                v2.TeacherId = v1.TeacherId;
                context.Set <TeacherMajorManager>().Add(v1);
                context.Set <TeacherMajorManager>().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 <TeacherMajorManager>().Find(v1.ID);
                var data2 = context.Set <TeacherMajorManager>().Find(v2.ID);
                Assert.AreEqual(data1.IsValid, false);
                Assert.AreEqual(data2.IsValid, false);
            }

            rv = _controller.BatchDelete(new string[] {});
            Assert.IsInstanceOfType(rv, typeof(OkResult));
        }
        public void GetTest()
        {
            TeacherMajorManager v = new TeacherMajorManager();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.ID        = 72;
                v.HonorId   = AddHonor();
                v.TeacherId = AddTeacher();
                context.Set <TeacherMajorManager>().Add(v);
                context.SaveChanges();
            }
            var rv = _controller.Get(v.ID.ToString());

            Assert.IsNotNull(rv);
        }
        public void CreateTest()
        {
            TeacherMajorManagerVM vm = _controller.Wtm.CreateVM <TeacherMajorManagerVM>();
            TeacherMajorManager   v  = new TeacherMajorManager();

            v.ID        = 72;
            v.HonorId   = AddHonor();
            v.TeacherId = AddTeacher();
            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 <TeacherMajorManager>().Find(v.ID);

                Assert.AreEqual(data.ID, 72);
                Assert.AreEqual(data.CreateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.CreateTime.Value).Seconds < 10);
            }
        }
        public void EditTest()
        {
            TeacherMajorManager v = new TeacherMajorManager();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.ID        = 72;
                v.HonorId   = AddHonor();
                v.TeacherId = AddTeacher();
                context.Set <TeacherMajorManager>().Add(v);
                context.SaveChanges();
            }

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

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

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

            vm.FC.Add("Entity.ID", "");
            vm.FC.Add("Entity.HonorId", "");
            vm.FC.Add("Entity.TeacherId", "");
            var rv = _controller.Edit(vm);

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

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

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