public void ThrowsUnauthorizedAccessExceptionWhenProcessDoesNotHaveRightToCreateFile() { using (new DirectoryAccessDenier(this.storageFolder, FileSystemRights.CreateFiles)) { var folder = new PlatformFolder(this.storageFolder); AssertEx.Throws <UnauthorizedAccessException>(() => folder.CreateFile(FileSystemTest.GetUniqueFileName())); } }
public void CreatesFileWithSpecifiedName() { var folder = new PlatformFolder(this.storageFolder); string fileName = GetUniqueFileName(); IPlatformFile file = folder.CreateFile(fileName); Assert.AreEqual(fileName, file.Name); }
public void ThrowsIOExceptionWhenFileWithThatNameAlreadyExists() { string fileName = GetUniqueFileName(); FileSystemTest.CreatePlatformFile(fileName, this.storageFolder); var folder = new PlatformFolder(this.storageFolder); AssertEx.Throws <IOException>(() => folder.CreateFile(fileName)); }
public void RecreatesFolderIfItWasDeleted() { var folder = new PlatformFolder(this.storageFolder); FileSystemTest.DeletePlatformItem(this.storageFolder); string fileName = GetUniqueFileName(); folder.CreateFile(fileName); Assert.IsNotNull(FileSystemTest.GetPlatformFile(fileName, this.storageFolder)); }
public void CreatesPhysicalFileInFileSystem() { var folder = new PlatformFolder(this.storageFolder); string fileName = GetUniqueFileName(); IPlatformFile file = folder.CreateFile(fileName); var storageFile = FileSystemTest.GetPlatformFile(fileName, this.storageFolder); Assert.IsNotNull(storageFile); }
public void ThrowsUnauthorizedAccessExceptionWhenProcessDoesNotHaveRightToCreateFile() { Trace.WriteLine(string.Format("{0} Blocking Listing Permission on: {1} ", DateTime.Now.ToLongTimeString(), this.storageFolder.FullName)); // Only on Windows as the APIs are not available in Linux. // The product also does not this this. using (new DirectoryAccessDenier(this.storageFolder, FileSystemRights.CreateFiles)) { var folder = new PlatformFolder(this.storageFolder); AssertEx.Throws <UnauthorizedAccessException>(() => folder.CreateFile(FileSystemTest.GetUniqueFileName())); } }
public void ThrowsIOExceptionWhenDesiredFileNameIsTooLong() { bool expectedException = false; try { var folder = new PlatformFolder(this.storageFolder); folder.CreateFile(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 ThrowsIOExceptionWhenFileWithThatNameAlreadyExists() { string fileName = GetUniqueFileName(); FileSystemTest.CreatePlatformFile(fileName, this.storageFolder); var folder = new PlatformFolder(this.storageFolder); Assert.Throws<IOException>(() => folder.CreateFile(fileName)); }
public void CreatesFileWithSpecifiedName() { var folder = new PlatformFolder(this.storageFolder); string fileName = GetUniqueFileName(); IPlatformFile file = folder.CreateFile(fileName); Assert.Equal(fileName, file.Name); }
public void ThrowsArgumentExceptionWhenDesiredFileNameIsEmpty() { var folder = new PlatformFolder(this.storageFolder); AssertEx.Throws <ArgumentException>(() => folder.CreateFile(string.Empty)); }
public void ThrowsIOExceptionWhenDesiredFileNameIsTooLong() { var folder = new PlatformFolder(this.storageFolder); AssertEx.Throws <PathTooLongException>(() => folder.CreateFile(new string('F', 1024))); }
public void ThrowsArgumentNullExceptionWhenGivenFileNameIsNull() { var folder = new PlatformFolder(this.storageFolder); Assert.Throws<ArgumentNullException>(() => folder.CreateFile(null)); }
public void ThrowsArgumentNullExceptionWhenGivenFileNameIsNull() { var folder = new PlatformFolder(this.storageFolder); AssertEx.Throws <ArgumentNullException>(() => folder.CreateFile(null)); }
public void ThrowsArgumentExceptionWhenDesiredFileNameIsEmpty() { var folder = new PlatformFolder(this.storageFolder); Assert.Throws<ArgumentException>(() => folder.CreateFile(string.Empty)); }
public void ThrowsIOExceptionWhenDesiredFileNameIsTooLong() { var folder = new PlatformFolder(this.storageFolder); Assert.Throws<PathTooLongException>(() => folder.CreateFile(new string('F', 1024))); }
public void CreatesPhysicalFileInFileSystem() { var folder = new PlatformFolder(this.storageFolder); string fileName = GetUniqueFileName(); IPlatformFile file = folder.CreateFile(fileName); var storageFile = FileSystemTest.GetPlatformFile(fileName, this.storageFolder); Assert.NotNull(storageFile); }
public void ThrowsUnauthorizedAccessExceptionWhenProcessDoesNotHaveRightToCreateFile() { using (new DirectoryAccessDenier(this.storageFolder, FileSystemRights.CreateFiles)) { var folder = new PlatformFolder(this.storageFolder); Assert.Throws<UnauthorizedAccessException>(() => folder.CreateFile(FileSystemTest.GetUniqueFileName())); } }
public void RecreatesFolderIfItWasDeleted() { var folder = new PlatformFolder(this.storageFolder); FileSystemTest.DeletePlatformItem(this.storageFolder); string fileName = GetUniqueFileName(); folder.CreateFile(fileName); Assert.NotNull(FileSystemTest.GetPlatformFile(fileName, this.storageFolder)); }