public void TestSimpleNArraySet() { var props = typeof(WithLists).GetProperties() .Where(pd => pd.GetCustomAttributes <PropertyDefinitionAttribute>().Any()) .Select(GetPropertyDef); var w = new WithLists(); props.First(pd => pd.Name == "NIntArray").Set(w, new int?[] { 1, 2, 3, null }.AsEnumerable()); Assert.AreEqual(4, w.NIntArray.Count()); }
public void TestSimpleIEnumerableSet() { var props = typeof(WithLists).GetProperties().Select(GetPropertyDef); var w = new WithLists(); props.First(pd => pd.Name == "StringEs").Set(w, new List <string> { "asdf", "qwer", null }.AsEnumerable()); Assert.AreEqual(3, w.StringEs.Count()); }
public void TestSimpleNArraySetNullProp() { var props = typeof(WithLists).GetProperties() .Where(pd => pd.GetCustomAttributes <PropertyDefinitionAttribute>().Any()) .Select(GetPropertyDef); var w = new WithLists(); var prop = props.First(pd => pd.Name == "NIntArray") as IProp <List <int?> >; prop.Set(w, null); Assert.AreEqual(null, w.NIntArray); }
public void TestSimpleNArrayGet() { var props = typeof(WithLists).GetProperties() .Where(pd => pd.GetCustomAttributes <PropertyDefinitionAttribute>().Any()) .Select(GetPropertyDef); var w = new WithLists(); w.NIntArray = new int?[] { 1, 2, 3, null }; var prop = props.First(pd => pd.Name == "NIntArray") as IProp <List <int?> >; var actual = prop.Get(w); Assert.AreEqual(4, actual.Count); }
public void TestSimpleIEnumerableGet() { var props = typeof(WithLists).GetProperties().Select(GetPropertyDef); var w = new WithLists(); w.StringEs = new List <string> { "asdf", "qwer", null }; var prop = props.First(pd => pd.Name == "StringEs") as IProp <List <string> >; var actual = prop.Get(w); Assert.AreEqual(3, actual.Count); }