Example #1
0
        public void Matches_RegexWronglySpecified_Validated()
        {
            var members = new MemberResult();

            members.Add("000-000-0000");
            members.Add("2126661234");

            var matchPatternConstraint = new MatchPatternConstraint();

            matchPatternConstraint = matchPatternConstraint.Regex(@"^[2-9]\d{2}-\d{3}-\d{4}$");

            //Method under test
            var res = matchPatternConstraint.Matches(members);

            //Test conclusion
            Assert.That(res, Is.False);
        }
Example #2
0
        public void Matches_RegexCorrectlySpecified_Validated()
        {
            var members = new MemberResult();

            members.Add("800-555-5555");
            members.Add("212-666-1234");

            var matchPatternConstraint = new MatchPatternConstraint();

            matchPatternConstraint = matchPatternConstraint.Regex(@"^[2-9]\d{2}-\d{3}-\d{4}$");

            //Method under test
            var res = matchPatternConstraint.Matches(members);

            //Test conclusion
            Assert.That(res, Is.True);
        }
        public void Matches_RegexCorrectlySpecified_Validated()
        {
            var cells = new FormattedResults();

            cells.Add("$185,125.12");
            cells.Add("$125.12");
            cells.Add("$125.00");

            var matchPatternConstraint = new MatchPatternConstraint();

            matchPatternConstraint = matchPatternConstraint.Regex(@"^\$?[0-9]{1,3}(?:,?[0-9]{3})*\.[0-9]{2}$");

            //Method under test
            var res = matchPatternConstraint.Matches(cells);

            //Test conclusion
            Assert.That(res, Is.True);
        }
Example #4
0
        public void Matches_RegexWronglySpecified_Validated()
        {
            var cells = new List <string>()
            {
                "$185,125.12",
                "$125.12",
                "$125"
            };

            var matchPatternConstraint = new MatchPatternConstraint();

            matchPatternConstraint = matchPatternConstraint.Regex(@"^\$?[0-9]{1,3}(?:,?[0-9]{3})*\.[0-9]{2}$");

            //Method under test
            var res = matchPatternConstraint.Matches(cells);

            //Test conclusion
            Assert.That(res, Is.False);
        }
        public void WriteDescription_OneItemHasFailed_CorrectKeywordsForActualValue()
        {
            var cells = new FormattedResults();

            cells.Add("$185,125.12");
            cells.Add("$125.12");
            cells.Add("$125");

            var matchPatternConstraint = new MatchPatternConstraint();

            matchPatternConstraint = matchPatternConstraint.Regex(@"^\$?[0-9]{1,3}(?:,?[0-9]{3})*\.[0-9]{2}$");

            //Method under test
            var res = matchPatternConstraint.Matches(cells);

            var msg = new MessageWriter();

            matchPatternConstraint.WriteActualValueTo(msg);

            //Test conclusion
            Assert.That(msg.Message, Is.StringContaining("$125")
                        .And.StringContaining("doesn't validate this pattern"));
        }
Example #6
0
        public void WriteDescription_OneItemHasFailed_CorrectKeywordsForPredicate()
        {
            var cells = new List <string>()
            {
                "$185,125.12",
                "$125.12",
                "$125"
            };

            var matchPatternConstraint = new MatchPatternConstraint();

            matchPatternConstraint = matchPatternConstraint.Regex(@"^\$?[0-9]{1,3}(?:,?[0-9]{3})*\.[0-9]{2}$");

            //Method under test
            var res = matchPatternConstraint.Matches(cells);

            var msg = new MessageWriter();

            matchPatternConstraint.WriteDescriptionTo(msg);

            //Test conclusion
            Assert.That(msg.Predicate, Is.StringContaining("cell")
                        .And.StringContaining("regex"));
        }