Пример #1
0
        /// <include file='Times.xdoc' path='docs/doc[@for="Times.Between"]/*'/>
        public static Times Between(int callCountFrom, int callCountTo, Range rangeKind)
        {
            if (rangeKind == Range.Exclusive)
            {
                Guard.NotOutOfRangeExclusive(callCountFrom, 0, callCountTo, nameof(callCountFrom));
                if (callCountTo - callCountFrom == 1)
                {
                    throw new ArgumentOutOfRangeException("callCountTo");
                }

                return(new Times(
                           c => c > callCountFrom && c < callCountTo,
                           callCountFrom,
                           callCountTo,
                           Resources.NoMatchingCallsBetweenExclusive));
            }

            Guard.NotOutOfRangeInclusive(callCountFrom, 0, callCountTo, nameof(callCountFrom));
            return(new Times(
                       c => c >= callCountFrom && c <= callCountTo,
                       callCountFrom,
                       callCountTo,
                       Resources.NoMatchingCallsBetweenInclusive));
        }
Пример #2
0
        /// <include file='Times.xdoc' path='docs/doc[@for="Times.AtMost"]/*'/>
        public static Times AtMost(int callCount)
        {
            Guard.NotOutOfRangeInclusive(callCount, 0, int.MaxValue, nameof(callCount));

            return(new Times(c => c >= 0 && c <= callCount, 0, callCount, Resources.NoMatchingCallsAtMost));
        }
Пример #3
0
        /// <include file='Times.xdoc' path='docs/doc[@for="Times.AtLeast"]/*'/>
        public static Times AtLeast(int callCount)
        {
            Guard.NotOutOfRangeInclusive(() => callCount, callCount, 1, int.MaxValue);

            return(new Times(c => c >= callCount, callCount, int.MaxValue, Resources.NoMatchingCallsAtLeast));
        }
Пример #4
0
        /// <include file='Times.xdoc' path='docs/doc[@for="Times.Exactly"]/*'/>
        public static Times Exactly(int callCount)
        {
            Guard.NotOutOfRangeInclusive(callCount, 0, int.MaxValue, nameof(callCount));

            return(new Times(c => c == callCount, callCount, callCount, Resources.NoMatchingCallsExactly));
        }
Пример #5
0
        public static Times MultiplyOf(int num)
        {
            Guard.NotOutOfRangeInclusive(() => num, num, 0, int.MaxValue);

            return(new Times(c => (c % num) == 0, num, num, Resources.NoMatchingCallsExactly));
        }