public void CanAddAlgorithm(string row, ModulusAlgorithm expected)
        {
            var actual = new ModulusWeightMapping(row);

            Assert.NotNull(actual);
            Assert.AreEqual(expected, actual.Algorithm);
        }
Ejemplo n.º 2
0
        public ValacdosSource()
        {
            var    assembly = Assembly.GetExecutingAssembly();
            string mappings;

            using (var stream = assembly.GetManifestResourceStream("ModulusChecking.Resources.valacdos.txt"))
                // ReSharper disable once AssignNullToNotNullAttribute
                using (var reader = new StreamReader(stream))
                {
                    mappings = reader.ReadToEnd();
                }

            if (mappings.Contains('\t'))
            {
                throw new Exception(
                          "valacdos.txt contains a tab instead of a set of spaces.\n\nUse a text editor to search for regex \\t to identify the issue.");
            }

            GetModulusWeightMappings = mappings
                                       .Trim()
                                       .Split(new[] { "\r\n", "\n" }, StringSplitOptions.None)
                                       .Where(row => row.Length > 0)
                                       .Select(row => ModulusWeightMapping.From(row))
                                       .ToArray();
        }
        public void Setup()
        {
            var mappingSource = new Mock <IRuleMappingSource>();

            mappingSource.Setup(ms => ms.GetModulusWeightMappings).Returns(new[]
            {
                ModulusWeightMapping.From(
                    "230872 230872 DBLAL    2    1    2    1    2    1    2    1    2    1    2    1    2    1"),
                ModulusWeightMapping.From(
                    "499273 499273 DBLAL    2   1    2    1    2    1    2    1    2    1    2    1    2    1   "),
                ModulusWeightMapping.From(
                    "499273 499273 DBLAL    2   1    2    1    2    1    2    1    2    1    2    1    2    1   "),
                ModulusWeightMapping.From(
                    "200000 200002 DBLAL    2    1    2    1    2    1    2    1    2    1    2    1    2    1   6")
            });
            _fakedModulusWeightTable = new Mock <IModulusWeightTable>();
            _fakedModulusWeightTable.Setup(fmwt => fmwt.RuleMappings).Returns(mappingSource.Object.GetModulusWeightMappings.ToList());
            _fakedModulusWeightTable.Setup(fmwt => fmwt.GetRuleMappings(new SortCode("499273")))
            .Returns(new []
            {
                ModulusWeightMapping.From
                    ("499273 499273 DBLAL    2   1    2    1    2    1    2    1    2    1    2    1    2    1   "),
                ModulusWeightMapping.From
                    ("499273 499273 DBLAL    2   1    2    1    2    1    2    1    2    1    2    1    2    1   ")
            });
            _fakedModulusWeightTable.Setup(fmwt => fmwt.GetRuleMappings(new SortCode("118765")))
            .Returns(new []
            {
                ModulusWeightMapping.From
                    ("110000 119280 DblAl    0   0    2    1    2    1    2    1    2    1    2    1    2    1   1")
            });
            _firstStepDblAlCalculator  = new FirstDoubleAlternateCalculator();
            _secondStepDblAlCalculator = new SecondDoubleAlternateCalculator();
        }
        public void ExceptionFiveValidationTestSumCheck()
        {
            var details = new BankAccountDetails("938611", "07806039");
            var mapping = ModulusWeightMapping.From("012345 012346 dblal 2 1 2 1 2 1 2 1 2 1 2 1 2 0 5");
            var actual  = _check.GetModulusSum(details, mapping);

            Assert.AreEqual(51, actual);
        }
        public void CalculatesSumAsExpected()
        {
            var details = new BankAccountDetails("499273", "12345678");
            var mapping = ModulusWeightMapping.From("012345 012346 dblal 2 1 2 1 2 1 2 1 2 1 2 1 2 1");
            var actual  = _check.GetModulusSum(details, mapping);

            Assert.AreEqual(70, actual);
        }
        public void CalculatesExceptionSixTestCaseCorrectly()
        {
            var details = new BankAccountDetails("202959", "63748472");
            var mapping = ModulusWeightMapping.From("012345 012346 dblal 2 1 2 1 2 1 2 1 2 1 2 1 2 1");
            var actual  = _check.GetModulusSum(details, mapping);

            Assert.AreEqual(60, actual);
        }
        public void ExceptionFiveFirstCheckCorrectSecondIncorrect()
        {
            var details = new BankAccountDetails("938063", "15764273");
            var mapping = ModulusWeightMapping.From("012345 012346 dblal 2 1 2 1 2 1 2 1 2 1 2 1 2 0 5");
            var actual  = _check.GetModulusSum(details, mapping);

            Assert.AreEqual(58, actual);
        }
