Beispiel #1
0
        public void IsAdjacentTo_AIsAdjacentToAndJustAfterB_ReturnsTrue()
        {
            IInterval <int> a = Interval.Create(20, 25);
            IInterval <int> b = Interval.Create(10, 20);

            var result = a.IsAdjacentTo(b);

            Assert.That(result, Is.True);
        }
Beispiel #2
0
        public void IsAdjacentTo_NullOther_ReturnsFalse()
        {
            IInterval <int> a = Interval.Create(10, 20);
            IInterval <int> b = null;

            var result = a.IsAdjacentTo(b);

            Assert.That(result, Is.False);
        }
Beispiel #3
0
        public void IsAdjacentTo_OverlappingIntervals_ReturnsFalse()
        {
            IInterval <int> a = Interval.Create(10, 20);
            IInterval <int> b = Interval.Create(15, 25);

            var result = a.IsAdjacentTo(b);

            Assert.That(result, Is.False);
        }
Beispiel #4
0
        public void IsAdjacentTo_NullInterval_ReturnsFalse()
        {
            IInterval <int> a = null;
            IInterval <int> b = Interval.Create(15, 25);

            var result = a.IsAdjacentTo(b);

            Assert.That(result, Is.False);
        }
Beispiel #5
0
        public static Interval <T> TryGetUnion <T>([CanBeNull] this IInterval <T> interval, [CanBeNull] IInterval <T> other)
            where T : struct, IComparable <T>
        {
            if (interval == null || other == null)
            {
                return(null);
            }

            if (!interval.IsOverlapping(other) && !interval.IsAdjacentTo(other))
            {
                return(null);
            }

            return(Interval.Create(Min(interval.Start, other.Start), Max(interval.End, other.End)));
        }