コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }