public void GetPropertyIndex_ShouldFind() { var comp = new ExpressionCompiler <Action>(); var lengthPi = typeof(string).GetProperty("Length"); var str = comp.Variable <string>("str"); var realIndex = comp.Property(str, lengthPi); var foundIndex = comp.GetPropertyIndex(lengthPi); Assert.Equal(realIndex, foundIndex); }
public void Compile_ShouldCreateDelegate() { var comp = new ExpressionCompiler <Func <string, int> >(); var lengthPi = typeof(string).GetProperty("Length"); var str = comp.Parameter <string>("str"); var strLength = comp.Property(str, lengthPi); comp.Emit(strLength); var dlg = comp.Compile(); Assert.NotNull(dlg); Assert.Equal(4, dlg("four")); }