Example #1
0
        protected override IExpectation GetExpectation(MethodInfo m, Range r, int actual)
        {
            CallbackExpectation expectation = new CallbackExpectation(new FakeInvocation(m), new DelegateDefinations.NoArgsDelegate(VoidNoArgs), new Range(1, 1));

            SetupExpectation(expectation, r, actual);
            return(expectation);
        }
Example #2
0
        /// <summary>
        /// Set a callback method for the last call
        /// </summary>
        public IMethodOptions <T> Callback(Delegate callback)
        {
            CallbackExpectation callbackExpectation = new CallbackExpectation(expectation, callback);

            ReplaceExpectation(callbackExpectation);
            return(this);
        }
Example #3
0
 public void ExceptionWhenArgsDontMatch()
 {
     Assert.Throws <InvalidOperationException>("Callback arguments didn't match the method arguments",
                                               () =>
                                               callback =
                                                   new CallbackExpectation(new FakeInvocation(method),
                                                                           new DelegateDefinations.NoArgsDelegate(VoidNoArgs),
                                                                           new Range(1, 1))
                                               );
 }
Example #4
0
 public void CallBackWithDifferentSignature()
 {
     Assert.Throws <InvalidOperationException>(
         "Callback arguments didn't match the method arguments",
         () =>
         callback = new CallbackExpectation(
             new FakeInvocation(method),
             new DelegateDefinations.IntArgDelegate(OneArg),
             new Range(1, 1)));
 }
Example #5
0
 public void CallMethodWhenTestIsExpected()
 {
     callback = new CallbackExpectation(new FakeInvocation(method), new DelegateDefinations.ThreeArgsDelegate(ThreeArgsDelegateMethod), new Range(1, 1));
     callback.IsExpected(new object[] { 1, "", 3.3f });
     Assert.True(callbackCalled);
 }