public void DelayConnectingHttpSocketAdapter_AddRequestHeader_AddsHeadersToExistingConnection()
        {
            // Arrange
            IHttpSocketAdapter delayAdapter = new DelayConnectingHttpSocketAdapter(ConnectOnlyOnce);

            delayAdapter.GetResponseStatusCode();

            // Act
            delayAdapter.AddRequestHeader("Hello", "World");

            // Assert
            Assert.True(_createdAdapter.RequestHeaders.ContainsKey("Hello"), "Header 'Hello' should be added.");
            Assert.Equal("World", _createdAdapter.RequestHeaders["Hello"]);
        }
        public void DelayConnectingHttpSocketAdapter_GetResponseStatusCode_ConnectsAndRequestsStatusCode()
        {
            // Arrange
            IHttpSocketAdapter delayAdapter = new DelayConnectingHttpSocketAdapter(ConnectOnlyOnce);

            // Act
            Task <int> result = delayAdapter.GetResponseStatusCode();

            // Assert
            Assert.True(_createdAdapter != null, "Adapter was not created.");
            TaskAssert.NotCompleted(result, "Status code should not be returned yet.");

            // Act
            _createdAdapter.SendResponseStatusCode(304);

            // Assert
            TaskAssert.ResultEquals(result, 304);
        }
        public void DelayConnectingHttpSocketAdapter_SetResponseHandler_SetsHandlerOnExistingConnection()
        {
            // Arrange
            IHttpSocketAdapter delayAdapter = new DelayConnectingHttpSocketAdapter(ConnectOnlyOnce);

            delayAdapter.GetResponseStatusCode();

            // Act
            delayAdapter.SetResponseHandler(HandleAsciiResponse);

            // Assert
            Assert.True(_createdAdapter.HasResponseHandler, "Response handler was not set.");

            // Act
            _createdAdapter.SendResponseBodyContent("This is a test", Encoding.ASCII);

            // Assert
            Assert.Equal("This is a test", _responseContent);
        }