public void Append_MoreComplexIntegerValue()
 {
     CalculationStack stack = new CalculationStack();
     stack.Append(1);
     stack.Append(2);
     stack.Append(3);
     Assert.AreEqual(123, stack.Input.Value);
 }
 public void Erase_IntegerValue()
 {
     CalculationStack stack = new CalculationStack();
     stack.Append(1);
     stack.Append(2);
     stack.Erase();
     Assert.AreEqual(1, stack.Input.Value);
 }
 public void Append_LeadingZeroesIntegerValue()
 {
     CalculationStack stack = new CalculationStack();
     stack.Append(0);
     stack.Append(0);
     stack.Append(1);
     stack.Append(2);
     stack.Append(3);
     Assert.AreEqual(123, stack.Input.Value);
 }
 public void Append_DoubleValue()
 {
     CalculationStack stack = new CalculationStack();
     stack.Append(1);
     stack.Append(2);
     stack.Append(3);
     stack.SetComma();
     stack.Append(0);
     stack.Append(5);
     stack.Append(1);
     Assert.AreEqual(123.051, stack.Input.Value);
 }
Example #5
0
 public MemoryRecall(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
 public PercentNumber(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #7
0
 public Swap(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #8
0
 public MemoryRecall(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
 public CalculateAction(CalculationStack stack, CalculationMode mode)
 {
     this.stack = stack;
     this.mode  = mode;
 }
Example #10
0
 public PercentNumber(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #11
0
 public Erase(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
 public void Erase_ToZero()
 {
     CalculationStack stack = new CalculationStack();
     stack.Append(1);
     stack.Append(2);
     stack.Append(2);
     stack.Erase();
     stack.Erase();
     stack.Erase();
     stack.Erase();
     Assert.AreEqual(0, stack.Input.Value);
 }
Example #13
0
 public ChangeSign(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #14
0
 public ChangeSign(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #15
0
 public AddTime(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #16
0
 public AddNumber(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
 public void Append_SimpleIntegerValue()
 {
     CalculationStack stack = new CalculationStack();
     stack.Append(1);
     Assert.AreEqual(1, stack.Input.Value);
 }
Example #18
0
 public Swap(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
        public void Erase_TillZeroAndAppendAgain()
        {
            CalculationStack stack = new CalculationStack();
            stack.Append(3);
            stack.SetComma();
            stack.Append(0);
            stack.Append(4);
            stack.Append(2);
            stack.Append(1);
            stack.Erase();
            stack.Erase();
            stack.Erase();
            stack.Erase();
            stack.Append(1);
            stack.Append(4);
            stack.Append(1);
            stack.Append(5);

            Assert.AreEqual(3.1415, stack.Input.Value);
        }
Example #20
0
 public AddDate(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #21
0
 public Operation(CalculationStack stack)
 {
     this.stack = stack;
 }
Example #22
0
 public Erase(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #23
0
 public Operation( CalculationStack stack)
 {
     this.stack = stack;
 }
Example #24
0
 public DivNumber(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #25
0
 public Clear(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #26
0
 public PowerNumber(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #27
0
 public MemoryMinus(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #28
0
 public SubDate(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #29
0
 public Enter(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #30
0
 public SqrtNumber(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #31
0
 public SubTime(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
        public static Operation Build(CalculationStack stack, CalculationMode mode, OperationType type)
        {
            // Zacznij od sprawdzania operacji ktore sa niezalezne od trybu
            switch (type)
            {
                case OperationType.C:
                        return new Erase(stack);
                case OperationType.AC:
                        return new Clear(stack);
                case OperationType.ENTER:
                        return new Enter(stack);
                case OperationType.POP:
                        return new Pop(stack);
                case OperationType.SWAP:
                        return new Swap(stack);
                case OperationType.MC:
                        return new MemoryClear(stack);
                case OperationType.MR:
                        return new MemoryRecall(stack);
                case OperationType.Mplus:
                        return new MemoryPlus(stack);
                case OperationType.Mminus:
                        return new MemoryMinus(stack);
            }

            if (mode == CalculationMode.Date) {
                switch (type)
                {
                    case OperationType.SUB:
                        return new SubDate(stack);
                    case OperationType.ADD:
                        return new AddDate(stack);
                }
            }

            if (mode == CalculationMode.Time)
            {
                switch (type)
                {
                    case OperationType.SUB:
                        return new SubTime(stack);
                    case OperationType.ADD:
                        return new AddTime(stack);
                }
            }

            switch (type)
            {
                case OperationType.SQRT:
                    return new SqrtNumber(stack);
                case OperationType.POW:
                    return new PowerNumber(stack);
                case OperationType.INV_X:
                    return new InvertNumber(stack);
                case OperationType.PLUS_MINUS:
                    return new ChangeSign(stack);
                case OperationType.PERCENT:
                    return new PercentNumber(stack);
                case OperationType.DIV:
                    return new DivNumber(stack);
                case OperationType.MUL:
                    return new MulNumber(stack);
                case OperationType.SUB:
                    return new SubNumber(stack);
                case OperationType.ADD:
                    return new AddNumber(stack);
            }

            return null;
        }
Example #33
0
 public Clear(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #34
0
 public SqrtNumber(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
 public ViewModelCalculator()
 {
     calculationStack = new CalculationStack();
     createCalculateCommand();
     calculationStack.PropertyChanged += StackChanged;
 }
Example #36
0
        public static Operation Build(CalculationStack stack, CalculationMode mode, OperationType type)
        {
            // Zacznij od sprawdzania operacji ktore sa niezalezne od trybu
            switch (type)
            {
            case OperationType.C:
                return(new Erase(stack));

            case OperationType.AC:
                return(new Clear(stack));

            case OperationType.ENTER:
                return(new Enter(stack));

            case OperationType.POP:
                return(new Pop(stack));

            case OperationType.SWAP:
                return(new Swap(stack));

            case OperationType.MC:
                return(new MemoryClear(stack));

            case OperationType.MR:
                return(new MemoryRecall(stack));

            case OperationType.Mplus:
                return(new MemoryPlus(stack));

            case OperationType.Mminus:
                return(new MemoryMinus(stack));
            }

            if (mode == CalculationMode.Date)
            {
                switch (type)
                {
                case OperationType.SUB:
                    return(new SubDate(stack));

                case OperationType.ADD:
                    return(new AddDate(stack));
                }
            }

            if (mode == CalculationMode.Time)
            {
                switch (type)
                {
                case OperationType.SUB:
                    return(new SubTime(stack));

                case OperationType.ADD:
                    return(new AddTime(stack));
                }
            }

            switch (type)
            {
            case OperationType.SQRT:
                return(new SqrtNumber(stack));

            case OperationType.POW:
                return(new PowerNumber(stack));

            case OperationType.INV_X:
                return(new InvertNumber(stack));

            case OperationType.PLUS_MINUS:
                return(new ChangeSign(stack));

            case OperationType.PERCENT:
                return(new PercentNumber(stack));

            case OperationType.DIV:
                return(new DivNumber(stack));

            case OperationType.MUL:
                return(new MulNumber(stack));

            case OperationType.SUB:
                return(new SubNumber(stack));

            case OperationType.ADD:
                return(new AddNumber(stack));
            }

            return(null);
        }
Example #37
0
 public MemoryClear(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #38
0
 public MemoryMinus(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #39
0
 public AddDate(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #40
0
 public AddNumber(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
 public CalculateAction(CalculationStack stack, CalculationMode mode)
 {
     this.stack = stack;
     this.mode = mode;
 }
Example #42
0
 public Pop(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #43
0
 public DivNumber(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #44
0
 public Enter(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #45
0
 public SubTime(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #46
0
 public Pop(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
 public ViewModelCalculator()
 {
     calculationStack = new CalculationStack();
     createCalculateCommand();
     calculationStack.PropertyChanged += StackChanged;
 }
Example #48
0
 public MulNumber(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }
Example #49
0
 public MulNumber(CalculationStack calculationStack)
     : base(calculationStack)
 {
 }