我正在执行一些测试,如果消费者设置了一些 ID 或提供者数据库中不存在的任何文本,那么我想在提供者测试中执行以下步骤
- 接收 PACT 文件,其中包含需要首先设置的信息
- 然后我将拥有我的功能,它将开始将那些不可用的数据插入数据库
- 然后对 进行 API 调用,这将提供实际响应。
现在我想知道,消费者应该使用哪个字段让提供者知道,在实际 API 调用之前需要一些先决条件或预先设置。
我看到了示例,其中有一个 setUp : InsertIntoDatabase 但没有说明如何找到消费者提供的输入。
我正在执行一些测试,如果消费者设置了一些 ID 或提供者数据库中不存在的任何文本,那么我想在提供者测试中执行以下步骤
现在我想知道,消费者应该使用哪个字段让提供者知道,在实际 API 调用之前需要一些先决条件或预先设置。
我看到了示例,其中有一个 setUp : InsertIntoDatabase 但没有说明如何找到消费者提供的输入。
[TestMethod]
public void Ensure_OfferApi_HonoursPact_WithDeal_ForSendingLatestSoftOffer()
{
//Arrange
var outputter = new CustomOutputter();
var config = new PactVerifierConfig();
config.ReportOutputters.Add(outputter);
IPactVerifier pactVerifier = new PactVerifier(() => { InsertEventIntoDatabase(); }, () => { }, config);
pactVerifier
.ProviderState(
"Given the Offer Exist in Offer System I WANT TO See Latest SoftOffer",
setUp: InsertEventsIntoDatabase); // in case you want to insert something
//Act / Assert
using (var client = new HttpClient { BaseAddress = new Uri("http://localhost:9999") })
{
pactVerifier
.ServiceProvider("Offer API", client)
.HonoursPactWith("Consumer")
.PactUri(@"C:\TOSS\TestSample\log\deal-offer.json")
.Verify();
}
// Verify that verifaction log is also sent to additional reporters defined in the config
Assert.IsNotNull(outputter.Output);
}
Lets say the setup function is InsertEventsIntoDatabase and I want to add events what ever consumer is providing via PACT file. so that I dont need to update this code when ever Consumer changes the input.