public void PropertyAccessModiferOnNotNullableMember() { IExpressionRewriter modifier = new PropertyAccessRewriter(); Expression <Func <Member, int> > expression = m => m.GroupId2; Expression newBody = modifier.Rewrite(expression.Body); expression = ExpressionUtils.ChangeBody(expression, newBody); int?result = expression.Compile().Invoke(null); }
public void PropertyAccessModiferOnCastedMember() { IExpressionRewriter modifier = new PropertyAccessRewriter(); Expression <Func <Member, int?> > expression = m => (int?)m.GroupId2; Expression newBody = modifier.Rewrite(expression.Body); expression = ExpressionUtils.ChangeBody(expression, newBody); int?result = expression.Compile().Invoke(null); Assert.IsNull(result); }
public void PropertyAccessModiferOnConvertedStaticMember() { IExpressionRewriter modifier = new PropertyAccessRewriter(); Expression <Func <DateTime?> > expression = () => (DateTime?)DateTime.Now; Expression newBody = modifier.Rewrite(expression.Body); expression = ExpressionUtils.ChangeBody(expression, newBody); DateTime?result = expression.Compile().Invoke(); Assert.IsNotNull(result); }
public void PropertyAccessModiferOnMappedNullableMember() { IExpressionRewriter modifier = new PropertyAccessRewriter(); Expression <Func <Member, string> > expression = m => m.GroupId == null ? "null" : "not null"; Expression newBody = modifier.Rewrite(expression.Body); expression = ExpressionUtils.ChangeBody(expression, newBody); string result = expression.Compile().Invoke(null); Assert.AreEqual("null", result); }
public void PropertyAccessModiferOnStaticMember() { IExpressionRewriter modifier = new PropertyAccessRewriter(); Expression <Func <string> > expression = () => PropertyAccessModifierFixture.Static; Expression newBody = modifier.Rewrite(expression.Body); expression = ExpressionUtils.ChangeBody(expression, newBody); string result = expression.Compile().Invoke(); Assert.IsNotNull(result); }