title: Set dummy IP address in integration test with Asp.Net Core TestServer
body: <p>I have a C# Asp.Net Core (1.x) project, implementing a web REST API, and its related integration test project, where before any test there's a setup similar to:</p>
  
  <pre class="lang-cs prettyprint-override"><code>// ...
  
  IWebHostBuilder webHostBuilder = GetWebHostBuilderSimilarToRealOne()
      .UseStartup&lt;MyTestStartup&gt;();
  
  TestServer server = new TestServer(webHostBuilder);
  server.BaseAddress = new Uri("http://localhost:5000");
  
  HttpClient client = server.CreateClient();
  
  // ...
  </code></pre>
  
  <p>During tests, the <code>client</code> is used to send HTTP requests to web API (the system under test) and retrieve responses.</p>
  
  <p>Within actual system under test there's some component extracting sender IP address from each request, as in:</p>
  
  <pre class="lang-cs prettyprint-override"><code>HttpContext httpContext = ReceiveHttpContextDuringAuthentication();
  
  // edge cases omitted for brevity
  string remoteIpAddress = httpContext?.Connection?.RemoteIpAddress?.ToString()
  </code></pre>
  
  <p>Now during integration tests this bit of code fails to find an IP address, as <code>RemoteIpAddress</code> is always null.</p>
  
  <p>Is there a way to set that to some known value from within test code? I searched here on SO but could not find anything similar. TA</p>