Exemplo n.º 1
0
        public CalculatorViewModel()
        {
            NumberCommand = new RelayCommand(param => { calculator.Number(Convert.ToInt32(param)); UpdateDisplay(); },
                                             param => calculator.CanDoNumber());

            PlusCommand = new RelayCommand(param => { calculator.Plus(); UpdateDisplay(); },
                                           param => calculator.CanDoSign());

            MinusCommand = new RelayCommand(param => { calculator.Minus(); UpdateDisplay(); },
                                            param => calculator.CanDoSign());

            TimesCommand = new RelayCommand(param => { calculator.Times(); UpdateDisplay(); },
                                            param => calculator.CanDoSign());

            OverCommand = new RelayCommand(param => { calculator.Over(); UpdateDisplay(); },
                                           param => calculator.CanDoSign());

            EqualsCommand = new RelayCommand(param => { calculator.Equals(); UpdateDisplay(); },
                                             param => calculator.CanDoEquals());

            ClearCommand = new RelayCommand(param => { calculator.Clear(); UpdateDisplay(); },
                                            param => calculator.CanDoClear());
        }
Exemplo n.º 2
0
 public void TestCantDoOperatorInitially()
 {
     Assert.False(calculator.CanDoSign());
 }