Example #1
0
        public void TheStringVariable()
        {
            var theVariable = "theValue";
            var actual      = ExpressionWithValue.ToValuedCode(() => theVariable);

            Assert.AreEqual("theVariable = theValue", actual);
        }
Example #2
0
        public void ArrayLength()
        {
            var arr    = new[] { 1 };
            var actual = ExpressionWithValue.ToValuedCode(() => arr.Length);

            Assert.AreEqual("arr.Length = 1", actual);
        }
Example #3
0
        public void ToValuedCode_ofNull_fails()
        {
            ExpressionToCodeTest obj = null;

            Assert.Catch <InvalidOperationException>(
                () =>
                ExpressionWithValue.ToValuedCode(() => obj.TheProperty));
        }
Example #4
0
        public void ThisStaticMethodCall()
        {
            var code = ExpressionWithValue.ToValuedCode(() => StaticReturnZero());

            Assert.AreEqual("ToValuedCodeTest.StaticReturnZero() = 0", code);
        }
Example #5
0
        public void ThisMethodCall()
        {
            var code = ExpressionWithValue.ToValuedCode(() => ReturnZero());

            Assert.AreEqual("ReturnZero() = 0", code);
        }
Example #6
0
        public void ThisIndexedProperty()
        {
            var actual = ExpressionWithValue.ToValuedCode(() => this[1]);

            Assert.AreEqual("ToValuedCodeTest[1] = TheIndexedValue", actual);
        }
Example #7
0
        public void TheGenericMethod()
        {
            var actual = ExpressionWithValue.ToValuedCode(() => TheGenericMethod <int>(2));

            Assert.AreEqual("TheGenericMethod<Int32>(2) = Return value is 4", actual);
        }
Example #8
0
        public void TheMethod()
        {
            var actual = ExpressionWithValue.ToValuedCode(() => TheMethod(1, "2"));

            Assert.AreEqual("TheMethod(1, \"2\") = TheMethod 1 2", actual);
        }
Example #9
0
        public void ThePropertyAccess()
        {
            var actual = ExpressionWithValue.ToValuedCode(() => TheProperty);

            Assert.AreEqual("TheProperty = TheValue", actual);
        }