public void ArrayLengthPropertyWorks() { var prop = LambdaExtract.Property((string[] x) => x.Length); Assert.NotNull(prop); Assert.Equal("Length", prop.Name); }
public void GetMemberWorksTyped() { Assert.Equal(typeof(List <int>).Property("Count"), LambdaExtract.Property((List <int> l) => l.Count)); Assert.Equal(typeof(SomeClass1).Constructor(), LambdaExtract.Constructor(() => new SomeClass1())); Assert.Equal(typeof(string).Constructor(typeof(char), typeof(int)), LambdaExtract.Constructor(() => new string('c', 10))); Assert.Equal(typeof(SomeClass1).Property("P00"), LambdaExtract.Property((SomeClass1 tc) => tc.P00)); Assert.Equal(typeof(SomeClass1).Field("F2"), LambdaExtract.Field((SomeClass1 tc) => tc.F2)); Assert.Equal(typeof(object).Method("GetHashCode"), LambdaExtract.Method((SomeClass1 tc) => tc.GetHashCode())); Assert.Equal(typeof(Dictionary <string, double>).Property("Keys"), LambdaExtract.Property((Dictionary <string, double> d) => d.Keys)); Assert.Equal(typeof(SomeClass3).Property("Item"), LambdaExtract.Property((SomeClass3 d) => d[0])); Assert.Equal(typeof(TestClass2).Property("F3"), LambdaExtract.Property(() => TestClass2.F3)); Assert.Equal(typeof(TestClass2).Field("FStatic"), LambdaExtract.Field(() => TestClass2.FStatic)); }