Is it possible with a custom data source attribute. An example can be:
public class XmlCustomDataSourceAttribute : Attribute, ITestDataSource
{
public IEnumerable<object[]> GetData(MethodInfo methodInfo)
{
foreach (var environment in YourStaticXmlParser.GetEnvironments())
{
yield return new object[] { environment.Name };
}
}
public string GetDisplayName(MethodInfo methodInfo, object[] data)
{
if (data != null)
{
return string.Format("Target Environmment- {0} ({1})", methodInfo.Name, data[0]);
}
return null;
}
}
and the test method should look like:
[DataTestMethod]
[XmlCustomDataSource]
public void Should_Blur(string environmentName)
{
var actualEnvironment = SomeMethodToGetActualEnvironment();
Assert.AreEqual(environmentName, actualEnvironment);
}
Finally your test detail will be:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…