public void RemoveWhiteSpaceCharsFromExpression(string expression)
        {
            var operands = new List <string>()
            {
                "(", "(", "45", "+", "45", ")", ")"
            };
            IRecognizer recognizer = new BaseRecognizer(GetAllOperations());
            var         result     = recognizer.Recognize(expression);

            Assert.AreEqual(operands, result);
        }
        public void Recognize_ReturnsCorrectNumberOfOperands()
        {
            var moqFirstOperation = new Mock <IOperation>();

            moqFirstOperation.Setup(operation => operation.StringPresentation).Returns("+");
            var moqSecondOperation = new Mock <IOperation>();

            moqSecondOperation.Setup(operation => operation.StringPresentation).Returns("-");
            var operationsList = new List <IOperation> {
                moqFirstOperation.Object, moqSecondOperation.Object
            };
            IRecognizer recognizer = new BaseRecognizer(operationsList);

            var result = recognizer.Recognize("2+6-8");

            Assert.AreEqual(5, result.Count);
        }
Exemplo n.º 3
0
        public void Recognize_ReturnsCorrectRecognizedOperands()
        {
            var moqFirstOperation = new Mock <IOperation>();

            moqFirstOperation.Setup(operation => operation.StringPresentation).Returns("+");
            var moqSecondOperation = new Mock <IOperation>();

            moqSecondOperation.Setup(operation => operation.StringPresentation).Returns("-");
            var operationsList = new List <IOperation> {
                moqFirstOperation.Object, moqSecondOperation.Object
            };
            IRecognizer recognizer = new BaseRecognizer(operationsList);

            var result = recognizer.Recognize("2+6-8");

            Assert.Equal(new[] { "2", "+", "6", "-", "8" }, result);
        }