Exemple #1
0
 public void OpenFile_ConflictingArguments_Throws(FileMode mode, FileAccess access, FileShare share)
 {
     // arrange
     using (var driver = new DiskDriver())
     {
         // act/assert
         var e = Assert.ThrowsException <ArgumentException>(() =>
         {
             driver.OpenFile(FileIdentifier.FromPath(@"c:\unexisting\file.txt"),
                             mode,
                             access,
                             share);
         });
     }
 }
Exemple #2
0
 public void OpenFile_PathDoesntExist_Throws(FileMode mode)
 {
     // arrange
     using (var driver = new DiskDriver())
     {
         // act/assert
         Assert.ThrowsException <DirectoryNotFoundException>(() =>
         {
             driver.OpenFile(FileIdentifier.FromPath(@"c:\unexisting\file.txt"),
                             mode,
                             FileAccess.Write,
                             FileShare.Write);
         });
     }
 }
Exemple #3
0
        public void OpenFile_OpenMode_FileDoesntExist_Throws()
        {
            // arrange
            using (var driver = new DiskDriver())
            {
                driver.CreateOrGetDirectory(@"c:\temp");

                // act/assert
                Assert.ThrowsException <FileNotFoundException>(() =>
                {
                    driver.OpenFile(FileIdentifier.FromPath(@"c:\temp\file.txt"),
                                    FileMode.Open,
                                    FileAccess.ReadWrite,
                                    FileShare.ReadWrite);
                });
            }
        }
Exemple #4
0
        public void OpenFile_CreateNewMode_FileExists_Throws()
        {
            // arrange
            using (var driver = new DiskDriver())
            {
                driver.CreateOrGetFile(@"c:\temp\file.txt");

                // act/assert
                Assert.ThrowsException <IOException>(() =>
                {
                    driver.OpenFile(FileIdentifier.FromPath(@"c:\temp\file.txt"),
                                    FileMode.CreateNew,
                                    FileAccess.ReadWrite,
                                    FileShare.ReadWrite);
                });
            }
        }