protected override void SetUp()
 {
     Matcher = new LessThanOrEqualConstraint(5);
     GoodValues = new object[] { 4 , 5 };
     BadValues = new object[] { 6 };
     Description = "less than or equal to 5";
 }
        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;
        }
        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);
        }
 public void SetUp()
 {
     TheConstraint        = ComparisonConstraint = new LessThanOrEqualConstraint(5);
     ExpectedDescription  = "less than or equal to 5";
     StringRepresentation = "<lessthanorequal 5>";
 }
 public void SetUp()
 {
     theConstraint = comparisonConstraint = new LessThanOrEqualConstraint(5);
     expectedDescription = "less than or equal to 5";
     stringRepresentation = "<lessthanorequal 5>";
 }
Beispiel #6
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);
        }