我在点网核心中使用pact-dotnet核心nuget编写合同测试。
在消费者测试中,如何动态指定body参数,我的意思是我想从文件中读取预期的响应并将其注入。 例如
**var expectedResponse = FileReader.GetJsonObject("GetCustomerResponse.json",
_environment);**
// Arrange
_mockProviderService.Given("There is data")
.UponReceiving("A valid GET request for get customer1")
.With(new ProviderServiceRequest
{
Method = HttpVerb.Get,
Path = "/customers/1234"
})
.WillRespondWith(new ProviderServiceResponse
{
Status = 200,
Headers = new Dictionary<string, object>
{
{ "Content-Type", "application/json; charset=utf-8" }
},
Body = **expectedResponse**
});
谢谢!