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.idAm 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
Мобильная версия