Ejemplo n.º 8
0
 public ValacdosSource()
 {
     GetModulusWeightMappings = Resources.valacdos
                                .Split(new[] { "\r\n", "\n" }, StringSplitOptions.None)
                                .Where(row => row.Length > 0)
                                .Select(row => ModulusWeightMapping.From(row))
                                .ToArray();
 }
Ejemplo n.º 9
0
        private static bool MappingContainsSortCode(SortCode sortCode, ModulusWeightMapping rm)
        {
            var mappingStart = rm.SortCodeStart.DoubleValue;
            var mappingEnd   = rm.SortCodeEnd.DoubleValue;
            var sc           = sortCode.DoubleValue;

            return(mappingStart <= sc && sc <= mappingEnd);
        }
        protected bool ProcessWeightingRule(AccountDetails bankAccountDetails, ModulusWeightMapping modulusWeightMapping)
        {
            var weightingSum = new StandardModulusCheck().GetModulusSum(bankAccountDetails, modulusWeightMapping);
            var remainder    = weightingSum % Modulus;

            return(modulusWeightMapping.Exception == 4
                       ? bankAccountDetails.AccountNumber.GetExceptionFourCheckValue == remainder
                       : remainder == 0);
        }
        //938000 938696 Mod11 7 6 5 4 3 2 7 6 5 4 3 2 0 0 5
        //938000 938696 DblAl 2 1 2 1 2 1 2 1 2 1 2 1 2 0 5
        public void ExceptionFiveDoubleAlternateWhenBothPass()
        {
            var details = new BankAccountDetails("938063", "55065200");
            var mapping = ModulusWeightMapping.From("938000 938696 DblAl 2 1 2 1 2 1 2 1 2 1 2 1 2 0 5");
            var actual  = _check.GetModulusSum(details, mapping);

            Assert.AreEqual(40, actual);
            Assert.AreEqual(0, actual % 10);
        }
        public void CanLoadWeightingValues()
        {
            var actual = new ModulusWeightMapping("230872 230872 DBLAL    2    1    2    1    2    1    2    1    2    1    2    1    2    1");
            var expectedWeightValues = new[] { 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1 };

            for (var i = 0; i < actual.WeightValues.Count(); i++)
            {
                Assert.AreEqual(actual.WeightValues.ElementAt(i), expectedWeightValues[i]);
            }
        }
        private void ValidateStandardModulusWeightSumCalculation(string sc, string an, string mappingString, int expected)
        {
            var details = new BankAccountDetails(sc, an)
            {
                WeightMappings = new [] { ModulusWeightMapping.From(mappingString) }
            };
            var actual = _checker.GetModulusSum(details, details.WeightMappings.First());

            Assert.AreEqual(expected, actual);
        }
        public void ExceptionOneChangesSum()
        {
            var details         = new BankAccountDetails("123456", "12345678");
            var mapping         = ModulusWeightMapping.From("012345 012346 dblal 1 2 3 4 5 6 7 8 9 10 11 12 13 14");
            var withNoException = _check.GetModulusSum(details, mapping);

            mapping = ModulusWeightMapping.From("012345 012346 dblal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1");
            var withException = _check.GetModulusSum(details, mapping);

            Assert.IsTrue(withNoException + 27 == withException);
        }
        private bool InitialSecondCheck(BankAccountDetails bankAccountDetails, ModulusWeightMapping mapping)
        {
            var alternativeWeightMapping = new ModulusWeightMapping(mapping)
            {
                WeightValues =
                    bankAccountDetails
                    .GetExceptionTwoAlternativeWeights(
                        mapping.WeightValues)
            };

            return(ProcessWeightingRule(bankAccountDetails, alternativeWeightMapping));
        }
