Beispiel #1
0
        public void IsnertTest()
        {
            var db          = DatabaseHelper.GetHelper("test");
            var repos       = new RepositoryDatabase <UserProfile>(db);
            var userprofile = Map.Create <UserProfile>();

            /*
             * Map.Create<UserProfile>()创建一个实体对象,与 new UserProfile()类似。
             * 但它们不同在于,Map.Create<UserProfile>()创建的对象可以探测到只赋值过的属性
             */
            userprofile.Name     = "test";
            userprofile.Email    = "*****@*****.**";
            userprofile.FixPhone = "860108888888";
            userprofile.Sex      = 1;
            repos.Insert(userprofile);

            var insertedUser = repos.Get(userprofile.Id);

            Assert.IsNotNull(insertedUser);
            Assert.AreEqual(userprofile.Id, insertedUser.Id);
            Assert.AreEqual(userprofile.Name, insertedUser.Name);
            Assert.AreEqual(userprofile.Email, insertedUser.Email);
            Assert.AreEqual(userprofile.FixPhone, insertedUser.FixPhone);
        }