Exemple #1
0
 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)));
 }
Exemple #2
0
        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));
        }
Exemple #3
0
 public void can_find_value_in_an_expression_that_requires_conversion(long value)
 {
     Assert.Equal((int)value, ValueExtractor.FindValueWithin(GetExpression(() => (int)value)));
 }
Exemple #4
0
 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))));
 }
Exemple #5
0
 public void can_find_value_in_an_expression_that_creates_an_array(object array)
 {
     Assert.Equal(array, ValueExtractor.FindValueWithin(GetExpression(() => array)));
 }
Exemple #6
0
        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)));
        }
Exemple #7
0
 public void can_find_value_in_an_expression_that_simply_returns_a_constant(object value)
 {
     Assert.Equal(value, ValueExtractor.FindValueWithin(GetExpression(() => value)));
 }
Exemple #8
0
 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))));
 }
Exemple #9
0
 public void can_find_null_in_an_expression()
 {
     Assert.Null(ValueExtractor.FindValueWithin(GetExpression(() => null)));
 }
Exemple #10
0
 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))));
 }