private void ApplyUpToOrder(T value, TOrder order)
 {
     Items
     .Where(x =>
            (x is IOrderedEvent <TKey, TOrder> orderedEvent) &&
            CompareUtilities.SmallerOrEqualTo(orderedEvent.Order, order))
     .Apply(value);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DetectionRange"/> class.
        /// </summary>
        /// <param name="low"></param>
        /// <param name="normal"></param>
        /// <param name="high"></param>
        /// <exception cref="ArgumentException">If <see cref=low"/> greater than <see cref="normal"/>.</exception>
        /// <exception cref="ArgumentException">If <see cref="high"/> smaller than <see cref="normal"/>.</exception>
        public ValueRange(TValue low, TValue normal, TValue high)
        {
            if (!CompareUtilities.SmallerOrEqualTo(low, normal))
            {
                throw new ArgumentException($"{nameof(low)} must be smaller or equal to {normal}.", nameof(low));
            }

            if (!CompareUtilities.GreaterOrEqualTo(high, normal))
            {
                throw new ArgumentException($"{nameof(high)} must be smaller or equal to {normal}.", nameof(high));
            }

            Low    = low;
            Normal = normal;
            High   = high;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DetectionRange"/> class.
        /// </summary>
        /// <param name="maxDetectionLow"></param>
        /// <param name="low"></param>
        /// <param name="normal"></param>
        /// <param name="high"></param>
        /// <param name="maxDetectionHigh"></param>
        /// <exception cref="ArgumentException">If <see cref="MaxDetectionLow"/> greater than <see cref="low"/>.</exception>
        /// <exception cref="ArgumentException">If <see cref="MaxDetectionHigh"/> smaller than <see cref="high"/>.</exception>
        public DetectionRange(TValue maxDetectionLow, TValue low, TValue normal, TValue high, TValue maxDetectionHigh)
            : base(low, normal, high)
        {
            if (!CompareUtilities.SmallerOrEqualTo(maxDetectionLow, low))
            {
                throw new ArgumentException($"{nameof(maxDetectionLow)} must be smaller or equal to {low}.", nameof(maxDetectionLow));
            }

            if (!CompareUtilities.GreaterOrEqualTo(maxDetectionHigh, high))
            {
                throw new ArgumentException($"{nameof(maxDetectionHigh)} must be smaller or equal to {high}.", nameof(maxDetectionHigh));
            }

            MaxDetectionLow  = maxDetectionLow;
            MaxDetectionHigh = maxDetectionHigh;
        }
Ejemplo n.º 4
0
 public void SmallerOrEqualTo_When_Double(int value, int compare, bool expected)
 {
     Assert.Equal(expected, CompareUtilities.SmallerOrEqualTo(RangeFactory.ToTestDouble(value), RangeFactory.ToTestDouble(compare)));
 }
Ejemplo n.º 5
0
 public void SmallerOrEqualTo_When_Int(int value, int compare, bool expected)
 {
     Assert.Equal(expected, CompareUtilities.SmallerOrEqualTo(value, compare));
 }
 /// <summary>
 /// Does the <see cref="range"/> equal or exceed the limits of <see cref="compare"/>
 /// Is <see cref="range.From"/> smaller or equal to <see cref="compare.From"/>
 /// 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 Ecapsulates <TValue>(this IRange <TValue> range, IRange <TValue> compare)
     where TValue : IComparable <TValue>
 {
     return(CompareUtilities.SmallerOrEqualTo(range.From, compare.From) && CompareUtilities.GreaterOrEqualTo(range.Till, compare.Till));
 }
 /// <summary>
 /// Is <see cref="value"/> greater or equal to <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 InRange <TValue>(this IRange <TValue> range, TValue value)
     where TValue : IComparable <TValue>
 {
     return(CompareUtilities.SmallerOrEqualTo(range.From, value) && CompareUtilities.GreaterThan(range.Till, value));
 }