Ejemplo n.º 1
0
        public void CalculateCharFailTest()
        {
            ICalculator calculator = new Calculator();

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

            Assert.Throws <CalculateException>(() => calculator.Counting("1 + /"));
            Assert.Throws <CalculateException>(() => calculator.Counting(""));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
        public void CalculateDoubleFailTest()
        {
            ICalculator calculator = new Calculator();

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