Skip to content

Commit 5e91cf9

Browse files
author
sunny
committed
update tests to ensure you can pass vertex_transaction_type to an adjustment within a purchase
1 parent b169aad commit 5e91cf9

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Test/PurchaseTest.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,45 @@ public void PurchaseWithVertexTransactionType()
313313
Assert.Equal(mockResponse.ChargeInvoice.State, Invoice.InvoiceState.Paid);
314314
}
315315

316+
[RecurlyFact(TestEnvironment.Type.Unit)]
317+
public void PurchaseWithAdjustmentsContainingVertexTransactionType()
318+
{
319+
// Create a purchase with adjustments that have vertex_transaction_type
320+
var account = NewAccountWithBillingInfo();
321+
322+
var adjustment1 = account.NewAdjustment("Adjustment with lease type", 580);
323+
adjustment1.Currency = "USD";
324+
adjustment1.Quantity = 1;
325+
adjustment1.VertexTransactionType = "lease";
326+
327+
var adjustment2 = account.NewAdjustment("Adjustment with rental type", 1200);
328+
adjustment2.Currency = "USD";
329+
adjustment2.Quantity = 2;
330+
adjustment2.UnitAmountInCents = 600;
331+
adjustment2.VertexTransactionType = "rental";
332+
333+
var purchase = new Purchase(account.AccountCode, "USD");
334+
purchase.Account = account;
335+
purchase.Adjustments.Add(adjustment1);
336+
purchase.Adjustments.Add(adjustment2);
337+
338+
// Verify the request serializes vertex_transaction_type correctly for each adjustment
339+
var xmlOutput = new System.Text.StringBuilder();
340+
using (var xmlWriter = new XmlTextWriter(new System.IO.StringWriter(xmlOutput)))
341+
{
342+
purchase.WriteXml(xmlWriter);
343+
}
344+
var xml = xmlOutput.ToString();
345+
346+
// Should contain vertex_transaction_type for both adjustments
347+
Assert.Contains("<vertex_transaction_type>lease</vertex_transaction_type>", xml);
348+
Assert.Contains("<vertex_transaction_type>rental</vertex_transaction_type>", xml);
349+
350+
// Verify both adjustments are in the XML with their properties
351+
Assert.Contains("<unit_amount_in_cents>580</unit_amount_in_cents>", xml);
352+
Assert.Contains("<unit_amount_in_cents>600</unit_amount_in_cents>", xml);
353+
}
354+
316355
private InvoiceCollection GetMockInvoiceCollectionResponse()
317356
{
318357
// Mock the Purchase.Invoice response using a fixture

0 commit comments

Comments
 (0)