示例#1
0
        public void CustomDelimiter()
        {
            var calc = new r365_calc.Calc();

            calc.Calculate("//;\n2;5");
            Assert.That(calc.Output() == 7);
        }
示例#2
0
        public void OneValue()
        {
            var calc = new r365_calc.Calc();

            calc.Calculate("20");
            Assert.That(calc.Output() == 20);
        }
示例#3
0
        public void Newline()
        {
            var calc = new r365_calc.Calc();

            calc.Calculate("1\n2,3");
            Assert.That(calc.Output() == 6);
        }
示例#4
0
        public void JunkValue()
        {
            var calc = new r365_calc.Calc();

            calc.Calculate("5,tytyt");
            Assert.That(calc.Output() == 5);
        }
示例#5
0
        public void MultipleValues()
        {
            var calc = new r365_calc.Calc();

            calc.Calculate("1,2,3,4,5,6,7,8,9,10,11,12");
            Assert.That(calc.Output() == 78);
        }
示例#6
0
        public void TwoValue()
        {
            var calc = new r365_calc.Calc();

            calc.Calculate("1,500");
            Assert.That(calc.Output() == 501);
        }
示例#7
0
        public void NoValue()
        {
            var calc = new r365_calc.Calc();

            calc.Calculate("");
            Assert.That(calc.Output() == 0);
        }
示例#8
0
        public void CustomMultipleArbitaryDelimiter()
        {
            var calc = new r365_calc.Calc();

            calc.Calculate("//[*][!!][r9r]\n11r9r22*33!!44");
            Assert.That(calc.Output() == 110);
        }
示例#9
0
        public void CustomArbitaryDelimiter()
        {
            var calc = new r365_calc.Calc();

            calc.Calculate("//[***]\n11***22***33");
            Assert.That(calc.Output() == 66);
        }
示例#10
0
        public void UnderThousand()
        {
            var calc = new r365_calc.Calc();

            calc.UpperBound = 1000;
            calc.Calculate("2,1001,6");
            Assert.That(calc.Output() == 8);
        }
示例#11
0
        public void NoNegatives()
        {
            var calc = new r365_calc.Calc();

            calc.NoNegatives = true;
            Assert.Throws <System.ApplicationException>(() => calc.Calculate("1,-2,3,-4"))
            .Message.Equals("Negatives are not allowed. You had: -2,-4");
        }
示例#12
0
        public void ThreeValue()
        {
            var calc = new r365_calc.Calc();

            // Changed requirement. No longer limited to a max of two values.
            calc.Calculate("1,1,1");
            Assert.That(calc.Output() == 3);
        }
示例#13
0
        public void AddSubractMultiplyDivide()
        {
            var calc = new r365_calc.Calc();

            calc.Calculate("1,2,*,3,/,3,-,1");
            Assert.That(calc.Output() == 2);
            Assert.That(calc.History() == "1+2*3/3-1");
        }
示例#14
0
        public void ShowFormula()
        {
            var calc = new r365_calc.Calc();

            calc.UpperBound = 1000;
            calc.Calculate("2,4,rrrr,1001,6");
            Assert.That(calc.Output() == 12);
            Assert.That(calc.History() == "2+4+0+0+6");
        }