Пример #1
0
        public void TheStringVariable()
        {
            var theVariable = "theValue";
            var actual      = ExpressionWithValue.ToValuedCode(() => theVariable);

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

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

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

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

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

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

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

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

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