This repository was archived by the owner on Feb 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Exception when running demo provider test #17
Copy link
Copy link
Open
Description
When I run the demo test project with Pactify library installed from NuGet, I'm getting this:
Demo.Test.Integration.Provider.Provider_Should_Meet_Consumers_Expectations
System.ArgumentNullException : Value cannot be null.
Parameter name: source
at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)
at Pactify.Verifiers.HttpCouplingVerifier.VerifyAsync(HttpInteractionDefinition definition, PactDefinitionOptions options)
at Pactify.PactVerifier.VerifyAsync()
at Demo.Test.Integration.Provider.Provider_Should_Meet_Consumers_Expectations() in /***/Provider.cs:line 15
--- End of stack trace from previous location where exception was thrown ---
When I run the demo test having Pactify cloned from this repo as a reference project, I'm getting this:
Demo.Test.Integration.Provider.Provider_Should_Meet_Consumers_Expectations
Pactify.PactifyException : Expected response status code OK, but was NotFound
Expected response header content-Type was not present.
at Pactify.PactVerifier.VerifyAsync() in /***/Pactify/PactVerifier.cs:line 90
at Demo.Test.Integration.Provider.Provider_Should_Meet_Consumers_Expectations() in /***/Provider.cs:line 15
--- End of stack trace from previous location where exception was thrown ---
Source code for Consumer.cs:
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Demo.Test.Integration.Fixtures;
using Pactify;
using Xunit;
namespace Demo.Test.Integration
{
public class Consumer
{
[Fact]
public async Task Consumer_Should_Create_A_Pact()
{
var options = new PactDefinitionOptions
{
IgnoreContractValues = true,
IgnoreCasing = true
};
await PactMaker
.Create(options)
.Between("orders", "parcels")
.WithHttpInteraction(cb => cb
.Given("There is a parcel with some id")
.UponReceiving("A GET Request to retrieve the parcel")
.With( request => request
.WithMethod(HttpMethod.Get)
.WithPath("api/parcels/1"))
.WillRespondWith(response => response
.WithHeader("Content-Type", "application/json")
.WithStatusCode(HttpStatusCode.OK)
.WithBody<ParcelReadModel>()))
.PublishedAsFile(System.IO.Path.Join(
(new DirectoryInfo(Environment.CurrentDirectory)).Parent.Parent.Parent.ToString(), "pacts"))
.MakeAsync();
}
}
}Source code for Provider.cs:
using System;
using System.IO;
using System.Threading.Tasks;
using Demo.Test.Integration.Fixtures;
using Pactify;
using Xunit;
namespace Demo.Test.Integration
{
public class Provider
{
[Fact]
public async Task Provider_Should_Meet_Consumers_Expectations()
{
await PactVerifier
.CreateFor<Startup>()
.Between("orders", "parcels")
.RetrievedFromFile(System.IO.Path.Join(
(new DirectoryInfo(Environment.CurrentDirectory)).Parent.Parent.Parent.ToString(), "pacts"))
.VerifyAsync();
}
}
}Project structure:
Demo.Test.Integration/
Fixtures/
ParcelReadModel.cs
Startup.cs
pacts/
orders-parcels.json (generated)
Consumer.cs
Provider.cs
The source code for files ParcelReadModel.cs and Startup.cs is untouched, they are exactly as is here. I also tried with netcoreapp2.1 and 3.1, I'm getting exactly the same result.
Thanks!
Metadata
Metadata
Assignees
Labels
No labels

