public void DelayConnectingHttpSocketAdapter_WriteToRequestAsync_DoesNotAttemptToConnectAfterFailure() { // Arrange IHttpSocketAdapter delayAdapter = new DelayConnectingHttpSocketAdapter(FailToConnect); byte[] bytesToWrite = Encoding.ASCII.GetBytes("Hello, world!"); delayAdapter.WriteToRequestAsync(bytesToWrite, 7, 5); // Act Task result = delayAdapter.WriteToRequestAsync(bytesToWrite, 7, 5); // Assert // If we got here, a second connection was not attempted TaskAssert.Completed(result); }
public void DelayConnectingHttpSocketAdapter_WriteToRequestAsync_WritesDataToSameConnection() { // Arrange IHttpSocketAdapter delayAdapter = new DelayConnectingHttpSocketAdapter(ConnectOnlyOnce); byte[] bytesToWrite = Encoding.ASCII.GetBytes("Hello, world!"); delayAdapter.WriteToRequestAsync(bytesToWrite, 0, 7); // Act delayAdapter.WriteToRequestAsync(bytesToWrite, 7, 5); // Assert Assert.True(_createdAdapter != null, "Adapter was not created."); Assert.Equal("Hello, world", _createdAdapter.RequestContent); }
public void DelayConnectingHttpSocketAdapter_WriteToRequestAsync_DoesNothingAfterFailureToConnect() { // Arrange IHttpSocketAdapter delayAdapter = new DelayConnectingHttpSocketAdapter(FailToConnect); byte[] bytesToWrite = Encoding.ASCII.GetBytes("Hello, world!"); // Act Task result = delayAdapter.WriteToRequestAsync(bytesToWrite, 7, 5); // Assert TaskAssert.Completed(result); }
public void DelayConnectingHttpSocketAdapter_WriteToRequestAsync_ConnectsAndWritesData() { // Arrange IHttpSocketAdapter delayAdapter = new DelayConnectingHttpSocketAdapter(ConnectOnlyOnce); byte[] bytesToWrite = Encoding.ASCII.GetBytes("Hello, world!"); // Act Task result = delayAdapter.WriteToRequestAsync(bytesToWrite, 7, 5); // Assert Assert.True(result != null, "No Task was returned."); Assert.True(_createdAdapter != null, "Adapter was not created."); Assert.Equal("world", _createdAdapter.RequestContent); }
public void DelayConnectingHttpSocketAdapter_CompleteRequest_DoesNotRecreateConnection() { // Arrange IHttpSocketAdapter delayAdapter = new DelayConnectingHttpSocketAdapter(ConnectOnlyOnce); byte[] bytesToWrite = Encoding.ASCII.GetBytes("Hello"); delayAdapter.WriteToRequestAsync(bytesToWrite, 0, bytesToWrite.Length); // Act delayAdapter.CompleteRequest(); // Assert Assert.True(_createdAdapter != null, "Adapter was not created."); Assert.True(_createdAdapter.IsCompleted, "Adapter was not Completed."); }