コード例 #1
0
 public void AddRoleTest()
 {
     var roleManageService = new RoleManageAppService();
     var role = roleManageService.AddRole("管理员", string.Empty);
     Assert.IsNotNull(role);
     Assert.AreNotEqual(string.Empty, role.Id);
 }
コード例 #2
0
        public void DeleteRoleTest()
        {
            var roleManageService = new RoleManageAppService();
            var role = roleManageService.AddRole("TestRole", string.Empty);
            Assert.IsNotNull(role);

            string roleId = role.Id;

            using (var context = RepositoryContext.Create())
            {
                var roleRepository = context.GetRepository<RoleRepository>();
                var roleEntity = roleRepository.Get(roleId);
                Assert.IsNotNull(roleEntity);
                Assert.AreNotEqual(string.Empty, roleEntity.Id);
            }

            using (var context = RepositoryContext.Create())
            {
                var roleRepository = context.GetRepository<RoleRepository>();
                roleManageService.DeleteRole(roleId);
                var testRoleEntity = roleRepository.Get(roleId);
                Assert.IsNull(testRoleEntity);
            }
        }