Tests/Identity.Api.Tests/Controllers/UsersControllerTests.cs
/// <summary>
/// Given not null request
/// and identity service returns a response
/// When unassigning user from a role
/// Return ok result
/// </summary>
Given not null request
and identity service returns a response
When unassigning user from a role
Return ok result
Given not null request and identity service returns a response When unassigning user from a role Return ok result
[Fact]
        public async Task UnassignRoleToUserAsync_NotNullRequest_IdentityServiceReturnsResponse_ReturnOkResult()
        {
            UserRoleAssignmentRequest request = new UserRoleAssignmentRequest
            {
                Login = "niahahaw",
                RoleName = "bully"
            };
            _identityServiceMock.Setup(mock => mock.UnassignRoleToUserAsync(request)).ReturnsAsync(new ResultMessage
            {
                OperationStatus = true
            });
            OkObjectResult result = await _usersController.UnassignRoleToUserAsync(request).ConfigureAwait(false)
                as OkObjectResult;
            Assert.NotNull(result); ;
            ResultMessage authenticationResult = result.Value as ResultMessage;
            Assert.True(authenticationResult.OperationStatus);
        }
[ Fact ] public async Task UnassignRoleToUserAsync_NotNullRequest_IdentityServiceReturnsResponse_ReturnOkResult ( ) { UserRoleAssignmentRequest request = new UserRoleAssignmentRequest { Login = " " , RoleName = " " } ; _identityServiceMock . Setup ( mock => mock . UnassignRoleToUserAsync ( request ) ) . ReturnsAsync ( new ResultMessage { OperationStatus = true } ) ; OkObjectResult result = await _usersController . UnassignRoleToUserAsync ( request ) . ConfigureAwait ( false ) as OkObjectResult ; Assert . NotNull ( result ) ; ; ResultMessage authenticationResult = result . Value as ResultMessage ; Assert . True ( authenticationResult . OperationStatus ) ; }
Given not null request
and identity service returns a response
When unassigning user from a role
Return ok result
Given not null request and identity service returns a response When unassigning user from a role Return ok result
// Arrange // Act // Assert