Пример #1
0
        public void SubscribeToAll_FireEvent1()
        {
            EventSubscriber subscriber = new EventSubscriber();
            IPublisherService proxy = DuplexChannelFactory<IPublisherService, IPublisherEvents>
                 .CreateChannel(subscriber, new NetNamedPipeBinding(), new EndpointAddress(address));

            // Subscribe to All, but only fire Event1
            proxy.Subscribe(EventType.AllEvents);
            proxy.FireEvents(EventType.Event1);

            Assert.AreEqual(EventType.Event1, (subscriber.EventFired & EventType.Event1));
            Assert.AreEqual(default(int), subscriber.Number);
            Assert.AreEqual(default(string), subscriber.Text);

            CloseProxy(proxy);
        }
Пример #2
0
        public void SubscribeToAll_FireAll()
        {
            EventSubscriber subscriber = new EventSubscriber();
            IPublisherService proxy = DuplexChannelFactory<IPublisherService, IPublisherEvents>
                 .CreateChannel(subscriber, new NetNamedPipeBinding(), new EndpointAddress(address));

            // Subscribe to All, Fire All
            proxy.Subscribe(EventType.AllEvents);
            proxy.FireEvents(EventType.AllEvents);

            Assert.AreEqual(EventType.AllEvents, (subscriber.EventFired & EventType.AllEvents));
            Assert.AreEqual(100, subscriber.Number);
            Assert.AreEqual("All", subscriber.Text);

            CloseProxy(proxy);
        }