예제 #1
0
        public void ReturnsTrueBetweenBounds(bool includeLeft, bool includeRight, double lower, double upper, double between)
        {
            var piece = new PiecewiseFunction.Piece {
                IncludeUpperBound = false, UpperBound = upper
            };

            Assert.IsTrue(piece.Contains(between, lower, includeLeft));
        }
예제 #2
0
        public void ReturnsFalseForExcludedUpperBound(bool includeLeft, double lower, double upper)
        {
            var piece = new PiecewiseFunction.Piece {
                IncludeUpperBound = false, UpperBound = upper
            };

            Assert.IsFalse(piece.Contains(upper, lower, includeLeft));
        }
예제 #3
0
        public void ReturnsFalseForExcludedLowerBound(bool includeRight, double lower, double upper)
        {
            var piece = new PiecewiseFunction.Piece {
                IncludeUpperBound = includeRight, UpperBound = upper
            };

            Assert.IsFalse(piece.Contains(lower, lower, false));
        }
예제 #4
0
        public void ReturnsFalseAboveUpperBound(bool includeLeft, bool includeRight, double lower, double upper, double above)
        {
            var piece = new PiecewiseFunction.Piece {
                IncludeUpperBound = false, UpperBound = upper
            };

            Assert.IsFalse(piece.Contains(above, lower, includeLeft));
        }
예제 #5
0
        public void ReturnsCorrectValueWhenIntersectionExists(bool includeLeft, bool includeRight, double lower, double upper, double value, double yIntersect, double slope, double expected)
        {
            var piece = new PiecewiseFunction.Piece {
                UpperBound = upper, Value = value, IncludeUpperBound = includeRight
            };
            var function = new LinearFunction(slope, yIntersect);

            var intersect = piece.GetIntersect(function, lower, includeLeft);

            Assert.IsTrue(intersect.HasValue);
            Assert.AreEqual(expected, intersect.Value);
        }
예제 #6
0
        public void ReturnsNullWhenNoIntersectionExists(
            bool includeLeft,
            bool includeRight,
            double lower,
            double upper,
            double value,
            double yIntersect,
            double slope)
        {
            var piece = new PiecewiseFunction.Piece {
                UpperBound = upper, Value = value, IncludeUpperBound = includeRight
            };
            var function = new LinearFunction(slope, yIntersect);

            var intersect = piece.GetIntersect(function, lower, includeLeft);

            Assert.IsFalse(intersect.HasValue);
        }