Example #1
0
        public void EventNameSet_IncompatibleEventSignatureWithSetSourceObject_ThrowsArgumentException()
        {
            EventObjectStub eventSource  = CreateEventObjectStub();
            EventTrigger    eventTrigger = CreateEventTrigger();

            AttachTriggerToObject(eventTrigger, eventSource);
            eventTrigger.SourceObject = eventSource;
            eventTrigger.EventName    = "IntEvent";
        }
Example #2
0
        public void EventNameSet_IncompatibleEventSignatureWithNoSourceObject_DoesNothing()
        {
            EventTrigger    eventTrigger = CreateEventTrigger();
            EventObjectStub eventStub    = CreateEventObjectStub();

            AttachTriggerToObject(eventTrigger, eventStub);
            eventTrigger.EventName = "IntEvent";
            // With no source object set, non-existant event did not throw.
        }
Example #3
0
        public void EventFired_SimpleEvent_Fires()
        {
            EventTrigger    eventTrigger = CreateEventTrigger("StubEvent");
            EventObjectStub eventStub    = CreateEventObjectStub();
            StubAction      eventAction  = AttachTriggerToObject(eventTrigger, eventStub);

            eventStub.FireStubEvent();
            Assert.AreEqual(eventAction.InvokeCount, 1, "Action was invoked in response to event.");
        }
Example #4
0
        public void EventNameSet_NonExistantEventWithSetSourceObject_ThrowsArgumentException()
        {
            EventObjectStub eventSource  = CreateEventObjectStub();
            EventTrigger    eventTrigger = CreateEventTrigger();

            AttachTriggerToObject(eventTrigger, eventSource);

            eventTrigger.SourceObject = eventSource;
            eventTrigger.EventName    = "FooEvent";
        }
Example #5
0
        public void SourceObjectEventFired_EventNameMatchesFiredEvent_Fires()
        {
            Button          host         = CreateButton();
            EventObjectStub eventSource  = CreateEventObjectStub();
            EventTrigger    eventTrigger = CreateEventTrigger("StubEvent");
            StubAction      action       = AttachTriggerToObject(eventTrigger, host);

            eventTrigger.SourceObject = eventSource;
            eventSource.FireStubEvent();

            Assert.AreEqual(action.InvokeCount, 1, "Trigger should be invoked when source object fires the event it is listening to.");
        }
Example #6
0
        public void EventFired_OldEventFiredAfterEventNameChanged_DoesNotFires()
        {
            Button          host         = CreateButton();
            EventObjectStub eventSource  = CreateEventObjectStub();
            EventTrigger    eventTrigger = CreateEventTrigger("StubEvent");
            StubAction      action       = AttachTriggerToObject(eventTrigger, host);

            eventTrigger.SourceObject = eventSource;
            eventTrigger.EventName    = "StubEvent2";
            eventSource.FireStubEvent();

            Assert.AreEqual(action.InvokeCount, 0, "Trigger should not be invoked when source object fires its event it is not listening to.");
        }
Example #7
0
        public void EventFired_OldSourceObjectFiresEvent_DoesNotFire()
        {
            Button          host           = CreateButton();
            EventObjectStub oldEventSource = CreateEventObjectStub();
            EventObjectStub newEventSource = CreateEventObjectStub();
            EventTrigger    eventTrigger   = CreateEventTrigger("StubEvent");
            StubAction      action         = AttachTriggerToObject(eventTrigger, host);

            eventTrigger.SourceObject = oldEventSource;
            eventTrigger.SourceObject = newEventSource;
            oldEventSource.FireStubEvent();

            Assert.AreEqual(action.InvokeCount, 0, "Trigger should not be invoked when an old source object fires the event it is listening to.");
        }