Tests/Identity.Api.Tests/Controllers/UsersControllerTests.cs
/// <summary>
/// Given identity service faild to retrieve users
/// When getting all users
/// return error message
/// </summary>
Given identity service faild to retrieve users
When getting all users
return error message
Given identity service faild to retrieve users When getting all users return error message
[Fact]
        public void GetAllUsers_WhenIdentityServiceFails_ReturnErrorMessage()
        {
            _identityServiceMock.Setup(mock => mock.Users).Throws(new Exception());
            ObjectResult result = _usersController.GetAllUsers() as ObjectResult;
            Assert.NotNull(result);
            Assert.Equal(500, result.StatusCode);
            UsersListMessage resultValue = result.Value as UsersListMessage;
            Assert.False(resultValue.OperationStatus);
            Assert.Equal(MessageResources.FetchingAllUsersFailed, resultValue.ErrorMessages.First());
        }
[ Fact ] public void GetAllUsers_WhenIdentityServiceFails_ReturnErrorMessage ( ) { _identityServiceMock . Setup ( mock => mock . Users ) . Throws ( new Exception ( ) ) ; ObjectResult result = _usersController . GetAllUsers ( ) as ObjectResult ; Assert . NotNull ( result ) ; Assert . Equal ( 500 , result . StatusCode ) ; UsersListMessage resultValue = result . Value as UsersListMessage ; Assert . False ( resultValue . OperationStatus ) ; Assert . Equal ( MessageResources . FetchingAllUsersFailed , resultValue . ErrorMessages . First ( ) ) ; }
Given identity service faild to retrieve users
When getting all users
return error message
Given identity service faild to retrieve users When getting all users return error message
// Arrange // Act // Assert