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);
        }
        public void GetCheckingParameters_PassValidAccountDetails_ReturnsModulusParmetersObject()
        {
            // Arrange
            var modulusParamtersFactory = new ModulusParametersFactory(CreateStandardModulusWeightingTable());

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

            // Assert
            Assert.IsNotNull(modulusParameters);
        }
        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));
        }
        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 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)));
 }