示例#1
0
 public void GetByKey()
 {
     try
     {
         _unitOfWork = new UnitOfWork();
         IRoleRepository roleRepository = new RoleUnitOfWorkRepository(_unitOfWork);
         Role            role           = roleRepository.GetByKey("TestUser");
         Role            expect         = new Role()
         {
             Id = "TestUser", Name = "测试用户"
         };
         Assert.AreEqual <Role>(expect, role);
         _unitOfWork.Commit();
     }
     catch (Exception ex)
     {
         Assert.IsTrue(false);
     }
 }
示例#2
0
        public void Add()
        {
            try
            {
                _unitOfWork = new UnitOfWork();
                IRoleRepository roleRepository = new RoleUnitOfWorkRepository(_unitOfWork);
                if (roleRepository.GetByKey("TestUser") == null)
                {
                    roleRepository.Add(new Role()
                    {
                        Id = "TestUser", Name = "测试用户"
                    });
                }

                _unitOfWork.Commit();
            }
            catch (Exception ex)
            {
                Assert.IsTrue(false);
            }
        }