Ejemplo n.º 1
0
        public void TryGetContents_WhenFileDoesNotExist_ReturnsNullAndFalse()
        {
            var fileInfo = new FileInfo(@"C:\This\File\Does\Not\Exist.xxx");

            using (var inspector = new LazyFileInspector(fileInfo))
            {
                string returnedContents;
                Assert.IsFalse(inspector.TryGetContents(out returnedContents));
                Assert.IsNull(returnedContents);
            }
        }
Ejemplo n.º 2
0
        public void TryGetContents_WhenFileExists_ReturnsContentsAndTrue()
        {
            string path = SpecialPathPolicy.For <LazyFileInspectorTest>().CreateTempFileWithUniqueName().FullName;

            File.WriteAllText(path, "Contents");

            var fileInfo = new FileInfo(path);

            using (var inspector = new LazyFileInspector(fileInfo))
            {
                string returnedContents;
                Assert.IsTrue(inspector.TryGetContents(out returnedContents));
                Assert.AreEqual("Contents", returnedContents);
            }
        }