Пример #1
0
        public void DectectIdNumbers_13DigitsOfInvalidIdNumber_ReturnsEmptyList()
        {
            const string search = "7303306765082";
            var          result = SouthAfricanIdNumberValidator.DetectIdNumbers(search);

            result.Count().ShouldBe(0);
        }
Пример #2
0
        public void DectectIdNumbers_EmptyParameter_ReturnsEmptyList()
        {
            var search = string.Empty;
            var result = SouthAfricanIdNumberValidator.DetectIdNumbers(search);

            result.Count().ShouldBe(0);
        }
Пример #3
0
        public void Gender_FemaleIdNumber_ShouldBeTrue()
        {
            var validator = new SouthAfricanIdNumberValidator("7303303132089");

            validator.IsFemale.ShouldBeTrue();
            validator.IsMale.ShouldBeFalse();
        }
Пример #4
0
        public void DectectIdNumbers_13DigitsOfValidIdNumber_ReturnsListOfOneIdNumber()
        {
            const string search = "7303306765083";
            var          result = SouthAfricanIdNumberValidator.DetectIdNumbers(search).ToList();

            result.Count.ShouldBe(1);
            result.First().ShouldBe(search);
        }
Пример #5
0
        public void DectectIdNumbers_TextContains13DigitsOfValidIdNumber_ReturnsListOfOneIdNumber()
        {
            const string search = "The following 13 digits 7303306765083 represent my uncles\'s Id";

            var result = SouthAfricanIdNumberValidator.DetectIdNumbers(search).ToList();

            result.Count.ShouldBe(1);
            search.ShouldContain(result.First());
        }
Пример #6
0
        public void DectectIdNumbers_TextStartsWith13DigitsOfValidIdNumber_ReturnsListOfOneIdNumber()
        {
            const string search = "7303306765083.45 this represent my uncles\'s Id whoops I added decimals to confuse you";

            var result = SouthAfricanIdNumberValidator.DetectIdNumbers(search).ToList();

            result.Count.ShouldBe(1);
            search.ShouldContain(result.First());
        }
Пример #7
0
        public void DectectIdNumbers_LargeTextContainsSeveralValidIdNumbersAndSeveralInvalidIdNumbers_ReturnsListOfValidNumbersOnly()
        {
            var search = "This 7501220027080.45 not this 7303306765089.34 and not this 7303306765086";

            search += "but this 7303306765083.34 and not this 7303306765082. There are only two valid Id numbers";

            var result = SouthAfricanIdNumberValidator.DetectIdNumbers(search).ToList();

            result.Count.ShouldBe(2);
            result.Exists(s => search.Contains(s)).ShouldBeTrue();
        }
Пример #8
0
        public void DectectIdNumbers_LargeTextContainsMultiLinesOfSeveralValidIdNumbersAndSeveralInvalidIdNumbers_ReturnsListOfValidNumbersOnly()
        {
            var search = "This 7501220027080.45 not this 7303306765089.34 and not this 7303306765086";

            search += "but this 7303306765083.34 and not this 7303306765082. There are only two valid Id numbers.";
            search += "\n\n\n\n";
            search += "Actually three is four Id Numbers, just another one at the end.";
            search += "\n\n\n\n";
            search += "\n\n\n\n";
            search += "#@#$%^7303303132089.89";

            var result = SouthAfricanIdNumberValidator.DetectIdNumbers(search).ToList();

            result.Count.ShouldBe(3);
            result.Exists(s => search.Contains(s)).ShouldBeTrue();
        }
Пример #9
0
        public void DectectIdNumbers_TextContainsFourDuplicateValidIdNumber_ReturnsListOfOneIdNumber()
        {
            var search = "This 7501220027080.45 not this 7303306765083.34 and not this 7303306765083";

            search += "but This 7501220027080.45 not this 7303306765083.34 and not this 7303306765083.";
            search += "\n\n\n";
            search += "These are duplicates there is only 2 sets of unique Id Number";

            var result = SouthAfricanIdNumberValidator.DetectIdNumbers(search).ToList();

            result.Count.ShouldBe(2);

            foreach (var id in result)
            {
                search.ShouldContain(id);
            }
        }
Пример #10
0
        public void IsValid_InvalidIdNotAllNumeric_ShouldBeFalse()
        {
            var validator = new SouthAfricanIdNumberValidator("73033067650a2");

            validator.IsValid.ShouldBeFalse();
        }
Пример #11
0
        public void IsValid_InvalidIdWrongLength_ShouldBeFalse()
        {
            var validator = new SouthAfricanIdNumberValidator("7500220027080");

            validator.IsValid.ShouldBeFalse();
        }
Пример #12
0
        public void IsValid_WrongDayAfter31_ShouldBeFalse()
        {
            var validator = new SouthAfricanIdNumberValidator("7501320027089");

            validator.IsValid.ShouldBeFalse();
        }
Пример #13
0
        public void IsValid_WronDayBefore01_ShouldBeFalse()
        {
            var validator = new SouthAfricanIdNumberValidator("7501000027086");

            validator.IsValid.ShouldBeFalse();
        }
Пример #14
0
        public void IsValid_WrongMonthAfter12_ShouldBeFalse()
        {
            var validator = new SouthAfricanIdNumberValidator("7513220027085");

            validator.IsValid.ShouldBeFalse();
        }
Пример #15
0
        public void IsValid_WrongMonthBefore01_ShouldBeFalse()
        {
            var validator = new SouthAfricanIdNumberValidator("7500220027082");

            validator.IsValid.ShouldBeFalse();
        }
Пример #16
0
        public void IsValid_SupplyNull_ShouldBeFalse()
        {
            var validator = new SouthAfricanIdNumberValidator(null);

            validator.IsValid.ShouldBeFalse();
        }
Пример #17
0
        public void IsValid_AllZeros_ShouldBeFalse()
        {
            var validator = new SouthAfricanIdNumberValidator("0000000000000");

            validator.IsValid.ShouldBeFalse();
        }
Пример #18
0
        public void IsValid_InvalidIdAlphaChars_ShouldBeFalse()
        {
            var validator = new SouthAfricanIdNumberValidator("73033067a5082");

            validator.IsValid.ShouldBeFalse();
        }
Пример #19
0
        public void IsValid_InvalidIdWrongCheckDigit_ShouldBeFalse()
        {
            var validator = new SouthAfricanIdNumberValidator("7303306765082");

            validator.IsValid.ShouldBeFalse();
        }
Пример #20
0
        public void IsValid_ValidId_Gender_ValidIdNumber_ShouldBeTrue()
        {
            var validator = new SouthAfricanIdNumberValidator("7501220027080");

            validator.IsValid.ShouldBeTrue();
        }
Пример #21
0
        public void IsSouthAfrican_ValidIdNumber_ShouldBeTrue()
        {
            var validator = new SouthAfricanIdNumberValidator("7303306765083");

            validator.IsSouthAfrican.ShouldBeTrue();
        }
Пример #22
0
        public void IsValid_ValidIdNumberWithTrailingSpaces_ShouldBeTrimmedAndPass()
        {
            var validator = new SouthAfricanIdNumberValidator("7303306765083   ");

            validator.IsValid.ShouldBeTrue();
        }