I’ve got a class that takes a string for the path to an xml file and outputs an object. I want to test the class using NUnit with some pre generated test scripts.
I have the scripts in a zip file and included in the project. I want to do something like this:
// Not sure how to do this
List<byte[]> scripts = GetTheScriptsSomehow();
foreach(var script in scripts )
{
var parsedScript = ScriptParser.Parse(script);
Assert.AreEqual(parsedScript.Blah, "BLAH");
}
The part I’m most concerned with is how to access the scripts that are zipped and part of the project.
Thanks!
Edit: To address some of the comments, the zip file is part of a unit test project, not the released codebase. It contains test scripts that should produce a known output that is testable. They’re zipped because the scripts are rather large (100mb each)
Add this zip file in resources (project properties / resources / Add Resource / Add existing file), and use SharpZipLib to extract it from zip, let’s say that your zip file is
code to extract scripts in string :
Here are some examples of SharpZipLib usage :
http://wiki.sharpdevelop.net/SharpZipLib-Zip-Samples.ashx