public void ExpressionReturnsMethodCall() { var newExp = InstanceToIndexExpressionMaker <Model> .Replace(0, m => m.DoSomething()); var func = newExp.Compile(); var retval = func(new[] { new Model() }); Assert.AreEqual("Call", retval); }
public void ExpressionReturnsSelf() { var newExp = InstanceToIndexExpressionMaker <Model> .Replace(0, m => m); var func = newExp.Compile(); var retval = func(new[] { new Model() { Name = "Mark" } }); Assert.AreEqual("Mark", retval.Name); }
public void ExpressionUsesParentService() { var service = new SomeService(); var newExp = InstanceToIndexExpressionMaker <Model> .Replace(0, m => service.GetSomething(m)); var func = newExp.Compile(); var retval = func(new[] { new Model() { Id = 7 } }); Assert.AreEqual(7, retval); }
public void ExpressionReturnsChildProperty() { var newExp = InstanceToIndexExpressionMaker <Model> .Replace(0, m => m.Child.Name); var func = newExp.Compile(); var retval = func(new[] { new Model() { Child = new ChildModel() { Name = "Chris" } } }); Assert.AreEqual("Chris", retval); }