public void CreateModulusParameters_PassAccountDetails_ReturnsCorrectWeightingValues(int digit, int expectedValue)
        {
            // Arrange
            var modulusWeightingDigit    = new ModulusWeightingDigit(digit);
            var bankDetails              = new BankDetails("089999", "66374958");
            var modulusParametersFactory = new ModulusParametersFactory(ModulusTestHelper.CreateSingleRangeWeightingTableModulusTenPass());

            // Act
            var modulusParameters = modulusParametersFactory.CreateModulusParameters(bankDetails);

            // Assert
            Assert.AreEqual(expectedValue, modulusParameters.GetWeighting(modulusWeightingDigit, bankDetails.VerificationValue));
        }
        public void CreateModulusParameters_PassAccountDetailsNotInWeightingTable_AlwaysReturnsZero(string sortCode, string accountNo)
        {
            // Arrange
            var modulusWeightingDigit    = new ModulusWeightingDigit(1);
            var bankDetails              = new BankDetails(sortCode, accountNo);
            var modulusParametersFactory = new ModulusParametersFactory(ModulusTestHelper.CreateSingleRangeWeightingTableModulusTenPass());

            // Act
            var modulusParameters = modulusParametersFactory.CreateModulusParameters(bankDetails);

            // Assert
            Assert.AreEqual(-1, modulusParameters.GetWeighting(modulusWeightingDigit, bankDetails.VerificationValue));
        }
Exemplo n.º 3
0
        public void Check_ValidLookingAccountDetails_ReturnsSuccessOrFailureCorrectly(string sortCode, string accountNo, bool expectedSuccess, ModulusCheckingMethod method)
        {
            // Arrange
            var accountDetails        = new BankDetails(sortCode, accountNo);
            var modulusWeightingTable = ModulusTestHelper.CreateStandardWeightingTable(method);
            var accountDetailsChecker = new AccountDetailsChecker(modulusWeightingTable);

            // Act
            var accountCheckResult = accountDetailsChecker.Check(accountDetails);

            // Assert
            Assert.AreEqual(expectedSuccess, accountCheckResult.Success);
        }
        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);
        }
 public static ModulusWeightingTable CreateStandardWeightingTable(ModulusCheckingMethod checkingMethod)
 {
     if (checkingMethod == ModulusCheckingMethod.StandardTen)
     {
         return(ModulusTestHelper.CreateSingleRangeWeightingTableModulusTenPass());
     }
     else if (checkingMethod == ModulusCheckingMethod.StandardEleven)
     {
         return(ModulusTestHelper.CreateSingleRangeWeightingTableModulusElevenPass());
     }
     else if (checkingMethod == ModulusCheckingMethod.AlternateDouble)
     {
         return(ModulusTestHelper.CreateSingleRangeWeightingTableModulusAlternateDouble());
     }
     return(new ModulusWeightingTable(new List <ModulusWeightingDetails>()));
 }