I have implemented PACT on consumer side in C# dotnet core and I was able to publish *.json pact file to PactBrocker using following code.
var pactPublisher = new PactPublisher("http://domain.pact.dius.com.au", new PactUriOptions("***", "***"));
pactPublisher.PublishToBroker($"..\pacts\userservice.api-event.api.json",
"1.0.2");
On provider side (again in C# dotnet core), when I try to verify the same published Pact, using a unit test case (see below code):
[Fact]
public void EnsureEventApiHonoursPactWithConsumer()
{
//Arrange
// createing the "config" object
//Act / Assert
IPactVerifier pactVerifier = new PactVerifier(config);
pactVerifier
.ProviderState($"{_providerUri}/provider-states")
.ServiceProvider("Event.API", _providerUri)
.HonoursPactWith("UserService.API")
.PactUri("http://domain.pact.dius.com.au/pacts/provider/Event.API/consumer/UserService.API/version/1.0.2", new PactUriOptions("***", "***")).Verify();
}
I get below error when I run that unit test.
PactNet.PactFailureException : Pact verification failed. See output for details. If the output is empty please provide a custom config.Outputters (IOutput) for your test framework, as we couldn't write to the console. at PactNet.Core.PactCoreHost`1.Start() in C:\projects\pact-net\PactNet\Core\PactCoreHost.cs:line 139
at Event.Test.EventApiTests.EnsureEventApiHonoursPactWithConsumer() in C:\POC\pact2\Event.Api\Event.Test\EventAPITests.cs:line 55
Error reading file from http://domain.pact.dius.com.au/pacts/provider/Event.API/consumer/UserService.API/version/1.0.2
No connection could be made because the target machine actively refused it. - connect(2) for "domain.pact.dius.com.au" port 80 C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:in `initialize'
C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:in `open'
C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:in `block in connect'
C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/timeout.rb:74:in `timeout'
C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:878:in `connect'
C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:863:in `do_start'
C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:852:in `start'
Can someone please help fixing this error? The PACT broker server is not in my control. I got it from http://pact.dius.com.au/ site.