Esempio n. 1
0
        public void CallsDoWhenDoCommand()
        {
            DoCommand doCommand = new DoCommand();

            _controllerFixture.Controller.Execute(doCommand);
            _controllerFixture.Do.Verify(x => x.Execute(It.IsAny <string>()), Times.Once);
        }
Esempio n. 2
0
 public Command(DoCommand doCommand, UndoCommand undoCommand, object doData, string name)
 {
     this.doCommand = doCommand;
     this.undoCommand = undoCommand;
     this.doData = doData;
     this.name = name;
 }
Esempio n. 3
0
        private void ProcessKeyPress(KeyPressEventArgs e)
        {
            commandArgs = new CommandEventArgs(e.Key, e.KeyString);

            if (waiting)
            {
                waiting = false;
            }
            else
            {
                DoCommand?.Invoke(this, commandArgs);
            }
        }
        public DataTemplateTestViewModel(IPageDialogService pageDlg)
        {
            ItemsSource = new ObservableCollection <Person>(
                new List <Person>
            {
                new Person {
                    Name = "ABC", Days = "1,2,3,4"
                },
                new Person {
                    Name = "DEF", Days = "5,6,7,8"
                },
            }
                );

            DoCommand.Subscribe(async _ => {
                await pageDlg.DisplayAlertAsync("", "Command", "OK");
            });

            AddCommand.Subscribe(_ => {
                ItemsSource.Add(new Person {
                    Name = "Add", Days = "9,9,9,9"
                });
            });

            DelCommand.Subscribe(_ => {
                ItemsSource.Remove(ItemsSource.Last());
            });

            RepCommand.Subscribe(_ => {
                ItemsSource[0] = new Person {
                    Name = "Rep", Days = "1,1,1,1"
                };
            });

            ClrCommand.Subscribe(_ => {
                ItemsSource.Clear();
            });

            BtmCommand.Subscribe(_ => {
                ScrollToBottom.Value = true;
            });

            TopCommand.Subscribe(_ => {
                ScrollToTop.Value = true;
            });
        }
Esempio n. 5
0
 public void Execute(DoCommand doCommand)
 {
     doUseCase.Execute(doCommand.Id);
 }
    public bool TryGetSimpleCommand(string command, out BaseCommand returnCommand)
    {
        returnCommand = null;
        string[] arguments  = null;
        string   methodName = GetMethodSingature(command, ref arguments);

        CommandsMethods commandEnum = _availableCommands.FirstOrDefault(com => com.ToString() == methodName);

        if (commandEnum == 0)
        {
            return(false);
        }

        switch (commandEnum)
        {
        case (CommandsMethods.Forward):
            if (arguments == null || arguments.Length != 1 || arguments[0] != string.Empty)
            {
                return(false);
            }

            returnCommand = new MoveCommand(_implementator, MoveSides.FORWARD);
            return(true);

        case (CommandsMethods.Backward):
            if (arguments == null || arguments.Length != 1 || arguments[0] != string.Empty)
            {
                return(false);
            }

            returnCommand = new MoveCommand(_implementator, MoveSides.BACKWARD);
            return(true);

        case (CommandsMethods.Turn):
        {
            if (arguments == null || arguments.Length == 0)
            {
                return(false);
            }

            var turnSide = arguments[0].ToLower();

            if (turnSide == TurnArguments.Right.ToString().ToLower())
            {
                returnCommand = new RotateCommand(_implementator, TurnArguments.Right);
            }
            else if (turnSide == TurnArguments.Left.ToString().ToLower())
            {
                returnCommand = new RotateCommand(_implementator, TurnArguments.Left);
            }
            return(true);
        }

        case (CommandsMethods.Do):
        {
            int count = 0;
            if (arguments == null || arguments.Length == 0 || !int.TryParse(arguments[0], out count))
            {
                return(false);
            }

            returnCommand = new DoCommand(_implementator, count);
            return(true);
        }

        case (CommandsMethods.While):
        {
            if (arguments == null || arguments.Length == 0)
            {
                return(false);
            }

            WhileConditions argument = _allWhileConditions.FirstOrDefault(com => com.ToString() == arguments[0]);

            if (argument == 0)
            {
                return(false);
            }

            returnCommand = new WhileCommand(_implementator, argument);
            return(true);
        }
        }

        return(false);
    }