示例#1
0
        public void AssertInvocationCountGeneric()
        {
            Expect.Once.On(this.testInterfaceGeneric).EventAdd("MyEvent");
            Expect.Once.On(this.testInterfaceGeneric).EventRemove("MyEvent");

            using (EventTester <EventArgs> eventHelper = new EventTester <EventArgs>(this.testInterfaceGeneric, "MyEvent"))
            {
                eventHelper.AssertInvocationCount(0);
                Assert.Throws <EventTesterException>(() => eventHelper.AssertInvocationCount(1));

                Fire.On(this.testInterfaceGeneric).Event("MyEvent").With(null, EventArgs.Empty);
                Assert.Throws <EventTesterException>(() => eventHelper.AssertInvocationCount(0));
                eventHelper.AssertInvocationCount(1);
                Assert.Throws <EventTesterException>(() => eventHelper.AssertInvocationCount(2));

                Fire.On(this.testInterfaceGeneric).Event("MyEvent").With(null, EventArgs.Empty);
                Assert.Throws <EventTesterException>(() => eventHelper.AssertInvocationCount(1));
                eventHelper.AssertInvocationCount(2);
                Assert.Throws <EventTesterException>(() => eventHelper.AssertInvocationCount(3));
            }

            this.mockery.VerifyAllExpectationsHaveBeenMet();
        }
示例#2
0
        public void AssertInvocationCountGeneric()
        {
            Expect.Once.On(this.testInterfaceGeneric).EventAdd("MyEvent");
            Expect.Once.On(this.testInterfaceGeneric).EventRemove("MyEvent");

            using (EventTester<EventArgs> eventHelper = new EventTester<EventArgs>(this.testInterfaceGeneric, "MyEvent"))
            {
                eventHelper.AssertInvocationCount(0);
                Assert.Throws<EventTesterException>(() => eventHelper.AssertInvocationCount(1));

                Fire.On(this.testInterfaceGeneric).Event("MyEvent").With(null, EventArgs.Empty);
                Assert.Throws<EventTesterException>(() => eventHelper.AssertInvocationCount(0));
                eventHelper.AssertInvocationCount(1);
                Assert.Throws<EventTesterException>(() => eventHelper.AssertInvocationCount(2));

                Fire.On(this.testInterfaceGeneric).Event("MyEvent").With(null, EventArgs.Empty);
                Assert.Throws<EventTesterException>(() => eventHelper.AssertInvocationCount(1));
                eventHelper.AssertInvocationCount(2);
                Assert.Throws<EventTesterException>(() => eventHelper.AssertInvocationCount(3));
            }

            this.mockery.VerifyAllExpectationsHaveBeenMet();
        }