public void ThrowsFileNotFoundExceptionWhenFileIsAlreadyDeleted() { var file = new PlatformFile(this.platformFile); FileSystemTest.DeletePlatformItem(this.platformFile); AssertEx.Throws <FileNotFoundException>(() => file.Open()); }
public void ThrowsUnauthorizedAccessExceptionWhenProcessHasNoRightToWriteToFile() { using (new FileAccessDenier(this.platformFile, FileSystemRights.Write)) { var file = new PlatformFile(this.platformFile); AssertEx.Throws <UnauthorizedAccessException>(() => file.Open()); } }
public void ThrowsUnauthorizedAccessExceptionWhenProcessHasNoRightToWriteToFile() { // Only on Windows as the APIs are not available in Linux. using (new FileAccessDenier(this.platformFile, FileSystemRights.Write)) { var file = new PlatformFile(this.platformFile); AssertEx.Throws <UnauthorizedAccessException>(() => file.Open()); } }
public void ThrowsIOExceptionWhenFileIsAlreadyOpen() { var file = new PlatformFile(this.platformFile); using (Stream previouslyOpenedStream = FileSystemTest.OpenPlatformFile(this.platformFile)) { AssertEx.Throws <IOException>(() => file.Open()); } }
public void ReturnsStreamThatCanBeUsedToModifyFileContents() { var file = new PlatformFile(this.platformFile); var writtenBytes = new byte[] { 4, 2 }; PlatformFileTest.WriteBytesAndDispose(file.Open(), writtenBytes); byte[] readBytes = ReadBytesAndDispose(FileSystemTest.OpenPlatformFile(this.platformFile)); AssertEx.AreEqual(writtenBytes, readBytes); }
public void ThrowsUnauthorizedAccessExceptionWhenProcessHasNoRightToWriteToFile() { using (new FileAccessDenier(this.platformFile, FileSystemRights.Write)) { var file = new PlatformFile(this.platformFile); Assert.Throws<UnauthorizedAccessException>(() => file.Open()); } }
public void ThrowsIOExceptionWhenFileIsAlreadyOpen() { var file = new PlatformFile(this.platformFile); using (Stream previouslyOpenedStream = FileSystemTest.OpenPlatformFile(this.platformFile)) { Assert.Throws<IOException>(() => file.Open()); } }
public void ThrowsFileNotFoundExceptionWhenFileIsAlreadyDeleted() { var file = new PlatformFile(this.platformFile); FileSystemTest.DeletePlatformItem(this.platformFile); Assert.Throws<FileNotFoundException>(() => file.Open()); }
public void ReturnsStreamThatCanBeUsedToModifyFileContents() { var file = new PlatformFile(this.platformFile); var writtenBytes = new byte[] { 4, 2 }; PlatformFileTest.WriteBytesAndDispose(file.Open(), writtenBytes); byte[] readBytes = ReadBytesAndDispose(FileSystemTest.OpenPlatformFile(this.platformFile)); Assert.Equal(writtenBytes, readBytes); }