public IHttpActionResult VerifyBankDetails(string sortCode, string accountNo) { var bankAccount = new BankDetails(sortCode, accountNo); var accountChecker = new StandardModulusCheck(_modulusParametersFactory.CreateModulusParameters(bankAccount)); return(Ok(new VerifyResult(accountChecker.IsValid(bankAccount)))); }
protected bool ProcessWeightingRule(BankAccountDetails bankAccountDetails, IModulusWeightMapping modulusWeightMapping) { var weightingSum = new StandardModulusCheck().GetModulusSum(bankAccountDetails, modulusWeightMapping); var remainder = weightingSum % Modulus; return(modulusWeightMapping.Exception == 4 ? bankAccountDetails.AccountNumber.GetExceptionFourCheckValue == remainder : remainder == 0); }
public void IsValid_ValidAccountDetails_ReturnsTrue(string sortCode, string accountNo, ModulusCheckingMethod checkingMethod) { // Arrange var bankDetails = new BankDetails(sortCode, accountNo); var modulusParametersFactory = new ModulusParametersFactory(ModulusTestHelper.CreateStandardWeightingTable(checkingMethod)); var modulusParameters = modulusParametersFactory.CreateModulusParameters(bankDetails); var standardModulusCheck = new StandardModulusCheck(modulusParameters); // Act var result = standardModulusCheck.IsValid(bankDetails); // Assert Assert.AreEqual(true, result); }
/// For the standard check with exception 5 the checkdigit is g from the original account number. /// • After dividing the result by 11; /// - if the remainder=0 and g=0 the account number is valid /// - if the remainder=1 the account number is invalid /// - for all other remainders, take the remainder away from 11. If the number you get is the same as g /// then the account number is valid. private new bool ProcessWeightingRule(BankAccountDetails bankAccountDetails, IModulusWeightMapping modulusWeightMapping) { var weightingSum = new StandardModulusCheck().GetModulusSum(bankAccountDetails, modulusWeightMapping); var remainder = weightingSum % Modulus; switch (remainder) { case 0: return(bankAccountDetails.AccountNumber.IntegerAt(6) == 0); case 1: return(false); default: return(Modulus - remainder == bankAccountDetails.AccountNumber.IntegerAt(6)); } }
public void Setup() { _checker = new StandardModulusCheck(); }