public void TrackInvocationCountImplementedCorrectlyForAction04( ) { var callCount = 0; DelegateInvocationCounter <Action <String, String, String, String> > counter = DelegateHelpers.TrackInvocationCount <String, String, String, String> ((arg1, arg2, arg3, arg4) => { callCount++; Assert.AreEqual("arg1", arg1); Assert.AreEqual("arg2", arg2); Assert.AreEqual("arg3", arg3); Assert.AreEqual("arg4", arg4); }); for (var i = 1; i < 6; i++) { counter.WrappedDelegate("arg1", "arg2", "arg3", "arg4"); Assert.AreEqual(i, counter.InvocationCount); Assert.AreEqual(i, callCount); } counter.Reset( ); Assert.AreEqual(0, counter.InvocationCount); }
public void TrackInvocationCountImplementedCorrectlyForFunc06( ) { var callCount = 0; DelegateInvocationCounter <Func <String, String, String, String, String, String, Int32> > counter = DelegateHelpers.TrackInvocationCount <String, String, String, String, String, String, Int32> ((arg1, arg2, arg3, arg4, arg5, arg6) => { callCount++; Assert.AreEqual("arg1", arg1); Assert.AreEqual("arg2", arg2); Assert.AreEqual("arg3", arg3); Assert.AreEqual("arg4", arg4); Assert.AreEqual("arg5", arg5); Assert.AreEqual("arg6", arg6); return(12 + callCount); }); for (var i = 1; i < 6; i++) { var ret = counter.WrappedDelegate("arg1", "arg2", "arg3", "arg4", "arg5", "arg6"); Assert.AreEqual(i, counter.InvocationCount); Assert.AreEqual(i, callCount); Assert.AreEqual(12 + i, ret); } }