예제 #1
0
        public void ItCanRevalidateDetailsOnImmediateRepeat()
        {
            var checker = new ModulusChecker();

            Assert.IsTrue(checker.CheckBankAccount(Sortcode, AccNumber));
            Assert.IsTrue(checker.CheckBankAccount(Sortcode, AccNumber));
        }
예제 #2
0
        public void ItCanRevalidateDetailsOnSeparatedRepeat(string sc, string an)
        {
            var checker = new ModulusChecker();

            Assert.IsTrue(checker.CheckBankAccount(Sortcode, AccNumber), string.Format("first check should have passed for {0} and {1}", Sortcode, AccNumber));
            Assert.IsTrue(checker.CheckBankAccount(sc, an), string.Format("separating check should have passed for {0} and {1}", sc, an));
            Assert.IsTrue(checker.CheckBankAccount(Sortcode, AccNumber), string.Format("second check should have passed for {0} and {1}", Sortcode, AccNumber));
        }
        public void ItCanProcessALargeFileInUnder(int seconds)
        {
            var stopwatch      = new Stopwatch();
            var modulusChecker = new ModulusChecker();

            var currentDirectory = TestContext.CurrentContext.TestDirectory;
            var fileName         = "sa.txt";
            var fullPath         = Path.Combine(currentDirectory, fileName);

            using (var sr = new StreamReader(fullPath))
            {
                stopwatch.Start();

                while (sr.Peek() >= 0)
                {
                    var segments = sr
                                   .ReadLine()
                                   .Split('\t');

                    modulusChecker.CheckBankAccount(segments.First(), segments.Last());
                }

                stopwatch.Stop();
            }

            Assert.IsTrue(stopwatch.Elapsed.Seconds <= seconds,
                          $"Failed to process a large number of sortcodes and account numbers in under {seconds} seconds. Took {stopwatch.Elapsed.Seconds}");
        }
예제 #4
0
        public void CanPassCurrentVocalinkTestCases(string sc, string an, bool expectedResult)
        {
            Assert.AreEqual(expectedResult, _modulusChecker.CheckBankAccount(sc, an));

            var outcomeWithExplanation = _modulusChecker.CheckBankAccountWithExplanation(sc, an);

            Assert.AreEqual(expectedResult, outcomeWithExplanation.Result);

            Console.WriteLine(outcomeWithExplanation.Explanation);
            Assert.IsNotEmpty(outcomeWithExplanation.Explanation);
        }
예제 #5
0
        public void ItCanProcessALargeFileInUnder(int seconds)
        {
            var stopwatch      = new Stopwatch();
            var modulusChecker = new ModulusChecker();

            using (var sr = new StreamReader("sa.txt"))
            {
                stopwatch.Start();

                while (sr.Peek() >= 0)
                {
                    var segments = sr
                                   .ReadLine()
                                   .Split('\t');

                    modulusChecker.CheckBankAccount(segments.First(), segments.Last());
                }

                stopwatch.Stop();
            }

            Assert.IsTrue(stopwatch.Elapsed.Seconds <= seconds, string.Format("Failed to process a large number of sortcodes and account numbers in under {0} seconds.", seconds));
        }
예제 #6
0
        public void SeparatingCheckPassesInIsolation(string sc, string an)
        {
            var checker = new ModulusChecker();

            Assert.IsTrue(checker.CheckBankAccount(Sortcode, AccNumber));
        }
예제 #7
0
 public void CanPassCurrentVocalinkTestCases(string sc, string an, bool expectedResult)
 {
     Assert.AreEqual(expectedResult, _modulusChecker.CheckBankAccount(sc, an));
 }