public void RenderFile_should_return_correct_string() { //arrange //int size = 940; //int size1 = 1880; var target = new NachaFile(new NachaFileInfo { BatchNumber = 12, CreationDate = new DateTime(2012, 07, 30, 12, 24, 1), CompanyDescriptiveDate = new DateTime(2010, 07, 29, 10, 24, 1), EffectiveEntryDate = new DateTime(2012, 10, 08, 02, 04, 1), FileIdModifier = "A" }, new List<NachaFileAppraiserEntry> { new NachaFileAppraiserEntry { AccountNumber = "123445", Amount = 10000.0, AppraiserOrCompanyId = "123456", AppraiserOrCompanyName = "FIRST APP COMPANY", RoutingNumber = "000345001", TypeOfAccount = AccountType.Checking, UniqueTraceNumber = 1 } }); //act var actual = target.RenderNachaFile(); //assert actual.Should().Be("101b121144557P4537372771207301224A094101SIERRA VISTA BANK DIRECT VALUATION SOLUTI000000005200DIRECT VAL SOL APPRAISER DISBURSE 1453737277CCDAPPRAISAL 100729121008 1121144550000012622000345001123445 0001000000AU0000000123456FIRST APP COMPANY 0121144550000001820000000100000345000000000000000000010000001453737277 1211445500000129000001000001000000010000034500000000000000000001000000 99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"); }
public Guid GenerateNachaFile(List<NachaFileAppraiserEntry> listOfAppraiserBilling, DateTime effectiveDate, DateTime throughDate, out bool isSuccess) { try { lock (Locker) { var firstUTN = _nachaFileGenerationManager.GetFirstUniqueTraceNumber(); int added = 0; for (int i = 0; i < listOfAppraiserBilling.Count; i++) { listOfAppraiserBilling[i].UniqueTraceNumber = i + firstUTN + added; if (i + firstUTN >= 9999999) { firstUTN = 1; added = -i; } } var lastUTN = firstUTN + listOfAppraiserBilling.Count - 1 + added; var fileIdModifier = _nachaFileGenerationManager.GetFileIdModifier(); var batchNumber = _nachaFileGenerationManager.GetBatchNumber(); var creationDate = DateTime.Now; var fileName = string.Format("dvs_ach_{0:yyyyMMdd_HH-mm-ss-tt}.ach", creationDate); var nachaFile = new NachaFile( new NachaFileInfo { FileIdModifier = fileIdModifier, BatchNumber = batchNumber, CreationDate = creationDate, EffectiveEntryDate = effectiveDate, CompanyDescriptiveDate = throughDate }, listOfAppraiserBilling).RenderNachaFile(); var documentInfo = new DocumentInfo() { AddedByUserId = _securityContext.CurrentUser.Id, DateAdded = creationDate, DocumentType = "nacha file", Name = fileName, Size = nachaFile.Length }; var documentStorageId = _documentService.StoreDocument(documentInfo, Encoding.Default.GetBytes(nachaFile)); var newNachaFile = new Model.Entities.NachaFile { BatchNumber = batchNumber, UniqueTraceNumber = lastUTN, CreationDate = creationDate, FileIdModifier = fileIdModifier, FileId = documentStorageId, FileName = fileName, DvsUser = _usersManagement.GetDvsUserByUserId(_securityContext.CurrentUser.Id) }; _nachaFilesRepository.Add(newNachaFile); isSuccess = true; return documentStorageId; } } catch (Exception) { isSuccess = false; throw; } }
public void RenderFile_should_return_correct_string_length() { //arrange int size = 940; int size1 = 1880; var target = new NachaFile(new NachaFileInfo { BatchNumber = 12, CreationDate = new DateTime(2012, 07, 30, 12, 24, 1), CompanyDescriptiveDate = new DateTime(2010, 07, 29, 10, 24, 1), EffectiveEntryDate = new DateTime(2012, 10, 08, 02, 04, 1), FileIdModifier = "A" }, new List<NachaFileAppraiserEntry> { new NachaFileAppraiserEntry { AccountNumber = "123445", Amount = 100000.0, AppraiserOrCompanyId = "123456", AppraiserOrCompanyName = "first app company", RoutingNumber = "000345001", TypeOfAccount = AccountType.Checking, UniqueTraceNumber = 1 } }); var target1 = new NachaFile(new NachaFileInfo { BatchNumber = 12, CreationDate = new DateTime(2012, 07, 30, 12, 24, 1), CompanyDescriptiveDate = new DateTime(2010, 07, 29, 10, 24, 1), EffectiveEntryDate = new DateTime(2012, 10, 08, 02, 04, 1), FileIdModifier = "A" }, new List<NachaFileAppraiserEntry> { new NachaFileAppraiserEntry { AccountNumber = "123445", Amount = 100000.0, AppraiserOrCompanyId = "123456", AppraiserOrCompanyName = "first app company", RoutingNumber = "000345001", TypeOfAccount = AccountType.Checking, UniqueTraceNumber = 1 }, new NachaFileAppraiserEntry { AccountNumber = "123445", Amount = 100000.0, AppraiserOrCompanyId = "123456", AppraiserOrCompanyName = "first app company", RoutingNumber = "000345001", TypeOfAccount = AccountType.Checking, UniqueTraceNumber = 2 }, new NachaFileAppraiserEntry { AccountNumber = "123445", Amount = 100000.0, AppraiserOrCompanyId = "123456", AppraiserOrCompanyName = "first app company", RoutingNumber = "000345001", TypeOfAccount = AccountType.Checking, UniqueTraceNumber = 3 }, new NachaFileAppraiserEntry { AccountNumber = "123445", Amount = 100000.0, AppraiserOrCompanyId = "123456", AppraiserOrCompanyName = "first app company", RoutingNumber = "000345001", TypeOfAccount = AccountType.Checking, UniqueTraceNumber = 4 }, new NachaFileAppraiserEntry { AccountNumber = "123445", Amount = 100000.0, AppraiserOrCompanyId = "123456", AppraiserOrCompanyName = "first app company", RoutingNumber = "000345001", TypeOfAccount = AccountType.Checking, UniqueTraceNumber = 5 }, new NachaFileAppraiserEntry { AccountNumber = "123445", Amount = 100000.0, AppraiserOrCompanyId = "123456", AppraiserOrCompanyName = "first app company", RoutingNumber = "000345001", TypeOfAccount = AccountType.Checking, UniqueTraceNumber = 6 }, new NachaFileAppraiserEntry { AccountNumber = "123445", Amount = 100000.0, AppraiserOrCompanyId = "123456", AppraiserOrCompanyName = "first app company", RoutingNumber = "000345001", TypeOfAccount = AccountType.Checking, UniqueTraceNumber = 7 } }); var target2 = new NachaFile(new NachaFileInfo { BatchNumber = 12, CreationDate = new DateTime(2012, 07, 30, 12, 24, 1), CompanyDescriptiveDate = new DateTime(2010, 07, 29, 10, 24, 1), EffectiveEntryDate = new DateTime(2012, 10, 08, 02, 04, 1), FileIdModifier = "A" }, new List<NachaFileAppraiserEntry> { new NachaFileAppraiserEntry { AccountNumber = "123445", Amount = 100000.0, AppraiserOrCompanyId = "123456", AppraiserOrCompanyName = "first app company", RoutingNumber = "000345001", TypeOfAccount = AccountType.Checking, UniqueTraceNumber = 1 }, new NachaFileAppraiserEntry { AccountNumber = "123445", Amount = 100000.0, AppraiserOrCompanyId = "123456", AppraiserOrCompanyName = "first app company", RoutingNumber = "000345001", TypeOfAccount = AccountType.Checking, UniqueTraceNumber = 2 }, new NachaFileAppraiserEntry { AccountNumber = "123445", Amount = 100000.0, AppraiserOrCompanyId = "123456", AppraiserOrCompanyName = "first app company", RoutingNumber = "000345001", TypeOfAccount = AccountType.Checking, UniqueTraceNumber = 3 }, new NachaFileAppraiserEntry { AccountNumber = "123445", Amount = 100000.0, AppraiserOrCompanyId = "123456", AppraiserOrCompanyName = "first app company", RoutingNumber = "000345001", TypeOfAccount = AccountType.Checking, UniqueTraceNumber = 4 }, new NachaFileAppraiserEntry { AccountNumber = "123445", Amount = 100000.0, AppraiserOrCompanyId = "123456", AppraiserOrCompanyName = "first app company", RoutingNumber = "000345001", TypeOfAccount = AccountType.Checking, UniqueTraceNumber = 5 }, new NachaFileAppraiserEntry { AccountNumber = "123445", Amount = 100000.0, AppraiserOrCompanyId = "123456", AppraiserOrCompanyName = "first app company", RoutingNumber = "000345001", TypeOfAccount = AccountType.Checking, UniqueTraceNumber = 6 } }); //act var actual = target.RenderNachaFile(); var actual1 = target1.RenderNachaFile(); var actual2 = target2.RenderNachaFile(); //assert actual.Length.Should().Be(size); actual1.Length.Should().Be(size1); actual2.Length.Should().Be(size); }