public void TestTranslatedArray()
        {
            var baseVar = Expression.Variable(typeof(SourceType1), "d");
            var jetRef = Expression.MakeMemberAccess(baseVar, typeof(SourceType1).GetMember("jets").First());

            ArrayInfoVector vec = new ArrayInfoVector(jetRef);

            CodeContext cc = new CodeContext();
            GeneratedCode gc = new GeneratedCode();

            var indexVar = vec.AddLoop(gc, cc, MEFUtilities.MEFContainer);
            gc.Add(new LINQToTTreeLib.Statements.StatementSimpleStatement("dude"));

            ///
            /// Make sure the indexvar is working correctly
            /// 

            Assert.IsInstanceOfType(indexVar.Item1, typeof(BinaryExpression), "inproper expression variable type");
            Assert.AreEqual(typeof(SourceType1SubType), indexVar.Item1.Type, "index var type");
            var be = indexVar.Item1 as BinaryExpression;
            Assert.AreEqual(ExpressionType.ArrayIndex, be.NodeType, "not array index");
            Assert.AreEqual(typeof(int), be.Right.Type, "Indexer of array type");
            Assert.IsInstanceOfType(be.Left, typeof(MemberExpression), "now the same paraemter, I think!");
            Assert.AreEqual(jetRef, be.Left, "array isn't right");

            ///
            /// Now, make sure we got as far as a proper size variable
            /// 

            var statements = gc.CodeBody.CodeItUp().ToArray();
            Assert.IsTrue(statements[1].Contains(".val1).size()"), "size statement incorrect: '" + statements[1] + "'");
        }
        public void TestSimpleArray()
        {
            var simpleArrayExpr = Expression.Variable(typeof(int[]), "d");
            ArrayInfoVector vec = new ArrayInfoVector(simpleArrayExpr);

            CodeContext cc = new CodeContext();
            GeneratedCode gc = new GeneratedCode();

            var indexVar = vec.AddLoop(gc, cc, MEFUtilities.MEFContainer);

            ///
            /// Add a dumb statement to force the rendering of the loop (empty loops don't render)
            /// 

            gc.Add(new LINQToTTreeLib.Statements.StatementSimpleStatement("d = d"));

            ///
            /// Make sure the index variable comes back correctly
            /// 

            Assert.IsInstanceOfType(indexVar.Item1, typeof(BinaryExpression), "inproper expression variable type");
            Assert.AreEqual(typeof(int), indexVar.Item1.Type, "bad value type");
            var be = indexVar.Item1 as BinaryExpression;
            Assert.AreEqual(ExpressionType.ArrayIndex, be.NodeType, "not array index");
            Assert.AreEqual(typeof(int), be.Right.Type, "Indexer of array type");
            Assert.IsInstanceOfType(be.Left, typeof(ParameterExpression), "now the same paraemter, I think!");
            Assert.AreEqual(simpleArrayExpr, be.Left, "array isn't right");

            Assert.AreEqual(typeof(int), indexVar.Item2.Type, "Bad index variable");

            ///
            /// Next, we need to look at the statements that have come back
            /// 

            var statements = gc.CodeBody.CodeItUp().ToArray();

            Assert.AreEqual("{", statements[0], "open brace");
            Assert.IsTrue(statements[1].Contains("int"), "statement 1 - int: '" + statements[1] + "'");
            Assert.IsTrue(statements[1].Contains("size();"), "statement 2 - x = 0;: '" + statements[2] + "'");
            Assert.IsTrue(statements[2].StartsWith("  for (int "), "statement 3 - for (): '" + statements[3] + "'");
            Assert.AreEqual("  {", statements[3], "for loop brace opening");
            Assert.AreEqual("    d = d;", statements[4], "the actual statement");
        }