So, how about making all the objects that you are testing share a common interface?
interface ITestable
{
void DoSomething();
}
and each object implements this interface differently:
class MySomething : ITestable
{
public void DoSomething()
{
//type specific implementation
}
}
class MyOtherSomething : ITestable
{
public void DoSomething()
{
//type specific implementation
}
}
Now:
foreach(ITestable testable in myTestablesList)
{
testable.DoSomething();
}
and all your switching logic disappears. Tada!