コード例 #1
0
        public void GetValue_PropertyThrowsException_ThrowsException()
        {
            var expression = ExpressionBody(() => PropertyThrowsException);

            Assert.Throws <Exception>(
                () => ExpressionUtilities.GetValue(expression));
        }
コード例 #2
0
        public void GetValue_RecursiveMethodCalls_ReturnValue()
        {
            var expression    = ExpressionBody(() => 666.ToString().ToString());
            var expectedValue = ExpressionUtilities.GetValueUsingCompile(expression);

            var value = ExpressionUtilities.GetValueWithoutCompiling(expression);

            Assert.That(value, Is.EqualTo(expectedValue));
        }
コード例 #3
0
        public void GetValue_MethodCallWithArguments_ReturnValue()
        {
            var expression    = ExpressionBody(() => string.Format("{0} {1} {2}", "foo", "bar", 1));
            var expectedValue = ExpressionUtilities.GetValueUsingCompile(expression);

            var value = ExpressionUtilities.GetValueWithoutCompiling(expression);

            Assert.That(value, Is.EqualTo(expectedValue));
        }
コード例 #4
0
        public void GetValue_StaticProperty_ReturnValue()
        {
            var expression    = ExpressionBody(() => StaticProperty);
            var expectedValue = ExpressionUtilities.GetValueUsingCompile(expression);

            var value = ExpressionUtilities.GetValueWithoutCompiling(expression);

            Assert.That(value, Is.EqualTo(expectedValue));
        }
コード例 #5
0
        public void GetValue_MemberExpression_ReturnProperty()
        {
            var expression    = ExpressionBody(() => Encoding.ASCII);
            var expectedValue = ExpressionUtilities.GetValueUsingCompile(expression);

            var value = ExpressionUtilities.GetValueWithoutCompiling(expression);

            Assert.That(value, Is.EqualTo(expectedValue));
        }
コード例 #6
0
        public void GetValue_Null_ReturnNull()
        {
            var expression    = ExpressionBody(() => (string)null);
            var expectedValue = ExpressionUtilities.GetValueUsingCompile(expression);

            var value = ExpressionUtilities.GetValueWithoutCompiling(expression);

            Assert.That(value, Is.EqualTo(expectedValue));
        }
コード例 #7
0
        public void GetValue_ConstantExpression_ReturnValue()
        {
            var expression    = ExpressionBody(() => "__String__");
            var expectedValue = ExpressionUtilities.GetValueUsingCompile(expression);

            var value = ExpressionUtilities.GetValueWithoutCompiling(expression);

            Assert.That(value, Is.EqualTo(expectedValue));
        }
コード例 #8
0
        public void GetValue_Local_ReturnLocal()
        {
            var local         = "__Local__";
            var expression    = ExpressionBody(() => local);
            var expectedValue = ExpressionUtilities.GetValueUsingCompile(expression);

            var value = ExpressionUtilities.GetValueWithoutCompiling(expression);

            Assert.That(value, Is.EqualTo(expectedValue));
        }
コード例 #9
0
        public void GetValue_Add_GetValueWithoutCompilingThrowsException()
        {
            var x             = 42;
            var expression    = ExpressionBody(() => x + 666);
            var expectedValue = ExpressionUtilities.GetValueUsingCompile(expression);

            var value = ExpressionUtilities.GetValue(expression);

            Assert.That(value, Is.EqualTo(expectedValue));
            Assert.Throws <Exception>(
                () => ExpressionUtilities.GetValueWithoutCompiling(expression));
        }