Ejemplo n.º 16
0
        public void CanProcessDoubleAlternate()
        {
            var bankDetails = new BankAccountDetails("123456", "12345678")
            {
                WeightMappings = new[]
                {
                    ModulusWeightMapping.From(
                        "090150 090156 DBLAL    0    0    0    0    0    9    8    7    6    5    4    3    2    1")
                }
            };

            _targetRouter.GetModulusCalculation(bankDetails);
            _mockFirstDoubleAlternator.Verify(calc => calc.Process(bankDetails));
        }
Ejemplo n.º 17
0
        public void CanProcessModulusElevenExceptionFive()
        {
            var bankDetails = new BankAccountDetails("123456", "12345678")
            {
                WeightMappings = new[]
                {
                    ModulusWeightMapping.From(
                        "090150 090156 MOD11    0    0    0    0    0    9    8    7    6    5    4    3    2    1    5")
                }
            };

            _targetRouterForExceptionFive.GetModulusCalculation(bankDetails);
            _mockFirstStandardElevenExceptionFiveCalculator.Verify(calc => calc.Process(bankDetails));
        }
Ejemplo n.º 18
0
        public void CanProcessDoubleAlternateWithExceptionFive()
        {
            var bankDetails = new BankAccountDetails("123456", "12345678")
            {
                WeightMappings = new[]
                {
                    ModulusWeightMapping.From(
                        "090150 090156 DBLAL    0    0    0    0    0    9    8    7    6    5    4    3    2    1    5"),
                    ModulusWeightMapping.From(
                        "090150 090156 DBLAL    0    0    0    0    0    9    8    7    6    5    4    3    2    1    5")
                }
            };

            _targetRouterForExceptionFive.GetModulusCalculation(bankDetails);
            _mockSecondDoubleAlternateExceptionFiveCalculator.Verify(calc => calc.Process(bankDetails));
        }
Ejemplo n.º 19
0
        public void CanProcessModulusTen()
        {
            var bankDetails = new BankAccountDetails("123456", "12345678")
            {
                WeightMappings = new[]
                {
                    ModulusWeightMapping.From(
                        "090150 090156 MOD10    0    0    0    0    0    9    8    7    6    5    4    3    2    1"),
                    ModulusWeightMapping.From(
                        "090150 090156 MOD10    0    0    0    0    0    9    8    7    6    5    4    3    2    1")
                }
            };

            _targetRouter.GetModulusCalculation(bankDetails);
            _mockSecondStandardTenCalculator.Verify(calc => calc.Process(bankDetails));
        }
        private static IEnumerable <ModulusWeightMapping> BuildMappingList(string sc, int desiredMappings, int exception)
        {
            var items = new List <ModulusWeightMapping>();

            for (var i = 0; i < desiredMappings; i++)
            {
                exception = i == 0
                                ? exception == ModulusExceptionFlag ? i : exception
                                : i;
                items.Add(
                    ModulusWeightMapping.From(
                        string.Format(
                            "{0} 089999 MOD10    0    0    0    0    0    0    7    1    3    7    1    3    7    7    {1}",
                            sc, exception)));
            }
            return(items);
        }
        /// 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, ModulusWeightMapping 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));
            }
        }
