Example #1
0
        public void ShouldThrowExceptionIfFromIsLessThanTo()
        {
            var comparer = new MyComparer <int>();

            rangeConstraint = new RangeConstraint <int>(42, 5);
            rangeConstraint.Using(comparer).Matches(19);
        }
Example #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);
        }
Example #3
0
        public void SetUp()
        {
#if CLR_2_0 || CLR_4_0
            theConstraint = rangeConstraint = new RangeConstraint <int>(5, 42);
#else
            theConstraint = rangeConstraint = new RangeConstraint(5, 42);
#endif
            expectedDescription  = "in range (5,42)";
            stringRepresentation = "<range 5 42>";
        }
Example #4
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));
        }
Example #5
0
 public void SetUp()
 {
     TheConstraint        = rangeConstraint = new RangeConstraint(5, 42);
     ExpectedDescription  = "in range (5,42)";
     StringRepresentation = "<range 5 42>";
 }