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 UpdatesNamePropertyToReflectChange() { var file = new PlatformFile(this.platformFile); string newName = GetUniqueFileName(); file.Rename(newName); Assert.AreEqual(newName, file.Name); }
public void ThrowsFileNotFoundExceptionWhenFileIsAlreadyDeleted() { var file = new PlatformFile(this.platformFile); FileSystemTest.DeletePlatformItem(this.platformFile); string newName = GetUniqueFileName(); AssertEx.Throws <FileNotFoundException>(() => file.Rename(newName)); }
public void ThrowsIOExceptionWhenFileWithDesiredNameAlreadyExists() { var file = new PlatformFile(this.platformFile); string newName = GetUniqueFileName(); var conflictingFile = FileSystemTest.CreatePlatformFile(newName); AssertEx.Throws <IOException>(() => file.Rename(newName)); FileSystemTest.DeletePlatformItem(conflictingFile); }
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 RenamesFileInFileSystem() { var file = new PlatformFile(this.platformFile); string oldName = GetPlatformFileName(this.platformFile); string newName = Guid.NewGuid().ToString("N"); file.Rename(newName); AssertEx.Throws <FileNotFoundException>(() => FileSystemTest.GetPlatformFile(oldName)); Assert.IsNotNull(FileSystemTest.GetPlatformFile(newName)); }
public void ThrowsIOExceptionWhenDesiredFileNameIsTooLong() { bool expectedException = false; try { var file = new PlatformFile(this.platformFile); file.Rename(new string('F', 1024)); } catch (PathTooLongException) { expectedException = true; } catch (IOException) { // NET CORE 3.0 changed the exception that can be thrown. expectedException = true; } Assert.IsTrue(expectedException); }
public void ThrowsIOExceptionWhenFileIsAlreadyOpen() { var file = new PlatformFile(this.platformFile); using (Stream previouslyOpenedStream = FileSystemTest.OpenPlatformFile(this.platformFile)) { Assert.Throws<IOException>(() => file.Open()); } }
public void ThrowsArgumentNullExceptionWhenDesiredNameIsNull() { var file = new PlatformFile(this.platformFile); AssertEx.Throws <ArgumentNullException>(() => file.Rename(null)); }
public void ThrowsUnauthorizedAccessExceptionWhenProcessHasNoRightToWriteToFile() { using (new FileAccessDenier(this.platformFile, FileSystemRights.Write)) { var file = new PlatformFile(this.platformFile); Assert.Throws<UnauthorizedAccessException>(() => file.Open()); } }
public void ThrowsArgumentNullExceptionWhenDesiredNameIsNull() { var file = new PlatformFile(this.platformFile); Assert.Throws<ArgumentNullException>(() => file.Rename(null)); }
public void UpdatesNamePropertyToReflectChange() { var file = new PlatformFile(this.platformFile); string newName = GetUniqueFileName(); file.Rename(newName); Assert.Equal(newName, file.Name); }
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); }
public void ReturnsNameOfGivenPlatformFile() { var file = new PlatformFile(this.platformFile); Assert.AreEqual(FileSystemTest.GetPlatformFileName(this.platformFile), file.Name); }
public void ThrowsArgumentExceptionWhenDesiredFileNameIsEmpty() { var file = new PlatformFile(this.platformFile); Assert.Throws<ArgumentException>(() => file.Rename(string.Empty)); }
public void ThrowsIOExceptionWhenDesiredFileNameIsTooLong() { var file = new PlatformFile(this.platformFile); Assert.Throws<PathTooLongException>(() => file.Rename(new string('F', 1024))); }
public void ThrowsIOExceptionWhenFileWithDesiredNameAlreadyExists() { var file = new PlatformFile(this.platformFile); string newName = GetUniqueFileName(); var conflictingFile = FileSystemTest.CreatePlatformFile(newName); Assert.Throws<IOException>(() => file.Rename(newName)); FileSystemTest.DeletePlatformItem(conflictingFile); }
public void ThrowsFileNotFoundExceptionWhenFileIsAlreadyDeleted() { var file = new PlatformFile(this.platformFile); FileSystemTest.DeletePlatformItem(this.platformFile); string newName = GetUniqueFileName(); Assert.Throws<FileNotFoundException>(() => file.Rename(newName)); }
public void ThrowsFileNotFoundExceptionWhenFileIsAlreadyDeleted() { var file = new PlatformFile(this.platformFile); FileSystemTest.DeletePlatformItem(this.platformFile); Assert.Throws<FileNotFoundException>(() => file.Open()); }
public void ThrowsIOExceptionWhenDesiredFileNameIsTooLong() { var file = new PlatformFile(this.platformFile); AssertEx.Throws <PathTooLongException>(() => file.Rename(new string('F', 1024))); }
public void ReturnsNameOfGivenPlatformFile() { var file = new PlatformFile(this.platformFile); Assert.Equal(FileSystemTest.GetPlatformFileName(this.platformFile), file.Name); }
public void RenamesFileInFileSystem() { var file = new PlatformFile(this.platformFile); string oldName = GetPlatformFileName(this.platformFile); string newName = Guid.NewGuid().ToString("N"); file.Rename(newName); Assert.Throws<FileNotFoundException>(() => FileSystemTest.GetPlatformFile(oldName)); Assert.NotNull(FileSystemTest.GetPlatformFile(newName)); }
public void ThrowsArgumentExceptionWhenDesiredFileNameIsEmpty() { var file = new PlatformFile(this.platformFile); AssertEx.Throws <ArgumentException>(() => file.Rename(string.Empty)); }
public void ReturnsDateCreatedOfGivenPlatformFile() { var file = new PlatformFile(this.platformFile); Assert.Equal(FileSystemTest.GetPlatformFileDateCreated(this.platformFile), file.DateCreated); }
public void ReturnsDateCreatedOfGivenPlatformFile() { var file = new PlatformFile(this.platformFile); Assert.AreEqual(FileSystemTest.GetPlatformFileDateCreated(this.platformFile), file.DateCreated); }
public void DeletesFileFromFileSystem() { var file = new PlatformFile(this.platformFile); file.Delete(); Assert.Throws<FileNotFoundException>(() => FileSystemTest.GetPlatformFile(FileSystemTest.GetPlatformFileName(this.platformFile))); }