Ejemplo n.º 22
0
        public int GetModulusSum(BankAccountDetails bankAccountDetails, ModulusWeightMapping weightMapping)
        {
            var combinedValue = bankAccountDetails.ToCombinedString();

            if (combinedValue.Length != 14)
            {
                throw new Exception(
                          string.Format("Combined SortCode and Account Number should be 14 characters long not {0}: {1}",
                                        combinedValue.Length, combinedValue));
            }
            var sum = 0;

            for (var i = 0; i < 14; i++)
            {
                sum += (int.Parse(combinedValue[i].ToString(CultureInfo.InvariantCulture)) * weightMapping.WeightValues[i]);
            }
            return(sum);
        }
Ejemplo n.º 23
0
        public void Before()
        {
            var mappingSource = new Mock <IRuleMappingSource>();

            mappingSource.Setup(ms => ms.GetModulusWeightMappings).Returns(new []
            {
                ModulusWeightMapping.From(
                    "000000 000100 MOD10 0 0 0 0 0 0 7 5 8 3 4 6 2 1 "),
                ModulusWeightMapping.From(
                    "499273 499273 DBLAL    0    0    2    1    2    1    2    1    2    1    2    1    2    1   1"),
                ModulusWeightMapping.From(
                    "200000 200002 DBLAL    2    1    2    1    2    1    2    1    2    1    2    1    2    1   6")
            });
            _fakedModulusWeightTable = new Mock <IModulusWeightTable>();
            _fakedModulusWeightTable.Setup(fmwt => fmwt.RuleMappings).Returns(mappingSource.Object.GetModulusWeightMappings);
            _fakedModulusWeightTable.Setup(fmwt => fmwt.GetRuleMappings(new SortCode("000000")))
            .Returns(new []
            {
                ModulusWeightMapping.From("000000 000100 MOD10 0 0 0 0 0 0 7 5 8 3 4 6 2 1 "),
            });
        }
Ejemplo n.º 24
0
        public void Before()
        {
            var mappingSource = new Mock <IRuleMappingSource>();

            mappingSource.Setup(ms => ms.GetModulusWeightMappings)
            .Returns(new []
            {
                ModulusWeightMapping.From(
                    "010004 010006 MOD10 2 1 2 1 2  1 2 1 2 1 2 1 2 1"),
                ModulusWeightMapping.From(
                    "010004 010006 DBLAL 2 1 2 1 2  1 2 1 2 1 2 1 2 1"),
                ModulusWeightMapping.From(
                    "010007 010010 DBLAL  2 1 2 1 2  1 2 1 2 1 2 1 2 1"),
                ModulusWeightMapping.From(
                    "010011 010013 MOD11    2 1 2 1 2  1 2 1 2 1 2 1 2 1"),
                ModulusWeightMapping.From(
                    "010014 010014 MOD11    2 1 2 1 2  1 2 1 2 1 2 1 2 1 5")
            });
            _mockModulusWeightTable = new Mock <IModulusWeightTable>();
            _mockModulusWeightTable.Setup(mwt => mwt.GetRuleMappings(new SortCode("010004"))).Returns(
                new[]
            {
                ModulusWeightMapping.From(
                    "010004 010006 MOD10 2 1 2 1 2  1 2 1 2 1 2 1 2 1"),
                ModulusWeightMapping.From(
                    "010004 010006 DBLAL 2 1 2 1 2  1 2 1 2 1 2 1 2 1"),
            });
            _mockModulusWeightTable.Setup(mwt => mwt.GetRuleMappings(new SortCode("010009"))).Returns(
                new []
            {
                ModulusWeightMapping.From(
                    "010007 010010 DBLAL  2 1 2 1 2  1 2 1 2 1 2 1 2 1")
            });
            _firstModulusCalculatorStep = new Mock <FirstModulusCalculatorStep>();
            _firstModulusCalculatorStep.Setup(fmc => fmc.Process(It.IsAny <BankAccountDetails>())).
            Returns(false);
            _ruleStep = new ConfirmDetailsAreValidForModulusCheck(_firstModulusCalculatorStep.Object);
        }
        public int GetModulusSum(BankAccountDetails bankAccountDetails, ModulusWeightMapping weightMapping)
        {
            var combinedValue = bankAccountDetails.ToCombinedString();

            if (combinedValue.Length != 14)
            {
                throw new Exception(
                          string.Format("Combined SortCode and Account Number should be 14 characters long not {0}: {1}",
                                        combinedValue.Length, combinedValue));
            }
            var sum = 0;

            for (var i = 0; i < 14; i++)
            {
                var multiplicationResult = (int.Parse(combinedValue[i].ToString()) * weightMapping.WeightValues[i]);
                sum += GetIntArray(multiplicationResult).Sum();
            }
            if (weightMapping.Exception == 1)
            {
                sum += 27;
            }
            return(sum);
        }
