private static void TestProperty(NeedsTesting target, PropertyInfo property) { bool result; property.SetValue(target, true); result = (bool)property.GetValue(target); VerifyEquals(result, true, string.Format("Property '{0}' failed to retain a 'true' value.", property.Name)); property.SetValue(target, false); result = (bool)property.GetValue(target); VerifyEquals(result, false, string.Format("Property '{0}' failed to retain a 'false' value.", property.Name)); }
private static void DoTest(NeedsTesting target) { Type type = typeof(NeedsTesting); PropertyInfo[] properties; int count = 0; properties = type.GetProperties(); foreach (PropertyInfo property in properties) { if (property.Name.StartsWith("Group")) { count++; TestProperty(target, property); } } if (count != 5) { VerifyEquals(false, true, "Did not find all 5 properties to test"); } }
static void Main() { NeedsTesting target = new NeedsTesting(); DoTest(target); }