virtual public bool TestGetCustomAttributes2(MemberInfo mem) { Util.print("\n\n" + this.GetType().ToString() + " - TestGetCustomAttributes2() started."); Util.print("For: " + mem.GetType().ToString() + "\n"); string strLoc = "L_31_000"; Object[] attrs = null; try { do { iCountTestcases++; strLoc = "L_31_001"; if (mem == null) { iCountErrors++; Util.printerr("E_31_75yhg - mem == null"); return(false); } iCountTestcases++; strLoc = "L_31_001.2"; attrs = mem.GetCustomAttributes(true); if (attrs == null) { iCountErrors++; Util.printerr("E_31_gfh4 - attrs == null"); return(false); } iCountTestcases++; strLoc = "L_31_001.3"; if (attrs.Length != iCountTotalAttrs) { iCountErrors++; Util.printerr("E_31_jhd3 - attrs.Length Failed!"); Util.print("Expected: " + iCountTotalAttrs + "; Returned: " + attrs.Length); Util.print(mem); } iCountTestcases++; strLoc = "L_31_001.3"; TestAttributes(attrs, mem); } while (false); } catch (Exception exc_runTest) { ++iCountErrors; Util.printerr("E_31_888un! - Uncaught Exception caught in TestGetCustomAttributes(); strLoc == " + strLoc); Util.printexc(exc_runTest); Util.print(exc_runTest.StackTrace); } if (iCountErrors == 0) { return(true); } else { return(false); } }
override public bool TestGetCustomAttribute_Type(ParameterInfo param) { Util.print("\n\n" + this.GetType().ToString() + " - TestGetCustomAttribute_Type() started."); Util.print("For ParamInfo on: " + param.Member.GetType().ToString() + "\n"); string strLoc = "L_2_000"; Attribute attr = null; try { do { iCountTestcases++; strLoc = "L_2_001"; iCountTestcases++; strLoc = "L_2_002.2"; attr = Attribute.GetCustomAttribute(param, typeof(ClassLib_Attributes.CA_AMfalse_INfalse), true); if (attr == null) { iCountErrors++; Util.printerr("E_2_gfh4 - attr == null"); } iCountTestcases++; strLoc = "L_2_001.4"; if (attr is ClassLib_Attributes.CA_AMfalse_INfalse) { if (((ClassLib_Attributes.CA_AMfalse_INfalse)attr).name.Equals("CA_AMfalse_INfalse2")) { iCountTestcases++; strLoc = "L_2_001.5"; if (!caAmfInf2.Equals(attr)) { iCountErrors++; Util.printerr("E_2_8d2p- caAmfInf2.Equals FAiLed!"); } } else { return(false); } } else { iCountErrors++; Util.printerr("E_2_9dus- UnExpected attr type! - " + attr.GetType().ToString()); } iCountTestcases++; strLoc = "L_3_002.2"; attr = Attribute.GetCustomAttribute(param, typeof(ClassLib_Attributes.CA_AMfalse_INtrue), true); if (attr == null) { iCountErrors++; Util.printerr("E_3_gfh4 - attr == null"); } iCountTestcases++; strLoc = "L_3_001.4"; if (attr is ClassLib_Attributes.CA_AMfalse_INtrue) { if (((ClassLib_Attributes.CA_AMfalse_INtrue)attr).name.Equals("CA_AMfalse_INtrue2")) { iCountTestcases++; strLoc = "L_3_001.5"; if (!caAmfInt2.Equals(attr)) { iCountErrors++; Util.printerr("E_3_8d2p- caAmfInt2.Equals FAiLed!"); } } else { iCountErrors++; Util.printerr("E_3_iu2h- UnExpected attr.name! - " + ((ClassLib_Attributes.CA_AMfalse_INtrue)attr).name); } } else { iCountErrors++; Util.printerr("E_3_9dus- UnExpected attr type! - " + attr.GetType().ToString()); } iCountTestcases++; strLoc = "L_4_002.2"; try { attr = Attribute.GetCustomAttribute(param, typeof(ClassLib_Attributes.CA_AMtrue_INtrue), true); if (!((param.Member is FieldInfo) || (param.Member is ConstructorInfo))) { iCountErrors++; Util.printerr("E_4_5_jhd3 - should 've thrown AmbiguousMatchException"); } } catch (AmbiguousMatchException) { } iCountTestcases++; strLoc = "L_5_002.2"; attr = Attribute.GetCustomAttribute(param, typeof(ClassLib_Attributes.CA_AMtrue_INfalse), true); if (attr == null) { iCountErrors++; Util.printerr("E_5_gfh4 - attr == null"); } iCountTestcases++; strLoc = "L_5_001.4"; if (attr is ClassLib_Attributes.CA_AMtrue_INfalse) { if (((ClassLib_Attributes.CA_AMtrue_INfalse)attr).name.Equals("CA_AMtrue_INfalse3")) { iCountTestcases++; strLoc = "L_5_001.5"; if (!caAmtInf3.Equals(attr)) { iCountErrors++; Util.printerr("E_5_8d2p5- caAmtInf3.Equals FAiLed!"); } } else { iCountErrors++; Util.printerr("E_5_djfh - UnExpected attr name! - " + ((ClassLib_Attributes.CA_AMtrue_INfalse)attr).name); } } else { iCountErrors++; Util.printerr("E_5_9dus- UnExpected attr type! - " + attr.GetType().ToString()); } iCountTestcases++; strLoc = "L_6_002.2"; try { attr = Attribute.GetCustomAttribute(param, typeof(System.Attribute), true); iCountErrors++; Util.printerr("E_6_5_jhd3 - should 've thrown AmbiguousMatchException"); } catch (AmbiguousMatchException) { } } while (false); } catch (Exception exc_runTest) { ++iCountErrors; Util.printerr("Err_333un! - Uncaught Exception caught in TestGetCustomAttribute_Type(); strLoc == " + strLoc); Util.printexc(exc_runTest); Util.print(exc_runTest.StackTrace); } if (iCountErrors == 0) { return(true); } else { return(false); } }
override public bool TestIsDefined_Type(ParameterInfo param) { Util.print("\n\n" + this.GetType().ToString() + " - TestIsDefined_Type() started."); Util.print("For ParamInfo on: " + param.Member.GetType().ToString() + "\n"); string strLoc = "L_2_000"; bool isattr = false; try { do { iCountTestcases++; strLoc = "L_2_001"; iCountTestcases++; strLoc = "L_2_002.2"; isattr = Attribute.IsDefined(param, typeof(ClassLib_Attributes.CA_AMfalse_INfalse), false); if (isattr) { iCountErrors++; Util.printerr("E_2_gfh4 - IsDefined returned true"); } iCountTestcases++; strLoc = "L_3_002.2"; isattr = Attribute.IsDefined(param, typeof(ClassLib_Attributes.CA_AMfalse_INtrue), true); if (param.Member is ConstructorInfo) { if (isattr) { iCountErrors++; Util.printerr("E_3_fkj2 - IsDefined returned true"); } } else if (!isattr) { iCountErrors++; Util.printerr("E_3_gfh4 - IsDefined returned false"); } iCountTestcases++; strLoc = "L_4_002.2"; isattr = Attribute.IsDefined(param, typeof(ClassLib_Attributes.CA_AMtrue_INtrue), true); if (param.Member is ConstructorInfo) { if (isattr) { iCountErrors++; Util.printerr("E_4_fkj2 - IsDefined returned true"); } } else if (!isattr) { iCountErrors++; Util.printerr("E_4_gfh4 - IsDefined returned false"); } iCountTestcases++; strLoc = "L_5_002.2"; isattr = Attribute.IsDefined(param, typeof(ClassLib_Attributes.CA_AMtrue_INfalse), false); if (!isattr) { iCountErrors++; Util.printerr("E_5_gfh4 - IsDefined returned false"); } iCountTestcases++; strLoc = "L_6_002.2"; isattr = Attribute.IsDefined(param, typeof(System.Attribute), true); if (!isattr) { iCountErrors++; Util.printerr("E_6_gfh4 - IsDefined returned false"); } } while (false); } catch (Exception exc_runTest) { ++iCountErrors; Util.printerr("Err_333un! - Uncaught Exception caught in TestIsDefined_Type(); strLoc == " + strLoc); Util.printexc(exc_runTest); Util.print(exc_runTest.StackTrace); } if (iCountErrors == 0) { return(true); } else { return(false); } }
override public bool TestGetCustomAttributes(ParameterInfo param) { Util.print("\n\n" + this.GetType().ToString() + " - TestGetCustomAttributes() started."); Util.print("For ParamInfo on: " + param.Member.GetType().ToString() + "\n"); string strLoc = "L_000"; Attribute[] attrs = null; try { do { iCountTestcases++; strLoc = "L_001"; if (param == null) { iCountErrors++; Util.printerr("E_75yhg - param == null"); return(false); } iCountTestcases++; strLoc = "L_001.2"; attrs = Attribute.GetCustomAttributes(param, true); if (attrs == null) { iCountErrors++; Util.printerr("E_gfh4 - attrs == null"); return(false); } iCountTestcases++; strLoc = "L_001.3"; if (param.Member is System.Reflection.ConstructorInfo) { if (attrs.Length != (iCountTotalAttrs - 2)) { iCountErrors++; Util.printerr("E_4_fk23 - attrs.Length != iCountTotalAttrs-2"); Util.print("Expected: " + (iCountTotalAttrs - 2) + ";Returned: " + attrs.Length); } } else if (attrs.Length != iCountTotalAttrs) { iCountErrors++; Util.printerr("E_jhd3 - attrs.Length Failed!"); Util.print("Expected: " + iCountTotalAttrs + "; Returned: " + attrs.Length); } iCountTestcases++; strLoc = "L_001.3"; TestAttributes(attrs, param.Member); } while (false); } catch (Exception exc_runTest) { ++iCountErrors; Util.printerr("Err_888un! - Uncaught Exception caught in TestGetCustomAttributes(); strLoc == " + strLoc); Util.printexc(exc_runTest); Util.print(exc_runTest.StackTrace); } if (iCountErrors == 0) { return(true); } else { return(false); } }
override public bool TestAttributes(Attribute[] attrs, MemberInfo mem) { string strLoc = "L_000"; String str = null; try { do { if (Util.DEBUG > 0) { Console.WriteLine("Number of attrs {0}", attrs.Length); } for (int i = 0; i < attrs.Length; i++) { iCountTestcases++; strLoc = "L_001.3.2"; str = attrs[i].ToString(); if (Util.DEBUG > 1) { Console.WriteLine("{0} : {1}\n\n", i, str); } iCountTestcases++; strLoc = "L_001.4"; if (attrs[i] is ClassLib_Attributes.CA_AMfalse_INfalse) { ClassLib_Attributes.CA_AMfalse_INfalse attr = (ClassLib_Attributes.CA_AMfalse_INfalse)attrs[i]; if (attr.name.Equals("CA_AMfalse_INfalse2")) { iCountTestcases++; strLoc = "L_001.5"; if (!caAmfInf2.Equals(attr)) { iCountErrors++; Util.printerr("E_8d2p- caAmfInf2.Equals FAiLed!"); } } else { iCountErrors++; Util.printerr("E_iu2h- UnExpected attr.name! - " + attr.name); } } else if (attrs[i] is ClassLib_Attributes.CA_AMfalse_INtrue) { ClassLib_Attributes.CA_AMfalse_INtrue attr = (ClassLib_Attributes.CA_AMfalse_INtrue)attrs[i]; if (attr.name.Equals("CA_AMfalse_INtrue2")) { iCountTestcases++; strLoc = "L_11_001.5"; if (!caAmfInt2.Equals(attr)) { iCountErrors++; Util.printerr("E_11_8d2p- caAmfInt2.Equals FAiLed!"); } } else { iCountErrors++; Util.printerr("E_11_iu2h- UnExpected attr.name! - " + attr.name); } } else if (attrs[i] is ClassLib_Attributes.CA_AMtrue_INtrue) { ClassLib_Attributes.CA_AMtrue_INtrue attr = (ClassLib_Attributes.CA_AMtrue_INtrue)attrs[i]; if (!(mem is System.Reflection.ConstructorInfo)) { if (attr.name.Equals("CA_AMtrue_INtrue")) { iCountTestcases++; strLoc = "L_12_001.5"; if (!caAmtInt.Equals(attr)) { iCountErrors++; Util.printerr("E_12_8d2p5- caAmtInt.Equals FAiLed!"); } } else if (attr.name.Equals("CA_AMtrue_INtrue2")) { iCountTestcases++; strLoc = "L_12_001.6"; if (!caAmtInt2.Equals(attr)) { iCountErrors++; Util.printerr("E_12_8d2p6- caAmtInt2.Equals FAiLed!"); } } else if (attr.name.Equals("CA_AMtrue_INtrue3")) { iCountTestcases++; strLoc = "L_12_001.6.2"; if (!caAmtInt3.Equals(attr)) { iCountErrors++; Util.printerr("E_12_dj2o - caAmtInt3.Equals FAiLed!"); } } else { iCountErrors++; Util.printerr("E_12_8dh2 - UnExpected attr.name! - " + attr.name); } } else if (attr.name.Equals("CA_AMtrue_INtrue3")) { iCountTestcases++; strLoc = "L_12_001.7"; if (!caAmtInt3.Equals(attr)) { iCountErrors++; Util.printerr("E_12_8d2p7- caAmtInt3.Equals FAiLed!"); } } else { iCountErrors++; Util.printerr("E_12_iu2h- UnExpected attr.name! - " + attr.name); } } else if (attrs[i] is ClassLib_Attributes.CA_AMtrue_INfalse) { ClassLib_Attributes.CA_AMtrue_INfalse attr = (ClassLib_Attributes.CA_AMtrue_INfalse)attrs[i]; if (attr.name.Equals("CA_AMtrue_INfalse3")) { iCountTestcases++; strLoc = "L_13_001.5"; if (!caAmtInf3.Equals(attr)) { iCountErrors++; Util.printerr("E_13_8d2p- caAmtInf3.Equals FAiLed!"); } } else { iCountErrors++; Util.printerr("E_13_iu2h- UnExpected attr.name! - " + attr.name); } } else { iCountErrors++; Util.printerr("E_iu2h- UnExpected attr type! - " + attrs[i].GetType().ToString()); } } } while (false); } catch (Exception exc_runTest) { ++iCountErrors; Util.printerr("Err_482un! - Uncaught Exception caught in TestAttributes(); strLoc == " + strLoc); Util.printexc(exc_runTest); Util.print(exc_runTest.StackTrace); } if (iCountErrors == 0) { return(true); } else { return(false); } }
public bool RunTest() { print(strPath + strTest + " RunTest() started."); string strLoc = "L_000"; MyClass myclass = new MyClass(); MyClass2 myclass2 = new MyClass2(); MemberInfo mem = null; MemberInfo mem2 = null; Attribute[] attrs = null; Attribute[] attrs2 = null; Type type = null; Type type2 = null; try { strLoc = "L_100_001"; iCountTestcases++; strLoc = "L_100_001.4"; try { attrs = Attribute.GetCustomAttributes((MemberInfo)null, true); iCountErrors++; Util.printerr("E_100_duo21 - Should 've thrown ArgNullExc"); } catch (ArgumentException) { } iCountTestcases++; strLoc = "L_100_001.4.2"; type = myclass.GetType(); mem = type.GetMethod("TestGetCustomAttributes"); if (mem == null) { iCountErrors++; Util.printerr("E_100_jkjs - mem == null"); } iCountTestcases++; strLoc = "L_100_001.5"; attrs = Attribute.GetCustomAttributes(mem, true); if (attrs == null) { iCountErrors++; Util.printerr("E_100_iudo - attrs == null"); return(false); } iCountTestcases++; strLoc = "L_100_001.6"; if (attrs.Length != 0 + 1) { iCountErrors++; Util.printerr("E_100_f3fw - attrs.Length != 1"); Util.print(attrs.Length); } iCountTestcases++; strLoc = "L_2_100_001.4.2"; type2 = myclass2.GetType(); mem2 = type2.GetMethod("TestGetCustomAttributes"); if (mem2 == null) { iCountErrors++; Util.printerr("E_2_100_jkjs - mem2 == null"); } iCountTestcases++; strLoc = "L_2_100_001.5"; attrs2 = Attribute.GetCustomAttributes(mem2, true); if (attrs2 == null) { iCountErrors++; Util.printerr("E_2_100_iudo - attrs2 == null"); return(false); } iCountTestcases++; strLoc = "L_2_100_001.6"; if (attrs2.Length != 0 + 1) { iCountErrors++; Util.printerr("E_2_100_f3fw - attrs2.Length != 1"); Util.print(attrs2.Length); } iCountTestcases++; strLoc = "L_100_001.7"; type = myclass.GetType(); mem = type; if (mem == null) { iCountErrors++; Util.printerr("E_100_skj2 - mem == null"); } else { myclass.TestGetCustomAttributes(mem); iCountTestcases++; strLoc = "L_100_001.7.2"; myclass.TestGetCustomAttributes2(mem); } iCountTestcases++; strLoc = "L_100_001.8"; mem = type.GetConstructor(Type.EmptyTypes); if (mem == null) { iCountErrors++; Util.printerr("E_100_001.8_skj2 - mem == null"); } else { myclass.TestGetCustomAttributes(mem); iCountTestcases++; strLoc = "L_100_001.8.2"; myclass.TestGetCustomAttributes2(mem); } iCountTestcases++; strLoc = "L_100_002"; mem = type.GetMethod("MyMethod"); if (mem == null) { iCountErrors++; Util.printerr("E_100_002_skj2 - mem == null"); } else { myclass.TestGetCustomAttributes(mem); iCountTestcases++; strLoc = "L_100_002.7.2"; myclass.TestGetCustomAttributes2(mem); } iCountTestcases++; strLoc = "L_100_003"; mem = type.GetField("MyField"); if (mem == null) { iCountErrors++; Util.printerr("E_100_003_skj2 - mem == null"); } else { myclass.TestGetCustomAttributes(mem); iCountTestcases++; strLoc = "L_100_003.7.2"; myclass.TestGetCustomAttributes2(mem); } iCountTestcases++; strLoc = "L_100_004"; mem = type.GetProperty("MyProp"); if (mem == null) { iCountErrors++; Util.printerr("E_100_004_skj2 - mem == null"); } else { myclass.TestGetCustomAttributes(mem); iCountTestcases++; strLoc = "L_100_004.7.2"; myclass.TestGetCustomAttributes2(mem); } iCountTestcases++; strLoc = "L_100_005"; mem = type.GetEvent("MyEvent"); if (mem == null) { iCountErrors++; Util.printerr("E_100_005_skj2 - mem == null"); } else { myclass.TestGetCustomAttributes(mem); iCountTestcases++; strLoc = "L_100_005.7.2"; myclass.TestGetCustomAttributes2(mem); } iCountTestcases++; strLoc = "L_2_100_001.7"; type2 = myclass2.GetType(); mem2 = type2; if (mem2 == null) { iCountErrors++; Util.printerr("E_2_100_skj2 - mem2 == null"); } else { myclass2.TestGetCustomAttributes(mem2); iCountTestcases++; strLoc = "L_2_100_001.7.2"; myclass2.TestGetCustomAttributes2(mem2); } iCountTestcases++; strLoc = "L_2_100_001.8"; mem2 = type2.GetConstructor(Type.EmptyTypes); if (mem2 == null) { iCountErrors++; Util.printerr("E_2_100_001.8_skj2 - mem2 == null"); } else { myclass2.TestGetCustomAttributes(mem2); iCountTestcases++; strLoc = "L_2_100_001.8.2"; myclass2.TestGetCustomAttributes2(mem2); } iCountTestcases++; strLoc = "L_2_100_002"; mem2 = type2.GetMethod("MyMethod"); if (mem2 == null) { iCountErrors++; Util.printerr("E_2_100_002_skj2 - mem2 == null"); } else { myclass2.TestGetCustomAttributes(mem2); iCountTestcases++; strLoc = "L_2_100_002.7.2"; myclass2.TestGetCustomAttributes2(mem2); } iCountTestcases++; strLoc = "L_2_100_003"; mem2 = type2.GetField("MyField", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly); if (mem2 == null) { iCountErrors++; Util.printerr("E_2_100_003_skj2 - mem2 == null"); } else { myclass2.TestGetCustomAttributes(mem2); iCountTestcases++; strLoc = "L_2_100_003.7.2"; myclass2.TestGetCustomAttributes2(mem2); } iCountTestcases++; strLoc = "L_2_100_004"; mem2 = type2.GetProperty("MyProp"); if (mem2 == null) { iCountErrors++; Util.printerr("E_2_100_004_skj2 - mem2 == null"); } else { myclass2.TestGetCustomAttributes(mem2); iCountTestcases++; strLoc = "L_2_100_004.7.2"; myclass2.TestGetCustomAttributes2(mem2); } iCountTestcases++; strLoc = "L_2_100_005"; mem2 = type2.GetEvent("MyEvent"); if (mem2 == null) { iCountErrors++; Util.printerr("E_2_100_005_skj2 - mem2 == null"); } else { myclass2.TestGetCustomAttributes(mem2); iCountTestcases++; strLoc = "L_2_100_005.7.2"; myclass2.TestGetCustomAttributes2(mem2); } } catch (Exception exc_runTest) { ++myclass2.iCountErrors; printerr("Err_888un! - Uncaught Exception caught in runTest(); strLoc == " + strLoc); printexc(exc_runTest); print(exc_runTest.StackTrace); } iCountErrors = myclass.iCountErrors + myclass2.iCountErrors; iCountTestcases = myclass.iCountTestcases + myclass2.iCountTestcases; if (iCountErrors == 0) { return(true); } else { print("Related Bugs: " + strBug); print("FAiL! " + strPath + strTest + " iCountErrors==" + iCountErrors.ToString()); return(false); } }
override public bool TestGetCustomAttributes2(MemberInfo mem) { Util.print("\n\n" + this.GetType().ToString() + " - TestGetCustomAttributes2() started."); Util.print("For: " + mem.GetType().ToString() + "\n"); string strLoc = "L_16_000"; Object[] attrs = null; try { do { iCountTestcases++; strLoc = "L_16_001"; if (mem == null) { iCountErrors++; Util.printerr("E_75yhg - mem == null"); return(false); } iCountTestcases++; strLoc = "L_16_001.1.1"; attrs = mem.GetCustomAttributes(false); if (attrs == null) { iCountErrors++; Util.printerr("E_16_dkd3 - attrs == null"); return(false); } if (attrs.Length != (iCountTotalAttrs - 2)) { iCountErrors++; Util.printerr("E_16_499s - attrs.Length != iCountTotalAttrs-2"); Util.print("Expected: " + (iCountTotalAttrs - 2) + ";Returned: " + attrs.Length); Util.print(mem); } iCountTestcases++; strLoc = "L_16_001.2"; attrs = mem.GetCustomAttributes(true); if (attrs == null) { iCountErrors++; Util.printerr("E_gfh4 - attrs == null"); return(false); } iCountTestcases++; strLoc = "L_16_001.3"; if ((mem is System.Reflection.FieldInfo) || (mem is System.Reflection.ConstructorInfo) || (mem is System.Reflection.PropertyInfo) || (mem is System.Reflection.EventInfo)) { if (attrs.Length != (iCountTotalAttrs - 2)) { iCountErrors++; Util.printerr("E_16_fk25 - attrs.Length != iCountTotalAttrs-2"); Util.print("Expected: " + (iCountTotalAttrs - 2) + ";Returned: " + attrs.Length); } } else { if (attrs.Length != iCountTotalAttrs) { iCountErrors++; Util.printerr("E_16_jhd4 - attrs.Length != iCountTotalAttrs"); Util.print("Expected: " + iCountTotalAttrs + "; Returned: " + attrs.Length); } } iCountTestcases++; strLoc = "L_16_001.3"; TestAttributes(attrs, mem); } while (false); } catch (Exception exc_runTest) { ++iCountErrors; Util.printerr("E_16_888un! - Uncaught Exception caught in TestGetCustomAttributes(); strLoc == " + strLoc); Util.printexc(exc_runTest); Util.print(exc_runTest.StackTrace); } if (iCountErrors == 0) { return(true); } else { return(false); } }
virtual public bool TestIsDefined_Type(MemberInfo mem) { Util.print("\n\n" + this.GetType().ToString() + " - TestIsDefined_Type() started."); Util.print("For: " + mem.GetType().ToString() + "\n"); string strLoc = "L_11_2_000"; bool isattr = false; try { do { iCountTestcases++; strLoc = "L_11_2_001"; iCountTestcases++; strLoc = "L_11_2_002.2"; isattr = Attribute.IsDefined(mem, typeof(ClassLib_Attributes.CA_AMfalse_INfalse), false); if (!isattr) { iCountErrors++; Util.printerr("E_11_2_gfh4 - IsDefined returned false"); } iCountTestcases++; strLoc = "L_11_3_002.2"; isattr = Attribute.IsDefined(mem, typeof(ClassLib_Attributes.CA_AMfalse_INtrue), true); if (!isattr) { iCountErrors++; Util.printerr("E_11_3_gfh4 - IsDefined returned false"); } iCountTestcases++; strLoc = "L_11_4_002.2"; isattr = Attribute.IsDefined(mem, typeof(ClassLib_Attributes.CA_AMtrue_INtrue), true); if (!isattr) { iCountErrors++; Util.printerr("E_11_4_gfh4 - IsDefined returned false"); } iCountTestcases++; strLoc = "L_11_5_002.2"; isattr = Attribute.IsDefined(mem, typeof(ClassLib_Attributes.CA_AMtrue_INfalse), false); if (!isattr) { iCountErrors++; Util.printerr("E_11_5_gfh4 - IsDefined returned false"); } iCountTestcases++; strLoc = "L_11_6_002.2"; isattr = Attribute.IsDefined(mem, typeof(System.Attribute), true); if (!isattr) { iCountErrors++; Util.printerr("E_11_6_gfh4 - IsDefined returned false"); } } while (false); } catch (Exception exc_runTest) { ++iCountErrors; Util.printerr("Err_333un! - Uncaught Exception caught in TestIsDefined_Type(); strLoc == " + strLoc); Util.printexc(exc_runTest); Util.print(exc_runTest.StackTrace); } if (iCountErrors == 0) { return(true); } else { return(false); } }
virtual public bool TestGetCustomAttribute_Type(MemberInfo mem) { Util.print("\n\n" + this.GetType().ToString() + " - TestGetCustomAttribute_Type() started."); Util.print("For: " + mem.GetType().ToString() + "\n"); string strLoc = "L_11_2_000"; Attribute attr = null; try { do { iCountTestcases++; strLoc = "L_11_2_001"; iCountTestcases++; strLoc = "L_11_2_002.2"; attr = Attribute.GetCustomAttribute(mem, typeof(ClassLib_Attributes.CA_AMfalse_INfalse), true); if (attr == null) { iCountErrors++; Util.printerr("E_11_2_gfh4 - attr == null"); } iCountTestcases++; strLoc = "L_11_2_001.4"; if (attr is ClassLib_Attributes.CA_AMfalse_INfalse) { if (((ClassLib_Attributes.CA_AMfalse_INfalse)attr).name.Equals("CA_AMfalse_INfalse")) { iCountTestcases++; strLoc = "L_11_2_001.5"; if (!caAmfInf.Equals(attr)) { iCountErrors++; Util.printerr("E_11_2_8d2p- caAmfInf2.Equals FAiLed!"); } } else { iCountErrors++; Util.printerr("E_11_2_iu2h- UnExpected attr.name! - " + ((ClassLib_Attributes.CA_AMfalse_INfalse)attr).name); } } else { iCountErrors++; Util.printerr("E_11_2_9dus- UnExpected attr type! - " + attr.GetType().ToString()); } iCountTestcases++; strLoc = "L_11_3_002.2"; attr = Attribute.GetCustomAttribute(mem, typeof(ClassLib_Attributes.CA_AMfalse_INtrue), true); if (attr == null) { iCountErrors++; Util.printerr("E_11_3_gfh4 - attr == null"); } iCountTestcases++; strLoc = "L_11_3_001.4"; if (attr is ClassLib_Attributes.CA_AMfalse_INtrue) { if (((ClassLib_Attributes.CA_AMfalse_INtrue)attr).name.Equals("CA_AMfalse_INtrue")) { iCountTestcases++; strLoc = "L_11_3_001.5"; if (!caAmfInt.Equals(attr)) { iCountErrors++; Util.printerr("E_11_3_8d2p- caAmfInt2.Equals FAiLed!"); } } else { iCountErrors++; Util.printerr("E_11_3_iu2h- UnExpected attr.name! - " + ((ClassLib_Attributes.CA_AMfalse_INtrue)attr).name); } } else { iCountErrors++; Util.printerr("E_11_3_9dus- UnExpected attr type! - " + attr.GetType().ToString()); } iCountTestcases++; strLoc = "L_11_4_002.2"; try { attr = Attribute.GetCustomAttribute(mem, typeof(ClassLib_Attributes.CA_AMtrue_INtrue), true); iCountErrors++; Util.printerr("E_11_4_jhd3 - should 've thrown AmbiguousMatchException"); } catch (AmbiguousMatchException) { } iCountTestcases++; strLoc = "L_11_5_002.2"; try { attr = Attribute.GetCustomAttribute(mem, typeof(ClassLib_Attributes.CA_AMtrue_INfalse), true); iCountErrors++; Util.printerr("E_11_5_jhd3 - should 've thrown AmbiguousMatchException"); } catch (AmbiguousMatchException) { } iCountTestcases++; strLoc = "L_11_6_002.2"; try { attr = Attribute.GetCustomAttribute(mem, typeof(System.Attribute), true); iCountErrors++; Util.printerr("E_11_6_jhd3 - should 've thrown AmbiguousMatchException"); } catch (AmbiguousMatchException) { } } while (false); } catch (Exception exc_runTest) { ++iCountErrors; Util.printerr("Err_333un! - Uncaught Exception caught in TestGetCustomAttribute_Type(); strLoc == " + strLoc); Util.printexc(exc_runTest); Util.print(exc_runTest.StackTrace); } if (iCountErrors == 0) { return(true); } else { return(false); } }