Ejemplo n.º 1
0
        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++;
    }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
0
        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();
            });
        }
Ejemplo n.º 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();
 }