Tests/Identity.Api.Tests/Controllers/RolesControllerTests.cs
/// <summary>
/// Given identity service faild to retrieve roles
/// When getting all roles
/// return error message
/// </summary>
Given identity service faild to retrieve roles
When getting all roles
return error message
Given identity service faild to retrieve roles When getting all roles return error message
[Fact]
        public void GetAllRoles_WhenIdentityServiceFails_ReturnErrorMessage()
        {
            _identityServiceMock.Setup(mock => mock.Roles).Throws(new Exception());
            ObjectResult result = _rolesController.GetAllRoles() as ObjectResult;
            Assert.NotNull(result);
            Assert.Equal(500, result.StatusCode);
            RolesListMessage resultValue = result.Value as RolesListMessage;
            Assert.False(resultValue.OperationStatus);
            Assert.Equal(MessageResources.FetchingAllRolesFailed, resultValue.ErrorMessages.First());
        }
[ Fact ] public void GetAllRoles_WhenIdentityServiceFails_ReturnErrorMessage ( ) { _identityServiceMock . Setup ( mock => mock . Roles ) . Throws ( new Exception ( ) ) ; ObjectResult result = _rolesController . GetAllRoles ( ) as ObjectResult ; Assert . NotNull ( result ) ; Assert . Equal ( 500 , result . StatusCode ) ; RolesListMessage resultValue = result . Value as RolesListMessage ; Assert . False ( resultValue . OperationStatus ) ; Assert . Equal ( MessageResources . FetchingAllRolesFailed , resultValue . ErrorMessages . First ( ) ) ; }
Given identity service faild to retrieve roles
When getting all roles
return error message
Given identity service faild to retrieve roles When getting all roles return error message
// Arrange // Act // Assert