public void CityBankTextFile_CanLoadFile_AndValidateData() { DTO.UploadData data = ReadDataFromFile(); IAS.DAL.Interfaces.IIASPersonEntities ctx = DAL.DALFactory.GetPersonContext(); CityFileHeader header = BankFileFactory.ConcreateCityBankFileTransfer(ctx, "test.txt", data); Assert.IsNotNull(header); Assert.AreEqual(header.CityFileBoxHeaders.Count(), 3); Assert.AreEqual(header.CityFileOverFlows.Count(), 7); Assert.AreEqual(header.CityFileBatchHeaders.Count(), 6); Assert.AreEqual(header.CityFileDetails.Count(), 6); Assert.AreEqual(header.CityFileBatchTotals.Count(), 6); Assert.AreEqual(header.CityFileTotals.Count(), 3); Assert.AreEqual(header.CityFileTotals.ElementAt(0).CityFileDetails.Count(), 1); Assert.AreEqual(header.CityFileTotals.ElementAt(1).CityFileDetails.Count(), 3); Assert.AreEqual(header.CityFileTotals.ElementAt(2).CityFileDetails.Count(), 2); Int32 rownum = (1 + header.CityFileBoxHeaders.Count() + header.CityFileOverFlows.Count() + header.CityFileBatchHeaders.Count() + header.CityFileDetails.Count() + header.CityFileBatchTotals.Count() + header.CityFileTotals.Count() + 1); Assert.AreEqual(header.RowCount, rownum); DTO.UploadResult <DTO.SummaryBankTransaction, DTO.BankTransaction> uploadResult = header.ValidateData(); }
public void CityBank_Upload_Can_Commit_ToEntity() { IAS.DAL.Interfaces.IIASPersonEntities ctx = DAL.DALFactory.GetPersonContext(); DTO.UploadData data = ReadDataFromFile(); String fileName = "testData.txt"; CityFileHeader bankHeader = BankFileFactory.ConcreateCityBankFileTransfer(ctx, fileName, data); var res = new DTO.ResponseService <DTO.UploadResult <DTO.SummaryBankTransaction, DTO.BankTransaction> >(); res.DataResponse = bankHeader.ValidateData(); if (res.IsError) { throw new ApplicationException(res.ErrorMsg); } AG_IAS_TEMP_PAYMENT_HEADER payment_g_t = new AG_IAS_TEMP_PAYMENT_HEADER(); bankHeader.MappingToEntity <CityFileHeader, AG_IAS_TEMP_PAYMENT_HEADER>(payment_g_t); ctx.AG_IAS_TEMP_PAYMENT_HEADER.AddObject(payment_g_t); foreach (CityFileDetail item in bankHeader.CityFileDetails) { AG_IAS_TEMP_PAYMENT_DETAIL detail = new AG_IAS_TEMP_PAYMENT_DETAIL(); item.MappingToEntity <AG_IAS_TEMP_PAYMENT_DETAIL>(detail); ctx.AG_IAS_TEMP_PAYMENT_DETAIL.AddObject(detail); } ctx.AG_IAS_TEMP_PAYMENT_TOTAL.AddObject(bankHeader.GetAG_IAS_TEMP_PAYMENT_TOTAL()); try { using (var ts = new TransactionScope()) { ctx.SaveChanges(); ts.Complete(); } } catch (Exception ex) { throw; } }