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)); }
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)); }
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)); }
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)); }
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); }
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); }