コード例 #1
0
        public void ShouldThrowExceptionIfFromIsLessThanTo()
        {
            var comparer = new MyComparer <int>();

            rangeConstraint = new RangeConstraint <int>(42, 5);
            rangeConstraint.Using(comparer).Matches(19);
        }
コード例 #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);
        }
コード例 #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>";
        }
コード例 #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));
        }
コード例 #5
0
 public void SetUp()
 {
     TheConstraint        = rangeConstraint = new RangeConstraint(5, 42);
     ExpectedDescription  = "in range (5,42)";
     StringRepresentation = "<range 5 42>";
 }