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); } }
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); } }