Beispiel #1
0
 public void TestCanDoSubtraction()
 {
     calculator.Number(1);
     calculator.Number(2);
     calculator.Minus();
     calculator.Number(1);
     calculator.Number(3);
     calculator.Equals();
     Assert.Equal(-1, calculator.Result);
 }
Beispiel #2
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());
        }