public async void AuthAsync_WithAuthRequest__ShouldPostToBankIdAuth_WithJsonPayload()
        {
            // Arrange

            // Act
            await _bankIdApiClient.AuthAsync(new AuthRequest("1.1.1.1"));

            // Assert
            Assert.Single(_messageHandlerMock.Invocations);
            var request = _messageHandlerMock.GetFirstArgumentOfFirstInvocation <HttpMessageHandler, HttpRequestMessage>();

            Assert.NotNull(request);

            Assert.Equal(HttpMethod.Post, request.Method);
            Assert.Equal(new Uri("https://bankid/auth"), request.RequestUri);
            Assert.Equal(new MediaTypeHeaderValue("application/json"), request.Content.Headers.ContentType);
        }
        public async void AuthAsync_WithAuthRequest__ShouldParseAndReturnOrderRef_AndAutoStartToken()
        {
            // Arrange
            var httpClient   = GetHttpClientMockWithOkResponse("{ \"orderRef\": \"abc123\", \"autoStartToken\": \"def456\" }");
            var bankIdClient = new BankIdApiClient(httpClient);

            // Act
            var result = await bankIdClient.AuthAsync(new AuthRequest("1.1.1.1"));

            // Assert
            Assert.NotNull(result);
            Assert.Equal("abc123", result.OrderRef);
            Assert.Equal("def456", result.AutoStartToken);
        }
        public async void ErrorResponse__ShouldThrowException_WithErrorCode_AndDetails()
        {
            // Arrange
            var messageHandlerMock = GetHttpClientMessageHandlerMock(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.BadRequest,
                Content    = new StringContent("{ \"errorCode\": \"AlreadyInProgress\", \"details\": \"d\" }", Encoding.Default, "application/json"),
            });

            var httpClient = new HttpClient(messageHandlerMock.Object)
            {
                BaseAddress = new Uri("https://bankid/")
            };
            var bankIdApiClient = new BankIdApiClient(httpClient);

            // Act
            var exception = await Assert.ThrowsAsync <BankIdApiException>(() => bankIdApiClient.AuthAsync(new AuthRequest("1.1.1.1")));

            // Assert
            Assert.Equal(ErrorCode.AlreadyInProgress, exception.ErrorCode);
            Assert.Equal("d", exception.ErrorDetails);
        }