Пример #1
0
        public void ChangingComparerTest()
        {
            RangeConstraint  test      = new RangeConstraint(5, 42);
            Comparison <int> rComparer = (x, y) => y.CompareTo(x);
            Comparison <int> comparer  = (x, y) => x.CompareTo(y);

            Assert.DoesNotThrow(() => test.ApplyTo(7));
            test.Using(rComparer);
            Assert.Throws <ArgumentException>(() => test.ApplyTo(7));
            Assert.Throws <ArgumentException>(() => test.Using(rComparer).ApplyTo(7));
            Assert.DoesNotThrow(() => test.Using(comparer).ApplyTo(7));
            test.Using(comparer);
            Assert.DoesNotThrow(() => test.ApplyTo(7));
        }
Пример #2
0
        public void RangeConstructorComparerThrowExceptionIfFromIsLessThanTo(object testObj, object from, object to, System.Collections.IComparer comparer)
        {
            RangeConstraint test = new RangeConstraint(from, to);

            test.Using(comparer);
            test.ApplyTo(testObj);
        }