示例#1
0
        public void CanExplainWhyItDoesNotCallSecondCheck()
        {
            var bankAccountDetails = BankDetailsTestMother.BankDetailsWithException(3);

            var modulusCheckOutcome = _isSecondCheckRequiredGate.Process(bankAccountDetails);

            Assert.AreEqual("first weight mapping exception does not require second check", modulusCheckOutcome.Explanation);
        }
示例#2
0
        public void ExceptionRequiresSecondCheckItCallsNext(int exception)
        {
            var bankAccountDetails = BankDetailsTestMother.BankDetailsWithException(exception);

            _isSecondCheckRequiredGate.Process(bankAccountDetails);

            _nextStep.Verify(ns => ns.Process(bankAccountDetails), Times.Once);
        }
示例#3
0
        public void DoesNotCallSecondCheckIfExceptionDoesNotRequireIt(int exception)
        {
            var bankAccountDetails = BankDetailsTestMother.BankDetailsWithException(exception);

            _isSecondCheckRequiredGate.Process(bankAccountDetails);

            _nextStep.Verify(ns => ns.Process(bankAccountDetails), Times.Never);
        }
示例#4
0
        public void CanCallNextStepWhenAccountDoesNotQualifyToSkip(int exception, bool firstCheck)
        {
            var details = BankDetailsTestMother.BankDetailsWithException(exception);

            details.FirstResult = firstCheck;

            _isExceptionTwoAndFirstCheckPassedGate.Process(details);

            _nextStep.Verify(ns => ns.Process(details), Times.Once);
        }
示例#5
0
            public void ItExplainsThatItCallsTheExceptionCalculatorWhenTheFirstTestFails()
            {
                var details = BankDetailsTestMother.BankDetailsWithException(14);

                details.FirstResult = false;

                var modulusCheckOutcome = _exceptionFourteenGate.Process(details);

                Assert.AreEqual("StandardModulusExceptionFourteenCalculator", modulusCheckOutcome.Explanation);
            }
示例#6
0
        public void CanSkipSecondCheckForExceptionTwoWithPassedFirstCheck()
        {
            var details = BankDetailsTestMother.BankDetailsWithException(2);

            details.FirstResult = true;

            _isExceptionTwoAndFirstCheckPassedGate.Process(details);

            _nextStep.Verify(ns => ns.Process(details), Times.Never);
        }
示例#7
0
            public void ItExplainsThatItReturnsFirstResultWhenThatPasses()
            {
                var details = BankDetailsTestMother.BankDetailsWithException(14);

                details.FirstResult = true;

                var modulusCheckOutcome = _exceptionFourteenGate.Process(details);

                Assert.AreEqual("Coutts Account with passing first check", modulusCheckOutcome.Explanation);
            }
示例#8
0
        public void CanExplainSkippingSecondCheck()
        {
            var details = BankDetailsTestMother.BankDetailsWithException(2);

            details.FirstResult = true;

            var modulusCheckOutcome = _isExceptionTwoAndFirstCheckPassedGate.Process(details);

            Assert.AreEqual("IsExceptionTwoAndFirstCheckPassed", modulusCheckOutcome.Explanation);
        }
示例#9
0
            public void ItCallsTheExceptionCalculatorWhenTheFirstTestFails()
            {
                var details = BankDetailsTestMother.BankDetailsWithException(14);

                details.FirstResult = false;

                _exceptionFourteenGate.Process(details);

                _nextStep.Verify(ns => ns.Process(details), Times.Never);
                _mockCalc.Verify(mc => mc.Process(details), Times.Once);
            }
示例#10
0
            public void ItReturnsFirstResultWhenThatPasses()
            {
                var details = BankDetailsTestMother.BankDetailsWithException(14);

                details.FirstResult = true;

                _exceptionFourteenGate.Process(details);

                _nextStep.Verify(ns => ns.Process(details), Times.Never);
                _mockCalc.Verify(mc => mc.Process(details), Times.Never);
            }
示例#11
0
        public void IfThereIsOnlyOneMappingItReturns()
        {
            _bankAccountDetails.WeightMappings = new[]
            {
                BankDetailsTestMother.AnyModulusWeightMapping()
            };

            _onlyOneWeightMappingGate.Process(_bankAccountDetails);

            _nextStep.Verify(ns => ns.Process(It.IsAny <BankAccountDetails>()), Times.Never);
        }
示例#12
0
        public void ItCanExplainThatThereWasOnlyOneMapping()
        {
            _bankAccountDetails.WeightMappings = new[]
            {
                BankDetailsTestMother.AnyModulusWeightMapping()
            };

            var modulusCheckOutcome = _onlyOneWeightMappingGate.Process(_bankAccountDetails);

            Assert.AreEqual("not proceeding to the second check as there is only one weight mapping", modulusCheckOutcome.Explanation);
        }
示例#13
0
        public void CanChooseDblAl()
        {
            var secondModulusCalculatorStep = new SecondModulusCalculatorStep(_secondStepRouter, _nextStep.Object);
            var details = BankDetailsTestMother.BankDetailsWithAlgorithm(ModulusAlgorithm.DblAl);

            secondModulusCalculatorStep.Process(details);

            _standardTen.Verify(st => st.Process(details), Times.Never);
            _standardEleven.Verify(st => st.Process(details), Times.Never);
            _doubleAlternate.Verify(st => st.Process(details), Times.Once);
            _nextStep.Verify(st => st.Process(details), Times.Once);
        }
