コード例 #1
0
        public void CanExecuteChangedMakesButtonRequeryCommandAndSetsIsEnabledAppropriately()
        {
            var mockCommand = new MockCommand();
            var button = new Button();
            button.IsEnabled = true;
            button.SetValue(CommandProperties.CommandProperty, mockCommand);

            mockCommand.CanExecuteReturnValue = false;
            mockCommand.RaiseCanExecuteChanged();

            Assert.IsFalse(button.IsEnabled);

            mockCommand.CanExecuteReturnValue = true;
            mockCommand.RaiseCanExecuteChanged();

            Assert.IsTrue(button.IsEnabled);
        }
コード例 #2
0
ファイル: CommandsFixture.cs プロジェクト: eslahi/prism
        public void CanExecuteChangedMakesButtonRequeryCommandAndSetsIsEnabledAppropriately()
        {
            var mockCommand = new MockCommand();
            var button      = new Button();

            button.IsEnabled = true;
            button.SetValue(CommandProperties.CommandProperty, mockCommand);

            mockCommand.CanExecuteReturnValue = false;
            mockCommand.RaiseCanExecuteChanged();

            Assert.IsFalse(button.IsEnabled);

            mockCommand.CanExecuteReturnValue = true;
            mockCommand.RaiseCanExecuteChanged();

            Assert.IsTrue(button.IsEnabled);
        }
コード例 #3
0
ファイル: CommandsFixture.cs プロジェクト: eslahi/prism
        public void WhenDesubscribedDontCallCanExecute()
        {
            var mockCommand = new MockCommand();
            var button      = new Button();

            button.IsEnabled = true;
            button.SetValue(CommandProperties.CommandProperty, mockCommand);
            button.SetValue(CommandProperties.CommandProperty, null);

            mockCommand.CanExecuteCalled = false;
            mockCommand.RaiseCanExecuteChanged();

            Assert.IsFalse(mockCommand.CanExecuteCalled);
        }
コード例 #4
0
ファイル: CommandsFixture.cs プロジェクト: eslahi/prism
        public void CanExecuteChangedGetsCalledPassingTheCommandParameter()
        {
            var mockCommand = new MockCommand();
            var button      = new Button();

            button.IsEnabled = true;
            button.SetValue(CommandProperties.CommandProperty, mockCommand);
            object parameter = new object();

            button.SetValue(CommandProperties.CommandParameterProperty, parameter);

            mockCommand.CanExecuteArgumentParameter = null;
            mockCommand.RaiseCanExecuteChanged();

            Assert.IsNotNull(mockCommand.CanExecuteArgumentParameter);
            Assert.AreSame(parameter, mockCommand.CanExecuteArgumentParameter);
        }
コード例 #5
0
        public void CanExecuteChangedGetsCalledPassingTheCommandParameter()
        {
            var mockCommand = new MockCommand();
            var button = new Button();
            button.IsEnabled = true;
            button.SetValue(CommandProperties.CommandProperty, mockCommand);
            object parameter = new object();
            button.SetValue(CommandProperties.CommandParameterProperty, parameter);

            mockCommand.CanExecuteArgumentParameter = null;
            mockCommand.RaiseCanExecuteChanged();

            Assert.IsNotNull(mockCommand.CanExecuteArgumentParameter);
            Assert.AreSame(parameter, mockCommand.CanExecuteArgumentParameter);
        }
コード例 #6
0
        public void WhenDesubscribedDontCallCanExecute()
        {
            var mockCommand = new MockCommand();
            var button = new Button();
            button.IsEnabled = true;
            button.SetValue(CommandProperties.CommandProperty, mockCommand);
            button.SetValue(CommandProperties.CommandProperty, null);

            mockCommand.CanExecuteCalled = false;
            mockCommand.RaiseCanExecuteChanged();

            Assert.IsFalse(mockCommand.CanExecuteCalled);
        }