Example #1
0
        /// <summary>
        /// Provides support for ordered Rhino.Mocks expectations without dedicated <see cref="MockRepository"/> instance. Create an
        /// <see cref="OrderedExpectationCounter"/>, then call this method with that counter for all expectations that should occur
        /// in the same order as declared.
        /// Use this method rather then <see cref="Ordered{T}"/> when you need to specify your own <see cref="IMethodOptions{T}.WhenCalled"/> handler.
        /// </summary>
        public static IMethodOptions <T> WhenCalledOrdered <T> (
            this IMethodOptions <T> options,
            OrderedExpectationCounter counter,
            Action <MethodInvocation> whenCalledAction,
            string message = null)
        {
            var expectedPosition = counter.GetNextExpectedPosition();

            return(options.WhenCalled(
                       mi =>
            {
                counter.CheckPosition(mi.Method.ToString(), expectedPosition, message);
                whenCalledAction(mi);
            }));
        }
Example #2
0
 /// <summary>
 /// Provides support for ordered Rhino.Mocks expectations without dedicated <see cref="MockRepository"/> instance. Create an
 /// <see cref="OrderedExpectationCounter"/>, then call this method with that counter for all expectations that should occur
 /// in the same order as declared.
 /// Uses <see cref="IMethodOptions{T}.WhenCalled"/> internally; use <see cref="WhenCalledOrdered{T}"/> when you need to specify your own
 /// <see cref="IMethodOptions{T}.WhenCalled"/> handler.
 /// </summary>
 public static IMethodOptions <T> Ordered <T> (this IMethodOptions <T> options, OrderedExpectationCounter counter, string message = null)
 {
     return(WhenCalledOrdered(options, counter, mi => { }, message));
 }