Tests/Identity.Api.Tests/Controllers/UsersControllerTests.cs
/// <summary>
/// Given not null request
/// and identity service returns a response
/// When authenticating user
/// Return ok result
/// </summary>
Given not null request
and identity service returns a response
When authenticating user
Return ok result
Given not null request and identity service returns a response When authenticating user Return ok result
[Fact]
        public async Task AuthenticateUserAsync_NotNullRequest_IdentityServiceReturnsResponse_ReturnOkResult()
        {
            string token = "haw-haw no token";
            AuthenticationRequest request = new AuthenticationRequest
            {
                Login = "niahahaw",
                Password = "mydummypassword"
            };
            _identityServiceMock.Setup(mock => mock.AuthenticateUserAsync(request)).ReturnsAsync(new AuthenticationResult
            {
                OperationStatus = true,
                Token = token
            });
            OkObjectResult result = await _usersController.AuthenticateUserAsync(request).ConfigureAwait(false)
                as OkObjectResult;
            Assert.NotNull(result);;
            AuthenticationResult authenticationResult = result.Value as AuthenticationResult;
            Assert.True(authenticationResult.OperationStatus);
            Assert.Equal(token, authenticationResult.Token);
        }
[ Fact ] public async Task AuthenticateUserAsync_NotNullRequest_IdentityServiceReturnsResponse_ReturnOkResult ( ) { string token = " " ; AuthenticationRequest request = new AuthenticationRequest { Login = " " , Password = " " } ; _identityServiceMock . Setup ( mock => mock . AuthenticateUserAsync ( request ) ) . ReturnsAsync ( new AuthenticationResult { OperationStatus = true , Token = token } ) ; OkObjectResult result = await _usersController . AuthenticateUserAsync ( request ) . ConfigureAwait ( false ) as OkObjectResult ; Assert . NotNull ( result ) ; ; AuthenticationResult authenticationResult = result . Value as AuthenticationResult ; Assert . True ( authenticationResult . OperationStatus ) ; Assert . Equal ( token , authenticationResult . Token ) ; }
Given not null request
and identity service returns a response
When authenticating user
Return ok result
Given not null request and identity service returns a response When authenticating user Return ok result
// Arrange // Act // Assert