public void GetAllProperties() { var item1 = new Item(); var item2 = new ChildItem(); var item3 = new ChildChildItem(); var itemProperties1 = item1.GetType() .GetAllProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public) .ToArray(); var itemProperties2 = item2.GetType() .GetAllProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public) .ToArray(); var itemProperties3 = item3.GetType() .GetAllProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public) .ToArray(); Assert.AreEqual(2, itemProperties1.Length); Assert.AreEqual(5, itemProperties2.Length); Assert.AreEqual(7, itemProperties3.Length); }
public void GetTopFields() { var item1 = new Item(); var item2 = new ChildItem(); var item3 = new ChildChildItem(); var fields1 = item1.GetType() .GetTopFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public) .ToArray(); var fields2 = item2.GetType() .GetTopFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public) .ToArray(); var fields3 = item3.GetType() .GetTopFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public) .ToArray(); Assert.AreEqual(2, fields1.Length); Assert.AreEqual(4, fields2.Length); Assert.AreEqual(5, fields3.Length); }