Пример #1
0
        public void AssertWasFiredGeneric()
        {
            Expect.Once.On(this.testInterfaceGeneric).EventAdd("MyEvent");
            Expect.Once.On(this.testInterfaceGeneric).EventRemove("MyEvent");

            using (EventTester <EventArgs> eventHelper = new EventTester <EventArgs>(this.testInterfaceGeneric, "MyEvent"))
            {
                // Check if an EventTesterException is thrown if the event has not occurred.
                Assert.Throws <EventTesterException>(eventHelper.AssertWasFired);

                // After the event was fired no exception occurs anymore
                Fire.On(this.testInterfaceGeneric).Event("MyEvent").With(null, EventArgs.Empty);
                eventHelper.AssertWasFired();

                // Another invocation can occur and still no execption is thrown
                Fire.On(this.testInterfaceGeneric).Event("MyEvent").With(null, EventArgs.Empty);
                eventHelper.AssertWasFired();
            }

            this.mockery.VerifyAllExpectationsHaveBeenMet();
        }
Пример #2
0
        public void AssertWasFiredGeneric()
        {
            Expect.Once.On(this.testInterfaceGeneric).EventAdd("MyEvent");
            Expect.Once.On(this.testInterfaceGeneric).EventRemove("MyEvent");

            using (EventTester<EventArgs> eventHelper = new EventTester<EventArgs>(this.testInterfaceGeneric, "MyEvent"))
            {
                // Check if an EventTesterException is thrown if the event has not occurred.
                Assert.Throws<EventTesterException>(eventHelper.AssertWasFired);

                // After the event was fired no exception occurs anymore
                Fire.On(this.testInterfaceGeneric).Event("MyEvent").With(null, EventArgs.Empty);
                eventHelper.AssertWasFired();

                // Another invocation can occur and still no execption is thrown
                Fire.On(this.testInterfaceGeneric).Event("MyEvent").With(null, EventArgs.Empty);
                eventHelper.AssertWasFired();
            }

            this.mockery.VerifyAllExpectationsHaveBeenMet();
        }