コード例 #1
0
        public void DeleteTest()
        {
            area_location v = new area_location();
            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
        		
                v.AreaID = AddArea();
                v.Location = "Cw7Go";
                context.Set<area_location>().Add(v);
                context.SaveChanges();
            }

            PartialViewResult rv = (PartialViewResult)_controller.Delete(v.ID.ToString());
            Assert.IsInstanceOfType(rv.Model, typeof(area_locationVM));

            area_locationVM vm = rv.Model as area_locationVM;
            v = new area_location();
            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<area_location>().Count(), 0);
            }

        }
コード例 #2
0
        public void CreateTest()
        {
            PartialViewResult rv = (PartialViewResult)_controller.Create();
            Assert.IsInstanceOfType(rv.Model, typeof(area_locationVM));

            area_locationVM vm = rv.Model as area_locationVM;
            area_location v = new area_location();
			
            v.AreaID = AddArea();
            v.Location = "Cw7Go";
            vm.Entity = v;
            _controller.Create(vm);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data = context.Set<area_location>().FirstOrDefault();
				
                Assert.AreEqual(data.Location, "Cw7Go");
                Assert.AreEqual(data.CreateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.CreateTime.Value).Seconds < 10);
            }

        }
コード例 #3
0
        public void EditTest()
        {
            area_location v = new area_location();
            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
       			
                v.AreaID = AddArea();
                v.Location = "Cw7Go";
                context.Set<area_location>().Add(v);
                context.SaveChanges();
            }

            PartialViewResult rv = (PartialViewResult)_controller.Edit(v.ID.ToString());
            Assert.IsInstanceOfType(rv.Model, typeof(area_locationVM));

            area_locationVM vm = rv.Model as area_locationVM;
            v = new area_location();
            v.ID = vm.Entity.ID;
       		
            v.Location = "Bs8U";
            vm.Entity = v;
            vm.FC = new Dictionary<string, object>();
			
            vm.FC.Add("Entity.AreaID", "");
            vm.FC.Add("Entity.Location", "");
            _controller.Edit(vm);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data = context.Set<area_location>().FirstOrDefault();
 				
                Assert.AreEqual(data.Location, "Bs8U");
                Assert.AreEqual(data.UpdateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.UpdateTime.Value).Seconds < 10);
            }

        }