示例#1
0
 public void ThrowsUnauthorizedAccessExceptionWhenProcessDoesNotHaveRightToCreateFile()
 {
     using (new DirectoryAccessDenier(this.storageFolder, FileSystemRights.CreateFiles))
     {
         var folder = new PlatformFolder(this.storageFolder);
         AssertEx.Throws <UnauthorizedAccessException>(() => folder.CreateFile(FileSystemTest.GetUniqueFileName()));
     }
 }
示例#2
0
            public void CreatesFileWithSpecifiedName()
            {
                var folder = new PlatformFolder(this.storageFolder);

                string        fileName = GetUniqueFileName();
                IPlatformFile file     = folder.CreateFile(fileName);

                Assert.AreEqual(fileName, file.Name);
            }
示例#3
0
            public void ThrowsIOExceptionWhenFileWithThatNameAlreadyExists()
            {
                string fileName = GetUniqueFileName();

                FileSystemTest.CreatePlatformFile(fileName, this.storageFolder);

                var folder = new PlatformFolder(this.storageFolder);

                AssertEx.Throws <IOException>(() => folder.CreateFile(fileName));
            }
示例#4
0
            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));
            }
示例#5
0
            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);
            }
示例#6
0
 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);
            }
示例#10
0
            public void ThrowsArgumentExceptionWhenDesiredFileNameIsEmpty()
            {
                var folder = new PlatformFolder(this.storageFolder);

                AssertEx.Throws <ArgumentException>(() => folder.CreateFile(string.Empty));
            }
示例#11
0
            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));
 }
示例#13
0
            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));
 }