Ejemplo n.º 26
0
 public BankDetailsTestMother WithSecondWeightMapping(ModulusWeightMapping modulusWeightMapping)
 {
     _weightMappings.Insert(1, modulusWeightMapping);
     return(this);
 }
        public void Before()
        {
            _standardTen     = new Mock <SecondStandardModulusTenCalculator>();
            _standardEleven  = new Mock <SecondStandardModulusElevenCalculator>();
            _doubleAlternate = new Mock <SecondDoubleAlternateCalculator>();
            _doubleAlternateExceptionFive =
                new Mock <SecondDoubleAlternateCalculatorExceptionFive>();

            var mappingSource = new Mock <IRuleMappingSource>();

            mappingSource.Setup(ms => ms.GetModulusWeightMappings)
            .Returns(new[]
            {
                ModulusWeightMapping.From(
                    "010004 010006 MOD10 2 1 2 1 2  1 2 1 2 1 2 1 2 1"),
                ModulusWeightMapping.From(
                    "010007 010010 DBLAL  2 1 2 1 2  1 2 1 2 1 2 1 2 1"),
                ModulusWeightMapping.From(
                    "010007 010010 DBLAL  2 1 2 1 2  1 2 1 2 1 2 1 2 1"),
                ModulusWeightMapping.From(
                    "010011 010013 MOD11    2 1 2 1 2  1 2 1 2 1 2 1 2 1"),
                ModulusWeightMapping.From(
                    "010011 010013 MOD11    2 1 2 1 2  1 2 1 2 1 2 1 2 1"),
                ModulusWeightMapping.From(
                    "010016 010016 dblal    2 1 2 1 2 1 2 1 2 1 2 1 2 1 5"),
                ModulusWeightMapping.From(
                    "010016 010016 dblal    2 1 2 1 2 1 2 1 2 1 2 1 2 1 5"),
                ModulusWeightMapping.From(
                    "010014 010014 MOD11    2 1 2 1 2  1 2 1 2 1 2 1 2 1 5"),
                ModulusWeightMapping.From(
                    "010014 010014 MOD11    2 1 2 1 2  1 2 1 2 1 2 1 2 1 5"),
                ModulusWeightMapping.From(
                    "010004 010006 MOD10 2 1 2 1 2  1 2 1 2 1 2 1 2 1"),
            });
            _mockModulusWeightTable = new Mock <IModulusWeightTable>();
            _mockModulusWeightTable.Setup(mwt => mwt.GetRuleMappings(new SortCode("010004"))).Returns(
                new[]
            {
                ModulusWeightMapping.From(
                    "010004 010006 MOD10 2 1 2 1 2  1 2 1 2 1 2 1 2 1"),
                ModulusWeightMapping.From(
                    "010004 010006 MOD10 2 1 2 1 2  1 2 1 2 1 2 1 2 1")
            });
            _mockModulusWeightTable.Setup(mwt => mwt.GetRuleMappings(new SortCode("010008"))).Returns(
                new[]
            {
                ModulusWeightMapping.From(
                    "010007 010010 DBLAL  2 1 2 1 2  1 2 1 2 1 2 1 2 1"),
                ModulusWeightMapping.From(
                    "010007 010010 DBLAL  2 1 2 1 2  1 2 1 2 1 2 1 2 1"),
            });
            _mockModulusWeightTable.Setup(mwt => mwt.GetRuleMappings(new SortCode("010013"))).Returns(
                new[]
            {
                ModulusWeightMapping.From(
                    "010011 010013 MOD11    2 1 2 1 2  1 2 1 2 1 2 1 2 1"),
                ModulusWeightMapping.From(
                    "010011 010013 MOD11    2 1 2 1 2  1 2 1 2 1 2 1 2 1"),
            });
            _mockModulusWeightTable.Setup(mwt => mwt.GetRuleMappings(new SortCode("010014"))).Returns(
                new[]
            {
                ModulusWeightMapping.From(
                    "010014 010014 MOD11    2 1 2 1 2  1 2 1 2 1 2 1 2 1 5"),
                ModulusWeightMapping.From(
                    "010014 010014 MOD11    2 1 2 1 2  1 2 1 2 1 2 1 2 1 5"),
            });
            _mockModulusWeightTable.Setup(mwt => mwt.GetRuleMappings(new SortCode("010016"))).Returns(
                new[]
            {
                ModulusWeightMapping.From(
                    "010016 010016 dblal    2 1 2 1 2 1 2 1 2 1 2 1 2 1 5"),
                ModulusWeightMapping.From(
                    "010016 010016 dblal    2 1 2 1 2 1 2 1 2 1 2 1 2 1 5")
            });
            _standardTen.Setup(nr => nr.Process(It.IsAny <BankAccountDetails>())).Returns(true);
            _standardEleven.Setup(nr => nr.Process(It.IsAny <BankAccountDetails>())).Returns(true);
            _doubleAlternate.Setup(nr => nr.Process(It.IsAny <BankAccountDetails>())).Returns(true);
            _doubleAlternateExceptionFive.Setup(nr => nr.Process(It.IsAny <BankAccountDetails>())).
            Returns(true);
        }
