Beispiel #1
0
        public void UsingdoOnMethodWithGenericReturnValue()
        {
            MockRepository          mocks         = new MockRepository();
            IGenericType <object>   mock          = mocks.StrictMock <IGenericType <object> >();
            IMethodOptions <object> methodOptions = Expect.Call(mock.MyMethod());

            methodOptions.Do((MyDelegate) delegate { return(new object()); });
        }
        public void TestExpectCallWithNonGenericDelegate()
        {
            MockRepository       mocks     = new MockRepository();
            ICache <string, int> mockCache = mocks.StrictMock <ICache <string, int> >();
            IMethodOptions <int> opts      = Expect.Call(mockCache.GetValue("a"));

            opts.Do(new StringInt(GetValue));
            mocks.ReplayAll();

            int i = mockCache.GetValue("a");

            Assert.Equal(2, i);

            mocks.VerifyAll();
        }
        public static IMethodOptions <Task> DoAsyncVoid(this IMethodOptions <Task> methodOptions,
                                                        Action action,
                                                        TimeSpan?delayBeforeYourAction = null)
        {
            Func <Task> executor = async() =>
            {
                if (delayBeforeYourAction != null)
                {
                    await Task.Delay(delayBeforeYourAction.Value);
                }
                action();
            };

            return(methodOptions.Do(executor));
        }
        public static IMethodOptions <Task <TReturnType> > DoAsync <TReturnType>(
            this IMethodOptions <Task <TReturnType> > methodOptions,
            Func <TReturnType> action,
            TimeSpan?delayBeforeYourAction = null)
        {
            Func <Task <TReturnType> > executor = async() =>
            {
                if (delayBeforeYourAction != null)
                {
                    await Task.Delay(delayBeforeYourAction.Value);
                }
                return(action());
            };

            return(methodOptions.Do(executor));
        }
Beispiel #5
0
 public static IMethodOptions <Rhino.Mocks.RhinoMocksExtensions.VoidType> Do(
     this IMethodOptions <Rhino.Mocks.RhinoMocksExtensions.VoidType> expectation, Action action)
 {
     return(expectation.Do(action));
 }
 /// <summary>
 /// Perform an action when a method invocation is matched.
 /// </summary>
 public static IMethodOptions <TResult> Do <T1, T2, TResult>(this IMethodOptions <TResult> options, Func <T1, T2, TResult> action)
 {
     return(options.Do((Delegate)action));
 }
 /// <summary>
 /// Allows a method to be stubbed with a supplied action.
 /// </summary>
 /// <remarks>This method is the same as Do but does not require IgnoreArguments() to be specified.</remarks>
 public static IMethodOptions <object> Do <T1>(this IMethodOptions <object> options, Action <T1> action)
 {
     return(options.Do(action));
 }
 /// <summary>
 /// Perform an action when a method invocation is matched.
 /// </summary>
 public static IMethodOptions <object> Do(this IMethodOptions <object> options, Action action)
 {
     return(options.Do((Delegate)action));
 }
Beispiel #9
0
 public IMethodOptions <T> Action(Action action)
 {
     return(m_methodOptions.Do(action));
 }