title: C# PACT - Consumer Driven Contact testing - writing test for provider
body: <p>I am trying to get my head about <a href="https://docs.pact.io/" rel="nofollow noreferrer">PACT</a> and I am using the <a href="https://github.com/SEEK-Jobs/pact-net" rel="nofollow noreferrer">PACT-Net</a> library to achieve this.</p>
  
  <p>My  tests on the Consumer are working fine but I am trying to setup the  tests on the Provider.  I am using the basic Web API project that loads when you use the Web API template within Visual Studio - which creates the Values API controller.  I am just testing the Get <code>IEumerable&lt;string&gt;</code> method as an end to end test of the process.  I am also following the example on the PACT-Net github site.  Here is the  test I have so far:</p>
  
  <pre><code>    [Fact]
      public void EnsureValuesReturnedFromApi()
      {
          var config = new PactVerifierConfig
          {
              Outputters = new List&lt;IOutput&gt;
              {
                  new XUnitOutput(_output)
              }
          };
  
      using (WebApp.Start&lt;TestStartup&gt;(serviceUri))
      {
          var pactVerifier = new PactVerifier(config);
          pactVerifier.ProviderState($"{serviceUri}/provider-states")
              .ServiceProvider("Values API", serviceUri)
              .HonoursPactWith("Consumer")
              .PactUri("http://localhost:8080/pacts/provider/Values%20API/consumer/Consumer/latest")
              .Verify();
      }
  }
  </code></pre>
  
  <p>When ever I run the unit test I get the following error:</p>
  
  <pre><code>Reading pact at http://localhost:8080/pacts/provider/Values%20API/consumer/Consumer/latest
  
  Verifying a pact between Consumer and Values API
    Given When I want the values
      Getting a list
        with GET /api/values
          returns a response which
            has status code 200 (FAILED - 1)
            has a matching body (FAILED - 2)
            includes headers
              "Accept" with value "application/json" (FAILED - 3)
              "Content-Type" with value "application/json" (FAILED - 4)
  
  Failures:
  
    1) Verifying a pact between Consumer and Values API Given When I want the values Getting a list with GET /api/values returns a response which has status code 200
       Failure/Error: set_up_provider_state interaction.provider_state, options[:consumer]
  
       Pact::ProviderVerifier::SetUpProviderStateError:
         Error setting up provider state 'When I want the values' for consumer 'Consumer' at http://localhost:9222/provider-states. response status=500 response body=
  
    2) Verifying a pact between Consumer and Values API Given When I want the values Getting a list with GET /api/values returns a response which has a matching body
       Failure/Error: set_up_provider_state interaction.provider_state, options[:consumer]
  
       Pact::ProviderVerifier::SetUpProviderStateError:
         Error setting up provider state 'When I want the values' for consumer 'Consumer' at http://localhost:9222/provider-states. response status=500 response body=
  
    3) Verifying a pact between Consumer and Values API Given When I want the values Getting a list with GET /api/values returns a response which includes headers "Accept" with value "application/json"
       Failure/Error: set_up_provider_state interaction.provider_state, options[:consumer]
  
       Pact::ProviderVerifier::SetUpProviderStateError:
         Error setting up provider state 'When I want the values' for consumer 'Consumer' at http://localhost:9222/provider-states. response status=500 response body=
  
    4) Verifying a pact between Consumer and Values API Given When I want the values Getting a list with GET /api/values returns a response which includes headers "Content-Type" with value "application/json"
       Failure/Error: set_up_provider_state interaction.provider_state, options[:consumer]
  
       Pact::ProviderVerifier::SetUpProviderStateError:
         Error setting up provider state 'When I want the values' for consumer 'Consumer' at http://localhost:9222/provider-states. response status=500 response body=
  
  1 interaction, 1 failure
  
  Failed interactions:
  
  * Getting a list given When I want the values
  </code></pre>
  
  <p>I guess my question is, do I need to actually test the HTTP calls to /api/values or am I missing something else?</p>
  
  <p>Thanks</p>