Ejemplo n.º 28
0
        public void Before()
        {
            _standardTen                       = new Mock <FirstStandardModulusTenCalculator>();
            _standardEleven                    = new Mock <FirstStandardModulusElevenCalculator>();
            _firstDoubleAlternate              = new Mock <FirstDoubleAlternateCalculator>();
            _standardExceptionFive             = new Mock <FirstStandardModulusElevenCalculatorExceptionFive>();
            _secondModulusCalculation          = new Mock <SecondModulusCalculatorStep>();
            _firstDoubleAlternateExceptionFive =
                new Mock <FirstDoubleAlternateCalculatorExceptionFive>();
            _exceptionFourteenCalculator = new Mock <StandardModulusExceptionFourteenCalculator>();

            var mappingSource = new Mock <IRuleMappingSource>();

            mappingSource.Setup(ms => ms.GetModulusWeightMappings)
            .Returns(new[]
            {
                ModulusWeightMapping.From(
                    "010004 010006 MOD10 2 1 2 1 2  1 2 1 2 1 2 1 2 1"),
                ModulusWeightMapping.From(
                    "010004 010006 DBLAL 2 1 2 1 2  1 2 1 2 1 2 1 2 1"),
                ModulusWeightMapping.From(
                    "010007 010010 DBLAL  2 1 2 1 2  1 2 1 2 1 2 1 2 1"),
                ModulusWeightMapping.From(
                    "010011 010013 MOD11    2 1 2 1 2  1 2 1 2 1 2 1 2 1"),
                ModulusWeightMapping.From(
                    "010016 010016 dblal    2 1 2 1 2 1 2 1 2 1 2 1 2 1 5"),
                ModulusWeightMapping.From(
                    "010014 010014 MOD11    2 1 2 1 2  1 2 1 2 1 2 1 2 1 5")
            });
            _mockModulusWeightTable = new Mock <IModulusWeightTable>();
            _mockModulusWeightTable.Setup(mwt => mwt.GetRuleMappings(new SortCode("010004"))).Returns(
                new []
            {
                ModulusWeightMapping.From(
                    "010004 010006 MOD10 2 1 2 1 2  1 2 1 2 1 2 1 2 1"),
                ModulusWeightMapping.From(
                    "010004 010006 DBLAL 2 1 2 1 2  1 2 1 2 1 2 1 2 1")
            });
            _mockModulusWeightTable.Setup(mwt => mwt.GetRuleMappings(new SortCode("010008"))).Returns(
                new[]
            {
                ModulusWeightMapping.From(
                    "010007 010010 DBLAL  2 1 2 1 2  1 2 1 2 1 2 1 2 1")
            });
            _mockModulusWeightTable.Setup(mwt => mwt.GetRuleMappings(new SortCode("010013"))).Returns(
                new[]
            {
                ModulusWeightMapping.From(
                    "010011 010013 MOD11    2 1 2 1 2  1 2 1 2 1 2 1 2 1")
            });
            _mockModulusWeightTable.Setup(mwt => mwt.GetRuleMappings(new SortCode("010014"))).Returns(
                new[]
            {
                ModulusWeightMapping.From(
                    "010014 010014 MOD11    2 1 2 1 2  1 2 1 2 1 2 1 2 1 5")
            });
            _mockModulusWeightTable.Setup(mwt => mwt.GetRuleMappings(new SortCode("010016"))).Returns(
                new[]
            {
                ModulusWeightMapping.From(
                    "010016 010016 dblal    2 1 2 1 2 1 2 1 2 1 2 1 2 1 5")
            });
            _mockModulusWeightTable.Setup(mwt => mwt.GetRuleMappings(new SortCode("180002"))).Returns(
                new[]
            {
                ModulusWeightMapping.From("180002 180002 Mod11 0 0 0 0 0 0 8 7 6 5 4 3 2 1 14")
            });
            _mockModulusWeightTable.Setup(mwt => mwt.GetRuleMappings(new SortCode("200915"))).Returns(
                new[]
            {
                ModulusWeightMapping.From("200901 201159 Mod11 0 0 0 0 0 0 0 7 6 5 4 3 2 1 6"),
                ModulusWeightMapping.From("200901 201159 DblAl 2 1 2 1 2 1 2 1 2 1 2 1 2 1 6")
            });

            _standardTen.Setup(nr => nr.Process(It.IsAny <BankAccountDetails>())).Returns(true);
            _exceptionFourteenPassesFirstTime  = new BankAccountDetails("180002", "98093517");
            _exceptionFourteenPassesSecondTime = new BankAccountDetails("180002", "00000190");
            _standardEleven.Setup(nr => nr.Process(_exceptionFourteenPassesFirstTime)).Returns(true);
            _standardEleven.Setup(nr => nr.Process(_exceptionFourteenPassesSecondTime)).Returns(false);
            _firstDoubleAlternate.Setup(nr => nr.Process(It.IsAny <BankAccountDetails>())).Returns(true);
            _standardExceptionFive.Setup(nr => nr.Process(It.IsAny <BankAccountDetails>())).Returns(true);
            _secondModulusCalculation.Setup(nr => nr.Process(It.IsAny <BankAccountDetails>())).Returns(
                true);
            _firstDoubleAlternateExceptionFive.Setup(nr => nr.Process(It.IsAny <BankAccountDetails>())).
            Returns(true);
            _exceptionFourteenCalculator.Setup(nr => nr.Process(It.IsAny <BankAccountDetails>())).Returns
                (true);

            _firstStepRouter = new Mock <FirstStepRouter>(_standardTen.Object, _standardEleven.Object, _firstDoubleAlternate.Object);
        }
        public void CanAddAlgorithm(string row, ModulusAlgorithm expected)
        {
            var actual = ModulusWeightMapping.From(row);

            Assert.AreEqual(expected, actual.Algorithm);
        }
 public void CannotAddUnknownAlgorithm()
 {
     Assert.Throws <ArgumentException>(() =>
                                       ModulusWeightMapping.From("123456 001234 PLOPPY 2 1 2 1 2 1 2 1 2 1 2 1 2 1"));
 }