public void FailDoubleAlternateModulusCheck(string sortCode, string accountNumber) { var account = new BankAccount(sortCode, accountNumber); // As exception 6 is not currently supported, the weight item // needs to be mocked so that the exception isn't included. var modulusWeight = new ModulusWeightItem { SortCodeStart = 202700, SortCodeEnd = 203239, ModulusCalculationType = ModulusCalculationType.DblAl, Weight = new int[] { 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1 } }; var doubleAltCalculator = new DoubleAlternateModulusCheck(account, modulusWeight); var modulsCheck = doubleAltCalculator.Process(); Assert.AreEqual(modulsCheck, ModulusCheckResult.Fail); }
internal BankAccountValidationPipeline CreateValidationPipeline(BankAccountDetails bankAccountDetails) { var pipeline = new BankAccountValidationPipeline(); // note - EISCDSortCodeValidationStep does not do anything. pipeline.InitialValidationStep = new EISCDSortCodeValidationStep(bankAccountDetails, pipeline); var currentValidationStep = pipeline.InitialValidationStep; var modulusWeightings = (new VocalinkModulusWeightingData().GetModulusWeightings()); var weightingsForSortCode = modulusWeightings.Where(w => w.SortCodeStart <= bankAccountDetails.SortCode && w.SortCodeEnd <= bankAccountDetails.SortCode); // Create validation pipeline steps according to weightings from Vocalink foreach (var weighting in weightingsForSortCode) { ModulusCheck modulusCheck = null; // Apply Execptions when creating pipeline // Exception 4 - adjust expected result if (4 == weighting.ExceptionNumber) { modulusCheck = new Standard11ModulusCheck(bankAccountDetails, weighting); modulusCheck.ExpectedResult = int.Parse(bankAccountDetails.CombinedNumberDigits[12].ToString() + bankAccountDetails.CombinedNumberDigits[12].ToString()); } else { switch (weighting.ModulusAlgorithmEnum) { case Enums.ModulusAlgorithmEnum.MOD10: modulusCheck = new Standard10ModulusCheck(bankAccountDetails, weighting); break; case Enums.ModulusAlgorithmEnum.MOD11: modulusCheck = new Standard11ModulusCheck(bankAccountDetails, weighting); break; case Enums.ModulusAlgorithmEnum.DBLAL: modulusCheck = new DoubleAlternateModulusCheck(bankAccountDetails, weighting); break; } } // Excpetion 7 - if g=9 then zeroise u-b if (7 == weighting.ExceptionNumber) { if (9 == bankAccountDetails.CombinedNumberDigits[12]) { for (int i = 0; i < 8; i++) { bankAccountDetails.CombinedNumberDigits[i] = 0; } } } // Indicate Exceptions not applied if (weighting.ExceptionNumber.HasValue && (!(weighting.ExceptionNumber == 4 || weighting.ExceptionNumber == 7)) ) { modulusCheck.ValidationDetails = string.Format("Excluded adjustment for Exception {0}", weighting.ExceptionNumber.ToString()); } var validationStep = new ModulusCheckValidationStep(modulusCheck, pipeline); currentValidationStep.NextStep = validationStep; currentValidationStep = validationStep; } return pipeline; }
public void Setup() { _check = new DoubleAlternateModulusCheck(); }