示例#1
0
        public void Scramble_TestMethod()
        {
            BSNVerification verification = new BSNVerification();

            foreach (string validBSNTestNummer in validTestBSNs)
            {
                scamble_TestMethod(verification, validBSNTestNummer);
            }
            runRandomManyTimesForAllLengths(verification, scamble_TestMethod);
        }
示例#2
0
        public void Complete_TestMethod()
        {
            BSNVerification verification = new BSNVerification();

            foreach (string becomesNineDigit in becomesNineDigits)
            {
                string nineDigit = verification.Complete(becomesNineDigit);
                bool   valid     = verification.IsValid(nineDigit);
                Assert.IsTrue(valid, "Completed {0} into {1}, but {1} was not valid", becomesNineDigit, nineDigit);
            }
        }
示例#3
0
 private static void runRandomManyTimesForAllLengths(BSNVerification verification, Action <BSNVerification, string> action)
 {
     for (int i = 0; i < 1000; i++)
     {
         for (int length = BSNVerification.MinBSNLength; length < BSNVerification.MaxBSNLength; length++)
         {
             string generatedBSN = verification.Random(length);
             action(verification, generatedBSN);
         }
     }
 }
示例#4
0
        private static void scamble_TestMethod(BSNVerification verification, string validBSNTestNummer)
        {
            string rot5 = verification.Scramble(validBSNTestNummer);

            {
                int result   = rot5.Length;
                int expected = validBSNTestNummer.Length;
                Assert.AreEqual(expected, result, "Expected length {0} of BSNVerification.Rot5 to the same as the plain length {1}", result, expected);
            }
            foreach (char item in rot5)
            {
                bool result   = char.IsNumber(item) || (item == '.');
                bool expected = true;
                Assert.AreEqual(expected, result, "Expected all characters returned by BSNVerification.Rot5 to be numeric or dot, but {0} isn't", item);
            }
        }
示例#5
0
        public void IsValid_TestMethod()
        {
            BSNVerification verification = new BSNVerification();

            foreach (string inValidBSNTestNummer in invalidTestBSNs)
            {
                bool result   = verification.IsValid(inValidBSNTestNummer);
                bool expected = false;
                Assert.AreEqual(expected, result, "Expected BSNVerification.IsValid({0} to be {1}", inValidBSNTestNummer, expected);
            }

            foreach (string validBSNTestNummer in validTestBSNs)
            {
                bool result   = verification.IsValid(validBSNTestNummer);
                bool expected = true;
                Assert.AreEqual(expected, result, "Expected BSNVerification.IsValid({0} to be {1}", validBSNTestNummer, expected);
            }
        }
示例#6
0
        public void Complete_cannotBecomeTenDigits_TestMethod()
        {
            BSNVerification verification = new BSNVerification();

            Exception exception = null;

            foreach (string cannotBecomeNineDigit in cannotBecomeNineDigits)
            {
                try
                {
                    string nineDigit = verification.Complete(cannotBecomeNineDigit);
                    Assert.Inconclusive("It should not be possible that {0} completed into {1}", Reflector.GetNameSeparatorValue(new { cannotBecomeNineDigit }), Reflector.GetNameSeparatorValue(new { nineDigit }));
                }
                catch (Exception ex)
                {
                    exception = ex;
                    continue;
                }
            }
            throw exception;
        }
示例#7
0
        public void Random_validLengths_TestMethod()
        {
            BSNVerification verification = new BSNVerification();

            runRandomManyTimesForAllLengths(verification, validateGeneratedNumber);
        }
示例#8
0
        private static void validateGeneratedNumber(BSNVerification verification, string generatedBSN)
        {
            bool validBSN = verification.IsValid(generatedBSN);

            Assert.IsTrue(validBSN, "Generated {0} is invalid", Reflector.GetNameSeparatorValue(new { generatedBSN }));
        }
示例#9
0
 public void Random_invalidLength_TestMethod()
 {
     BSNVerification verification = new BSNVerification();
     string          generatedBSN = verification.Random(100); // invalid length; should throw an exception
 }