I use this code in our scripts to determine whether I am running in a test item or not:
function NotRunningInTestItem()
{
return !Project.TestItems.Current;
}
For your purposes, to get a test name you could do something along the lines:
var testName;
if (NotRunningInTestItem())
testName = "unknown";
else
testName = Project.TestItems.Current.Name;
Or if you want to be terse:
var testName = !Project.TestItems.Current ? "unknown" : Project.TestItems.Current.Name;
As far as distinguishing whether you're running the Suite or an individual Project, I don't know how you would do that.