protected static void AssertEqualForInvoicePaymentItems(ArrayList expected, ArrayList actual) { Assert.AreEqual(expected.Count, actual.Count, "Incorrect number of items."); for (int i = 0; i < expected.Count; i++) { InvoicePaymentItemDto expectedItem = (InvoicePaymentItemDto)expected[i]; AssertFound(expectedItem, actual, i); } }
protected static void AssertFound(InvoicePaymentItemDto expectedItem, ArrayList actual, int index) { for (int i = 0; i < actual.Count; i++) { InvoicePaymentItemDto item = (InvoicePaymentItemDto)actual[i]; if (expectedItem.InvoiceUid == item.InvoiceUid && expectedItem.Amount == item.Amount) { return; } } Assert.Fail("Expected invoice payment item at index " + index.ToString() + " is not found."); }
public void TestDeletePurchasePayment() { CrudProxy proxy = new InvoiceProxy(); InvoiceDto purchase1 = this.GetUnpaidItemPurchase(); InvoiceDto purchase2 = this.GetUnpaidServicePurchase(); proxy.Insert(purchase1); proxy.Insert(purchase2); InvoicePaymentDto paymentInfo1 = new InvoicePaymentDto(TransactionType.PurchasePayment); paymentInfo1.Date = DateTime.Today.Date; paymentInfo1.PaymentAccountUid = this.Westpac.Uid; paymentInfo1.Reference = Guid.NewGuid().ToString(); paymentInfo1.Summary = "Payment for 2 Outstanding Invoices"; paymentInfo1.Fee = 3.99m; InvoicePaymentItemDto item = null; item = new InvoicePaymentItemDto(); item.InvoiceUid = purchase2.Uid; item.Amount = 20.05M; paymentInfo1.Items.Add(item); item = new InvoicePaymentItemDto(); item.InvoiceUid = purchase1.Uid; item.Amount = 23.75M; paymentInfo1.Items.Add(item); proxy = new InvoicePaymentProxy(); proxy.Insert(paymentInfo1); Assert.IsTrue(paymentInfo1.Uid > 0, "Uid must be > 0 after save."); InvoicePaymentDto paymentInfo2 = (InvoicePaymentDto)proxy.GetByUid(paymentInfo1.Uid); AssertEqual(paymentInfo1, paymentInfo2); proxy = new InvoicePaymentProxy(); proxy.DeleteByUid(paymentInfo1.Uid); try { proxy.GetByUid(paymentInfo1.Uid); } catch (RestException ex) { Assert.AreEqual("RecordNotFoundException", ex.Type); } }