|
| 1 | +using ObjectSemantics.NET.Tests.MoqModels; |
| 2 | +using System; |
| 3 | +using System.Collections.Generic; |
| 4 | +using System.IO; |
| 5 | +using System.Text; |
| 6 | +using Xunit; |
| 7 | + |
| 8 | +namespace ObjectSemantics.NET.Tests |
| 9 | +{ |
| 10 | + public class TemplateFileMappingTests |
| 11 | + { |
| 12 | + [Fact] |
| 13 | + public void Should_Map_Large_File_Template() |
| 14 | + { |
| 15 | + string template = File.ReadAllText("MoqFiles/PaymentTemplate.xml", Encoding.UTF8); |
| 16 | + string expectedResult = File.ReadAllText("MoqFiles/PaymentTemplate.result.xml", Encoding.UTF8); |
| 17 | + |
| 18 | + |
| 19 | + var payment = new CustomerPayment |
| 20 | + { |
| 21 | + Id = 12719, |
| 22 | + CustomerId = 54, |
| 23 | + Amount = 300.0, |
| 24 | + LedgerAccountId = 1, |
| 25 | + ReferenceNo = "CP-20251029-14QH", |
| 26 | + PaidBy = "JOHN DOE", |
| 27 | + PaidByMobile = "N/A", |
| 28 | + PaymentDate = DateTime.Parse("2025-10-29T14:03:19.4147588"), |
| 29 | + PaymentStatus = null, |
| 30 | + RegisteredBy = "George Waynne", |
| 31 | + Customer = new Customer |
| 32 | + { |
| 33 | + Id = 54, |
| 34 | + FirstName = "JOHN DOE", |
| 35 | + LastName = "ENTERPRISES", |
| 36 | + CompanyName = "John Doe Enterprises", |
| 37 | + PrimaryMobile = "N/A", |
| 38 | + SecondaryMobile = null, |
| 39 | + PrimaryEmail = "", |
| 40 | + SecondaryEmail = null, |
| 41 | + Address = "", |
| 42 | + OpeningBalance = 0.0, |
| 43 | + OpeningDate = DateTime.Parse("2023-11-13T00:00:00"), |
| 44 | + CurrentBalance = 19095.0, |
| 45 | + CreditLimit = 0.0, |
| 46 | + TaxRefNo = "", |
| 47 | + BankAccount = null, |
| 48 | + RoutingNo = null, |
| 49 | + MoreDetails = "", |
| 50 | + LastModified = DateTime.Parse("2024-06-18T18:11:41.7819616"), |
| 51 | + LastModifiedAtBranchId = 1, |
| 52 | + ModifiedBy = "Joe Maina", |
| 53 | + DefaultPriceScheme = "SELLING PRICE", |
| 54 | + IsActive = true, |
| 55 | + Status = "ACTIVE", |
| 56 | + FullName = "Afrique" |
| 57 | + }, |
| 58 | + Narration = null, |
| 59 | + CustomerName = "JOHN DOE ENTERPRISES", |
| 60 | + LedgerAccountName = "Cash A/C", |
| 61 | + LedgerAccount = new LedgerAccount |
| 62 | + { |
| 63 | + Id = 1, |
| 64 | + LedgerAccountTypeId = 4, |
| 65 | + AccountCode = "82187", |
| 66 | + AccountName = "Cash A/C", |
| 67 | + Description = "Current Cash", |
| 68 | + OpeningBalance = 0.0, |
| 69 | + OpeningDate = DateTime.Parse("2020-03-20T10:39:12"), |
| 70 | + IsBankAccount = false, |
| 71 | + BankAccountName = null, |
| 72 | + BankAccountNumber = null, |
| 73 | + AcCode = "82187", |
| 74 | + LedgerAccountType = null |
| 75 | + }, |
| 76 | + CompanyBranchId = 1, |
| 77 | + CompanyBranch = null |
| 78 | + }; |
| 79 | + |
| 80 | + |
| 81 | + //additional headers |
| 82 | + var additionalParams = new Dictionary<string, object> |
| 83 | + { |
| 84 | + ["BranchId"] = "1", |
| 85 | + ["BranchName"] = "MAIN BRANCH", |
| 86 | + ["BranchMobile"] = "Default", |
| 87 | + ["BranchEmail"] = "Default", |
| 88 | + ["BranchAddress"] = "Default", |
| 89 | + ["customer_name"] = "Afrique", |
| 90 | + ["customer_email"] = "", |
| 91 | + ["customer_mobile"] = "N/A", |
| 92 | + ["customer_address"] = "", |
| 93 | + ["customer_taxrefno"] = "", |
| 94 | + ["customer_prevBalance"] = "19,395.00", |
| 95 | + ["customer_currentBalance"] = "19,095.00", |
| 96 | + ["CompanyAddress"] = "Test Address", |
| 97 | + ["CompanyBusinessType"] = "RETAIL & WHOLESALE STORE", |
| 98 | + ["CompanyEmail"] = "test@gmail.com", |
| 99 | + ["CompanyMobile"] = "+2547000000001", |
| 100 | + ["CompanyName"] = "TEST COMPANY", |
| 101 | + ["CompanyTaxNo"] = "P000000001", |
| 102 | + ["ReportsDeliveryEmailAddresses"] = "", |
| 103 | + ["CompanyLogo"] = "logo.jpg", |
| 104 | + ["footer"] = "!Thank you and Come Again!" |
| 105 | + }; |
| 106 | + |
| 107 | + |
| 108 | + //map |
| 109 | + var result = payment.Map(template, additionalParams); |
| 110 | + |
| 111 | + Assert.Equal(result, expectedResult); |
| 112 | + } |
| 113 | + |
| 114 | + } |
| 115 | +} |
0 commit comments