public void ImplicitMultiplicationRewriter_TokenStream_Needs_To_Be_In_Infix_Notation()
 {
     TokenStream stream = new TokenStream(Enumerable.Empty<Token>(), TokenNotation.Postfix);
     ImplicitMultiplicationRewriter rewriter = new ImplicitMultiplicationRewriter();
     var exception = Assert.Throws<MathExpressionException>(() => rewriter.Rewrite(stream));
     Assert.AreEqual("Token stream is not in infix notation.", exception.Message);
 }
 public void ImplicitMultiplicationRewriter_Can_Rewrite_Implicit_Multiplication_When_Operand_Is_Followed_By_Parenthesis()
 {
     // 5(2)
     List<Token> tokens = new List<Token>();
     tokens.Add(new Token(TokenType.Numeric, 5D));
     tokens.Add(new Token(TokenType.OpeningParenthesis, "("));
     tokens.Add(new Token(TokenType.Numeric, 2D));
     tokens.Add(new Token(TokenType.ClosingParenthesis, ")"));
     TokenStream stream = new TokenStream(tokens, TokenNotation.Infix);
     ImplicitMultiplicationRewriter processor = new ImplicitMultiplicationRewriter();
     Token[] result = processor.Rewrite(stream).ToArray();
     Assert.AreEqual(5, result.Length);
     Assert.AreEqual(TokenType.Multiplication, result[1].Type);
 }
 public void ImplicitMultiplicationRewriter_Can_Rewrite_Implicit_Multiplication_When_Constant_Is_Followed_By_Variable()
 {
     // 5x
     List<Token> tokens = new List<Token>();
     tokens.Add(new Token(TokenType.Numeric, 2D));
     tokens.Add(new Token(TokenType.Variable, "x"));
     ImplicitMultiplicationRewriter processor = new ImplicitMultiplicationRewriter();
     TokenStream stream = new TokenStream(tokens, TokenNotation.Infix);
     Token[] result = processor.Rewrite(stream).ToArray();
     Assert.AreEqual(3, result.Length);
     Assert.AreEqual(TokenType.Numeric, result[0].Type);
     Assert.AreEqual(TokenType.Multiplication, result[1].Type);
     Assert.AreEqual(TokenType.Variable, result[2].Type);
 }