public void can_find_value_in_an_expression_that_returns_a_dereferenced_value() { Assert.Equal(DateTime.MinValue, ValueExtractor.FindValueWithin(GetExpression(() => DateTime.MinValue))); Assert.Equal(decimal.MinValue, ValueExtractor.FindValueWithin(GetExpression(() => decimal.MinValue))); Assert.Equal(decimal.MaxValue, ValueExtractor.FindValueWithin(GetExpression(() => decimal.MaxValue))); Assert.Equal(decimal.MinusOne, ValueExtractor.FindValueWithin(GetExpression(() => decimal.MinusOne))); }
public void can_find_value_in_an_expression_that_includes_a_lambda() { Expression <Func <int, bool> > expression = x => x % 2 == 0; var value = ValueExtractor.FindValueWithin(expression); Assert.NotNull(value); var castValue = Assert.IsType <Func <int, bool> >(value); Assert.True(castValue(0)); Assert.False(castValue(1)); Assert.True(castValue(2)); Assert.False(castValue(3)); }
public void can_find_value_in_an_expression_that_requires_conversion(long value) { Assert.Equal((int)value, ValueExtractor.FindValueWithin(GetExpression(() => (int)value))); }
public void can_find_value_in_an_expression_that_news_up_an_object() { Assert.Equal(new DateTime(1979, 10, 26), ValueExtractor.FindValueWithin(GetExpression(() => new DateTime(1979, 10, 26)))); Assert.Equal(Tuple.Create("one", 1), ValueExtractor.FindValueWithin(GetExpression(() => new Tuple <string, int>("one", 1)))); }
public void can_find_value_in_an_expression_that_creates_an_array(object array) { Assert.Equal(array, ValueExtractor.FindValueWithin(GetExpression(() => array))); }
public void can_find_value_in_an_expression_that_returns_a_local_value(object value) { var local = value; Assert.Equal(value, ValueExtractor.FindValueWithin(GetExpression(() => local))); }
public void can_find_value_in_an_expression_that_simply_returns_a_constant(object value) { Assert.Equal(value, ValueExtractor.FindValueWithin(GetExpression(() => value))); }
public void can_find_value_in_a_binary_expression() { Assert.Equal(7, ValueExtractor.FindValueWithin(GetExpression(() => 3 + 1 + 3))); Assert.Equal(TimeSpan.FromSeconds(4), ValueExtractor.FindValueWithin(GetExpression(() => TimeSpan.FromSeconds(1) + TimeSpan.FromSeconds(3)))); }
public void can_find_null_in_an_expression() { Assert.Null(ValueExtractor.FindValueWithin(GetExpression(() => null))); }
public void can_find_value_in_a_method_invocation() { Assert.Equal(Tuple.Create("one", 1), ValueExtractor.FindValueWithin(GetExpression(() => Tuple.Create("one", 1)))); Assert.Equal(TimeSpan.FromSeconds(1), ValueExtractor.FindValueWithin(GetExpression(() => TimeSpan.FromSeconds(1)))); }