コード例 #1
0
        public void Matches_SqlCommand_CallToResultSetBuilderOnce()
        {
            var resultSet = new ResultSet();

            resultSet.Load("a;b;c");
            var cmd = new SqlCommand();

            var rsbMock = new Mock <ResultSetBuilder>();

            rsbMock.Setup(engine => engine.Build(It.IsAny <object>()))
            .Returns(resultSet);
            var rsb = rsbMock.Object;

            var child = new NUnitCtr.GreaterThanConstraint(0);

            var rowCount = new RowCountConstraint(child)
            {
                ResultSetBuilder = rsb
            };

            rowCount.ResultSetBuilder = rsb;

            //Method under test
            rowCount.Matches(cmd);

            //Test conclusion
            rsbMock.Verify(engine => engine.Build(It.IsAny <object>()), Times.Once());
        }
コード例 #2
0
 protected override void SetUp()
 {
     Matcher = new GreaterThanConstraint(5);
     GoodValues = new object[] { 6 };
     BadValues = new object[] { 4, 5 };
     Description = "greater than 5";
 }
コード例 #3
0
        protected virtual NUnitCtr.Constraint BuildChildConstraint(AbstractComparerXml xml)
        {
            NUnitCtr.Constraint ctr = null;
            if (xml is LessThanXml)
            {
                if (((LessThanXml)xml).OrEqual)
                    ctr = new NUnitCtr.LessThanOrEqualConstraint(xml.Value);
                else
                    ctr = new NUnitCtr.LessThanConstraint(xml.Value);
            }
            else if (xml is MoreThanXml)
            {
                if (((MoreThanXml)xml).OrEqual)
                    ctr = new NUnitCtr.GreaterThanOrEqualConstraint(xml.Value);
                else
                    ctr = new NUnitCtr.GreaterThanConstraint(xml.Value);
            }
            else if (xml is EqualXml)
            {
                ctr = new NUnitCtr.EqualConstraint(xml.Value);
            }

            if (ctr == null)
                throw new ArgumentException();

            return ctr;
        }
コード例 #4
0
ファイル: CountConstraint.cs プロジェクト: ywscr/NBi
        protected override NUnitCtr.Constraint BuildInternalConstraint()
        {
            NUnitCtr.Constraint ctr = null;

            if (exactly.HasValue)
            {
                if (ctr != null)
                {
                    ctr = ctr.And.EqualTo(exactly.Value);
                }
                else
                {
                    ctr = new NUnitCtr.EqualConstraint(exactly.Value);
                }
            }

            if (moreThan.HasValue)
            {
                if (ctr != null)
                {
                    ctr = ctr.And.GreaterThan(moreThan.Value);
                }
                else
                {
                    ctr = new NUnitCtr.GreaterThanConstraint(moreThan.Value);
                }
            }

            if (lessThan.HasValue)
            {
                if (ctr != null)
                {
                    ctr = ctr.And.LessThan(lessThan.Value);
                }
                else
                {
                    ctr = new NUnitCtr.LessThanConstraint(lessThan.Value);
                }
            }

            return(ctr);
        }
コード例 #5
0
        protected virtual NUnitCtr.Constraint BuildChildConstraint(AbstractComparerXml xml)
        {
            NUnitCtr.Constraint ctr = null;
            if (xml is LessThanXml)
            {
                if (((LessThanXml)xml).OrEqual)
                {
                    ctr = new NUnitCtr.LessThanOrEqualConstraint(xml.Value);
                }
                else
                {
                    ctr = new NUnitCtr.LessThanConstraint(xml.Value);
                }
            }
            else if (xml is MoreThanXml)
            {
                if (((MoreThanXml)xml).OrEqual)
                {
                    ctr = new NUnitCtr.GreaterThanOrEqualConstraint(xml.Value);
                }
                else
                {
                    ctr = new NUnitCtr.GreaterThanConstraint(xml.Value);
                }
            }
            else if (xml is EqualXml)
            {
                ctr = new NUnitCtr.EqualConstraint(xml.Value);
            }

            if (ctr == null)
            {
                throw new ArgumentException();
            }

            return(ctr);
        }
コード例 #6
0
 public void SetUp()
 {
     theConstraint        = comparisonConstraint = new GreaterThanConstraint(5);
     expectedDescription  = "greater than 5";
     stringRepresentation = "<greaterthan 5>";
 }
コード例 #7
0
ファイル: CountConstraint.cs プロジェクト: zyh329/nbi
        protected override NUnitCtr.Constraint BuildInternalConstraint()
        {
            NUnitCtr.Constraint ctr = null;

            if (exactly.HasValue)
            {
                if (ctr != null)
                    ctr = ctr.And.EqualTo(exactly.Value);
                else
                    ctr = new NUnitCtr.EqualConstraint(exactly.Value);
            }

            if (moreThan.HasValue)
            {
                if (ctr != null)
                    ctr = ctr.And.GreaterThan(moreThan.Value);
                else
                    ctr = new NUnitCtr.GreaterThanConstraint(moreThan.Value);
            }

            if (lessThan.HasValue)
            {
                if (ctr != null)
                    ctr = ctr.And.LessThan(lessThan.Value);
                else
                    ctr = new NUnitCtr.LessThanConstraint(lessThan.Value);
            }

            return ctr;
        }
コード例 #8
0
 public void SetUp()
 {
     theConstraint = comparisonConstraint = new GreaterThanConstraint(5);
     expectedDescription = "greater than 5";
     stringRepresentation = "<greaterthan 5>";
 }
コード例 #9
0
        protected virtual NUnitCtr.Constraint BuildChildConstraint(AbstractComparerXml xml)
        {
            var value = xml.Value.Replace(" ", "");

            object numericValue;

            try
            {
                if (value.EndsWith("%"))
                {
                    numericValue = Decimal.Parse(xml.Value.Substring(0, xml.Value.Length - 1)) / new Decimal(100);
                }
                else
                {
                    numericValue = Int32.Parse(xml.Value);
                }
            }
            catch (Exception ex)
            {
                var exception = new ArgumentException
                                (
                    String.Format("The assertion row-count is expecting an integer or percentage value for comparison. The provided value '{0}' is not a integer or percentage value.", value)
                    , ex
                                );
                throw exception;
            }


            NUnitCtr.Constraint ctr = null;
            if (xml is LessThanXml)
            {
                if (((LessThanXml)xml).OrEqual)
                {
                    ctr = new NUnitCtr.LessThanOrEqualConstraint(numericValue);
                }
                else
                {
                    ctr = new NUnitCtr.LessThanConstraint(numericValue);
                }
            }
            else if (xml is MoreThanXml)
            {
                if (((MoreThanXml)xml).OrEqual)
                {
                    ctr = new NUnitCtr.GreaterThanOrEqualConstraint(numericValue);
                }
                else
                {
                    ctr = new NUnitCtr.GreaterThanConstraint(numericValue);
                }
            }
            else if (xml is EqualXml)
            {
                ctr = new NUnitCtr.EqualConstraint(numericValue);
            }

            if (ctr == null)
            {
                throw new ArgumentException();
            }

            return(ctr);
        }