Ejemplo n.º 1
0
        public void ReturnFalseOnNullLeft()
        {
            Range <int> left  = null;
            var         right = Range <int> .All();

            Assert.False(Range <int> .Equals(left, right));
        }
Ejemplo n.º 2
0
        public static void CreationTest()
        {
            Range range = Range.Create(new Index(10, fromEnd: false), new Index(2, fromEnd: true));

            Assert.Equal(10, range.Start.Value);
            Assert.False(range.Start.FromEnd);
            Assert.Equal(2, range.End.Value);
            Assert.True(range.End.FromEnd);

            range = Range.FromStart(new Index(7, fromEnd: false));
            Assert.Equal(7, range.Start.Value);
            Assert.False(range.Start.FromEnd);
            Assert.Equal(0, range.End.Value);
            Assert.True(range.End.FromEnd);

            range = Range.ToEnd(new Index(3, fromEnd: true));
            Assert.Equal(0, range.Start.Value);
            Assert.False(range.Start.FromEnd);
            Assert.Equal(3, range.End.Value);
            Assert.True(range.End.FromEnd);

            range = Range.All();
            Assert.Equal(0, range.Start.Value);
            Assert.False(range.Start.FromEnd);
            Assert.Equal(0, range.End.Value);
            Assert.True(range.End.FromEnd);
        }
Ejemplo n.º 3
0
        public void ToStringHandlesAllRange()
        {
            var range = Range <int> .All();

            var expected = "(-∞..+∞)";
            var actual   = range.ToString();

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 4
0
        public void InfiniteRangesEqual()
        {
            var a = Range <int> .All();

            var b = Range <int> .All();

            Assert.True(a.Equals(b));
            Assert.True(b.Equals(a));
        }
Ejemplo n.º 5
0
        public void ReturnUnboundedForLowerInfiniteBound()
        {
            var range = Range <int> .All();

            Assert.Equal(BoundType.UNBOUNDED, range.LowerBoundType);
        }
Ejemplo n.º 6
0
        public void HasUpperBoundReturnsFalse()
        {
            var infinite = Range <int> .All();

            Assert.False(infinite.HasUpperEndpoint);
        }
Ejemplo n.º 7
0
        public void ThrowsWhenAccessingUpperBound()
        {
            var infinite = Range <int> .All();

            Assert.Throws <InvalidOperationException>(() => infinite.UpperEndpoint);
        }