public void Execute_NullAuthenticateUserShouldReturnNullDataInResult()
        {
            //arrange
            var tokenManager     = new Mock <ITokenManager>();
            var authenticateUser = new AuthenticateUser(tokenManager.Object);

            //act
            var result = authenticateUser.Execute(new LoginModel());

            //assert
            Assert.Null(result.Data);
        }
        public void Execute_NullAuthenticateUserShouldReturnErrorMessageInResult()
        {
            //arrange
            var tokenManager     = new Mock <ITokenManager>();
            var authenticateUser = new AuthenticateUser(tokenManager.Object);

            //act
            var result = authenticateUser.Execute(new LoginModel());

            //assert
            Assert.Equal("Login failed.  Please try again.", result.Message);
        }
        public void Execute_ShouldReturnUnsuccessfulResultModel()
        {
            //arrange
            var tokenManager     = new Mock <ITokenManager>();
            var authenticateUser = new AuthenticateUser(tokenManager.Object);

            //act
            var result = authenticateUser.Execute(new LoginModel());

            //assert
            Assert.False(result.Success);
        }
        public async Task <ActionResult> Authenticate([FromBody] UserIdentity userIdentity)
        {
            try
            {
                var authenticationResult = await _authenticateUser.Execute(userIdentity);

                return(StatusCode((int)authenticationResult.ResultType, authenticationResult.Object));
            }
            catch (System.Exception exc)
            {
                return(StatusCode((int)ResultType.InternalServerError, exc.Message));
            }
        }