public void Compute(char @operator, int operand)
        {
            ICommand command = new CalculateCommand(calculator, @operator, operand);

            command.Execute();
            _commands.Add(command);
            _current++;
        }
    public void Compute(Operations @operator, int operand)
    {
        ICommand command = new CalculateCommand(_calculator, @operator, operand);

        command.Execute();
        _commands.Add(command);
        _commandIndex++;
    }
Exemple #3
0
 private void ResetAllInputValues()
 {
     _isPlanUpdating = true;
     foreach (var p in Payments)
     {
         // we mark all items as autogenerated to remove user overrides.
         // This will lead the calculation to ignore the user values and to use the calculated ones.
         p.Payment = new Currency(p.Payment);
         p.UnscheduledRepayment = new Currency(p.UnscheduledRepayment);
     }
     _isPlanUpdating = false;
     CalculateCommand.Execute();
 }
        public void CalculateCommand_WhenValidDataValueExists_ReturnsExpectedTotal()
        {
            //Arrange            
            var stubFileRepo = new StubFileRepository();
            string fileContent = "3, 5";
            string expectedTotal = "8";

            var model = new FileDataViewModel(stubFileRepo) { FileContent = fileContent };
            var command = new CalculateCommand();

            //Act
            command.Execute(model);

            //Assert             
            Assert.AreEqual(expectedTotal, model.TotalValue);
        }
        private void ApplyOnClick(object sender, EventArgs e)
        {
            var calculateModel = new CalculateRequest(_duration.Text, _amount.Text, _percent.Text, _type);

            ShowLoaderInMainThread();

            ThreadPool.QueueUserWorkItem(w =>
            {
                if (calculateModel.IsValid(ShowError))
                {
                    var commandDelegate = new CommandDelegate <CalculateResponce>(OnSuccess, ShowError, ShowErrorNotEnternet);
                    var command         = new CalculateCommand(LocalDb.Instance, commandDelegate);
                    command.Execute(calculateModel);
                }
                DissmissLoaderInMainThread();
            });
        }
Exemple #6
0
 private void PaymentViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     // whenever an item is modified inside we want the complete plan to be recalculated
     CalculateCommand.Execute();
 }