示例#1
0
        public void TrackInvocationCountImplementedCorrectlyForAction16( )
        {
            var callCount = 0;
            DelegateInvocationCounter <Action <String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String> > counter = DelegateHelpers.TrackInvocationCount <String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String> ((arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16) =>
            {
                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);
                Assert.AreEqual("arg7", arg7);
                Assert.AreEqual("arg8", arg8);
                Assert.AreEqual("arg9", arg9);
                Assert.AreEqual("arg10", arg10);
                Assert.AreEqual("arg11", arg11);
                Assert.AreEqual("arg12", arg12);
                Assert.AreEqual("arg13", arg13);
                Assert.AreEqual("arg14", arg14);
                Assert.AreEqual("arg15", arg15);
                Assert.AreEqual("arg16", arg16);
            });

            for (var i = 1; i < 6; i++)
            {
                counter.WrappedDelegate("arg1", "arg2", "arg3", "arg4", "arg5", "arg6", "arg7", "arg8", "arg9", "arg10", "arg11", "arg12", "arg13", "arg14", "arg15", "arg16");

                Assert.AreEqual(i, counter.InvocationCount);
                Assert.AreEqual(i, callCount);
            }

            counter.Reset( );
            Assert.AreEqual(0, counter.InvocationCount);
        }
示例#2
0
        public void TrackInvocationCountImplementedCorrectlyForAction( )
        {
            var callCount = 0;
            DelegateInvocationCounter <Action> counter = DelegateHelpers.TrackInvocationCount(() =>
            {
                callCount++;
            });

            for (var i = 1; i < 6; i++)
            {
                counter.WrappedDelegate( );

                Assert.AreEqual(i, counter.InvocationCount);
                Assert.AreEqual(i, callCount);
            }

            counter.Reset( );
            Assert.AreEqual(0, counter.InvocationCount);
        }
示例#3
0
        public void TrackInvocationCountImplementedCorrectlyForAction01( )
        {
            var callCount = 0;
            DelegateInvocationCounter <Action <String> > counter = DelegateHelpers.TrackInvocationCount <String> ((arg1) =>
            {
                callCount++;
                Assert.AreEqual("arg1", arg1);
            });

            for (var i = 1; i < 6; i++)
            {
                counter.WrappedDelegate("arg1");

                Assert.AreEqual(i, counter.InvocationCount);
                Assert.AreEqual(i, callCount);
            }

            counter.Reset( );
            Assert.AreEqual(0, counter.InvocationCount);
        }