Example #1
0
        [Test] public void HandlesDateTimes()
        {
            int year  = 2009;
            int month = 5;
            int day   = 12;

            int hour   = 4;
            int minute = 14;
            int second = 30;

            DateTime minVal = new DateTime(year, month, day, hour, minute, second);
            DateTime maxVal = new DateTime(year, month, day, hour + 1, minute, second);

            IGenericRange <DateTime> genR = new GenericRange <DateTime>(minVal, maxVal);

            DateTime inRange    = new DateTime(year, month, day, hour, minute + 30, second);
            DateTime equalToMax = new DateTime(year, month, day, hour + 1, minute, second);
            DateTime toLarge    = new DateTime(year, month, day, hour + 1, minute, second + 1);
            DateTime toSmall    = new DateTime(year, month, day, hour, minute, second - 1);

            Assert.That(genR.IncludesValue(inRange));
            Assert.That(genR.IncludesValue(equalToMax));
            Assert.That(!genR.IncludesValue(toLarge));
            Assert.That(!genR.IncludesValue(toSmall));
        }
Example #2
0
        [Test] public void HandlesDoubles()
        {
            double minVal = 2.3;
            double maxVal = 7.8;

            IGenericRange <double> genR = new GenericRange <double>(minVal, maxVal);

            Assert.That(genR.MinValue, Is.EqualTo(minVal));
            Assert.That(genR.MaxValue, Is.EqualTo(maxVal));

            double inRange    = 4.5;
            double equalToMax = maxVal;
            double toLarge    = maxVal * 2.0;
            double toSmall    = minVal / 2.0;

            Assert.That(genR.IncludesValue(inRange));
            Assert.That(genR.IncludesValue(equalToMax));
            Assert.That(!genR.IncludesValue(toLarge));
            Assert.That(!genR.IncludesValue(toSmall));
        }
Example #3
0
 public static bool IsIn <T>(this T value, GenericRange <T> range) where T : IComparable
 {
     return(range.IncludesValue(value));
 }