public void ThrowsFileNotFoundExceptionWhenFileIsAlreadyDeleted()
            {
                var file = new PlatformFile(this.platformFile);

                FileSystemTest.DeletePlatformItem(this.platformFile);
                AssertEx.Throws <FileNotFoundException>(() => file.Open());
            }
            public void ThrowsFileNotFoundExceptionWhenFileIsDeleted()
            {
                var file = new PlatformFile(this.platformFile);

                FileSystemTest.DeletePlatformItem(this.platformFile);
                AssertEx.Throws <FileNotFoundException>(() => { var length = file.Length; });
            }
Exemple #3
0
            public void ThrowsIOExceptionWhenFileIsAlreadyDeleted()
            {
                IPlatformFolder folder = new PlatformFolder(this.storageFolder);

                FileSystemTest.DeletePlatformItem(this.storageFolder);

                AssertEx.Throws <DirectoryNotFoundException>(() => folder.Delete());
            }
Exemple #4
0
            public void ReturnsFalseWhenFolderDoesNotExist()
            {
                FileSystemTest.DeletePlatformItem(this.storageFolder);
                IPlatformFolder folder = new PlatformFolder(this.storageFolder);

                bool folderExists = folder.Exists();

                Assert.IsFalse(folderExists);
            }
Exemple #5
0
            public void ReturnsEmptyEnumerableWhenStorageFolderWasDeleted()
            {
                var folder = new PlatformFolder(this.storageFolder);

                FileSystemTest.DeletePlatformItem(this.storageFolder);
                IEnumerable <IPlatformFile> files = folder.GetFiles();

                Assert.IsNotNull(files);
                AssertEx.IsEmpty(files);
            }
Exemple #6
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));
            }
            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);
            }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing == true)
     {
         try
         {
             FileSystemTest.DeletePlatformItem(this.platformFile);
         }
         catch (IOException)
         {
             // File already deleted
         }
     }
 }
Exemple #10
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing == true)
     {
         try
         {
             FileSystemTest.DeletePlatformItem(this.storageFolder);
         }
         catch (COMException)
         {
             // WinRT exception if Folder is already deleted
         }
         catch (IOException)
         {
             // !WinRT exception if Folder is already deleted
         }
     }
 }