Exemplo n.º 1
0
        public void CanExtendWithAnyPower()
        {
            var calculator = new CalculatorBuilder()
                             .AddDefaultOperations()
                             .AddOperation("^", (prev, arg) => Math.Pow(prev, arg))
                             .Build();

            calculator.Perform("+", 3)
            .Perform("^", 3)
            .Result
            .Should()
            .Be(27);
        }
Exemplo n.º 2
0
        public void CanExtendWithSquareRoot()
        {
            var calculator = new CalculatorBuilder()
                             .AddDefaultOperations()
                             .AddOperation("root", (prev, arg) => Math.Pow(prev, 1 / arg))
                             .Build();

            calculator.Perform("+", 4)
            .Perform("root", 2)
            .Result
            .Should()
            .Be(2);
        }