예제 #1
0
 public void InterceptNotifyException()
 {
     var hlp = new Helpers.EventProviderProxy();
     using (var ep = new EventProvider(hlp))
     {
         var e = Helpers.GetTestEventsNames();
         Exception tesEx = null;
         EvntHandler ehp = (sender, evName, args) => { throw Helpers.GetTestException(); };
         ep.ListenEvent(hlp, ehp, e[0]);
         Assert.IsFalse(ep.TryNotifyEvent(e[0], out tesEx), "Ошибка логики вызова событий");
         throw tesEx;
     }
 }
예제 #2
0
 public void ThrowNotifyExceptionTest()
 {
     var hlp = new Helpers.EventProviderProxy();
     using (var ep = new EventProvider(hlp))
     {
         var e = Helpers.GetTestEventsNames();
         var testEx = Helpers.GetTestException();
         EvntHandler ehp = (sender, evName, args) => { throw Helpers.GetTestException(); };
         ep.ListenEvent(hlp, ehp, e[0]);
         ep.NotifyEvent(e[0]);
     }
 }
예제 #3
0
 public void OneBindingUnlistenEvent()
 {
     var hlp = new Helpers.EventProviderProxy();
     using (var ep = new EventProvider(hlp))
     {
         var e = Helpers.GetTestEventsNames();
         int cntCalls = e.Length;
         EvntHandler ehp = (sender, evName, args) => cntCalls-- > int.MinValue;
         for (int i = 0; i < cntCalls; i++)
             ep.ListenEvent(hlp, ehp, e[0]);
         ep.UnlistenEvent(hlp, ehp, e[0]);
         ep.NotifyEvent(e[0]);
         Assert.IsTrue(cntCalls == 1, "Ошибка логики привязки/вызова событий");
     }
 }
예제 #4
0
        public void DettachObjectTest()
        {
            var hlp = new Helpers.EventProviderProxy();
            using (var ep = new EventProvider(hlp))
            {
                var e = Helpers.GetTestEventsNames();
                int cntCalls = 0;
                EvntHandler ehp = (sender, evName, args) => cntCalls-- > int.MinValue;

                foreach (var item in e)
                    ep.ListenEvent(hlp, ehp, item);
                ep.ListenEvent(hlp, ehp, e[0]);

                ep.DettachObject(hlp);

                foreach (var item in e)
                    ep.NotifyEvent(item);
                ep.NotifyEvent(e[0]);

                Assert.IsTrue(cntCalls == 0, "Ошибка логики привязки событий");
            }
        }
예제 #5
0
 public void BindingListenEvent()
 {
     var hlp = new Helpers.EventProviderProxy();
     using (var ep = new EventProvider(hlp))
     {
         var e = Helpers.GetTestEventsNames();
         var e1 = e.ToList();
         int cntCalls = e.Length;
         EvntHandler ehp = (sender, evName, args) => e1.Remove(evName) && cntCalls-- > int.MinValue;
         foreach (var item in e)
             ep.ListenEvent(hlp, ehp, item);
         foreach (var item in e)
             ep.NotifyEvent(item);
         Assert.IsTrue(cntCalls == 0, "Ошибка логики привязки/вызова событий");
     }
 }