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); }); } }
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); }); } }
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); }); } }
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); }); } }