public void TwoNumbersAdditionCorrectPostfixString()
        {
            var operationProvider = new Mock<IOperationProvider>();

            operationProvider.Setup(m => m.IsOperation(@"+")).Returns(true);

            var infix = @"2 + 2";

            var postfixConverter = new PostfixConverterSortStation(operationProvider.Object);
            var postfix = postfixConverter.Convert(infix);

            Assert.Equal(@"2 2 +", postfix);
        }
        public void ComplexExpressionCorrectCalculation()
        {
            var operationProvider = new BasicOperationProvider();

            var converter = new PostfixConverterSortStation(operationProvider);
            var executor = new PostfixExecutor(operationProvider);

            var input = @"4 * 5 - 27 / 3";

            var calculator = new Calculator(converter, executor);
            var result = calculator.Calculate(input);

            Assert.Equal(11, result);
        }
        public void TwoPriorityLevelOperationsCorrectPostfixString()
        {
            var operationProvider = new Mock<IOperationProvider>();

            operationProvider.Setup(m => m.IsOperation(@"-")).Returns(true);
            operationProvider.Setup(m => m.IsOperation(@"*")).Returns(true);
            operationProvider.Setup(m => m.ComparePriority(@"-", @"*")).Returns(-1);

            var infix = @"6 * 1 - 2";

            var postfixConverter = new PostfixConverterSortStation(operationProvider.Object);
            var postfix = postfixConverter.Convert(infix);

            Assert.Equal(@"6 1 * 2 -", postfix);
        }
        public void AdditionAndSubtractionCorrectPostfixString()
        {
            var operationProvider = new Mock<IOperationProvider>();

            operationProvider.Setup(m => m.IsOperation(@"+")).Returns(true);
            operationProvider.Setup(m => m.IsOperation(@"-")).Returns(true);
            operationProvider.Setup(m => m.ComparePriority(@"-", @"+")).Returns(0);

            var infix = @"2 + 2 - 1";

            var postfixConverter = new PostfixConverterSortStation(operationProvider.Object);
            var postfix = postfixConverter.Convert(infix);

            Assert.Equal(@"2 2 1 - +", postfix);
        }
        public void DivisionByZeroExceptionThrow()
        {
            var operationProvider = new BasicOperationProvider();

            var converter = new PostfixConverterSortStation(operationProvider);
            var executor = new PostfixExecutor(operationProvider);

            var input = @"13 / 0";

            var calculator = new Calculator(converter, executor);

            Assert.Throws(typeof(DivideByZeroException), () =>
            {
                calculator.Calculate(input);
            });
        }
        public void MissingOperandExpressionExceptionThrow()
        {
            var operationProvider = new BasicOperationProvider();

            var converter = new PostfixConverterSortStation(operationProvider);
            var executor = new PostfixExecutor(operationProvider);

            var input = @"2 + + 7";

            var calculator = new Calculator(converter, executor);

            Assert.Throws(typeof(IncorrectExpressionException), () =>
            {
                calculator.Calculate(input);
            });
        }
        public void TwoNumbersAdditionCorrectCalculation()
        {           
            var operationProvider = new Mock<IOperationProvider>();
            operationProvider.Setup(m => m.IsOperation(@"+")).Returns(true);

            var converter = new PostfixConverterSortStation(operationProvider.Object);

            var executor = new Mock<IPostfixExecutor>();
            executor.Setup(m => m.Execute(@"2 2 +")).Returns(4);

            var input = @"2 + 2";

            var calculator = new Calculator(converter, executor.Object);
            var result = calculator.Calculate(input);

            Assert.Equal(4, result);
        }
        public void ComplexExpressionCorrectPostfixString()
        {
            var operationProvider = new BasicOperationProvider();

            var infix = @"3 * 10 - 26 / 13";

            var postfixConverter = new PostfixConverterSortStation(operationProvider);
            var postfix = postfixConverter.Convert(infix);

            Assert.Equal(@"3 10 * 26 13 / -", postfix);
        }
        public void DivisionOperationCorrectPostfixString()
        {
            var operationProvider = new Mock<IOperationProvider>();

            operationProvider.Setup(m => m.IsOperation(@"+")).Returns(true);
            operationProvider.Setup(m => m.IsOperation(@"/")).Returns(true);
            operationProvider.Setup(m => m.ComparePriority(@"/", @"+")).Returns(1);

            var infix = @"4 + 6 / 2";

            var postfixConverter = new PostfixConverterSortStation(operationProvider.Object);
            var postfix = postfixConverter.Convert(infix);

            Assert.Equal(@"4 6 2 / +", postfix);
        }
        public void IncorrectCharactersInInputStringExceptionThrow()
        {
            var operationProvider = new BasicOperationProvider();

            var infix = @"2asb + 7";

            var postfixConverter = new PostfixConverterSortStation(operationProvider);

            Assert.Throws(typeof(IncorrectCharacterException), () =>
            {
                postfixConverter.Convert(infix);
            });
        }