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))); }
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); } }
public void Expression_NullOrEmptyArgument_ShouldThrowArgumentNullExpression(string arg) { Assert.That(() => ExpressionReflection.Expression <DateTime>(arg), Throws.InstanceOf <ArgumentNullException>()); }