I’ve got unit tests I want to run against a sample XML file. How should I go about exposing these files to the unit tests? I’ve tried playing with the content build action, but I don’t have access to an application context so GetContentStream is out.
I’m aware I can use a DataContext to a SQL Database, but I feel this is the wrong approach.
If you are looking to deploy the XML file with your tests, you have a few options:
Embedded Content
You can embed the Xml file as content within the assembly.
Example:
DeploymentItemAttribute
You can annotate the test method or class with a [DeploymentItemAttribute]. The file path is relative to the solution.
Test Settings
You can deploy individual files or entire directories using the Deployment configuration inside the Test Settings file. (Tests -> Edit Settings -> Filename.testsettings)