public void CorrectStringCanBeParsedToEnumType()
        {
            _enumRelayCommand = new RelayCommand<DummyEnum>(ExecuteFunction, CanExecuteFunction);

            _enumRelayCommand.Execute("AnotherValue");

            Assert.AreEqual(DummyEnum.AnotherValue, _enumArgument);
        }
        public void CorrectArgumentIsSent()
        {
            _intRelayCommand = new RelayCommand<int>(ExecuteFunction, CanExecuteFunction);

            _intRelayCommand.Execute(1);

            Assert.AreEqual(1, _intArgument);
        }
        public void CommandIsExecuted()
        {
            _relayCommand = new RelayCommand(OnActionCalled);

            _relayCommand.Execute(null);

            Assert.AreEqual(true, _actionHasBeenCalled);
        }
Example #4
0
 public CarInfoCollection()
 {
     Cars = new ObservableCollection<CarInfoViewModel>();
     UpdateEntryList = new RelayCommand("Refresh", (p) =>
     {
         ReloadEntryList();
     });
     UpdateEntryList.Execute(null);
 }
		public void RelayCommand_Construction_WithoutCanExecuteCanActuallyExecute()
		{
			var count = 0;
			var cmd = new RelayCommand(o => count = (int) o);

			if (cmd.CanExecute())
				cmd.Execute(15);

			Assert.AreEqual(15, count);
		}
Example #6
0
        public void ExecuteExecutesTheAction()
        {
            var run = false;

            var command = new RelayCommand(o => { run = true; });

            command.Execute(null);

            run.Should().BeTrue();
        }
Example #7
0
        public void ExecuteDoesNotExecuteTheActionIfCanExecuteIsFalse()
        {
            var run = false;

            var command = new RelayCommand(o => { run = true; }, o => false);

            command.Execute(null);

            run.Should().BeFalse();
        }
        public void WrongTypeThrowsException()
        {
            _intRelayCommand = new RelayCommand<int>(ExecuteFunction, CanExecuteFunction);

            _intRelayCommand.Execute(0.0);
        }
        public void IncorrectStringThrowsException()
        {
            _enumRelayCommand = new RelayCommand<DummyEnum>(ExecuteFunction, CanExecuteFunction);

            _enumRelayCommand.Execute("InvalidValue");
        }
Example #10
0
        private void AddCommandToService(OleMenuCommandService service, Guid cmdSet, int cmdId, RelayCommand relayCommand)
        {
            var commandId = new CommandID(cmdSet, cmdId);
            var menuCommand = new OleMenuCommand((sender, args) =>
            {
                relayCommand.Execute(null);
            }, commandId);

            menuCommand.BeforeQueryStatus += (sender, args) =>
            {
                menuCommand.Enabled = relayCommand.CanExecute(null);
            };

            service.AddCommand(menuCommand);
        }