internal static Anomaly Validate <TValue>(this IDetectionRange <TValue> range, TValue value) where TValue : IComparable <TValue> { if (CompareUtilities.GreaterThan(value, range.MaxDetectionHigh)) { return(Anomaly.High); } if (CompareUtilities.SmallerThan(value, range.MaxDetectionLow)) { return(Anomaly.Low); } return(Anomaly.None); }
public void SmallerThan_When_DateTimeOffset(int value, int compare, bool expected) { Assert.Equal(expected, CompareUtilities.SmallerThan(RangeFactory.ToTestDateTimeOffset(value), RangeFactory.ToTestDateTimeOffset(compare))); }
public void SmallerThan_When_Int(int value, int compare, bool expected) { Assert.Equal(expected, CompareUtilities.SmallerThan(value, compare)); }
/// <summary> /// Do the ranges overlap. /// Is <see cref="range.From"/> smaller than <see cref="compare.Till"/> /// And <see cref="range.Till"/> greater than <see cref="compare.From"/> /// </summary> /// <typeparam name="TValue"></typeparam> /// <param name="range"></param> /// <param name="compare"></param> /// <returns></returns> public static bool OverLaps <TValue>(this IRange <TValue> range, IRange <TValue> compare) where TValue : IComparable <TValue> { return(CompareUtilities.SmallerThan(range.From, compare.Till) && CompareUtilities.GreaterThan(range.Till, compare.From)); }
/// <summary> /// Is <see cref="value"/> greater than <see cref="IRange{TValue}.From"/> and smaller than <see cref="IRange{TValue}.Till"/> /// </summary> /// <typeparam name="TValue"></typeparam> /// <param name="range"></param> /// <param name="value"></param> /// <returns></returns> public static bool InBetween <TValue>(this IRange <TValue> range, TValue value) where TValue : IComparable <TValue> { return(CompareUtilities.SmallerThan(range.From, value) && CompareUtilities.GreaterThan(range.Till, value)); }
/// <summary> /// Does the <see cref="range"/> equal or exceed the limits of <see cref="compare.Till"/> /// Is <see cref="range.From"/> smaller than <see cref="compare.Till"/> /// Is <see cref="range.Till"/> greater or equal to <see cref="compare.Till"/> /// </summary> /// <typeparam name="TValue"></typeparam> /// <param name="range"></param> /// <param name="compare"></param> /// <returns></returns> public static bool EcapsulatesTill <TValue>(this IRange <TValue> range, IRange <TValue> compare) where TValue : IComparable <TValue> { return(CompareUtilities.SmallerThan(range.From, compare.Till) && CompareUtilities.GreaterOrEqualTo(range.Till, compare.Till)); }