private void VerifyInvoiceEmailMessagesAreEqual(Saasu.API.Core.Models.Email msg1, Saasu.API.Core.Models.Email msg2) { if (msg1 == null || msg2 == null) { Assert.IsNull(msg1, "Expected first email message to be null"); Assert.IsNull(msg2, "Expected second email message to be null"); return; } Assert.AreEqual(msg1.To, msg2.To, "Email 'to' is not equal"); Assert.AreEqual(msg1.From, msg2.From, "Email 'from' is not equal"); Assert.AreEqual(msg1.Cc, msg2.Cc, "Email 'Cc' is not equal"); Assert.AreEqual(msg1.Bcc, msg2.Bcc, "Email 'Bcc' is not equal"); Assert.AreEqual(msg1.Subject, msg2.Subject, "Email 'subject' is not equal"); Assert.AreEqual(msg1.Body, msg2.Body, "Email 'body' is not equal"); }
private InvoiceTransactionDetail GetTestInsertInvoice(string invoiceLayout, List<InvoiceTransactionLineItem> lineItems = null, string notesInternal = null, string notesExternal = null, InvoiceTradingTerms terms = null, List<FileAttachmentInfo> attachments = null, int? templateId = null, bool emailContact = false, Saasu.API.Core.Models.Email emailMessage = null, string currency = null, string invoiceNumber = null, string purchaseOrderNumber = null, string invoiceType = null, string transactionType = null, string summary = null, decimal? totalAmountInclTax = null, bool requiresFollowUp = false, DateTime? transactionDate = null, int? billingContactId = null, int? shippingContactId = null, List<string> tags = null, decimal? fxRate = null, string invoiceStatus = null, bool actuallyInsertAndVerifyResponse = false, bool autoPopulateFxRate = false) { var tranType = transactionType ?? "S"; var invDetail = new InvoiceTransactionDetail { LineItems = lineItems ?? GetInsertItems(invoiceLayout, tranType), NotesInternal = notesInternal ?? "Test internal note", NotesExternal = notesExternal ?? "Test external note", Terms = terms ?? GetTradingTerms(), Attachments = attachments ?? GetAttachments(), TemplateId = templateId ?? GetTemplateUid(), SendEmailToContact = emailContact, EmailMessage = emailMessage ?? GetEmailMessage(), Currency = currency ?? "AUD", InvoiceNumber = invoiceNumber ?? AutoNumber, PurchaseOrderNumber = purchaseOrderNumber ?? AutoNumber, InvoiceType = invoiceType ?? "Tax Invoice", TransactionType = tranType, Layout = invoiceLayout, Summary = summary ?? "Summary InsertInvoiceWithServiceItemsNoEmailToContact", TotalAmount = totalAmountInclTax ?? new decimal(20.00), IsTaxInc = true, RequiresFollowUp = requiresFollowUp, TransactionDate = transactionDate ?? DateTime.Now.AddDays(-10), BillingContactId = billingContactId ?? _BillingContactId, ShippingContactId = shippingContactId ?? _ShippingContactId, FxRate = fxRate, AutoPopulateFxRate = autoPopulateFxRate, InvoiceStatus = invoiceStatus, Tags = tags ?? new List<string> { "invoice header tag 1", "invoice header tag 2" } }; if (actuallyInsertAndVerifyResponse) { var response = new InvoiceProxy().InsertInvoice(invDetail); Assert.IsNotNull(response, "Inserting an invoice did not return a response"); Assert.IsTrue(response.IsSuccessfull, "Inserting an invoice was not successfull. Status code: " + ((int)response.StatusCode).ToString()); Assert.IsNotNull(response.RawResponse, "No raw response returned as part of inserting an invoice"); var serialized = response.DataObject; Assert.IsTrue(serialized.InsertedEntityId > 0, "Invoice insert did not return an InsertedEntityId > 0"); invDetail.TransactionId = serialized.InsertedEntityId; } return invDetail; }