示例#1
0
        public void NullInput()
        {
            string      display = string.Empty;
            ICalcParser parser  = _calculator.GetParser(CalculationTypes.AnyNumberItems);
            int         result  = parser.Add(null, ref display);

            Assert.AreEqual(0, result);
        }
        public void TwoNumbersOneBad()
        {
            string      display = string.Empty;
            ICalcParser parser  = _calculator.GetParser(CalculationTypes.Max2Items);
            int         result  = parser.Add("33,asf", ref display);

            Assert.AreEqual(33, result);
        }
        public void TwoGoodNumbers()
        {
            string      display = string.Empty;
            ICalcParser parser  = _calculator.GetParser(CalculationTypes.Max2Items);
            int         result  = parser.Add("0,1", ref display);

            Assert.AreEqual(1, result);
        }
示例#4
0
        public void SockItToIT()
        {
            string      display = string.Empty;
            ICalcParser parser  = _calculator.GetParser(CalculationTypes.AnyNumberItems);

            int result = parser.Add("//R\n//[QQQ][$$$]\n55R123,22QQQ25,@@$$$124,66\n441", ref display);

            Assert.AreEqual(856, result);
        }
示例#5
0
        public void TestManyNumbersCustomDelimMixed()
        {
            string      display = string.Empty;
            ICalcParser parser  = _calculator.GetParser(CalculationTypes.AnyNumberItems);

            int result = parser.Add("//R\n//[QQQ]\n55R123,22QQQ25$$$124,66//[$$$]\n", ref display);

            Assert.AreEqual(415, result);
        }
示例#6
0
        public void TestManyNumbersCustomDelim()
        {
            string      display = string.Empty;
            ICalcParser parser  = _calculator.GetParser(CalculationTypes.AnyNumberItems);

            int result = parser.Add("//Q\n,55Q123", ref display);

            Assert.AreEqual(178, result);
        }
示例#7
0
        public void TestManyNumbersNewLine()
        {
            string      display = string.Empty;
            ICalcParser parser  = _calculator.GetParser(CalculationTypes.AnyNumberItems);

            int result = parser.Add(" 33\n\nasf,55", ref display);

            Assert.AreEqual(88, result);
        }
示例#8
0
        public void TestManyNumbers()
        {
            string      display = string.Empty;
            ICalcParser parser  = _calculator.GetParser(CalculationTypes.AnyNumberItems);

            int result = parser.Add("5, 1, 33, 98", ref display);

            Assert.AreEqual(137, result);
        }
        public void TestAddSubNeg()
        {
            string      display = string.Empty;
            ICalcParser parser  = _calculator.GetParser(CalculationTypes.Max2Items);

            int result = parser.Add("5,-3", ref display);

            Assert.AreEqual(2, result);
        }
        public void AddSub3()
        {
            int         result  = 0;
            string      display = string.Empty;
            ICalcParser parser  = _calculator.GetParser(CalculationTypes.Max2Items);

            try
            {
                result = parser.Add("0,1,3", ref display);
            }
            catch (Exception e)
            {
                if (e.Message != "Undefined Operation")
                {
                    return;
                }
            }
            Assert.AreEqual(0, result);
        }
示例#11
0
        public void TestManyNumbersNegative()
        {
            int         result  = 0;
            string      display = string.Empty;
            ICalcParser parser  = _calculator.GetParser(CalculationTypes.AnyNumberItems);

            try
            {
                result = parser.Add("5,-3, 1, 33, 98", ref display);
            }
            catch (Exception e)
            {
                Assert.IsNotNull(e.InnerException);

                if (e.InnerException != null && (e.InnerException.Message == "NegativeValue"))
                {
                    Assert.AreEqual("-3", e.Message);
                }
            }
            Assert.AreEqual(0, result);
        }