public void UnknownSign_ThrowsExceptions()
        {
            // Arrange
            var unknownOperator = 'x';

            // Act
            var result = sut.Create(unknownOperator, 0);

            // Assert
            Assert.Fail("Should have thrown an exception");
        }
Пример #2
0
        public void GetMaxPrecedence()
        {
            List <MathToken> tokens = _lexer.GetTokens("3 + 3 * 2");
            MathToken        token  = _precedence.GetMaxPrecedence(tokens);
            MathOperator     op     = OperatorFactory.Create(token.Token);

            Assert.AreEqual(op.Token, "*");
        }
        public void ThrowExceptionGivenNoOperator()
        {
            // Arrange
            OperatorFactory SystemUnderTest = new OperatorFactory();

            string InvalidOperation = "1242&213124";

            // Act + Assert
            Should.Throw <ArgumentException>(() => SystemUnderTest.Create(InvalidOperation));
        }
        public void CreateCorrectType(string operationText, Type createdType)
        {
            // Arrange
            OperatorFactory SystemUnderTest = new OperatorFactory();

            // Act
            IOperator createdOperator = SystemUnderTest.Create(operationText);

            // Assert
            createdOperator.ShouldBeOfType(createdType);
        }
Пример #5
0
        public void CreateDivisionOperator()
        {
            MathOperator op = OperatorFactory.Create("/");

            Assert.AreEqual(op.Precedence, 2);
        }
Пример #6
0
        public void CreateMultiplyOperator()
        {
            MathOperator op = OperatorFactory.Create("*");

            Assert.AreEqual(op.Precedence, 2);
        }