Keep in mind, currently, you only get the list of the attribute names and don't have access to the values (if any). The latter is on our list to add.
private bool IsTestMethod()
{
SubMain.GhostDoc.T4.Attribute[] attributes = Context.CurrentCodeElement.Attributes;
if(attributes != null)
{
foreach(SubMain.GhostDoc.T4.Attribute attribute in attributes)
{
if(string.Compare(attribute.Name, "TestAttribute", false) == 0 || string.Compare(attribute.Name, "Test", false) == 0 ||
string.Compare(attribute.Name, "TestCaseAttribute", false) == 0 || string.Compare(attribute.Name, "TestCase", false) == 0 ||
string.Compare(attribute.Name, "TestMethodAttribute", false) == 0 || string.Compare(attribute.Name, "TestMethod", false) == 0 ||
string.Compare(attribute.Name, "FactAttribute", false) == 0 || string.Compare(attribute.Name, "Fact", false) == 0 ||
string.Compare(attribute.Name, "TheoryAttribute", false) == 0 || string.Compare(attribute.Name, "Theory", false) == 0 ||
string.Compare(attribute.Name, "RowTestAttribute", false) == 0 || string.Compare(attribute.Name, "RowTest", false) == 0 ||
string.Compare(attribute.Name, "RowAttribute", false) == 0 || string.Compare(attribute.Name, "Row", false) == 0)
{
return true;
}
}
}
return false;
}