예제 #1
0
        public void SimpleFileSystemProvider_OpenRead_WithNoFile_ShouldSwallowExceptionAndReturnNullStream()
        {
            if (SkipTests)
            {
                Assert.Inconclusive("Problems with one-time setup prevented the test from running.");
            }
            else
            {
                SimpleFileSystemProvider sfs = new SimpleFileSystemProvider();
                Stream fileStream            = null;

                fileStream = sfs.OpenRead(string.Empty);

                Assert.IsNull(fileStream, "No stream should have been returned for a file that doesn't exist.");
            }
        } // end test
예제 #2
0
        public void SimpleFileSystemProvider_OpenRead_WithValidFile_ShouldReturnFileContentsAsStream()
        {
            if (SkipTests)
            {
                Assert.Inconclusive("Problems with one-time setup prevented the test from running.");
            }
            else
            {
                SimpleFileSystemProvider sfs = new SimpleFileSystemProvider();
                Stream fileStream            = null;
                string expectedContents      = string.Concat("Line 1", Environment.NewLine, "Line 2", Environment.NewLine, "Line 3", Environment.NewLine);
                string actualContents        = string.Empty;
                using (var reader = new StreamReader(fileStream = sfs.OpenRead(this._targetFileName))) {
                    actualContents = reader.ReadToEnd();
                }

                Assert.AreEqual(expectedContents, actualContents, "The method did not open or read the file correctly.");
            }
        } // end test