Exemplo n.º 1
0
        public void TestTriggerActionInvoked()
        {
            var bindable      = new MockBindableWithEvent();
            var triggeraction = new MockTriggerAction();
            var eventtrigger  = new EventTrigger()
            {
                Event = "MockEvent", Actions = { triggeraction }
            };
            var collection = bindable.Triggers;

            collection.Add(eventtrigger);

            Assert.False(triggeraction.Invoked);
            bindable.FireEvent();
            Assert.True(triggeraction.Invoked);
        }
Exemplo n.º 2
0
        public void TestChangeEventOnEventTrigger()
        {
            var bindable      = new MockBindableWithEvent();
            var triggeraction = new MockTriggerAction();
            var eventtrigger  = new EventTrigger {
                Event = "MockEvent", Actions = { triggeraction }
            };
            var collection = bindable.Triggers;

            collection.Add(eventtrigger);

            triggeraction.Invoked = false;
            Assert.False(triggeraction.Invoked);
            bindable.FireEvent();
            Assert.True(triggeraction.Invoked);

            triggeraction.Invoked = false;
            Assert.False(triggeraction.Invoked);
            bindable.FireEvent2();
            Assert.False(triggeraction.Invoked);

            Assert.Throws <InvalidOperationException>(() => eventtrigger.Event = "MockEvent2");
        }