public async Task AddPermission_WithPermissionId_ReturnsOkResult() { // Arrange var appRole = new ApplicationRole(); var mockRoleManager = Setup.GetRoleManagerMock(); var controller = new RoleController(mockRoleManager.Object); mockRoleManager.Setup(roleManager => roleManager.FindByIdAsync(It.IsAny <string>())).ReturnsAsync(appRole).Verifiable(); mockRoleManager.Setup(roleManager => roleManager.AddClaimAsync( It.Is <ApplicationRole>(role => role.Equals(appRole)), It.Is <Claim>(claim => claim.Type.Equals("Permission") && claim.Value.Equals("1")))) .ReturnsAsync(IdentityResult.Success) .Verifiable(); // Act var result = await controller.AddPermission(1, 1); // Assert mockRoleManager.Verify(); Assert.IsType <OkResult>(result); }