当前位置: 首页>>代码示例>>C#>>正文


C# Calculator.Calculate方法代码示例

本文整理汇总了C#中Calculator.Calculate方法的典型用法代码示例。如果您正苦于以下问题:C# Calculator.Calculate方法的具体用法?C# Calculator.Calculate怎么用?C# Calculator.Calculate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Calculator的用法示例。


在下文中一共展示了Calculator.Calculate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestIncorrectExpressionsWithOperators

        public void TestIncorrectExpressionsWithOperators(String input, double expectedResult)
        {
            Calculator calculator = new Calculator();
            double result = calculator.Calculate(input);

            Assert.Throws<InvalidOperationException>(() => calculator.Calculate(input));
        }
开发者ID:ByAgenT,项目名称:Calculator,代码行数:7,代码来源:CalculatorTest.cs

示例2: Happy_day_Nth_op_builds_on_previous

 public void Happy_day_Nth_op_builds_on_previous()
 {
     var sut = new Calculator();
     sut.Calculate(2, "+");
     var result = sut.Calculate(3, "+");
     Assert.AreEqual(5, result);
 }
开发者ID:ralfw,项目名称:TDDaiymiByExample,代码行数:7,代码来源:test_Calculator.cs

示例3: Division_by_zero_does_not_affect_calculator_state

 public void Division_by_zero_does_not_affect_calculator_state()
 {
     var sut = new Calculator();
     sut.Calculate(8, "/");
     Assert.Throws<DivideByZeroException>(() => sut.Calculate(0, "="));
     Assert.AreEqual(4, sut.Calculate(2, "="));
 }
开发者ID:ralfw,项目名称:TDDaiymiByExample,代码行数:7,代码来源:test_Calculator.cs

示例4: Main

 static void Main()
 {
     Calculator calc = new Calculator(new ExpressionTransformer(), new OnpAlgorithm());
     Console.WriteLine(calc.Calculate("((2+7)/3+(14-3)*4)/2"));
     Console.WriteLine(calc.Calculate("((2+7)/3+(14-3)*4)"));
     Console.ReadLine();
 }
开发者ID:Andegawen,项目名称:Calculator,代码行数:7,代码来源:Program.cs

示例5: NotEnoughDiamonds

        public void NotEnoughDiamonds()
        {
            Calculator calculator = new Calculator();

            Assert.AreEqual(0, calculator.Calculate(0, 0, 0));
            Assert.AreEqual(0, calculator.Calculate(5, 0, 2));
            Assert.AreEqual(0, calculator.Calculate(14, 0, 4));
        }
开发者ID:ajlopez,项目名称:TddRocks,代码行数:8,代码来源:CalculatorTests.cs

示例6: OddCoordinates

        public void OddCoordinates()
        {
            Calculator calculator = new Calculator();

            Assert.AreEqual(0, calculator.Calculate(1, 1, 0));
            Assert.AreEqual(0, calculator.Calculate(1, 2, 1));
            Assert.AreEqual(0, calculator.Calculate(1, 2, 3));
        }
开发者ID:ajlopez,项目名称:TddRocks,代码行数:8,代码来源:CalculatorTests.cs

示例7: Check_ops

        public int Check_ops(string op)
        {
            var sut = new Calculator();

            sut.Calculate(12, op);

            return sut.Calculate(3, "=");
        }
开发者ID:ralfw,项目名称:TDDaiymiByExample,代码行数:8,代码来源:test_Calculator.cs

示例8: EnoughDiamonds

        public void EnoughDiamonds()
        {
            Calculator calculator = new Calculator();

            Assert.AreEqual(1, calculator.Calculate(1, 0, 0));
            Assert.AreEqual(1, calculator.Calculate(6, -2, 0));
            Assert.AreEqual(1, calculator.Calculate(6, 0, 2));
            Assert.AreEqual(1, calculator.Calculate(6, 2, 0));
        }
开发者ID:ajlopez,项目名称:TddRocks,代码行数:9,代码来源:CalculatorTests.cs

示例9: InsufficientDiamonds

        public void InsufficientDiamonds()
        {
            Calculator calculator = new Calculator();

            Assert.AreEqual(0, calculator.Calculate(0, 0, 0));
            Assert.AreEqual(0, calculator.Calculate(1, -2, 0));
            Assert.AreEqual(0, calculator.Calculate(1, 0, 2));
            Assert.AreEqual(0, calculator.Calculate(1, 2, 0));
        }
开发者ID:ajlopez,项目名称:TddRocks,代码行数:9,代码来源:CalculatorTests.cs

示例10: Equal_resets_previous_data

        public void Equal_resets_previous_data()
        {
            var sut = new Calculator();
            sut.Calculate(2, "+");
            sut.Calculate(3, "=");

            Assert.AreEqual(4, sut.Calculate(4, "*"));
            Assert.AreEqual(8, sut.Calculate(2, "="));
        }
开发者ID:ralfw,项目名称:TDDaiymiByExample,代码行数:9,代码来源:test_Calculator.cs

示例11: TestIncorrectCalculations

        public void TestIncorrectCalculations(String input, double expectedResult)
        {
            Calculator calculator = new Calculator();
            double result = calculator.Calculate(input);

            Assert.AreNotEqual(result, expectedResult, "Calculation is not correct for {0}", input);
        }
开发者ID:ByAgenT,项目名称:Calculator,代码行数:7,代码来源:CalculatorTest.cs

示例12: TestCorrectExpressionsWithSpaces

        public void TestCorrectExpressionsWithSpaces(String input, double expectedResult)
        {
            Calculator calculator = new Calculator();
            double result = calculator.Calculate(input);

            Assert.AreEqual(result, expectedResult, "Calculation is not correct for {0}", input);
        }
开发者ID:ByAgenT,项目名称:Calculator,代码行数:7,代码来源:CalculatorTest.cs

示例13: Calculator_Should_Calculate_Test1

        public void Calculator_Should_Calculate_Test1()
        {
            var calculator = new Calculator();
            var result = calculator.Calculate("(5+3)*4");

            result.Should().Be(32);
        }
开发者ID:gaiazov,项目名称:Calculator,代码行数:7,代码来源:CalculatorTests.cs

示例14: Calculator_Should_Calculate_Test2

        public void Calculator_Should_Calculate_Test2()
        {
            var calculator = new Calculator();
            var result = calculator.Calculate("(5+3)*(4-1)");

            result.Should().Be(24);
        }
开发者ID:gaiazov,项目名称:Calculator,代码行数:7,代码来源:CalculatorTests.cs

示例15: Calculator_Should_Calculate_Test4

        public void Calculator_Should_Calculate_Test4()
        {
            var calculator = new Calculator();
            var result = calculator.Calculate("5+5*2-1");

            result.Should().Be(14);
        }
开发者ID:gaiazov,项目名称:Calculator,代码行数:7,代码来源:CalculatorTests.cs


注:本文中的Calculator.Calculate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。