Example #1
0
        public void Expression_NotNullArgument_ShouldReturnExpressionCallingSpecifiedProperty()
        {
            //Arrange
            var expression = ExpressionReflection.Expression <DateTime>("Day");
            var argument   = DateTime.Now;

            Assert.That(argument.Day, Is.EqualTo(expression.Compile().Invoke(argument)));
        }
Example #2
0
 private static Expression <Func <ComponentInterface, object> > ParseOrderByParameter(string orderBy)
 {
     Contract.Ensures(Contract.Result <Expression <Func <ComponentInterface, object> > >() != null);
     try
     {
         return(ExpressionReflection.Expression <ComponentInterface>(orderBy));
     }
     catch (Exception ex)
     {
         throw new InvalidInputException(string.Format(Messages.InvalidOrderByParameterMsg, orderBy), ex);
     }
 }
Example #3
0
 public void Expression_NullOrEmptyArgument_ShouldThrowArgumentNullExpression(string arg)
 {
     Assert.That(() => ExpressionReflection.Expression <DateTime>(arg),
                 Throws.InstanceOf <ArgumentNullException>());
 }