2008-03-28 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Fri, 28 Mar 2008 19:12:44 +0000 (19:12 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Fri, 28 Mar 2008 19:12:44 +0000 (19:12 -0000)
* IsolatedStorageFileTest.cs: Add test cases for creating directory
(bug #372377) and also getting delaing with subdirectories.

svn path=/trunk/mcs/; revision=99233

mcs/class/corlib/Test/System.IO.IsolatedStorage/ChangeLog
mcs/class/corlib/Test/System.IO.IsolatedStorage/IsolatedStorageFileTest.cs

index 0b9564130ff15600a0ebbcff3d6555b49917e280..e2ca48ad6fee227e83da841e70848a19c983b3e0 100644 (file)
@@ -1,3 +1,8 @@
+2008-03-28  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * IsolatedStorageFileTest.cs: Add test cases for creating directory 
+       (bug #372377) and also getting delaing with subdirectories.
+
 2008-01-17  Sebastien Pouliot  <sebastien@ximian.com>
 
        * IsolatedStorageFileTest.cs: Added test case against regression of
index 411db7957924a4410d98d4ac6aa11cc2a84626ff..6f50c3c446d7e29f29b34cac34d4cbb64e53c587 100644 (file)
@@ -411,5 +411,64 @@ namespace MonoTests.System.IO.IsolatedStorageTest {
                        
                        Assert.AreEqual (expected, actual);
                }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void CreateDirectory_Null ()
+               {
+                       IsolatedStorageFile.GetUserStoreForAssembly ().CreateDirectory (null);
+               }
+
+               [Test]
+               public void CreateDirectory_FileWithSameNameExists ()
+               {
+                       string path = "bug374377";
+                       using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForDomain ()) {
+                               using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream (path, FileMode.OpenOrCreate, isf)) {
+                               }
+                               try {
+                                       isf.CreateDirectory (path);
+                               }
+                               catch (IOException ex) {
+                                       Assert.AreEqual (typeof (IOException), ex.GetType (), "Type");
+                                       // don't leak path information
+                                       Assert.IsFalse (ex.Message.IndexOf (path) >= 0, "Message");
+                                       Assert.IsNull (ex.InnerException, "InnerException");
+                               }
+                       }
+               }
+
+               [Test]
+               public void CreateDirectory_DirectoryWithSameNameExists ()
+               {
+                       string dir = "new-dir";
+                       string file = Path.Combine (dir, "new-file");
+                       IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
+                       try {
+                               isf.CreateDirectory (dir);
+                               using (IsolatedStorageFileStream isfs = new IsolatedStorageFileStream (file, FileMode.OpenOrCreate, isf)) {
+                                       isfs.WriteByte (0);
+                               }
+                               string pattern = Path.Combine (dir, "*");
+                               Assert.AreEqual (1, isf.GetFileNames (file).Length, "file exists");
+
+                               // create again directory
+                               isf.CreateDirectory (dir);
+                               Assert.AreEqual (1, isf.GetFileNames (file).Length, "file still exists");
+                       }
+                       finally {
+                               isf.DeleteFile (file);
+                               isf.DeleteDirectory (dir);
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (SecurityException))]
+               public void GetFilesInSubdirs ()
+               {
+                       IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
+                       string pattern = Path.Combine ("..", "*");
+                       isf.GetFileNames (pattern);
+               }
        }
 }