I have an API provder at http:///pay. This API accepts a POST method with a body like this:
Код: Выделить всё
{ "amount": 115, "currency" "EUR" }
Код: Выделить всё
{ "id":"4f34e5ef-80c0-4696-8d2c-4cc755b31861", "status":true, "description":"" }
Код: Выделить всё
[Fact] public async void PaymentIsOk() { PaymentRequest paymentRequest = new PaymentRequest(115, "EUR"); PaymentResponse paymentResponse = new PaymentResponse {id = Guid.NewGuid().ToString(), status = true}; this.pactBuilder .UponReceiving("a request for paying an order") .WithRequest(HttpMethod.Post, "/pay") .WithHeader("Content-Type", "application/json") .WithJsonBody(paymentRequest) .WillRespond() .WithStatus(HttpStatusCode.OK) .WithJsonBody(paymentResponse); this.pactBuilder.Verify(ctx => { // Act var paymentGatewayClient = new PaymentGatewayClient(ctx.MockServerUri.ToString()); var paymentGatewayClientResponse = paymentGatewayClient.Pay(paymentRequest); // Assert // how can I test for Id? Assert.Empty(paymentGatewayClientResponse.description); Assert.True(paymentGatewayClientResponse.status); }); }
Код: Выделить всё
Pay
Код: Выделить всё
paymentResponse
Код: Выделить всё
paymentGatewayClientResponse.id
Код: Выделить всё
paymentResponse.id
Am I missing something in the reasoning?
Sure a possible solution would be to force
Код: Выделить всё
paymentResponse.id = paymentGatewayClientResponse.id
Источник: https://stackoverflow.com/questions/781 ... n-pact-net