static void Main(string[] args)
        {
            UserController contoller = new UserController();
            BusinessController contollerCom = new BusinessController();

            //insert
            string _guid0 = Guid.NewGuid().ToString();
            var myusers = new users(){
                userid = _guid0,username = "******",passwordword = "1",name = "0a",sex = "男"
            };
            Console.WriteLine("after insert:" + _guid0);
            contollerCom.Insert<users>(myusers);
            Console.WriteLine(contoller.print(contollerCom.Get<users>("userid", _guid0)));

            var myuserLists = new List<users>{
                new users(){userid = Guid.NewGuid().ToString(),username = "******",passwordword = "1",name = "1a"},
                new users(){userid = Guid.NewGuid().ToString(),username = "******",passwordword = "1",name = "2a"}
            };
            Console.WriteLine("after insert many:");            ;
            Console.WriteLine(contollerCom.InsertList<users>(myuserLists));

            //update
            List<users> mylist = contollerCom.Get<users>(u => u.username == "0");
            var curUser = mylist.First<users>();
            Console.WriteLine("before update:" + curUser.userid);
            Console.WriteLine(contoller.print(curUser));
            curUser.username = "******";
            contollerCom.Update<users>(curUser, "userid");
            Console.WriteLine("after update:" + curUser.userid);
            Console.WriteLine(contoller.print(contollerCom.Get<users>(u => u.username == "0axiugai")));
            //manual update
            Console.WriteLine("manual update:" + curUser.userid);
            contoller.Modify(curUser.userid);
            Console.WriteLine(contoller.print(contollerCom.Get<users>(u => u.userid == curUser.userid)));

            //delete
            Console.WriteLine("delete all:" + _guid0);
            contollerCom.Delete<users>("userid", _guid0);
            Console.WriteLine(contoller.print(contollerCom.Get<users>("select * from users ")));
            Console.WriteLine("delete u.sex==男:");
            contollerCom.Delete<users>(u=>u.sex=="男");
            Console.WriteLine(contoller.print(contollerCom.Get<users>("select * from users ")));

            //select
            Console.WriteLine("select all:");
            Console.WriteLine(contoller.print());
            Console.WriteLine("select * from users where username='******'");
            Console.WriteLine(contoller.print(
                contollerCom.Get<users>("select * from users where username='******'")
                ));
            Console.WriteLine("u=>u.username==1");
            Console.WriteLine(contoller.print(
                contollerCom.Get<users>(u => u.username == "1a")
                ));

            Console.ReadKey();
        }
Exemple #2
0
        public void Update_NotExistObject_ShouldReturnNotFound()
        {
            var bus3 = new Business {
                Id = 3, Name = "name3", Families = null
            };

            mock.Setup(repo => repo.GetAllItems(null)).Returns(listItems.AsQueryable());
            mock.Setup(repo => repo.Update(bus3));
            var controller = new BusinessController(mockChild.Object, mock.Object);

            var result = controller.Update(bus3);

            Assert.IsAssignableFrom <ActionResult <Business> >(result);
            Assert.IsType <NotFoundResult>(result.Result);
        }
Exemple #3
0
        public void Update_ValidObject_ShouldReturnUpdatedObject()
        {
            var bus3 = new Business {
                Id = 1, Name = "name3", Families = null
            };

            mock.Setup(repo => repo.GetAllItems(null)).Returns(listItems.AsQueryable());
            mock.Setup(repo => repo.Update(bus3));
            var controller = new BusinessController(mockChild.Object, mock.Object);

            var result = controller.Update(bus3);

            Assert.IsAssignableFrom <ActionResult <Business> >(result);
            Assert.Equal(bus3.Id, result.Value.Id);
        }