public void ShouldHookUpClickCommandBehaviorWhenSettingProperty()
        {
            var clickableObject = new MockClickableObject();
            var command         = new MockCommand();

            Click.SetCommand(clickableObject, command);
            Assert.IsFalse(command.ExecuteCalled);

            clickableObject.RaiseClick();

            Assert.IsTrue(command.ExecuteCalled);
            Assert.AreSame(command, Click.GetCommand(clickableObject));
        }
        public void ShouldUpdateCommandOnBehaviorWhenChangingProperty()
        {
            var clickableObject = new MockClickableObject();
            var oldCommand      = new MockCommand();
            var newCommand      = new MockCommand();

            Click.SetCommand(clickableObject, oldCommand);
            Click.SetCommand(clickableObject, newCommand);

            clickableObject.RaiseClick();

            Assert.IsTrue(newCommand.ExecuteCalled);
            Assert.IsFalse(oldCommand.ExecuteCalled);
        }
        public void ShouldExecuteWithCommandParameter()
        {
            var clickableObject = new MockClickableObject();
            var command         = new MockCommand();
            var parameter       = new object();

            Click.SetCommand(clickableObject, command);
            Click.SetCommandParameter(clickableObject, parameter);
            Assert.IsNull(command.ExecuteParameter);

            clickableObject.RaiseClick();

            Assert.IsTrue(command.ExecuteCalled);
            Assert.IsNotNull(command.ExecuteParameter);
            Assert.AreSame(parameter, command.ExecuteParameter);
        }
        public void ShouldCallCanExecuteOnParameterChange()
        {
            var clickableObject = new MockClickableObject();

            var command   = new MockCommand();
            var parameter = new object();

            Click.SetCommand(clickableObject, command);
            Assert.IsNull(command.CanExecuteParameter);
            Assert.IsTrue(clickableObject.IsEnabled);

            command.CanExecuteReturnValue = false;
            Click.SetCommandParameter(clickableObject, parameter);

            Assert.IsNotNull(command.CanExecuteParameter);
            Assert.AreSame(parameter, command.CanExecuteParameter);
            Assert.IsFalse(clickableObject.IsEnabled);
        }