public void PreferPassingInMemoryStreamsRatherThanFilePath() { string s = "Hello World"; using (ClassUsingFile unit = new ClassUsingFile(StreamContaining(s))) { Assert.That(unit.GetStreamContents(), Is.EqualTo(s)); } }
public void ExampleOfHowToWriteTestThatUsesPhysicalFiles() { //strictly if a test touches the file system its not a unit test //(ie a unit test must be fast)! FileInfo file = TempFile.CreateWithContents("Hello"); using (ClassUsingFile unit = new ClassUsingFile(file.FullName)) { Assert.That(unit.GetStreamContents(), Is.EqualTo("Hello")); } }