public void ConstantParsedDoesNotTakeBadInput()
 {
     // still not sure why this doesn't work.
     ConstantParser TestConstantParser = new ConstantParser();
     bool results = TestConstantParser.ConstTest("xy = 0");
     Assert.AreEqual(false, results);
 }
 public void CanExtractNumFromConst()
 {
     ConstantParser TstParser = new ConstantParser();
     string input = "x = 3";
     int result = TstParser.ConstNum(input);
     Assert.AreEqual(3, result);
 }
 public void CanExtractKeyFromConst()
 {
     ConstantParser TstParser = new ConstantParser();
     string input = "x = 3";
     string result = TstParser.ConstKey(input);
     Assert.AreEqual("x", result);
 }
        public string Calculate(string input)
        {
            // creates a new RegexProcessor
            RegexUtil regexProcessing = new RegexUtil();

            // creates a new setting ConstantParser
            ConstantParser constantSetting = new ConstantParser();

            // extract integers
            ArrayList integers = regexProcessing.ExtractNums(input);

            // extracts operand
            string thisOp = regexProcessing.ExtractsOp(input);

            // holds answer value
            string answer;

            // make a new instance of the applicable class per the
            // operand extracted
            switch (thisOp)
            {
                case "+":
                    AddIt thisAddExp = new AddIt();
                    answer = thisAddExp.Addition(integers).ToString();
                    LastQnA.LastAns = Convert.ToInt32(answer);
                    LastQnA.LastQ = input;
                    return answer;
                case "-":
                    SubtractIt thisSubExp = new SubtractIt();
                    answer = thisSubExp.Subtraction(integers).ToString();
                    LastQnA.LastAns = Convert.ToInt32(answer);
                    LastQnA.LastQ = input;
                    return answer;
                case "*":
                    MultiplyIt thisMultiExp = new MultiplyIt();
                    answer = thisMultiExp.Multiplication(integers).ToString();
                    LastQnA.LastAns = Convert.ToInt32(answer);
                    LastQnA.LastQ = input;
                    return answer;
                case "/":
                    DivideIt thisDivExp = new DivideIt();
                    answer = thisDivExp.Division(integers).ToString();
                    LastQnA.LastAns = Convert.ToInt32(answer);
                    LastQnA.LastQ = input;
                    return answer;
                case "%":
                    ModIt thisModExp = new ModIt();
                    answer = thisModExp.Modulation(integers).ToString();
                    LastQnA.LastAns = Convert.ToInt32(answer);
                    LastQnA.LastQ = input;
                    return answer;
                case "=":
                    answer = "Your value has been set";
                    return answer;
                default: throw new ArgumentException("Input doesn't contain an operand understood {0}", thisOp);
            }
        }
 public void ConstantParsing()
 {
     ConstantParser TestConstantParser = new ConstantParser();
     bool results = TestConstantParser.ConstTest("t = 0");
     Assert.AreEqual(true, results);
 }
 public void ConstantParsedDoesNotTakeBadInput2()
 {
     ConstantParser TestConstantParser = new ConstantParser();
     bool results = TestConstantParser.ConstTest("0 = x");
     Assert.AreEqual(false, results);
 }