Great stuff on using NUnit in conjunction with external files from Patrick Cauldwell. It's one of those "Doh!" things that I've always MEANT to do, but somehow ended up using Pre- and Post-Build events instead. I MUCH prefer Patrick's method. It's much cleaner and it allows the once-external file to LIVE with the test.
[SetUp] public void SetUp() { Assembly a = Assembly.GetExecutingAssembly(); using (Stream s = a.GetManifestResourceStream("MyNameSpace.something.txt")) { using (StreamReader sr = new StreamReader(s)) { using (StreamWriter sw = File.CreateText(webConfigPath)) { sw.Write(sr.ReadToEnd()); sw.Flush(); } } } } [TearDown] public void TearDown() { if(File.Exists(webConfigPath)) { File.Delete(webConfigPath); } }
Scott at DevReach in Bulgaria in October
Developer Stand up Comedy - Coding 4 Fun
TechDays/DevDays Netherlands and Belgium:
Posts by Category Posts by Month
Greatest Hits Dev Tools List