RaiseClick() public méthode

public RaiseClick ( ) : void
Résultat void
        public void ShouldObserveClickEvent()
        {
            var clickableObject = new MockClickableObject();
            var command = new MockCommand();

            var behavior = new ButtonBaseClickCommandBehavior(clickableObject);
            behavior.Command = command;
            Assert.IsFalse(command.ExecuteCalled);

            clickableObject.RaiseClick();

            Assert.IsTrue(command.ExecuteCalled);
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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 ChangingCommandsShouldExecuteOnNewCommand()
        {
            var clickableObject = new MockClickableObject();
            var originalCommand = new MockCommand() { CanExecuteReturnValue = true };
            var newCommand = new MockCommand() { CanExecuteReturnValue = true };

            var behavior = new ButtonBaseClickCommandBehavior(clickableObject);
            behavior.Command = originalCommand;

            clickableObject.RaiseClick();
            Assert.IsFalse(newCommand.ExecuteCalled);

            behavior.Command = newCommand;
            clickableObject.RaiseClick();
            Assert.IsTrue(newCommand.ExecuteCalled);
        }
        public void ShouldExecuteWithCommandParameter()
        {
            var clickableObject = new MockClickableObject();
            var command = new MockCommand();
            var parameter = new object();
            var behavior = new ButtonBaseClickCommandBehavior(clickableObject);
            behavior.Command = command;
            behavior.CommandParameter = parameter;
            Assert.IsNull(command.ExecuteParameter);

            clickableObject.RaiseClick();

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

            var behavior = new ButtonBaseClickCommandBehavior(clickableObject);
            behavior.Command = command;

            behavior.Command = null;
            clickableObject.RaiseClick();
        }