public void FileHeaderRecord_ValidateRecordMissingFileIdModifier_ShouldThrowApplicationException() { // arrange var fakeBrokerBankAccount = GenerateBrokerBankAccount(); var fakeBrokerOrigin = GenerateBrokerOrigin(); var record = new FileHeaderRecord(fakeBrokerBankAccount, fakeBrokerOrigin, ""); // act Action act = record.Validate; // assert act.ShouldThrow <ApplicationException>().And.Message.Should().Be("All record fields must be present"); }
public void FileHeaderRecord_ValidateRecordWithNonAlphanumericFileIdModifier_ShouldThrowApplicationException_AndIsValidatedShouldBeFalse() { // arrange var fakeBrokerBankAccount = GenerateBrokerBankAccount(); var fakeBrokerOrigin = GenerateBrokerOrigin(); var record = new FileHeaderRecord(fakeBrokerBankAccount, fakeBrokerOrigin, "$"); // act Action act = record.Validate; // assert act.ShouldThrow <ApplicationException>().And.Message.Should().Be("File ID restricted to alpha-numeric characters only"); record.IsValidated.Should().BeFalse(); }
private static X9_DepositFile depositFile; //Singleton #endregion public X9_DepositFile() { deposits = new List <X9_Deposit>(); #if DEBUG fileHeader = new FileHeaderRecord('T', 'N', "044000037"); #else fileHeader = new FileControlRecord('P', 'N', "044000037"); #endif records = new Dictionary <FileHeaderRecord, FileControlRecord>(); fileHeader = new FileHeaderRecord('T', 'N', "044000037"); fileControl = new FileControlRecord(1, 14, 0, 0); addRecords(); }
public static ItemAcknowledgement FromString(StreamReader reader) { var result = new ItemAcknowledgement(); // first line should be header record var line = reader.ReadLine(); if (line == null || line.Substring(0, 2) != ItemRecordTypes.FileHeaderRecord) { throw new ArgumentException("stream bad format"); } result.Header = FileHeaderRecord.FromString(line); while ((line = reader.ReadLine()) != null) { var type = line.Substring(0, 2); if (type == ItemRecordTypes.CashLetterHeaderRecord) { result.CashLetters.Add(new CashLetterRecord()); var header = CashLetterHeaderRecord.FromString(line); result.CashLetters.Last().Header = header; } else if (type == ItemRecordTypes.ItemDetailRecord) { var item = ItemDetailRecord.FromString(line); result.CashLetters.Last().Details.Add(item); } else if (type == ItemRecordTypes.ItemDetailAddendumRecord) { var addendum = ItemDetailAddendumRecord.FromString(line); result.CashLetters.Last().Details.Last().Addendums.Add(addendum); } else if (type == ItemRecordTypes.CashLetterControlRecord) { var control = CashLetterControlRecord.FromString(line); result.CashLetters.Last().Control = control; } else if (type == ItemRecordTypes.FileControlRecord) { result.Control = FileControlRecord.FromString(line); } } return(result); }
public void FileHeaderRecord_ValidateRecordWithInvalidBrokerBankAccountRoutingNumber_ShouldThrowApplicationException() { // arrange const string InvalidRoutingNum = "123456789"; var fakeBrokerBankAccount = GenerateBrokerBankAccount(); fakeBrokerBankAccount.RoutingNumber = InvalidRoutingNum; var fakeBrokerOrigin = GenerateBrokerOrigin(); var record = new FileHeaderRecord(fakeBrokerBankAccount, fakeBrokerOrigin); // act Action act = record.Validate; // assert act.ShouldThrow <ApplicationException>().And.Message.Should().Be("Invalid routing number"); }
public static ReceiptAcknowledgement FromString(StreamReader reader) { var result = new ReceiptAcknowledgement(); // first line should be header record var line = reader.ReadLine(); if (line == null || line.Substring(0, 2) != ReceiptRecordTypes.FileHeaderRecord) { throw new ArgumentException("stream bad format"); } result.Header = FileHeaderRecord.FromString(line); while ((line = reader.ReadLine()) != null) { var type = line.Substring(0, 2); if (type == ReceiptRecordTypes.FileDetailRecord) { var detail = FileDetailRecord.FromString(line); result.Details.Add(detail); } else if (type == ReceiptRecordTypes.FileDetailAddendumRecord) { var addendum = FileDetailAddendumRecord.FromString(line); // reference last added detail record result.Details.Last().Addendums.Add(addendum); } else if (type == ReceiptRecordTypes.FileControlRecord) { result.Control = FileControlRecord.FromString(line); } } return(result); }
public NachaFile() { Batches = new List <BatchRecord>(); FileHeader = new FileHeaderRecord(); FileControl = new FileControlRecord(); }