Example #1
0
        public void TestIntersect()
        {
            var range1         = Range.Of(0, 9);
            var range2         = Range.Of(0, 2);
            var intersectRange = range1.Intersect(range2);

            Assert.Equal(0, intersectRange.Start);
            Assert.Equal(2, intersectRange.End);

            range2         = Range.Of(10, 20);
            intersectRange = range1.Intersect(range2);
            Assert.Null(intersectRange);

            range2         = Range.Of(-10, -1);
            intersectRange = range1.Intersect(range2);
            Assert.Null(intersectRange);

            range2         = Range.Of(-5, 5);
            intersectRange = range1.Intersect(range2);
            Assert.Equal(0, intersectRange.Start);
            Assert.Equal(5, intersectRange.End);

            range2         = Range.Of(5, 15);
            intersectRange = range1.Intersect(range2);
            Assert.Equal(5, intersectRange.Start);
            Assert.Equal(9, intersectRange.End);
        }
Example #2
0
        public void TestInvalid()
        {
            var ex = Assert.Throws <ArgumentException>(() => Range.Of(0, -5));

            _output.WriteLine(ex.Message);
            Assert.True(ex.Message.Equals("Range end must >= range start."));
        }
Example #3
0
        public void TestOf()
        {
            var range = Range.Of(0, 3);

            Assert.Equal(0, range.Start);
            Assert.Equal(3, range.End);
        }