Пример #1
0
 public MessageHandlerBase()
 {
     if (MVVMMessagerService.ReceiverExist <T>())
     {
         MVVMMessagerService.UnregisterReceiver <T>();
     }
 }
Пример #2
0
        public void unregistering_receivers_should_work()
        {
            MVVMMessagerService.RegisterReceiver <TestMessage>((t) => { });
            MVVMMessagerService.UnregisterReceiver <TestMessage>();

            Assert.IsFalse(MVVMMessagerService.ReceiverExist <TestMessage>());
        }
Пример #3
0
 public void InitializeTest()
 {
     if (MVVMMessagerService.ReceiverExist <TestMessage>())
     {
         MVVMMessagerService.UnregisterReceiver <TestMessage>();
     }
 }
Пример #4
0
        public void unregistering_unexisted_receiver_should_throw_error()
        {
            Assert.Throws <Exception>(unregister_unexist_receiver);

            void unregister_unexist_receiver()
            {
                MVVMMessagerService.UnregisterReceiver <TestMessage>();
            }
        }
Пример #5
0
        public void unregistering_receivers_should_work()
        {
            int excpetedReceiversCount = 0;

            MVVMMessagerService.RegisterReceiver(typeof(MVVMMessagerService), () => { });
            MVVMMessagerService.UnregisterReceiver(typeof(MVVMMessagerService));

            Assert.AreEqual(excpetedReceiversCount, MVVMMessagerService.GetReceiversNum(typeof(MVVMMessagerService)));
        }
Пример #6
0
        public void message_should_be_received_and_parameters_given()
        {
            int    expectedValue1 = 5;
            double expectedValue2 = 25.5;

            MVVMMessagerService.RegisterReceiver <int, double>(typeof(MVVMMessagerService),
                                                               (value1, value2) =>
            {
                Assert.AreEqual(expectedValue1, value1);
                Assert.AreEqual(expectedValue2, value2);
            });

            MVVMMessagerService.SendMessage(typeof(MVVMMessagerService), expectedValue1, expectedValue2);
            MVVMMessagerService.UnregisterReceiver(typeof(MVVMMessagerService));
        }
 protected override void OnDetaching()
 {
     base.OnDetaching();
     AssociatedObject.Loaded -= StackPanel_Loaded;
     MVVMMessagerService.UnregisterReceiver(typeof(StackPanelFramesAnimationBehavior));
 }
Пример #8
0
 public void receiver_should_exist()
 {
     MVVMMessagerService.RegisterReceiver(typeof(MVVMMessagerService), () => { });
     Assert.AreEqual(true, MVVMMessagerService.ReceiverExist(typeof(MVVMMessagerService)));
     MVVMMessagerService.UnregisterReceiver(typeof(MVVMMessagerService));
 }