示例#14
0
        public void IfThereAreTwoMappingsItCallsTheNextStep()
        {
            _bankAccountDetails.WeightMappings = new[]
            {
                BankDetailsTestMother.AnyModulusWeightMapping(),
                    BankDetailsTestMother.AnyModulusWeightMapping()
            };

            _onlyOneWeightMappingGate.Process(_bankAccountDetails);

            _nextStep.Verify(ns => ns.Process(_bankAccountDetails), Times.Once);
        }
示例#15
0
            public void ItCallsTheNextStep()
            {
                var mockCalc = new Mock <StandardModulusExceptionFourteenCalculator>();
                var nextStep = new Mock <IProcessAStep>();
                var gate     = new ExceptionFourteenGate(mockCalc.Object, nextStep.Object);

                var details = BankDetailsTestMother.BankDetailsWithException(0);

                gate.Process(details);

                nextStep.Verify(ns => ns.Process(details), Times.Once);
                mockCalc.Verify(mc => mc.Process(details), Times.Never);
            }
        public void CallsNextStepWhenAccountRequiresSecondCheck(int exception, string accountNumberCharacter)
        {
            var bankAccountDetails = new BankAccountDetails("012345", $"00{accountNumberCharacter}00000")
            {
                WeightMappings = new[]
                {
                    BankDetailsTestMother.WeightMappingWithException(3),
                    BankDetailsTestMother.WeightMappingWithException(exception)
                }
            };

            _isExceptionThreeAndCanSkipSecondCheck.Process(bankAccountDetails);

            _nextStep.Verify(ns => ns.Process(bankAccountDetails), Times.Once);
        }
        public void CanExplainSkippingSecondCheck()
        {
            var bankAccountDetails = new BankAccountDetails("012345", "00600000")
            {
                WeightMappings = new[]
                {
                    BankDetailsTestMother.WeightMappingWithException(3),
                    BankDetailsTestMother.WeightMappingWithException(3)
                }
            };

            var modulusCheckOutcome = _isExceptionThreeAndCanSkipSecondCheck.Process(bankAccountDetails);

            Assert.AreEqual("IsExceptionThreeAndCanSkipSecondCheck", modulusCheckOutcome.Explanation);
        }
        public void CanSkipSecondCheckWhenExceptionThreeAndSixOrNineAtPositionTwoInAccountNumber(string accountNumber)
        {
            var bankAccountDetails = new BankAccountDetails("012345", $"00{accountNumber}00000")
            {
                WeightMappings = new[]
                {
                    BankDetailsTestMother.WeightMappingWithException(3),
                    BankDetailsTestMother.WeightMappingWithException(3)
                }
            };

            _isExceptionThreeAndCanSkipSecondCheck.Process(bankAccountDetails);

            _nextStep.Verify(ns => ns.Process(bankAccountDetails), Times.Never);
        }
        public void OtherwiseSecondCheckDeterminesResult(bool firstCheck, bool secondCheck, bool expected)
        {
            var step = new PostProcessModulusCheckResult();

            var bankAccountDetails = new BankDetailsTestMother()
                                     .WithFirstWeightMapping(BankDetailsTestMother.WeightMappingWithException(-1))
                                     .WithSecondWeightMapping(BankDetailsTestMother.WeightMappingWithException(-1))
                                     .WithFirstCheckResult(firstCheck)
                                     .WithSecondCheckResult(secondCheck)
                                     .Build();

            var modulusCheckOutcome = step.Process(bankAccountDetails);

            Assert.AreEqual(expected, modulusCheckOutcome.Result);
            Assert.AreEqual("no exceptions affect result - using second check result", modulusCheckOutcome.Explanation);
        }
        public void ExceptionTwelveAndThirteenEitherCanPass(bool firstCheck, bool secondCheck, bool expected)
        {
            var step = new PostProcessModulusCheckResult();

            var bankAccountDetails = new BankDetailsTestMother()
                                     .WithFirstWeightMapping(BankDetailsTestMother.WeightMappingWithException(12))
                                     .WithSecondWeightMapping(BankDetailsTestMother.WeightMappingWithException(13))
                                     .WithFirstCheckResult(firstCheck)
                                     .WithSecondCheckResult(secondCheck)
                                     .Build();

            var modulusCheckOutcome = step.Process(bankAccountDetails);

            Assert.AreEqual(expected, modulusCheckOutcome.Result);
            Assert.AreEqual("exception 12 and 13 - so second or first check must pass", modulusCheckOutcome.Explanation);
        }
        public void ExceptionFiveBothChecksMustPass(bool firstCheck, bool secondCheck, bool expected)
        {
            var step = new PostProcessModulusCheckResult();

            var bankAccountDetails = new BankDetailsTestMother()
                                     .WithFirstWeightMapping(BankDetailsTestMother.WeightMappingWithException(5))
                                     .WithSecondWeightMapping(BankDetailsTestMother.WeightMappingWithException(5))
                                     .WithFirstCheckResult(firstCheck)
                                     .WithSecondCheckResult(secondCheck)
                                     .Build();

            var modulusCheckOutcome = step.Process(bankAccountDetails);

            Assert.AreEqual(expected, modulusCheckOutcome.Result);
            Assert.AreEqual("exception 5 - so first and second check must pass", modulusCheckOutcome.Explanation);
        }