コード例 #1
0
        public void CreateModulusParameters_PassAccountDetailsRelatingToMethod_ReturnsSpecifiedMethod(string expectedSortCode, ModulusCheckingMethod expectedCheckingMethod)
        {
            // Arrange
            var modulusParamtersFactory = new ModulusParametersFactory(CreateStandardModulusWeightingTable());

            // Act
            var modulusParameters = modulusParamtersFactory.CreateModulusParameters(new BankDetails(expectedSortCode, _standardAccountNo));

            // Assert
            Assert.AreEqual(expectedCheckingMethod, modulusParameters.CheckingMethod);
        }
コード例 #2
0
        public void GetCheckingParameters_PassValidAccountDetails_ReturnsModulusParmetersObject()
        {
            // Arrange
            var modulusParamtersFactory = new ModulusParametersFactory(CreateStandardModulusWeightingTable());

            // Act
            var modulusParameters = modulusParamtersFactory.CreateModulusParameters(new BankDetails("204455", _standardAccountNo));

            // Assert
            Assert.IsNotNull(modulusParameters);
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }
コード例 #5
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);
        }
コード例 #6
0
 public ModulusController(IWeightingsRepository weightingsRepository, ModulusWeightingFactory modulusWeightingFactory)
 {
     _modulusParametersFactory = new ModulusParametersFactory(new ModulusWeightingTable(weightingsRepository.GetAllWeightings().Select(modulusWeightingFactory.Create)));
 }