public async Task Admin_ClientUserPermissionOperationsTest() { var permissionId = 888; var userId = 777; var ids = new IdArrayRequest(new List <int> { 1, 2, 3 }); var permissionRepository = container.Resolve <IPermissionRepository>(); var permissionRepositoryMock = Mock.Get(permissionRepository); permissionRepositoryMock .Setup(x => x.FindUserPermissionsByUserIds(It.IsAny <List <int> >())) .ReturnsAsync(new[] { new Repository.Model.UserPermission() { Id = permissionId } }); using (var http = new HttpClient()) { http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", TestContainerBuilder.BuildToken(container, 1, TokenClaims.CLAIM_PERMISSIONS_ADMIN)); var client = new Domain0Client(TEST_URL, http); await client.AddUserPermissionsAsync(userId, ids); permissionRepositoryMock.Verify(t => t.AddUserPermission(userId, It.IsAny <int[]>()), Times.Once); var permissions = await client.LoadPermissionsByUserFilterAsync(new UserPermissionFilter(new List <int> { userId })); permissionRepositoryMock.Verify(t => t.FindUserPermissionsByUserIds(It.Is <List <int> >(userIds => userIds.Contains(userId))), Times.Once); Assert.Equal(permissionId, permissions.FirstOrDefault()?.Id); await client.RemoveUserPermissionsAsync(userId, ids); permissionRepositoryMock.Verify(t => t.RemoveUserPermissions(userId, It.IsAny <int[]>()), Times.Once); } }