Exemplo n.º 1
0
        public void PreferPassingInMemoryStreamsRatherThanFilePath()
        {
            string s = "Hello World";

            using (ClassUsingFile unit = new ClassUsingFile(StreamContaining(s)))
            {
                Assert.That(unit.GetStreamContents(), Is.EqualTo(s));
            }
        }
Exemplo n.º 2
0
        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"));
            }
        }