예제 #1
0
        public void CanExecuteChangedEventShouldBeWeak()
        {
            bool        b         = false;
            Action      execute   = (() => { });
            Func <bool> predicate = (() => b);
            var         command   = new DelegateCommand(execute, predicate);

            command.CanExecuteChanged += new EventConsumer().EventHandler;

            // Garbage collect the EventConsumer.
            GC.Collect();

            EventConsumer.Clear();
            command.RaiseCanExecuteChanged();
            Assert.IsFalse(EventConsumer.EventCalled);
        }
예제 #2
0
        public void CanExecuteChangedEventShouldBeWeak()
        {
            var command1 = new DelegateCommand(() => { }, null);
            var command2 = new DelegateCommand <int>(i => { }, null);

            var compositeCommand = new CompositeCommand();

            compositeCommand.RegisterCommand(command1);
            compositeCommand.RegisterCommand(command2);
            compositeCommand.CanExecuteChanged += new EventConsumer().EventHandler;

            // Garbage collect the EventConsumer.
            GC.Collect();

            EventConsumer.Clear();
            command1.RaiseCanExecuteChanged();
            command2.RaiseCanExecuteChanged();
            Assert.IsFalse(EventConsumer.EventCalled);
        }