c3d4e01665ac4b9900e6e8080589393a984a1b70
[mono.git] / mcs / class / corlib / Test / System.IO.IsolatedStorage / IsolatedStorageFileTest.cs
1 //
2 // IsolatedStorageFileTest.cs 
3 //      - Unit Tests for abstract IsolatedStorageFile class
4 //
5 // Author:
6 //      Sebastien Pouliot  <sebastien@ximian.com>
7 //
8 // Copyright (C) 2005 Novell Inc. (http://www.novell.com)
9 // Copyright 2011 Xamarin Inc (http://www.xamarin.com).
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 using System;
32 using System.Collections;
33 using System.IO;
34 using System.IO.IsolatedStorage;
35 using System.Reflection;
36 using System.Security;
37 using System.Security.Permissions;
38 using System.Security.Policy;
39
40 using NUnit.Framework;
41
42 namespace MonoTests.System.IO.IsolatedStorageTest {
43
44         [TestFixture]
45         public class IsolatedStorageFileTest {
46
47                 private const string dirname = "mono-unit-test";
48
49                 private void CheckEnumerated (int n, IsolatedStorageScope scope, IsolatedStorageFile isf)
50                 {
51                         string prefix = n.ToString () + " - " + scope.ToString () + " - ";
52                         Assert.IsNotNull (isf, prefix + "IsolatedStorageFile");
53                         Assert.IsTrue (((scope & isf.Scope) != 0), prefix + "Scope");
54
55                         if ((isf.Scope & IsolatedStorageScope.Assembly) != 0)
56                                 Assert.IsNotNull (isf.AssemblyIdentity, prefix + "AssemblyIdentity");
57                         if ((isf.Scope & IsolatedStorageScope.Domain) != 0)
58                                 Assert.IsNotNull (isf.DomainIdentity, prefix + "DomainIdentity");
59 #if NET_2_0
60                         if ((isf.Scope & IsolatedStorageScope.Application) != 0)
61                                 Assert.IsNotNull (isf.ApplicationIdentity, prefix + "ApplicationIdentity");
62 #endif
63                 }
64
65                 private void GetEnumerator (IsolatedStorageScope scope)
66                 {
67                         IEnumerator e = IsolatedStorageFile.GetEnumerator (scope);
68                         int n = 0;
69                         while (e.MoveNext ())
70                         {
71                                 IsolatedStorageFile isf = (IsolatedStorageFile)e.Current;
72                                 CheckEnumerated (++n, scope, isf);
73                         }
74                 }
75
76                 [Test]
77                 public void GetEnumerator_User ()
78                 {
79                         GetEnumerator (IsolatedStorageScope.User);
80                 }
81
82                 [Test]
83                 [ExpectedException (typeof (ArgumentException))]
84                 public void GetEnumerator_User_Details ()
85                 {
86                         // giving more details is bad
87                         GetEnumerator (IsolatedStorageScope.User | IsolatedStorageScope.Assembly | IsolatedStorageScope.Domain);
88                 }
89
90                 [Test]
91                 public void GetEnumerator_UserRoaming ()
92                 {
93                         GetEnumerator (IsolatedStorageScope.User | IsolatedStorageScope.Roaming);
94                 }
95
96                 [Test]
97                 [ExpectedException (typeof (ArgumentException))]
98                 public void GetEnumerator_UserRoaming_Details ()
99                 {
100                         // giving more details is bad
101                         GetEnumerator (IsolatedStorageScope.User | IsolatedStorageScope.Assembly | IsolatedStorageScope.Domain | IsolatedStorageScope.Roaming);
102                 }
103 #if NET_2_0
104                 [Test]
105                 public void GetEnumerator_Machine ()
106                 {
107                         GetEnumerator (IsolatedStorageScope.Machine);
108                 }
109
110                 [Test]
111                 [ExpectedException (typeof (ArgumentException))]
112                 public void GetEnumerator_Machine_Details ()
113                 {
114                         GetEnumerator (IsolatedStorageScope.Machine | IsolatedStorageScope.Assembly);
115                 }
116
117                 [Test]
118                 [ExpectedException (typeof (ArgumentException))]
119                 public void GetEnumerator_Application ()
120                 {
121                         // we can't enum application
122                         GetEnumerator (IsolatedStorageScope.Application);
123                 }
124 #endif
125                 [Test]
126                 public void GetUserStoreForAssembly ()
127                 {
128                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
129                         Assert.AreEqual (Int64.MaxValue, isf.MaximumSize, "MaximumSize");
130                         Assert.AreEqual (IsolatedStorageScope.User | IsolatedStorageScope.Assembly, isf.Scope, "Scope");
131 #if !NET_2_1
132                         Assert.IsTrue ((isf.AssemblyIdentity is Url), "AssemblyIdentity");
133                         // note: mono transforms the CodeBase into uppercase
134                         // for net 1.1 which uses file:// and not file:///
135                         string codebase = Assembly.GetExecutingAssembly ().CodeBase.ToUpper ().Substring (8);
136                         Assert.IsTrue ((isf.AssemblyIdentity.ToString ().ToUpper ().IndexOf (codebase) > 0), "Url");
137                         Assert.IsTrue ((isf.AssemblyIdentity.ToString ().ToUpper ().IndexOf (codebase) > 0), "Url");
138 #endif
139                         Assert.IsTrue ((isf.CurrentSize >= 0), "CurrentSize");
140                 }
141
142                 [Test]
143                 [ExpectedException (typeof (InvalidOperationException))]
144                 public void GetUserStoreForAssembly_DomainIdentity ()
145                 {
146                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
147                         object o = isf.DomainIdentity;
148                 }
149
150 #if NET_2_0
151                 [Test]
152                 [ExpectedException (typeof (InvalidOperationException))]
153                 public void GetUserStoreForAssembly_ApplicationIdentity ()
154                 {
155                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
156                         object o = isf.ApplicationIdentity;
157                 }
158 #endif
159
160                 [Test]
161                 public void GetUserStoreForDomain ()
162                 {
163                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForDomain ();
164                         Assert.AreEqual (Int64.MaxValue, isf.MaximumSize, "MaximumSize");
165                         Assert.AreEqual (IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly, isf.Scope, "Scope");
166 #if !NET_2_1
167                         Assert.IsTrue ((isf.AssemblyIdentity is Url), "AssemblyIdentity");
168                         // note: mono transforms the CodeBase into uppercase
169                         // for net 1.1 which uses file:// and not file:///
170                         string codebase = Assembly.GetExecutingAssembly ().CodeBase.ToUpper ().Substring (8);
171                         Assert.IsTrue ((isf.AssemblyIdentity.ToString ().ToUpper ().IndexOf (codebase) > 0), "Url");
172                         Assert.IsTrue ((isf.DomainIdentity is Url), "DomainIdentity");
173                         // note: with MS Assembly.GetEntryAssembly () only works in the default (first) AppDomain
174                         // so we're using the first parameter to GetCommandLineArgs
175                         string exe = Environment.GetCommandLineArgs ()[0].Replace ("\\", "/").ToUpper ();
176                         Assert.IsTrue ((isf.DomainIdentity.ToString ().ToUpper ().IndexOf (exe) > 0), exe + "\n" + isf.DomainIdentity.ToString ().ToUpper ()); //"Url - Domain");
177 #endif
178                         Assert.IsTrue ((isf.CurrentSize >= 0), "CurrentSize");
179                 }
180
181 #if NET_2_0
182                 [Test]
183                 [ExpectedException (typeof (InvalidOperationException))]
184                 public void GetUserStoreForDomain_ApplicationIdentity ()
185                 {
186                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForDomain ();
187                         object o = isf.ApplicationIdentity;
188                 }
189
190                 [Test]
191 #if !MOBILE
192                 [ExpectedException (typeof (IsolatedStorageException))]
193 #endif
194                 public void GetUserStoreForApplication_WithoutApplicationIdentity ()
195                 {
196                         // note: a manifest is required
197                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication ();
198                 }
199
200                 [Test]
201 #if !MOBILE
202                 [ExpectedException (typeof (IsolatedStorageException))]
203 #endif
204                 public void GetUserStoreForApplication ()
205                 {
206                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication ();
207                         Assert.AreEqual (Int64.MaxValue, isf.MaximumSize, "MaximumSize");
208 #if !NET_2_1
209                         Assert.AreEqual (IsolatedStorageScope.User | IsolatedStorageScope.Assembly, isf.Scope, "Scope");
210                         Assert.IsTrue ((isf.AssemblyIdentity is Url), "AssemblyIdentity");
211                         Assert.IsTrue ((isf.AssemblyIdentity.ToString ().IndexOf (Assembly.GetExecutingAssembly ().CodeBase) > 0), "Url");
212 #endif
213                         Assert.IsTrue ((isf.CurrentSize >= 0), "CurrentSize");
214                 }
215                 
216 #if !NET_2_1
217                 [Test]
218                 [ExpectedException (typeof (IsolatedStorageException))]
219                 public void GetUserStoreForApplication_AssemblyIdentity ()
220                 {
221                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication ();
222                         object o = isf.AssemblyIdentity;
223                 }
224
225                 [Test]
226                 [ExpectedException (typeof (IsolatedStorageException))]
227                 public void GetUserStoreForApplication_DomainIdentity ()
228                 {
229                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication ();
230                         object o = isf.DomainIdentity;
231                 }
232 #endif
233 #endif
234
235 #if NET_4_0
236                 // This is supposed to be working only in SL.
237                 [Test]
238                 [ExpectedException (typeof (NotSupportedException))]
239                 public void GetUserStoreForSite ()
240                 {
241                         IsolatedStorageFile.GetUserStoreForSite ();
242                 }
243 #endif
244
245                 [Test]
246                 public void GetStore_Domain_Zone ()
247                 {
248                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly;
249                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, typeof (Zone), typeof (Zone));
250                         Assert.AreEqual (Int64.MaxValue, isf.MaximumSize, "MaximumSize");
251 #if !NET_2_1
252                         Assert.AreEqual (IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly, isf.Scope, "Scope");
253                         Assert.IsTrue ((isf.AssemblyIdentity is Zone), "AssemblyIdentity");
254                         Assert.IsTrue ((isf.AssemblyIdentity.ToString ().IndexOf ("MyComputer") > 0), "Zone - Assembly");
255                         Assert.IsTrue ((isf.DomainIdentity is Zone), "DomainIdentity");
256                         Assert.IsTrue ((isf.DomainIdentity.ToString ().IndexOf ("MyComputer") > 0), "Zone - Domain");
257 #endif
258                         Assert.IsTrue ((isf.CurrentSize >= 0), "CurrentSize");
259                 }
260
261                 [Test]
262 #if !MOBILE
263                 [ExpectedException (typeof (IsolatedStorageException))]
264 #endif
265                 public void GetStore_Domain_NonPresentEvidences ()
266                 {
267                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly;
268                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, typeof (StrongName), typeof (Publisher));
269                 }
270
271                 [Test]
272                 public void GetStore_Assembly_NonPresentDomainEvidences ()
273                 {
274                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Assembly;
275                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, typeof (StrongName), typeof (Url));
276                         Assert.AreEqual (Int64.MaxValue, isf.MaximumSize, "MaximumSize");
277                         Assert.AreEqual (scope, isf.Scope, "Scope");
278 #if !NET_2_1
279                         Assert.IsTrue ((isf.AssemblyIdentity is Url), "AssemblyIdentity");
280                         // note: mono transforms the CodeBase into uppercase
281                         // for net 1.1 which uses file:// and not file:///
282                         string codebase = Assembly.GetExecutingAssembly ().CodeBase.ToUpper ().Substring (8);
283                         Assert.IsTrue ((isf.AssemblyIdentity.ToString ().ToUpper ().IndexOf (codebase) > 0), "Url");
284                         // DomainIdentity throws a InvalidOperationException
285 #endif
286                         Assert.IsTrue ((isf.CurrentSize >= 0), "CurrentSize");
287                 }
288
289 #if !MOBILE
290                 [Test]
291                 [ExpectedException (typeof (ArgumentNullException))]
292                 public void GetStore_Domain_DomainNullObject ()
293                 {
294                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly;
295                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, (object)null, new Zone (SecurityZone.MyComputer));
296                 }
297
298                 [Test]
299                 [ExpectedException (typeof (ArgumentNullException))]
300                 public void GetStore_Domain_AssemblyNullObject ()
301                 {
302                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly;
303                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, new Zone (SecurityZone.MyComputer), (object)null);
304                 }
305
306                 [Test]
307                 public void GetStore_Assembly_DomainNullObject ()
308                 {
309                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Assembly;
310                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, (object)null, new Zone (SecurityZone.Internet));
311                         Assert.AreEqual (Int64.MaxValue, isf.MaximumSize, "MaximumSize");
312                         Assert.AreEqual (scope, isf.Scope, "Scope");
313                         Assert.IsTrue ((isf.AssemblyIdentity is Zone), "AssemblyIdentity");
314                         Assert.IsTrue ((isf.AssemblyIdentity.ToString ().IndexOf ("Internet") > 0), "Zone - Assembly");
315                         Assert.IsTrue ((isf.CurrentSize >= 0), "CurrentSize");
316                 }
317
318                 [Test]
319                 [ExpectedException (typeof (ArgumentNullException))]
320                 public void GetStore_Assembly_AssemblyNullObject ()
321                 {
322                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Assembly;
323                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, new Zone (SecurityZone.MyComputer), (object)null);
324                 }
325
326                 [Test]
327                 public void GetStore_Domain_ZoneObjectZoneObject ()
328                 {
329                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly;
330                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, new Zone (SecurityZone.Internet), new Zone (SecurityZone.Internet));
331                         Assert.AreEqual (Int64.MaxValue, isf.MaximumSize, "MaximumSize");
332                         Assert.AreEqual (scope, isf.Scope, "Scope");
333                         Assert.IsTrue ((isf.AssemblyIdentity is Zone), "AssemblyIdentity");
334                         Assert.IsTrue ((isf.AssemblyIdentity.ToString ().IndexOf ("Internet") > 0), "Zone - Assembly");
335                         Assert.IsTrue ((isf.DomainIdentity is Zone), "DomainIdentity");
336                         Assert.IsTrue ((isf.DomainIdentity.ToString ().IndexOf ("Internet") > 0), "Zone - Domain");
337                         Assert.IsTrue ((isf.CurrentSize >= 0), "CurrentSize");
338                 }
339 #endif
340
341                 [Test]
342                 [ExpectedException (typeof (ArgumentNullException))]
343                 public void GetStore_Application_NullObject ()
344                 {
345                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Application;
346                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, (object)null);
347                 }
348
349                 [Test]
350 #if !MOBILE
351                 [ExpectedException (typeof (IsolatedStorageException))]
352 #endif
353                 public void GetStore_Application_NullType ()
354                 {
355                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Application;
356                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, (Type)null);
357                         // again it's the lack of a manifest
358                 }
359
360 #if !MOBILE
361                 [Test]
362                 public void GetStore_DomainScope_Evidences ()
363                 {
364                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly;
365
366                         Evidence de = new Evidence ();
367                         de.AddHost (new Zone (SecurityZone.Internet));
368                         Evidence ae = new Evidence ();
369                         ae.AddHost (new Zone (SecurityZone.Intranet));
370                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, de, typeof (Zone), ae, typeof (Zone));
371
372                         // Maximum size for Internet isn't (by default) Int64.MaxValue
373                         Assert.AreEqual (scope, isf.Scope, "Scope");
374 #if !NET_2_1
375                         Assert.IsTrue ((isf.AssemblyIdentity is Zone), "AssemblyIdentity");
376                         Assert.IsTrue ((isf.AssemblyIdentity.ToString ().IndexOf ("Intranet") > 0), "Zone - Assembly");
377                         Assert.IsTrue ((isf.DomainIdentity is Zone), "DomainIdentity");
378                         Assert.IsTrue ((isf.DomainIdentity.ToString ().IndexOf ("Internet") > 0), isf.DomainIdentity.ToString ()); //"Zone - Domain");
379 #endif
380                         Assert.IsTrue ((isf.CurrentSize >= 0), "CurrentSize");
381                 }
382
383                 [Test]
384                 [ExpectedException (typeof (ArgumentNullException))]
385                 public void GetStore_DomainScope_Evidence_NullAssemblyEvidence ()
386                 {
387                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly;
388
389                         Evidence de = new Evidence ();
390                         de.AddHost (new Zone (SecurityZone.Internet));
391                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, de, typeof (Zone), null, null);
392                 }
393
394                 [Test]
395                 [ExpectedException (typeof (ArgumentNullException))]
396                 public void GetStore_DomainScope_Evidence_NullDomainEvidence ()
397                 {
398                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly;
399
400                         Evidence ae = new Evidence ();
401                         ae.AddHost (new Zone (SecurityZone.Internet));
402                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, null, null, ae, typeof (Zone));
403                 }
404
405                 [Test]
406                 [ExpectedException (typeof (ArgumentNullException))]
407                 public void GetStore_AssemblyScope_Evidence_NullAssemblyEvidence ()
408                 {
409                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Assembly;
410
411                         Evidence de = new Evidence ();
412                         de.AddHost (new Zone (SecurityZone.Internet));
413                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, de, typeof (Zone), null, null);
414                 }
415
416                 [Test]
417                 public void GetStore_AssemblyScope_Evidence_NullDomainEvidence ()
418                 {
419                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Assembly;
420
421                         Evidence ae = new Evidence ();
422                         ae.AddHost (new Zone (SecurityZone.Internet));
423                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, null, null, ae, typeof (Zone));
424                 }
425 #endif
426
427                 [Test]
428                 public void RegressionBNC354539 ()
429                 {
430                         string filename = "test-bnc-354539";
431                         byte[] expected = new byte[] { 0x01, 0x42, 0x00 };
432                         byte[] actual = new byte [expected.Length];
433
434                         using (IsolatedStorageFile file = IsolatedStorageFile.GetStore (IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null)) {
435                                 using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream (filename, FileMode.Create, FileAccess.Write, FileShare.None, file)) {
436                                         stream.Write (expected, 0, expected.Length);
437                                 }
438                         }
439
440                         using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForAssembly ()) {
441                                 using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream (filename, FileMode.Open, FileAccess.Read, FileShare.Read, file)) {
442                                         stream.Read (actual, 0, actual.Length);
443                                 }
444
445                                 file.DeleteFile (filename);
446                         }
447                         
448                         Assert.AreEqual (expected, actual);
449                 }
450
451                 [Test]
452                 [ExpectedException (typeof (ArgumentNullException))]
453                 public void CreateDirectory_Null ()
454                 {
455                         IsolatedStorageFile.GetUserStoreForAssembly ().CreateDirectory (null);
456                 }
457
458                 [Test]
459                 public void CreateDirectory_FileWithSameNameExists ()
460                 {
461                         string path = "bug374377";
462                         using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForDomain ()) {
463                                 using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream (path, FileMode.OpenOrCreate, isf)) {
464                                 }
465                                 try {
466                                         isf.CreateDirectory (path);
467                                 }
468 #if NET_4_0
469                                 catch (IsolatedStorageException ex) {
470                                         Assert.IsFalse (ex.Message.IndexOf (path) >= 0, "Message");
471                                         Assert.IsNull (ex.InnerException, "InnerException");
472                                 }
473 #else
474                                 catch (IOException ex) {
475                                         Assert.AreEqual (typeof (IOException), ex.GetType (), "Type");
476                                         // don't leak path information
477                                         Assert.IsFalse (ex.Message.IndexOf (path) >= 0, "Message");
478                                         Assert.IsNull (ex.InnerException, "InnerException");
479                                 }
480 #endif
481                         }
482                 }
483
484                 [Test]
485                 public void CreateDirectory_DirectoryWithSameNameExists ()
486                 {
487                         string dir = "new-dir";
488                         string file = Path.Combine (dir, "new-file");
489                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
490                         try {
491                                 isf.CreateDirectory (dir);
492                                 using (IsolatedStorageFileStream isfs = new IsolatedStorageFileStream (file, FileMode.OpenOrCreate, isf)) {
493                                         isfs.WriteByte (0);
494                                 }
495                                 string pattern = Path.Combine (dir, "*");
496                                 Assert.AreEqual (1, isf.GetFileNames (file).Length, "file exists");
497
498                                 // create again directory
499                                 isf.CreateDirectory (dir);
500                                 Assert.AreEqual (1, isf.GetFileNames (file).Length, "file still exists");
501                         }
502                         finally {
503                                 isf.DeleteFile (file);
504                                 isf.DeleteDirectory (dir);
505                         }
506                 }
507
508                 [Test]
509 #if NET_4_0
510                 [ExpectedException (typeof (ArgumentException))]
511 #else
512                 [ExpectedException (typeof (SecurityException))]
513 #endif
514                 public void GetFilesInSubdirs ()
515                 {
516                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
517                         string pattern = Path.Combine ("..", "*");
518                         isf.GetFileNames (pattern);
519                 }
520
521         
522 #if NET_4_0
523                 [Test]
524                 [ExpectedException (typeof (ArgumentException))]
525                 public void GetDirsInSubDirs ()
526                 {
527                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
528                         isf.CreateDirectory ("subdir");
529                         string [] dir_names = isf.GetDirectoryNames ("subdir/../*");
530                 }
531 #endif
532
533                 [Test] // https://bugzilla.novell.com/show_bug.cgi?id=376188
534                 public void CreateSubDirectory ()
535                 {
536                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
537                         isf.CreateDirectory ("subdir");
538                         isf.CreateDirectory ("subdir/subdir2");
539                         Assert.AreEqual (1, isf.GetDirectoryNames ("*").Length, "subdir");
540                         Assert.AreEqual (1, isf.GetDirectoryNames ("subdir/*").Length, "subdir/subdir2");
541                         isf.DeleteDirectory ("subdir/subdir2");
542                         isf.DeleteDirectory ("subdir");
543                 }
544
545                 [Test]
546                 [ExpectedException (typeof (IsolatedStorageException))]
547                 public void DeleteDirectory_NonEmpty ()
548                 {
549                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
550                         isf.CreateDirectory ("subdir");
551                         isf.CreateDirectory ("subdir/subdir2");
552                         isf.DeleteDirectory ("subdir");
553                 }
554
555                 [Test]
556                 public void DeleteFile ()
557                 {
558                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
559
560                         try {
561                                 isf.DeleteFile (null);
562                                 Assert.Fail ("#Exc0");
563                         } catch (ArgumentNullException) {
564                         }
565
566 #if NET_4_0
567                         // We are getting an internal IndexOutOfRangeException in 2.0
568                         // Not sure we want to mimic that one.
569                         try {
570                                 isf.DeleteFile (String.Empty);
571                                 Assert.Fail ("#Exc1");
572                         } catch (IsolatedStorageException) {
573                         }
574 #endif
575
576                         try {
577                                 isf.DeleteFile ("idontexist");
578                                 Assert.Fail ("#Exc2");
579                         } catch (IsolatedStorageException) {
580                         }
581
582 #if NET_4_0
583                         try {
584                                 isf.DeleteFile ("../../file");
585                                 Assert.Fail ("#Exc3");
586                         } catch (IsolatedStorageException) {
587                         }
588 #endif
589                 
590                         try {
591                                 isf.DeleteFile ("subdir/file");
592                                 Assert.Fail ("#Exc4");
593                         } catch (IsolatedStorageException) {
594                         }
595
596                         isf.CreateDirectory ("subdir");
597                         try {
598                                 isf.DeleteFile ("subdir");
599                                 Assert.Fail ("#Exc5");
600                         } catch (IsolatedStorageException) {
601                         }
602                 }
603
604                 [Test]
605                 public void GetStore_NullTypes ()
606                 {
607                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Roaming | IsolatedStorageScope.Assembly | IsolatedStorageScope.Domain;
608                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, null, null);
609 #if !NET_2_1
610                         Assert.AreEqual (typeof (Url), isf.AssemblyIdentity.GetType (), "AssemblyIdentity");
611                         Assert.AreEqual (typeof (Url), isf.DomainIdentity.GetType (), "DomainIdentity");
612 #endif
613                 }
614
615                 [Test]
616                 public void RemoveFromOtherInstance ()
617                 {
618                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
619                         IsolatedStorageFile isf2 = IsolatedStorageFile.GetUserStoreForAssembly ();
620
621                         isf.Remove ();
622                         try {
623                                 isf2.Remove ();
624                                 Assert.Fail ("#Exc1");
625                         } catch (IsolatedStorageException) {
626                         }
627                 }
628
629 #if NET_4_0
630                 [Test]
631                 public void Remove ()
632                 {
633                         // Test that we can call Remove several times
634                         IsolatedStorageFile.Remove (IsolatedStorageScope.User);
635                         IsolatedStorageFile.Remove (IsolatedStorageScope.User);
636
637                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
638                         isf.Remove ();
639
640                         // The second call to Remove should cause an InvalidOperationException, due to
641                         // marking itself as closed.
642                         try {
643                                 isf.Remove ();
644                                 Assert.Fail ("#Exc1");
645                         } catch (InvalidOperationException) {
646                         }
647
648                         // Open, Close and try to Remove
649                         isf = IsolatedStorageFile.GetUserStoreForAssembly ();
650                         isf.Close ();
651                         try {
652                                 isf.Remove ();
653                                 Assert.Fail ("#Exc2");
654                         } catch (InvalidOperationException) {
655                         }
656                 }
657
658                 [Test]
659                 public void UsedSize ()
660                 {
661                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
662                         IsolatedStorageFileStream isfs = isf.CreateFile ("file");
663                         StreamWriter writer = new StreamWriter (isfs);
664                         writer.WriteLine ("hello mono");
665                         writer.Close ();
666
667                         Assert.AreEqual (true, isf.UsedSize > 0, "#A0");
668
669                         isf.Close ();
670                         try {
671                                 Console.WriteLine (isf.UsedSize);
672                                 Assert.Fail ("#Exc1");
673                         } catch (InvalidOperationException) {
674                         }
675
676                         isf.Dispose ();
677                         try {
678                                 Console.WriteLine (isf.UsedSize);
679                                 Assert.Fail ("#Exc2");
680                         } catch (ObjectDisposedException) {
681                         }
682                 }
683
684                 [Test]
685                 public void IncreateQuotaTo ()
686                 {
687                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
688
689                         try {
690                                 isf.IncreaseQuotaTo (-2);
691                                 Assert.Fail ("#Exc1");
692                         } catch (ArgumentException) {
693                         }
694
695                         // I wonder how this behaves on some systems
696                         try {
697                                 isf.IncreaseQuotaTo (100);
698                                 Assert.Fail ("#Exc2");
699                         } catch (ArgumentException) {
700                         }
701
702                         // Since 'Quota' seems to be returning Int64.MaxValue, we cannot truly test against a value
703                         // larger than that.
704                 }
705
706                 [Test]
707                 public void DirectoryExists ()
708                 {
709                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
710                         isf.CreateDirectory ("subdir");
711                         isf.CreateDirectory ("subdir/subdir2");
712                         isf.CreateDirectory ("subdir3");
713
714                         Assert.AreEqual (true, isf.DirectoryExists ("subdir/"), "#A0");
715                         Assert.AreEqual (true, isf.DirectoryExists ("subdir/subdir2/"), "#A1");
716                         Assert.AreEqual (true, isf.DirectoryExists ("subdir3"), "#A2");
717                         Assert.AreEqual (true, isf.DirectoryExists (String.Empty), "#A3"); // Weird
718                         Assert.AreEqual (false, isf.DirectoryExists ("subdir99"), "#A4");
719                         Assert.AreEqual (false, isf.DirectoryExists ("../../subdir"), "#A5");
720                         Assert.AreEqual (false, isf.DirectoryExists ("*"), "#A5");
721                         Assert.AreEqual (false, isf.DirectoryExists ("subdir*"), "#A6");
722
723                         isf.DeleteDirectory ("subdir3");
724                         Assert.AreEqual (false, isf.DirectoryExists ("subdir3"), "#B0");
725
726                         isf.DeleteDirectory ("subdir/subdir2");
727                         isf.DeleteDirectory ("subdir");
728
729                         try {
730                                 isf.DirectoryExists (null);
731                                 Assert.Fail ("#Exc1");
732                         } catch (ArgumentNullException) {
733                         }
734
735                         isf.Close ();
736                         try {
737                                 isf.DirectoryExists ("subdir");
738                                 Assert.Fail ("#Exc2");
739                         } catch (InvalidOperationException) {
740                         }
741
742                         isf.Dispose ();
743                         try {
744                                 isf.DirectoryExists ("subdir");
745                                 Assert.Fail ("#Exc3");
746                         } catch (ObjectDisposedException) {
747                         }
748
749                         // We want to be sure that if not closing but disposing
750                         // should fire ObjectDisposedException instead of InvalidOperationException
751                         isf = IsolatedStorageFile.GetUserStoreForAssembly ();
752                         isf.Dispose ();
753
754                         try {
755                                 isf.DirectoryExists ("subdir");
756                                 Assert.Fail ("#Exc4");
757                         } catch (ObjectDisposedException) {
758                         }
759                 }
760
761                 [Test]
762                 public void FileExists ()
763                 {
764                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
765                         IsolatedStorageFileStream file_a = new IsolatedStorageFileStream ("file-a", FileMode.Create, isf);
766                         IsolatedStorageFileStream file_b = new IsolatedStorageFileStream ("file-b", FileMode.Create, isf);
767                         file_a.Close ();
768                         file_b.Close ();
769
770                         Assert.AreEqual (true, isf.FileExists ("file-a"), "#A0");
771                         Assert.AreEqual (true, isf.FileExists ("file-b"), "#A1");
772                         Assert.AreEqual (false, isf.FileExists (String.Empty), "#A2");
773                         Assert.AreEqual (false, isf.FileExists ("file-"), "#A3");
774                         Assert.AreEqual (false, isf.FileExists ("file-*"), "#A4");
775                         Assert.AreEqual (false, isf.FileExists ("../../file-a"), "#A5");
776
777                         isf.CreateDirectory ("subdir");
778                         Assert.AreEqual (false, isf.FileExists ("subdir"), "#B0");
779
780                         try {
781                                 isf.FileExists (null);
782                                 Assert.Fail ("#Exc1");
783                         } catch (ArgumentNullException) {
784                         }
785
786                         isf.Close ();
787                         try {
788                                 isf.FileExists ("file-a");
789                                 Assert.Fail ("#Exc2");
790                         } catch (InvalidOperationException) {
791                         }
792
793                         isf.Dispose ();
794                         try {
795                                 isf.FileExists ("file-a");
796                                 Assert.Fail ("#Exc3");
797                         } catch (ObjectDisposedException) {
798                         }
799                 }
800
801                 [Test]
802                 public void CreateFile ()
803                 {
804                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
805                         // Make sure we are actually creating it, by first removing it in case it already exists
806                         if (isf.FileExists ("file-a"))
807                                 isf.DeleteFile ("file-a");
808
809                         IsolatedStorageFileStream isf_stream = isf.CreateFile ("file-a");
810                         isf_stream.Close ();
811                         Assert.AreEqual (true, isf.FileExists ("file-a"), "#A0");
812
813                         // Re-open the file that is already created, so we make sure we are passing
814                         // the proper FileOpen
815                         isf_stream = isf.CreateFile ("file-a");
816                         isf_stream.Close ();
817
818                         try {
819                                 isf.CreateFile (null);
820                                 Assert.Fail ("#Exc1");
821                         } catch (ArgumentNullException) {
822                         }
823
824                         try {
825                                 isf.CreateFile ("random-dir/fileb");
826                                 Assert.Fail ("#Exc2");
827                         } catch (DirectoryNotFoundException) {
828                         }
829
830                         isf.Close ();
831                         try {
832                                 isf.CreateFile ("file-b");
833                                 Assert.Fail ("#Exc3");
834                         } catch (InvalidOperationException) {
835                         }
836
837                         isf.Dispose ();
838                         try {
839                                 isf.CreateFile ("file-a");
840                                 Assert.Fail ("#Exc4");
841                         } catch (ObjectDisposedException) {
842                         }
843                 }
844
845                 [Test]
846                 public void GetCreationTime ()
847                 {
848                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
849
850                         // This is not causing an exception
851                         isf.GetCreationTime ("doesntexist");
852                         isf.GetCreationTime ("dir/doesntexist");
853
854                         try {
855                                 isf.GetCreationTime (String.Empty);
856                                 Assert.Fail ("#Exc1");
857                         } catch (ArgumentException) {
858                         }
859
860                         try {
861                                 isf.GetCreationTime ("   ");
862                                 Assert.Fail ("#Exc2");
863                         } catch (ArgumentException) {
864                         }
865
866                         isf.Close ();
867                         try {
868                                 isf.GetCreationTime ("doesntexist");
869                                 Assert.Fail ("#Exc3");
870                         } catch (InvalidOperationException) {
871                         }
872
873                         isf.Dispose ();
874                         try {
875                                 isf.GetCreationTime ("doesntexist");
876                                 Assert.Fail ("#Exc4");
877                         } catch (ObjectDisposedException) {
878                         }
879                 }
880
881                 [Test]
882                 public void MoveDirectory ()
883                 {
884                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
885                         // Mare sure to remove them if they exist already
886                         if (isf.DirectoryExists ("subdir"))
887                                 isf.DeleteDirectory ("subdir");
888                         if (isf.DirectoryExists ("subdir-new"))
889                                 isf.DeleteDirectory ("subdir-new");
890
891                         isf.CreateDirectory ("subdir");
892                         Assert.AreEqual (true, isf.DirectoryExists ("subdir"), "#A0");
893
894                         isf.MoveDirectory ("subdir", "subdir-new");
895                         Assert.AreEqual (false, isf.DirectoryExists ("subdir"), "#A1");
896                         Assert.AreEqual (true, isf.DirectoryExists ("subdir-new"), "#A2");
897
898                         try {
899                                 isf.MoveDirectory (String.Empty, "subdir-new-new");
900                                 Assert.Fail ("#Exc1");
901                         } catch (ArgumentException) {
902                         }
903
904                         try {
905                                 isf.MoveDirectory ("  ", "subdir-new-new");
906                                 Assert.Fail ("#Exc2");
907                         } catch (ArgumentException) {
908                         }
909
910                         try {
911                                 isf.MoveDirectory ("doesntexist", "subdir-new-new");
912                                 Assert.Fail ("#Exc3");
913                         } catch (DirectoryNotFoundException) {
914                         }
915
916                         try {
917                                 isf.MoveDirectory ("doesnexist/doesntexist", "subdir-new-new");
918                                 Assert.Fail ("#Exc4");
919                         } catch (DirectoryNotFoundException) {
920                         }
921
922                         try {
923                                 isf.MoveDirectory ("subdir-new", "doesntexist/doesntexist");
924                                 Assert.Fail ("#Exc5");
925                         } catch (DirectoryNotFoundException) {
926                         }
927
928                         // Out of storage dir
929                         try {
930                                 isf.MoveDirectory ("subdir-new", "../../subdir-new");
931                                 Assert.Fail ("#Exc6");
932                         } catch (IsolatedStorageException) {
933                         }
934
935                         isf.Remove ();
936                         isf.Close ();
937                         isf.Dispose ();
938                 }
939
940                 [Test]
941                 public void CopyFile ()
942                 {
943                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
944                         if (isf.FileExists ("file"))
945                                 isf.DeleteFile ("file");
946                         if (isf.FileExists ("file-new"))
947                                 isf.DeleteFile ("file-new");
948
949                         isf.CreateFile ("file").Close ();
950                         isf.CopyFile ("file", "file-new");
951                         Assert.AreEqual (true, isf.FileExists ("file"), "#A0");
952                         Assert.AreEqual (true, isf.FileExists ("file-new"), "#A1");
953
954                         // At this point 'file-exists' already exists.
955                         isf.CopyFile ("file", "file-new", true);
956                         Assert.AreEqual (true, isf.FileExists ("file"), "#B0");
957                         Assert.AreEqual (true, isf.FileExists ("file-new"), "#B1");
958
959                         isf.CreateDirectory ("subdir");
960                         isf.CreateFile ("subdir/subfile").Close ();
961                         isf.CopyFile ("subdir/subfile", "subdir/subfile-new");
962                         Assert.AreEqual (true, isf.FileExists ("subdir/subfile"), "#C0");
963                         Assert.AreEqual (true, isf.FileExists ("subdir/subfile-new"), "#C1");
964
965                         try {
966                                 isf.CopyFile ("file", "file-new");
967                                 Assert.Fail ("#Exc0");
968                         } catch (IsolatedStorageException) {
969                         }
970
971                         // Using the same file name is failing for even when passing override=true.
972                         try {
973                                 isf.CopyFile ("file-new", "file-new", true);
974                                 Assert.Fail ("#Exc1");
975                         } catch (IsolatedStorageException) {
976                         }
977
978                         try {
979                                 isf.CopyFile ("file-new", "file-new", false);
980                                 Assert.Fail ("#Exc2");
981                         } catch (IsolatedStorageException) {
982                         }
983
984                         // Remove 'file-new' for cleaness purposes.
985                         isf.DeleteFile ("file-new");
986
987                         try {
988                                 isf.CopyFile ("doesntexist", "file-new", false);
989                                 Assert.Fail ("#Exc3");
990                         } catch (FileNotFoundException) {
991                         }
992
993                         try {
994                                 isf.CopyFile ("doesnexist/doesntexist", "file-new", false);
995                                 Assert.Fail ("#Exc4");
996                         } catch (DirectoryNotFoundException) {
997                         }
998
999                         // I'd have expected a DirectoryNotFoundException here.
1000                         try {
1001                                 isf.CopyFile ("file", "doesntexist/doesntexist");
1002                                 Assert.Fail ("#Exc5");
1003                         } catch (IsolatedStorageException) {
1004                         }
1005
1006                         // Out of storage dir
1007                         try {
1008                                 isf.CopyFile ("file", "../../file");
1009                                 Assert.Fail ("#Exc6");
1010                         } catch (IsolatedStorageException) {
1011                         }
1012
1013                         try {
1014                                 isf.CopyFile ("../file", "file-new");
1015                                 Assert.Fail ("#Exc7");
1016                         } catch (IsolatedStorageException) {
1017                         }
1018
1019                         // We are creating a subdirectory and files within it, so remove it just in case.
1020                         isf.Remove ();
1021
1022                         isf.Close ();
1023                         isf.Dispose ();
1024                 }
1025
1026                 [Test]
1027                 public void MoveFile ()
1028                 {
1029                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
1030                         // Mare sure to remove them if they exist already
1031                         if (isf.FileExists ("file"))
1032                                 isf.DeleteFile ("file");
1033                         if (isf.FileExists ("file-new"))
1034                                 isf.DeleteFile ("file-new");
1035                         if (isf.FileExists ("subdir/subfile"))
1036                                 isf.DeleteFile ("subdir/subfile");
1037                         if (isf.FileExists ("subdir/subfile-new"))
1038                                 isf.DeleteFile ("subdir/subfile-new");
1039
1040                         isf.CreateFile ("file").Close ();
1041                         Assert.AreEqual (true, isf.FileExists ("file"), "#A0");
1042
1043                         // Same file
1044                         isf.MoveFile ("file", "file");
1045                         Assert.AreEqual (true, isf.FileExists ("file"), "#A0-1");
1046
1047                         isf.MoveFile ("file", "file-new");
1048                         Assert.AreEqual (false, isf.FileExists ("file"), "#A1");
1049                         Assert.AreEqual (true, isf.FileExists ("file-new"), "#A2");
1050
1051                         isf.CreateDirectory ("subdir");
1052                         isf.CreateFile ("subdir/subfile").Close ();
1053                         isf.MoveFile ("subdir/subfile", "subdir/subfile-new");
1054                         Assert.AreEqual (false, isf.FileExists ("subdir/subfile"), "#B0");
1055                         Assert.AreEqual (true, isf.FileExists ("subdir/subfile-new"), "#B1");
1056
1057                         try {
1058                                 isf.MoveFile (String.Empty, "file-new-new");
1059                                 Assert.Fail ("#Exc1");
1060                         } catch (ArgumentException) {
1061                         }
1062
1063                         try {
1064                                 isf.MoveFile ("  ", "file-new-new");
1065                                 Assert.Fail ("#Exc2");
1066                         } catch (ArgumentException e) {
1067                                 Console.WriteLine (e);
1068                         }
1069
1070                         try {
1071                                 isf.MoveFile ("doesntexist", "file-new-new");
1072                                 Assert.Fail ("#Exc3");
1073                         } catch (FileNotFoundException) {
1074                         }
1075
1076                         // CopyFile is throwing a DirectoryNotFoundException here.
1077                         try {
1078                                 isf.MoveFile ("doesnexist/doesntexist", "file-new-new");
1079                                 Assert.Fail ("#Exc4");
1080                         } catch (FileNotFoundException) {
1081                         }
1082
1083                         // I'd have expected a DirectoryNotFoundException here.
1084                         try {
1085                                 isf.MoveFile ("file-new", "doesntexist/doesntexist");
1086                                 Assert.Fail ("#Exc5");
1087                         } catch (IsolatedStorageException) {
1088                         }
1089
1090                         // Out of storage dir
1091                         try {
1092                                 isf.MoveFile ("file-new", "../../file-new");
1093                                 Assert.Fail ("#Exc6");
1094                         } catch (IsolatedStorageException) {
1095                         }
1096
1097                         isf.Remove ();
1098                         isf.Close ();
1099                         isf.Dispose ();
1100                 }
1101
1102                 [Test]
1103                 public void MultiLevel ()
1104                 {
1105                         // see bug #4101
1106                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
1107                         try {
1108                                 isf.CreateDirectory ("dir1");
1109                                 string [] dirs = isf.GetDirectoryNames ("*");
1110                                 Assert.AreEqual (dirs.Length, 1, "1a");
1111                                 Assert.AreEqual (dirs [0], "dir1", "1b");
1112         
1113                                 isf.CreateDirectory ("dir1/test");
1114                                 dirs = isf.GetDirectoryNames ("dir1/*");
1115                                 Assert.AreEqual (dirs.Length, 1, "2a");
1116                                 Assert.AreEqual (dirs [0], "test", "2b");
1117         
1118                                 isf.CreateDirectory ("dir1/test/test2a");
1119                                 isf.CreateDirectory ("dir1/test/test2b");
1120                                 dirs = isf.GetDirectoryNames ("dir1/test/*");
1121                                 Assert.AreEqual (dirs.Length, 2, "3a");
1122                                 Assert.AreEqual (dirs [0], "test2a", "3b");
1123                                 Assert.AreEqual (dirs [1], "test2b", "3c");
1124                         }
1125                         finally {
1126                                 isf.DeleteDirectory ("dir1/test/test2a");
1127                                 isf.DeleteDirectory ("dir1/test/test2b");
1128                                 isf.DeleteDirectory ("dir1/test");
1129                                 isf.DeleteDirectory ("dir1");
1130                         }
1131                 }
1132 #endif
1133                 [Test]
1134                 public void RootedDirectory ()
1135                 {
1136                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
1137                         try {
1138                                 isf.CreateDirectory ("test/nested/directory/structure/without/root");
1139                                 isf.CreateDirectory ("/test/nested/directory/structure/with/root");
1140                         }
1141                         finally {
1142                                 isf.DeleteDirectory ("test/nested/directory/structure/without/root");
1143                                 isf.DeleteDirectory ("test/nested/directory/structure/without");
1144
1145                                 isf.DeleteDirectory ("/test/nested/directory/structure/with/root");
1146                                 isf.DeleteDirectory ("/test/nested/directory/structure/with");
1147                                 isf.DeleteDirectory ("/test/nested/directory/structure");
1148                                 isf.DeleteDirectory ("/test/nested/directory");
1149                                 isf.DeleteDirectory ("/test/nested");
1150                                 isf.DeleteDirectory ("/test");
1151                         }
1152                 }
1153         }
1154 }