In the code given below:
Assembly _assembly = Assembly.LoadFile(AssembleyPath);
Type[] types = _assembly.GetExportedTypes();
foreach (Type type in types)
{
Attribute _classAttribute = type.GetCustomAttribute(typeof(TestClassAttribute));
if (_classAttribute != null)
{
TreeNode _n = new TreeNode();
_n.Text = type.Name;
if (type.Name.ToLower().Contains("testbase"))
// For exculding test base class from tree node list
continue;
MemberInfo[] members =
type.GetMembers(BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.Default);
foreach (MemberInfo member in members)
{
Attribute _att = member.GetCustomAttribute(typeof(TestMethodAttribute));
if (_att != null)
{
var _t = type.GetMethod(member.Name);
var testCategories = _t.GetCustomAttributes(typeof(TestCategoryAttribute));
}
}
}
}
I want to extract test category value which i can see while i debug in the Quickwatch window by expanding the elements but when i try to access it using the dot operator i'm unable to access it.
when i hover my mouse on testCategories (last line of the code), i see {Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute[3]} On further expanding the arrary say at index 0 i see TestCategories and TypeId. On expanding TestCategories i see the value i want to use but when i try to access in the code, i'm only able to access TypeId. I'm unable to access TestCategories. Is there any way by which i can access it? I tried accessing it using lambda expression like this: testCategories.Any(c => c == "xyz")
but it doesn't yield anything.
Aucun commentaire:
Enregistrer un commentaire