Exemplo n.º 1
0
        public void AddEventHandler2()
        {
            tlog.Debug(tag, $"AddEventHandler START");

            var testingTarget = new WeakEventManager();

            Assert.IsNotNull(testingTarget, "Can't create success object WeakEventManager.");
            visibilityChangedEventHandler = (o, e) => { };
            Assert.Throws <ArgumentNullException> (() => testingTarget.AddEventHandler <VisibilityChangedEventArgs>(null, visibilityChangedEventHandler));
            Assert.Throws <ArgumentNullException>(() => testingTarget.AddEventHandler <VisibilityChangedEventArgs>("visibilityChangedEventHandler", null));
            eventHandler = (o, e) => { };
            Assert.Throws <ArgumentNullException>(() => testingTarget.AddEventHandler(null, eventHandler));
            Assert.Throws <ArgumentNullException>(() => testingTarget.AddEventHandler("eventHandler", null));

            tlog.Debug(tag, $"AddEventHandler END");
        }
Exemplo n.º 2
0
        public void HandleEvent()
        {
            tlog.Debug(tag, $"HandleEvent START");
            try
            {
                var testingTarget = new WeakEventManager();
                Assert.IsNotNull(testingTarget, "Can't create success object WeakEventManager.");
                visibilityChangedEventHandler = (o, e) => { };
                testingTarget.AddEventHandler <VisibilityChangedEventArgs>("visibilityChangedEventHandler", visibilityChangedEventHandler);
                eventHandler = (o, e) => { };
                testingTarget.AddEventHandler("eventHandler", eventHandler);
                testingTarget.HandleEvent(null, new EventArgs(), "eventHandler");
                testingTarget.HandleEvent(null, new VisibilityChangedEventArgs(), "visibilityChangedEventHandler");
            }
            catch (Exception e)
            {
                Assert.Fail("Catch exception: " + e.Message.ToString());
            }

            tlog.Debug(tag, $"HandleEvent END");
        }
        public void AddHandlerWithNullEventNameThrowsException()
        {
            var wem = new WeakEventManager();

            Assert.Throws <ArgumentNullException>(() => wem.AddEventHandler((sender, args) => { }, null));
        }
        public void AddHandlerWithNullEventHandlerThrowsException()
        {
            var wem = new WeakEventManager();

            Assert.Throws <ArgumentNullException>(() => wem.AddEventHandler(null, "test"));
        }
Exemplo n.º 5
0
 public void AddHandler(INotifyPropertyChanged source, string eventName, EventHandler <PropertyChangedEventArgs> handler)
 {
     weakEventManager.AddEventHandler(handler, eventName);
 }
        public void AddHandlerWithNullEventNameThrowsException()
        {
            var wem = new WeakEventManager();

            wem.AddEventHandler((sender, args) => { }, null);
        }
        public void AddHandlerWithNullEventHandlerThrowsException()
        {
            var wem = new WeakEventManager();

            wem.AddEventHandler(null, "test");
        }