title: "mocking" a class when in development
body: <p>I have this problem where I need to make an external API call, however when in production I have to use a certificate for the API call and in development I don't really need one. I was wondering how to implement a solution where I can have separation between production code and development code so I don't have to comment the part out and possible forget to change it. Any tips would be appreciated!</p>
  <pre><code>public async Task&lt;GetPersonResponse&gt; PostPerson(PersonDto dto) 
  {
      try {
          var httpHandler = new HttpClientHandler();
  
          var certificate = new X509Certificate2(
              Path.Join(_certOptions.Path, _certOptions.Name),
              _certOptions.Password, 
              X509KeyStorageFlags.MachineKeySet);
  
          httpHandler.ClientCertificates.Add(certificate);
  
          var client = new HttpClient(httpHandler);
  
          var soapRequest = GenerateRequest(dto);
  
          var request = new HttpRequestMessage() {
              RequestUri = new Uri(_options.Value.URL),
              Method = HttpMethod.Post,
              Content = new StringContent(soapRequest.ToString(), Encoding.UTF8, &quot;text/xml&quot;),
          };
  
          var response = await client.SendAsync(request);
      }
  }
  
  </code></pre>