title: NSubstitute returns first InlineData value for all tests
body: <p>I am relatively new to testing. We use XUnit and NSubstitute as our testing frameworks and I am having trouble with what should be a simple test. I am using a Class library to interact with an external api and I need to be able to determine if the api is available before performing operations. (I should mention that the dll already works. We are retroactively adding tests.) </p>
  
  <p>The problem I am encountering is that no matter what the InlineData is for the test, the substitute (client.Execute...) only ever returns the value for the first InlineData value. If the first value is HttpStatusCode.OK, then other InlineData values fail the test because the substitute only returns HttpStatusCode.OK. If I swap OK with Forbidden, then the HttpStatusCode.OK fails because the substitute only ever returns Forbidden as the StatusCode.</p>
  
  <p>I could break these out into separate tests, but I would prefer to understand the behavior before doing so.</p>
  
  <h2>The Test</h2>
  
  <pre><code>[Theory]
  [InlineData(HttpStatusCode.OK)]
  [InlineData(HttpStatusCode.Forbidden)]
  [InlineData(HttpStatusCode.BadRequest)]
  [InlineData(HttpStatusCode.NotFound)]
  public void ConnectionCheck(HttpStatusCode code)
  {
      var d2lClient = new d2lClient("userid", "userkey", "mappid", "mappkey", "serviceurl.com", "1");
      var client = Substitute.For&lt;IRestClient&gt;();
      var authenticator = Substitute.For&lt;iITGValenceAuthenticator&gt;();
  
      client.Execute&lt;WhoAmIUser&gt;(Arg.Any&lt;IRestRequest&gt;()).ReturnsForAnyArgs(x =&gt; new RestResponse&lt;WhoAmIUser&gt;()
          {
              StatusCode = code
          });
  
  
      d2lClient.GetOrCreateRestClient(client);
      d2lClient.GetOrCreateAuthenticator(authenticator);
  
      if (code == HttpStatusCode.OK)
      {
          Assert.True(d2lClient.ConnectionCheck(), "client.ConnectionCheck() should be true for " + code);
      }
      else
      {
          Assert.False(d2lClient.ConnectionCheck(), "client.ConnectionCheck() should be false for " + code);
      }
  }
  </code></pre>
  
  <h2>The Method</h2>
  
  <pre><code>public bool ConnectionCheck()
  {
      if (_userId == null || _userKey == null || _mAppId == null || _mAppKey == null)
          return false;
  
      try
      {
          var response = GetRestResponse&lt;WhoAmIUser&gt;(_userId, _userKey, d2lRoute.WhoAmI());
  
          return response.StatusCode == HttpStatusCode.OK;
      }
      catch (Exception ex)
      {
          return false;
      }
  }
  
  public IRestResponse&lt;T&gt; GetRestResponse&lt;T&gt;(string userId, string userKey, string url, List&lt;Parameter&gt; parameters = null, IRestRequest request = null, IRestClient client = null, iITGValenceAuthenticator authenticator = null) where T : new()
  {
      /*
         Irrelevant code
      */
      return _client.Execute&lt;T&gt;(request);
  }
  </code></pre>