我有使用 pact v3 的代码。我已升级到 pact v4,并按照升级指南中的说明进行操作。
当我运行契约消费者测试时,出现以下错误:
Message: PactNet.Exceptions.PactFailureException : Unable to perform
the given action. The interop call indicated failure
Stack Trace: InteropActionExtensions.CheckInteropSuccess(Boolean
success) HttpInteractionDriver.WithRequest(String method, String path)
RequestBuilder.WithRequest(String method, String path)
RequestBuilder.WithRequest(HttpMethod method, String path)
IRequestBuilderV2.WithRequest(HttpMethod method, String path)
CasClientPact.EnsureCasClientHandlesAddItemEndpointWhenAlreadyIn() line 63
using NUnit.Framework;
using PactNet.Infrastructure.Outputters;
using PactNet;
public CasClientPact()
{
var config = new PactConfig
{
PactDir = @"..\..\..\..\artifacts\pacts"
};
IPactV2 pact = Pact.V2("CasClient", "Cas", config);
this.pact = pact.WithHttpInteractions(9222);
}
[Test]
async public Task EnsureCasClientHandlesAddItemEndpointWhenAlreadyIn()
{
pact
.UponReceiving("A request to add item that is already stored")
.WithRequest(HttpMethod.Post, "/cas/someNs")
.WithBody("alreadyin", "application/octet-stream")
.WillRespond()
.WithStatus(200)
.WithBody("/cas/someNs/content/-AFBB8Hv7uIEEmV1Srn0Y-OkfnMplM-FX8TEh4-SucM", "text/plain; charset=utf-8");
await pact.VerifyAsync(async ctx =>
{
byte[] bytes = Encoding.ASCII.GetBytes("alreadyin");
var result = await Client.AddItemAsync("someNs", bytes, "application/octet-stream");
Assert.AreEqual("/cas/someNs/content/-AFBB8Hv7uIEEmV1Srn0Y-OkfnMplM-FX8TEh4-SucM", result);
});
}
当 .Given 调用中包含土耳其语字符(具体为 ş 或 ı)时,我收到此错误。您的代码没有 .Given 调用,这可能是原因吗?