예제 #1
0
        public void CalculateCharFailTest()
        {
            ICalculator calculator = new Calculator();

            Assert.Throws <CalculateException>(() => calculator.Counting("abc"));
            Assert.Throws <CalculateException>(() => calculator.Counting("1 a +"));
        }
예제 #2
0
        public void CalculateNullArgumentFailTest()
        {
            ICalculator calculator = new Calculator();

            Assert.Throws <CalculateException>(() => calculator.Counting("1 + /"));
            Assert.Throws <CalculateException>(() => calculator.Counting(""));
        }
예제 #3
0
        public void CalculateTest1()
        {
            ICalculator calculator = new Calculator();
            string      expression = "1 1 +";
            double      value      = calculator.Counting(expression);

            Assert.Equal(2, value);

            expression = "2 3 2 / * ";
            value      = calculator.Counting(expression);
            Assert.Equal(3, value);

            expression = "2 1,5 * ";
            value      = calculator.Counting(expression);
            Assert.Equal(3, value);
        }
예제 #4
0
        public void CalculateDoubleFailTest()
        {
            ICalculator calculator = new Calculator();

            Assert.Throws <CalculateException>(() => calculator.Counting("1 1.12 +"));
        }