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

            delayAdapter.WaitForResponseComplete();

            // Act
            delayAdapter.Dispose();

            // Assert
            Assert.True(_createdAdapter.IsDisposed);
        }
        public void DelayConnectingHttpSocketAdapter_AddRequestHeader_AddsHeadersAfterConnection()
        {
            // Arrange
            IHttpSocketAdapter delayAdapter = new DelayConnectingHttpSocketAdapter(ConnectOnlyOnce);

            delayAdapter.AddRequestHeader("Hello", "World");
            delayAdapter.AddRequestHeader("Hello2", "Planet");

            // Act
            delayAdapter.WaitForResponseComplete();

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

            // Act
            Task result = delayAdapter.WaitForResponseComplete();

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

            // Act
            _createdAdapter.SendResponseComplete();

            // Assert
            TaskAssert.Completed(result);
        }
        public void DelayConnectingHttpSocketAdapter_SetResponseHandler_SetsHandlerOnConnection()
        {
            // Arrange
            IHttpSocketAdapter delayAdapter = new DelayConnectingHttpSocketAdapter(ConnectOnlyOnce);

            delayAdapter.SetResponseHandler(HandleAsciiResponse);

            // Act
            delayAdapter.WaitForResponseComplete();

            // 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);
        }