public void OpenDocument_ForNonExistingFile_ReturnsNull()
        {
            InNewTempDirectory(path =>
            {
                var source   = new DirectoryDocumentSource(path);
                var document = new DocumentInfo("text.txt", source);

                using (var reader = source.OpenDocument(document))
                {
                    Assert.That(reader, Is.Null);
                }
            });
        }
 public void OpenDocument_ForLockedFile_Fails()
 {
     InNewTempDirectory(path =>
     {
         var destFile = CopyContentFilesTo("text.txt", path).Single();
         var source   = new DirectoryDocumentSource(path);
         var document = source.FindAllDocuments().SingleAsync().Wait();
         using (File.Open(destFile, FileMode.Open, FileAccess.ReadWrite, FileShare.None))
         {
             Assert.That(() => source.OpenDocument(document), Throws.InstanceOf <IOException>());
         }
     });
 }
        public void OpenDocument_ForExistingFile_ReturnsStream()
        {
            InNewTempDirectory(path =>
            {
                CopyContentFilesTo("text.txt", path);
                var source   = new DirectoryDocumentSource(path);
                var document = source.FindAllDocuments().SingleAsync().Wait();

                using (var reader = source.OpenDocument(document))
                {
                    Assert.That(reader, Is.Not.Null);
                    Assert.That(reader.ReadLine(), Is.Not.Empty);
                }
            });
        }