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); }
/// <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); }
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)) ); }
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))); }
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); }