コード例 #1
0
ファイル: MatchPatternConstraint.cs プロジェクト: kalyon/NBi
        public override bool Matches(object actual)
        {
            if (actual is IDbCommand)
            {
                return(Process((IDbCommand)actual));
            }
            else if (actual is FormattedResults)
            {
                this.actual = actual;

                var res = true;
                foreach (var result in (FormattedResults)actual)
                {
                    var ctr = BuildInternalConstraint();
                    if (!DoMatch(ctr, result))
                    {
                        res = false;
                        invalidMembers.Add(result);
                    }
                }
                return(res);
            }
            else
            {
                throw new ArgumentException();
            }
        }
コード例 #2
0
        public void Matches_RegexWronglySpecified_Validated()
        {
            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);

            //Test conclusion
            Assert.That(res, Is.False);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: QueryAdomdEngine.cs プロジェクト: WimDeRons/NBi
        public FormattedResults GetFormats()
        {
            var cellSet          = ExecuteCellSet();
            var formattedResults = new FormattedResults();

            foreach (var cell in cellSet.Cells)
            {
                formattedResults.Add(cell.FormattedValue);
            }
            return(formattedResults);
        }
コード例 #5
0
        public void WriteDescription_OneItemHasFailed_CorrectKeywordsForPredicate()
        {
            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.WriteDescriptionTo(msg);

            //Test conclusion
            Assert.That(msg.Predicate, Is.StringContaining("cell")
                .And.StringContaining("regex"));
        }
コード例 #6
0
        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"));
        }
コード例 #7
0
ファイル: QuerySqlEngine.cs プロジェクト: zyh329/nbi
        public FormattedResults GetFormats()
        {
            var dataSet          = Execute();
            var formattedResults = new FormattedResults();

            foreach (DataRow row in dataSet.Tables[0].Rows)
            {
                foreach (var item in row.ItemArray)
                {
                    formattedResults.Add(item.ToString());
                }
            }
            return(formattedResults);
        }
コード例 #8
0
        public FormattedResults GetFormats()
        {
            var cellSet = ExecuteCellSet();
            var formattedResults = new FormattedResults();

            foreach (var cell in cellSet.Cells)
            {
                formattedResults.Add(cell.FormattedValue);
            }
            return formattedResults;
        }
コード例 #9
0
ファイル: QuerySqlEngine.cs プロジェクト: Waltervondehans/NBi
        public FormattedResults GetFormats()
        {
            var dataSet = Execute();
            var formattedResults = new FormattedResults();

            foreach (DataRow row in dataSet.Tables[0].Rows)
            {
                foreach (var item in row.ItemArray)
                    formattedResults.Add(item.ToString());
            }
            return formattedResults;
        }