I want to write tests to check the existance (and other stuff) of certain files that will be shipped with our project.
This is what I have right now:
[DeploymentItem("1.pdf")]
[DeploymentItem("2.pdf")]
public class DoFilesExist
{
List<string> _Files;
public DoFilesExist()
{
_Files = new List<string>();
_Files.Add("1.pdf");
_Files.Add("2.pdf");
}
delegate void fileTest(string fileName);
void Map(fileTest test)
{
foreach (string file in _Files)
{
test(file);
}
}
[TestMethod]
public void TestExists()
{
Map( x => Assert.IsTrue(File.Exists(x), x + " doesn't exist") );
}
}
As you can see, when I want to add another file to test, I have to add to the [DeploymentItem] and the _Files List
Is there a way to Dynamically Change the DeploymentItems? Or to grab from them during run time. I will probably end up having over 30 files here, and I do not want two lists.
Thanks in advance!