public void GetValue_PropertyThrowsException_ThrowsException() { var expression = ExpressionBody(() => PropertyThrowsException); Assert.Throws <Exception>( () => ExpressionUtilities.GetValue(expression)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }