コード例 #1
0
        public void CommandBehaviorBaseAllowsDisableByDefault()
        {
            var targetUIElement = new UIElement();
            var target          = new TestableCommandBehaviorBase(targetUIElement);

            Assert.True(target.AutoEnable);
        }
コード例 #2
0
        public void ExecuteUsesParameterWhenCommandParameterNotSet()
        {
            var         targetUIElement = new UIElement();
            var         target          = new TestableCommandBehaviorBase(targetUIElement);
            TestCommand testCommand     = new TestCommand();

            target.Command = testCommand;

            target.ExecuteCommand("testparam");

            Assert.Equal("testparam", testCommand.ExecuteCalledWithParameter);
        }
コード例 #3
0
        public void CommandBehaviorBaseEnablesUIElement()
        {
            var targetUIElement = new UIElement();

            targetUIElement.IsEnabled = false;

            var         target      = new TestableCommandBehaviorBase(targetUIElement);
            TestCommand testCommand = new TestCommand();

            target.Command = testCommand;
            target.ExecuteCommand(null);

            Assert.True(targetUIElement.IsEnabled);
        }
コード例 #4
0
        public void CommandBehaviorBaseDisablesUIElement()
        {
            var targetUIElement = new UIElement();

            targetUIElement.IsEnabled = true;

            var         target      = new TestableCommandBehaviorBase(targetUIElement);
            TestCommand testCommand = new TestCommand();

            testCommand.CanExecuteResult = false;
            target.Command = testCommand;
            target.ExecuteCommand(null);

            Assert.False(targetUIElement.IsEnabled);
        }
コード例 #5
0
        public void WhenAutoEnableIsFalse_ThenDisabledUIElementRemainsDisabled()
        {
            var targetUIElement = new UIElement();

            targetUIElement.IsEnabled = false;

            var target = new TestableCommandBehaviorBase(targetUIElement);

            target.AutoEnable = false;
            TestCommand testCommand = new TestCommand();

            target.Command = testCommand;
            target.ExecuteCommand(null);

            Assert.False(targetUIElement.IsEnabled);
        }
コード例 #6
0
        public void WhenAutoEnableIsUpdated_ThenEnabledUIElementIsDisabled()
        {
            var targetUIElement = new UIElement();

            targetUIElement.IsEnabled = true;

            var target = new TestableCommandBehaviorBase(targetUIElement);

            target.AutoEnable = false;
            TestCommand testCommand = new TestCommand();

            testCommand.CanExecuteResult = false;
            target.Command = testCommand;
            target.ExecuteCommand(null);

            Assert.True(targetUIElement.IsEnabled);

            target.AutoEnable = true;

            Assert.False(targetUIElement.IsEnabled);
        }