2db033fc1dbff34235453f7deb92a8369098b131
[mono.git] / mcs / class / corlib / Test / System.IO / DirectoryTest.cs
1 //\r
2 // System.IO.Directory\r
3 //\r
4 // Authors: \r
5 //      Ville Palo (vi64pa@kolumbus.fi)\r
6 //\r
7 // (C) 2003 Ville Palo\r
8 //\r
9 // TODO: Find out why ArgumentOutOfRange tests does not release directories properly\r
10 //\r
11 \r
12 using System;\r
13 using System.Diagnostics;\r
14 using System.Globalization;\r
15 using System.IO;\r
16 using System.Text;\r
17 using System.Threading;\r
18 \r
19 using NUnit.Framework;\r
20 \r
21 namespace MonoTests.System.IO\r
22 {\r
23 \r
24 [TestFixture]\r
25 public class DirectoryTest\r
26 {\r
27         string TempFolder = Path.Combine (Path.GetTempPath (), "MonoTests.System.IO.Tests");\r
28         static readonly char DSC = Path.DirectorySeparatorChar;\r
29 \r
30         [SetUp]\r
31         public void SetUp ()\r
32         {\r
33                 if (!Directory.Exists (TempFolder))\r
34                         Directory.CreateDirectory (TempFolder);\r
35 \r
36                 Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US");\r
37         }\r
38         \r
39         [TearDown]\r
40         public void TearDown () {\r
41                 if (Directory.Exists (TempFolder))\r
42                         Directory.Delete (TempFolder, true);\r
43         }\r
44 \r
45         [Test]\r
46         public void CreateDirectory ()\r
47         {\r
48                 string path = TempFolder + DSC + "DirectoryTest.Test.1";\r
49                 DeleteDirectory (path);\r
50                 try {\r
51                         DirectoryInfo info = Directory.CreateDirectory (path);\r
52                         Assert.IsTrue (info.Exists, "#1");\r
53                         Assert.AreEqual (".1", info.Extension, "#2");\r
54                         Assert.IsTrue (info.FullName.EndsWith ("DirectoryTest.Test.1"), "#3");\r
55                         Assert.AreEqual ("DirectoryTest.Test.1", info.Name, "#4");\r
56                 } finally {\r
57                         DeleteDirectory (path);\r
58                 }\r
59         }\r
60         \r
61         [Test]\r
62         public void CreateDirectoryNotSupportedException ()\r
63         {\r
64                 DeleteDirectory (":");\r
65                 try {\r
66                         DirectoryInfo info = Directory.CreateDirectory (":");\r
67                         Assert.Fail ();\r
68                 } catch (ArgumentException) {\r
69                 }\r
70                 DeleteDirectory (":");\r
71         }\r
72 \r
73         [Test]\r
74         [ExpectedException(typeof(ArgumentNullException))]\r
75         public void CreateDirectoryArgumentNullException ()\r
76         {\r
77                 DirectoryInfo info = Directory.CreateDirectory (null as string);\r
78         }\r
79 \r
80         [Test]\r
81         [ExpectedException(typeof(ArgumentException))]\r
82         public void CreateDirectoryArgumentException1 ()\r
83         {\r
84                 DirectoryInfo info = Directory.CreateDirectory ("");\r
85         }\r
86 \r
87         [Test]\r
88         [ExpectedException(typeof(ArgumentException))]\r
89         public void CreateDirectoryArgumentException2 ()\r
90         {\r
91                 DirectoryInfo info = Directory.CreateDirectory ("            ");\r
92         }\r
93 \r
94         [Test]\r
95         [ExpectedException(typeof(ArgumentException))]\r
96         public void CreateDirectoryArgumentException3 ()\r
97         {\r
98                 string path = TempFolder + DSC + "DirectoryTest.Test";\r
99                 DeleteDirectory (path);\r
100                 try {\r
101                         path += '\x00';\r
102                         path += ".2";\r
103                         DirectoryInfo info = Directory.CreateDirectory (path);\r
104                 } finally {\r
105                         DeleteDirectory (path);\r
106                 }\r
107         }\r
108 \r
109         [Test]\r
110         public void CreateDirectoryAlreadyExists ()\r
111         {\r
112                 string path = TempFolder + DSC + "DirectoryTest.Test.Exists";\r
113                 DeleteDirectory (path);\r
114                 try {\r
115                         DirectoryInfo info1 = Directory.CreateDirectory (path);\r
116                         DirectoryInfo info2 = Directory.CreateDirectory (path);\r
117 \r
118                         Assert.IsTrue (info2.Exists, "#1");\r
119                         Assert.IsTrue (info2.FullName.EndsWith ("DirectoryTest.Test.Exists"), "#2");\r
120                         Assert.AreEqual ("DirectoryTest.Test.Exists", info2.Name, "#3");\r
121                 } finally {\r
122                         DeleteDirectory (path);\r
123                 }\r
124         }\r
125 \r
126         [Test]\r
127         public void CreateDirectoryAlreadyExistsAsFile ()\r
128         {\r
129                 string path = TempFolder + DSC + "DirectoryTest.Test.ExistsAsFile";\r
130                 DeleteDirectory (path);\r
131                 DeleteFile (path);\r
132                 try {\r
133                         FileStream fstream = File.Create (path);\r
134                         fstream.Close();\r
135 \r
136                         DirectoryInfo dinfo = Directory.CreateDirectory (path);\r
137 #if NET_2_0\r
138                         Assert.Fail ("#1");\r
139                 } catch (IOException ex) {\r
140                         Assert.AreEqual (typeof (IOException), ex.GetType (), "#2");\r
141                         Assert.IsNotNull (ex.Message, "#3");\r
142                         Assert.IsNull (ex.InnerException, "#4");\r
143 #else\r
144                         Assert.IsFalse (dinfo.Exists, "#2");\r
145                         Assert.IsTrue (dinfo.FullName.EndsWith ("DirectoryTest.Test.ExistsAsFile"), "#3");\r
146                         Assert.AreEqual ("DirectoryTest.Test.ExistsAsFile", dinfo.Name, "#4");\r
147 #endif\r
148                 } finally {\r
149                         DeleteDirectory (path);\r
150                         DeleteFile (path);\r
151                 }\r
152         }\r
153 \r
154         [Test]\r
155         public void Delete ()\r
156         {\r
157                 string path = TempFolder + DSC + "DirectoryTest.Test.Delete.1";\r
158                 DeleteDirectory (path);\r
159                 try {\r
160                         Directory.CreateDirectory (path);\r
161                         Assert.IsTrue (Directory.Exists (path), "#1");\r
162                 \r
163                         Directory.CreateDirectory (path + DSC + "DirectoryTest.Test.Delete.1.2");\r
164                         Assert.IsTrue (Directory.Exists (path + DSC + "DirectoryTest.Test.Delete.1.2"), "#2");\r
165                 \r
166                         Directory.Delete (path + DSC + "DirectoryTest.Test.Delete.1.2");\r
167                         Assert.IsFalse (Directory.Exists (path + DSC + "DirectoryTest.Test.Delete.1.2"), "#3");\r
168                         Assert.IsTrue (Directory.Exists (path), "#4");\r
169                 \r
170                         Directory.Delete (path);\r
171                         Assert.IsFalse (Directory.Exists (path + DSC + "DirectoryTest.Test.Delete.1.2"), "#5");\r
172                         Assert.IsFalse (Directory.Exists (path), "#6");\r
173         \r
174                         Directory.CreateDirectory (path);\r
175                         Directory.CreateDirectory (path + DSC + "DirectoryTest.Test.Delete.1.2");\r
176                         Assert.IsTrue (Directory.Exists (path + DSC + "DirectoryTest.Test.Delete.1.2"), "#7");\r
177                         Assert.IsTrue (Directory.Exists (path), "#8");\r
178                 \r
179                         Directory.Delete (path, true);\r
180                         Assert.IsFalse (Directory.Exists (path + DSC + "DirectoryTest.Test.Delete.1.2"), "#9");\r
181                         Assert.IsFalse (Directory.Exists (path), "#10");\r
182                 } finally {\r
183                         DeleteDirectory (path);\r
184                 }\r
185         }\r
186 \r
187         [Test]  \r
188         [ExpectedException(typeof(ArgumentException))]\r
189         public void DeleteArgumentException ()\r
190         {\r
191                 Directory.Delete ("");\r
192         }\r
193 \r
194         [Test]  \r
195         [ExpectedException(typeof(ArgumentException))]\r
196         public void DeleteArgumentException2 ()\r
197         {\r
198                 Directory.Delete ("     ");\r
199         }\r
200 \r
201         [Test]  \r
202         [ExpectedException(typeof(ArgumentException))]\r
203         public void DeleteArgumentException3 ()\r
204         {\r
205                 string path = TempFolder + DSC + "DirectoryTest.Test.4";\r
206                 DeleteDirectory (path);\r
207                 \r
208                 path += Path.InvalidPathChars [0];\r
209                 Directory.Delete (path);\r
210         }\r
211 \r
212         [Test]  \r
213         [ExpectedException(typeof(ArgumentNullException))]\r
214         public void DeleteArgumentNullException ()\r
215         {\r
216                 Directory.Delete (null as string);\r
217         }\r
218 \r
219         [Test]  \r
220         [ExpectedException(typeof(DirectoryNotFoundException))]\r
221         public void DeleteDirectoryNotFoundException ()\r
222         {\r
223                 string path = TempFolder + DSC + "DirectoryTest.Test.5";\r
224                 DeleteDirectory (path);\r
225                 \r
226                 Directory.Delete (path);\r
227         }\r
228 \r
229         [Test]  \r
230         [ExpectedException(typeof(IOException))]\r
231         public void DeleteArgumentException4 ()\r
232         {\r
233                 string path = TempFolder + DSC + "DirectoryTest.Test.6";\r
234                 DeleteDirectory (path);\r
235                 FileStream s = null;\r
236                 Directory.CreateDirectory (path);\r
237                 try {\r
238                         s = File.Create (path + DSC + "DirectoryTest.Test.6");\r
239                         Directory.Delete (path);\r
240                 } finally {\r
241                         if (s != null)\r
242                                 s.Close ();\r
243                         DeleteDirectory (path);\r
244                 };\r
245         }\r
246 \r
247         [Test]\r
248         public void Exists ()\r
249         {\r
250                 Assert.IsFalse (Directory.Exists (null as string));\r
251         }\r
252 \r
253 #if !TARGET_JVM // We don't support yet the Process class.\r
254         [Test]\r
255         [Category("NotDotNet")]\r
256         public void ExistsAccessDenied ()\r
257         {\r
258                 // bug #78239\r
259 \r
260                 if (Path.DirectorySeparatorChar == '\\')\r
261                         return; // this test does not work on Windows.\r
262 \r
263                 string path = TempFolder + DSC + "ExistsAccessDenied";\r
264 \r
265                 Directory.CreateDirectory (path);\r
266                 Process.Start ("/bin/chmod", "000 " + path).WaitForExit ();\r
267                 try {\r
268                         Assert.IsFalse (Directory.Exists(path + DSC + "b"));\r
269                 } finally {\r
270                         Process.Start ("/bin/chmod", "755 " + path).WaitForExit ();\r
271                         Directory.Delete (path);\r
272                 }\r
273         }\r
274 #endif\r
275         \r
276         [Test]\r
277         [ExpectedException(typeof(ArgumentNullException))]\r
278 #if TARGET_JVM\r
279     [Category("NotWorking")]\r
280 #endif  \r
281     public void GetCreationTimeException1 ()\r
282         {\r
283                 Directory.GetCreationTime (null as string);\r
284         }\r
285 \r
286         [Test]\r
287         [ExpectedException(typeof(ArgumentException))]\r
288 #if TARGET_JVM\r
289     [Category("NotWorking")]\r
290 #endif\r
291         public void GetCreationTimeException2 ()\r
292         {\r
293                 Directory.GetCreationTime ("");\r
294         }\r
295         \r
296         [Test]\r
297 #if !NET_2_0\r
298         [ExpectedException(typeof(IOException))]\r
299 #endif\r
300 #if TARGET_JVM\r
301     [Category("NotWorking")]\r
302 #endif\r
303         public void GetCreationTimeException_NonExistingPath ()\r
304         {\r
305                 string path = TempFolder + DSC + "DirectoryTest.GetCreationTime.1";\r
306                 DeleteDirectory (path);\r
307                 try {\r
308                         DateTime time = Directory.GetCreationTime (path);\r
309 \r
310 #if NET_2_0\r
311                         DateTime expectedTime = (new DateTime (1601, 1, 1)).ToLocalTime ();\r
312                         Assert.AreEqual (expectedTime.Year, time.Year, "#1");\r
313                         Assert.AreEqual (expectedTime.Month, time.Month, "#2");\r
314                         Assert.AreEqual (expectedTime.Day, time.Day, "#3");\r
315                         Assert.AreEqual (expectedTime.Hour, time.Hour, "#4");\r
316                         Assert.AreEqual (expectedTime.Second, time.Second, "#5");\r
317                         Assert.AreEqual (expectedTime.Millisecond, time.Millisecond, "#6");\r
318 #endif\r
319                 } finally {\r
320                         DeleteDirectory (path);\r
321                 }\r
322         }\r
323 \r
324         [Test]\r
325         [ExpectedException(typeof(ArgumentException))]\r
326 #if TARGET_JVM\r
327     [Category("NotWorking")]\r
328 #endif\r
329         public void GetCreationTimeException4 ()\r
330         {\r
331                 Directory.GetCreationTime ("    ");\r
332         }\r
333 \r
334         [Test]\r
335         [ExpectedException(typeof(ArgumentException))]\r
336 #if TARGET_JVM\r
337     [Category("NotWorking")]\r
338 #endif\r
339         public void GetCreationTimeException5 ()\r
340         {\r
341                 Directory.GetCreationTime (Path.InvalidPathChars [0].ToString ());\r
342         }\r
343 \r
344         [Test]\r
345         [ExpectedException(typeof(ArgumentNullException))]\r
346 #if TARGET_JVM\r
347     [Category("NotWorking")]\r
348 #endif\r
349         public void GetCreationTimeUtcException1 ()\r
350         {\r
351                 Directory.GetCreationTimeUtc (null as string);\r
352         }\r
353 \r
354         [Test]\r
355         [ExpectedException(typeof(ArgumentException))]\r
356 #if TARGET_JVM\r
357     [Category("NotWorking")]\r
358 #endif\r
359         public void GetCreationTimeUtcException2 ()\r
360         {\r
361                 Directory.GetCreationTimeUtc ("");\r
362         }\r
363         \r
364         [Test]\r
365 #if !NET_2_0\r
366         [ExpectedException (typeof (IOException))]\r
367 #endif\r
368 #if TARGET_JVM\r
369     [Category("NotWorking")]\r
370 #endif\r
371         public void GetCreationTimeUtc_NonExistingPath ()\r
372         {\r
373                 string path = TempFolder + DSC + "DirectoryTest.GetCreationTimeUtc.1";\r
374                 DeleteDirectory (path);\r
375                 \r
376                 try {\r
377                         DateTime time = Directory.GetCreationTimeUtc (path);\r
378 \r
379 #if NET_2_0\r
380                         Assert.AreEqual (1601, time.Year, "#1");\r
381                         Assert.AreEqual (1, time.Month, "#2");\r
382                         Assert.AreEqual (1, time.Day, "#3");\r
383                         Assert.AreEqual (0, time.Hour, "#4");\r
384                         Assert.AreEqual (0, time.Second, "#5");\r
385                         Assert.AreEqual (0, time.Millisecond, "#6");\r
386 #endif\r
387                 } finally {\r
388                         DeleteDirectory (path);\r
389                 }\r
390         }\r
391 \r
392         [Test]\r
393         [ExpectedException(typeof(ArgumentException))]\r
394 #if TARGET_JVM\r
395     [Category("NotWorking")]\r
396 #endif\r
397         public void GetCreationTimeUtcException4 ()\r
398         {\r
399                 Directory.GetCreationTimeUtc ("    ");\r
400         }\r
401 \r
402         [Test]\r
403         [ExpectedException(typeof(ArgumentException))]\r
404 #if TARGET_JVM\r
405     [Category("NotWorking")]\r
406 #endif\r
407         public void GetCreationTimeUtcException5 ()\r
408         {\r
409                 Directory.GetCreationTime (Path.InvalidPathChars [0].ToString ());\r
410         }\r
411 \r
412         [Test]\r
413         [ExpectedException(typeof(ArgumentNullException))]\r
414 #if TARGET_JVM\r
415     [Category("NotWorking")]\r
416 #endif\r
417         public void GetLastAccessTime_Null ()\r
418         {\r
419                 Directory.GetLastAccessTime (null as string);\r
420         }\r
421 \r
422         [Test]\r
423         [ExpectedException(typeof(ArgumentException))]\r
424 #if TARGET_JVM\r
425     [Category("NotWorking")]\r
426 #endif\r
427         public void GetLastAccessTimeException2 ()\r
428         {\r
429                 Directory.GetLastAccessTime ("");\r
430         }\r
431         \r
432         [Test]\r
433 #if !NET_2_0\r
434         [ExpectedException (typeof (IOException))]\r
435 #endif\r
436 #if TARGET_JVM\r
437     [Category("NotWorking")]\r
438 #endif\r
439         public void GetLastAccessTime_NonExistingPath ()\r
440         {\r
441                 string path = TempFolder + DSC + "DirectoryTest.GetLastAccessTime.1";\r
442                 DeleteDirectory (path);\r
443                 \r
444                 try {\r
445                         DateTime time = Directory.GetLastAccessTime (path);\r
446 \r
447 #if NET_2_0\r
448                         DateTime expectedTime = (new DateTime (1601, 1, 1)).ToLocalTime ();\r
449                         Assert.AreEqual (expectedTime.Year, time.Year, "#1");\r
450                         Assert.AreEqual (expectedTime.Month, time.Month, "#2");\r
451                         Assert.AreEqual (expectedTime.Day, time.Day, "#3");\r
452                         Assert.AreEqual (expectedTime.Hour, time.Hour, "#4");\r
453                         Assert.AreEqual (expectedTime.Second, time.Second, "#5");\r
454                         Assert.AreEqual (expectedTime.Millisecond, time.Millisecond, "#6");\r
455 #endif\r
456                 } finally {\r
457                         DeleteDirectory (path);\r
458                 }\r
459         }\r
460 \r
461         [Test]\r
462         [ExpectedException(typeof(ArgumentException))]\r
463 #if TARGET_JVM\r
464     [Category("NotWorking")]\r
465 #endif\r
466         public void GetLastAccessTimeException4 ()\r
467         {\r
468                 Directory.GetLastAccessTime ("    ");\r
469         }\r
470 \r
471         [Test]\r
472         [ExpectedException(typeof(ArgumentException))]\r
473 #if TARGET_JVM\r
474     [Category("NotWorking")]\r
475 #endif\r
476         public void GetLastAccessTimeException5 ()\r
477         {\r
478                 Directory.GetLastAccessTime (Path.InvalidPathChars [0].ToString ());\r
479         }\r
480 \r
481         [Test]\r
482         [ExpectedException(typeof(ArgumentNullException))]\r
483 #if TARGET_JVM\r
484     [Category("NotWorking")]\r
485 #endif\r
486         public void GetLastAccessTimeUtc_Null ()\r
487         {\r
488                 Directory.GetLastAccessTimeUtc (null as string);\r
489         }\r
490 \r
491         [Test]\r
492         [ExpectedException(typeof(ArgumentException))]\r
493 #if TARGET_JVM\r
494     [Category("NotWorking")]\r
495 #endif\r
496         public void GetLastAccessTimeUtcException2 ()\r
497         {\r
498                 Directory.GetLastAccessTimeUtc ("");\r
499         }\r
500         \r
501         [Test]\r
502 #if !NET_2_0\r
503         [ExpectedException (typeof (IOException))]\r
504 #endif\r
505 #if TARGET_JVM\r
506     [Category("NotWorking")]\r
507 #endif\r
508         public void GetLastAccessTimeUtc_NonExistingPath ()\r
509         {\r
510                 string path = TempFolder + DSC + "DirectoryTest.GetLastAccessTimeUtc.1";\r
511                 DeleteDirectory (path);\r
512                 try {\r
513                         DateTime time = Directory.GetLastAccessTimeUtc (path);\r
514 \r
515 #if NET_2_0\r
516                         Assert.AreEqual (1601, time.Year, "#1");\r
517                         Assert.AreEqual (1, time.Month, "#2");\r
518                         Assert.AreEqual (1, time.Day, "#3");\r
519                         Assert.AreEqual (0, time.Hour, "#4");\r
520                         Assert.AreEqual (0, time.Second, "#5");\r
521                         Assert.AreEqual (0, time.Millisecond, "#6");\r
522 #endif\r
523                 } finally {\r
524                         DeleteDirectory (path);\r
525                 }\r
526         }\r
527 \r
528         [Test]\r
529         [ExpectedException(typeof(ArgumentException))]\r
530 #if TARGET_JVM\r
531     [Category("NotWorking")]\r
532 #endif\r
533         public void GetLastAccessTimeUtcException4 ()\r
534         {\r
535                 Directory.GetLastAccessTimeUtc ("    ");\r
536         }\r
537 \r
538         [Test]\r
539         [ExpectedException(typeof(ArgumentException))]\r
540 #if TARGET_JVM\r
541     [Category("NotWorking")]\r
542 #endif\r
543         public void GetLastAccessTimeUtcException5 ()\r
544         {\r
545                 Directory.GetLastAccessTimeUtc (Path.InvalidPathChars [0].ToString ());\r
546         }\r
547 \r
548         [Test]\r
549         [ExpectedException(typeof(ArgumentNullException))]\r
550         public void GetLastWriteTimeException1 ()\r
551         {\r
552                 Directory.GetLastWriteTime (null as string);\r
553         }\r
554 \r
555         [Test]\r
556         [ExpectedException(typeof(ArgumentException))]\r
557         public void GetLastWriteTimeException2 ()\r
558         {\r
559                 Directory.GetLastWriteTime ("");\r
560         }\r
561         \r
562         [Test]\r
563 #if !NET_2_0\r
564         [ExpectedException (typeof (IOException))]\r
565 #endif\r
566         public void GetLastWriteTime_NonExistingPath ()\r
567         {\r
568                 string path = TempFolder + DSC + "DirectoryTest.GetLastWriteTime.1";\r
569                 DeleteDirectory (path);\r
570                 try {\r
571                         DateTime time = Directory.GetLastWriteTime (path);\r
572 \r
573 #if NET_2_0\r
574                         DateTime expectedTime = (new DateTime (1601, 1, 1)).ToLocalTime ();\r
575                         Assert.AreEqual (expectedTime.Year, time.Year, "#1");\r
576                         Assert.AreEqual (expectedTime.Month, time.Month, "#2");\r
577                         Assert.AreEqual (expectedTime.Day, time.Day, "#3");\r
578                         Assert.AreEqual (expectedTime.Hour, time.Hour, "#4");\r
579                         Assert.AreEqual (expectedTime.Second, time.Second, "#5");\r
580                         Assert.AreEqual (expectedTime.Millisecond, time.Millisecond, "#6");\r
581 #endif\r
582                 } finally {\r
583                         DeleteDirectory (path);\r
584                 }\r
585         }\r
586 \r
587         [Test]\r
588         [ExpectedException(typeof(ArgumentException))]\r
589         public void GetLastWriteTimeException4 ()\r
590         {\r
591                 Directory.GetLastWriteTime ("    ");\r
592         }\r
593 \r
594         [Test]\r
595         [ExpectedException(typeof(ArgumentException))]\r
596         public void GetLastWriteTimeException5 ()\r
597         {\r
598                 Directory.GetLastWriteTime (Path.InvalidPathChars [0].ToString ());\r
599         }\r
600 \r
601         [Test]\r
602         [ExpectedException(typeof(ArgumentNullException))]\r
603         public void GetLastWriteTimeUtcException1 ()\r
604         {\r
605                 Directory.GetLastWriteTimeUtc (null as string);\r
606         }\r
607 \r
608         [Test]\r
609         [ExpectedException(typeof(ArgumentException))]\r
610         public void GetLastWriteTimeUtcException2 ()\r
611         {\r
612                 Directory.GetLastWriteTimeUtc ("");\r
613         }\r
614         \r
615         [Test]\r
616 #if !NET_2_0\r
617         [ExpectedException (typeof (IOException))]\r
618 #endif\r
619         public void GetLastWriteTimeUtc_NonExistingPath ()\r
620         {\r
621                 string path = TempFolder + DSC + "DirectoryTest.GetLastWriteTimeUtc.1";\r
622                 DeleteDirectory (path);\r
623                 try {\r
624                         DateTime time = Directory.GetLastWriteTimeUtc (path);\r
625 \r
626 #if NET_2_0\r
627                         Assert.AreEqual (1601, time.Year, "#1");\r
628                         Assert.AreEqual (1, time.Month, "#2");\r
629                         Assert.AreEqual (1, time.Day, "#3");\r
630                         Assert.AreEqual (0, time.Hour, "#4");\r
631                         Assert.AreEqual (0, time.Second, "#5");\r
632                         Assert.AreEqual (0, time.Millisecond, "#6");\r
633 #endif\r
634                 } finally {\r
635                         DeleteDirectory (path);\r
636                 }\r
637                 \r
638         }\r
639 \r
640         [Test]\r
641         [ExpectedException(typeof(ArgumentException))]\r
642         public void GetLastWriteTimeUtcException4 ()\r
643         {\r
644                 Directory.GetLastWriteTimeUtc ("    ");\r
645         }\r
646 \r
647         [Test]\r
648         [ExpectedException(typeof(ArgumentException))]\r
649         public void GetLastWriteTimeUtcException5 ()\r
650         {\r
651                 Directory.GetLastWriteTimeUtc (Path.InvalidPathChars[0].ToString ());\r
652         }\r
653 \r
654         [Test]\r
655         public void Move ()\r
656         {\r
657                 string path = TempFolder + DSC + "DirectoryTest.Test.9";\r
658                 string path2 = TempFolder + DSC + "DirectoryTest.Test.10";\r
659                 DeleteDirectory (path);\r
660                 DeleteDirectory (path2);\r
661                 try {\r
662                         Directory.CreateDirectory (path);\r
663                         Directory.CreateDirectory (path + DSC + "dir");\r
664                         Assert.IsTrue (Directory.Exists (path + DSC + "dir"), "#1");\r
665                 \r
666                         Directory.Move (path, path2);\r
667                         Assert.IsFalse (Directory.Exists (path + DSC + "dir"), "#2");\r
668                         Assert.IsTrue (Directory.Exists (path2 + DSC + "dir"), "#3");\r
669                 } finally {\r
670                         DeleteDirectory (path);\r
671                         DeleteDirectory (path2);\r
672                         if (Directory.Exists (path2 + DSC + "dir"))\r
673                                 Directory.Delete (path2 + DSC + "dir", true);\r
674                 }\r
675         }\r
676         \r
677         [Test]\r
678         [ExpectedException(typeof(IOException))]\r
679         public void MoveException1 ()\r
680         {\r
681                 string path = TempFolder + DSC + "DirectoryTest.Test.8";\r
682                 DeleteDirectory (path);\r
683                 try {\r
684                         Directory.Move (path, path);\r
685                 } finally {\r
686                         DeleteDirectory (path);\r
687                 }\r
688         }\r
689 \r
690         [Test]\r
691         [ExpectedException(typeof(ArgumentException))]\r
692         public void MoveException2 ()\r
693         {\r
694                 string path = TempFolder + DSC + "DirectoryTest.Test.11";\r
695                 DeleteDirectory (path);\r
696                 try {\r
697                         Directory.Move ("", path);\r
698                 } finally {\r
699                         DeleteDirectory (path);\r
700                 }\r
701         }\r
702 \r
703         [Test]\r
704         [ExpectedException(typeof(ArgumentException))]\r
705         public void MoveException3 ()\r
706         {\r
707                 string path = TempFolder + DSC + "DirectoryTest.Test.12";\r
708                 DeleteDirectory (path);\r
709                 try {\r
710                         Directory.Move ("             ", path);\r
711                 } finally {\r
712                         DeleteDirectory (path);\r
713                 }\r
714         }\r
715 \r
716         [Test]\r
717         [ExpectedException(typeof(ArgumentException))]\r
718         [Ignore ("On IA64, causes nunit to abort due to bug #76388")]\r
719         public void MoveException4 ()\r
720         {\r
721                 string path = TempFolder + DSC + "DirectoryTest.Test.13";\r
722                 path += Path.InvalidPathChars [0];\r
723                 string path2 = TempFolder + DSC + "DirectoryTest.Test.13";\r
724                 DeleteDirectory (path);\r
725                 DeleteDirectory (path2);\r
726                 try {\r
727                         Directory.CreateDirectory (path2);\r
728                         Directory.Move (path2, path);\r
729                 } finally {\r
730                         DeleteDirectory (path);\r
731                         DeleteDirectory (path2);\r
732                 }\r
733         }\r
734 \r
735         [Test]\r
736         [ExpectedException(typeof(DirectoryNotFoundException))]\r
737         public void MoveException5 ()\r
738         {\r
739                 string path = TempFolder + DSC + "DirectoryTest.Test.14";\r
740                 DeleteDirectory (path);\r
741                 try {\r
742                         Directory.Move (path, path + "Test.Test");\r
743                 } finally {\r
744                         DeleteDirectory (path);\r
745                         DeleteDirectory (path + "Test.Test");\r
746                 }\r
747         }\r
748 \r
749         [Test]\r
750         [ExpectedException(typeof(IOException))]\r
751         public void MoveException6 ()\r
752         {\r
753                 string path = TempFolder + DSC + "DirectoryTest.Test.15";\r
754                 DeleteDirectory (path);\r
755                 try {\r
756                         Directory.CreateDirectory (path);\r
757                         Directory.Move (path, path + DSC + "dir");\r
758                 } finally {\r
759                         DeleteDirectory (path);\r
760                         DeleteDirectory (path + DSC + "dir");\r
761                 }\r
762         }\r
763 \r
764         [Test]\r
765         [ExpectedException(typeof(IOException))]\r
766         public void MoveException7 ()\r
767         {\r
768                 string path = TempFolder + DSC + "DirectoryTest.Test.16";\r
769                 string path2 = TempFolder + DSC + "DirectoryTest.Test.17";\r
770                 \r
771                 DeleteDirectory (path);\r
772                 DeleteDirectory (path2);\r
773                 try {\r
774                         Directory.CreateDirectory (path);\r
775                         Directory.CreateDirectory (path2);\r
776                         Directory.Move (path, path2);\r
777                 } finally {\r
778                         DeleteDirectory (path);\r
779                         DeleteDirectory (path2);\r
780                 }\r
781         }\r
782         \r
783         [Test]\r
784 #if TARGET_JVM\r
785     [Category("NotWorking")]\r
786 #endif\r
787         public void CreationTime ()\r
788         {\r
789                 // check for Unix platforms - see FAQ for more details\r
790                 // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F\r
791                 int platform = (int) Environment.OSVersion.Platform;\r
792                 if ((platform == 4) || (platform == 128))\r
793                         Assert.Ignore ("Unix doesn't support CreationTime");\r
794 \r
795                 string path = TempFolder + DSC + "DirectoryTest.CreationTime.1";\r
796                 DeleteDirectory (path);\r
797                 \r
798                 try {\r
799                         Directory.CreateDirectory (path);\r
800                         Directory.SetCreationTime (path, new DateTime (2003, 6, 4, 6, 4, 0));\r
801 \r
802                         DateTime time = Directory.GetCreationTime (path);\r
803                         Assert.AreEqual (2003, time.Year, "#A1");\r
804                         Assert.AreEqual (6, time.Month, "#A2");\r
805                         Assert.AreEqual (4, time.Day, "#A3");\r
806                         Assert.AreEqual (6, time.Hour, "#A4");\r
807                         Assert.AreEqual (4, time.Minute, "#A5");\r
808                         Assert.AreEqual (0, time.Second, "#A6");\r
809                 \r
810                         time = TimeZone.CurrentTimeZone.ToLocalTime (Directory.GetCreationTimeUtc (path));\r
811                         Assert.AreEqual (2003, time.Year, "#B1");\r
812                         Assert.AreEqual (6, time.Month, "#B2");\r
813                         Assert.AreEqual (4, time.Day, "#B3");\r
814                         Assert.AreEqual (6, time.Hour, "#B4");\r
815                         Assert.AreEqual (4, time.Minute, "#B5");\r
816                         Assert.AreEqual (0, time.Second, "#B6");\r
817 \r
818                         Directory.SetCreationTimeUtc (path, new DateTime (2003, 6, 4, 6, 4, 0));\r
819                         time = TimeZone.CurrentTimeZone.ToUniversalTime (Directory.GetCreationTime (path));\r
820                         Assert.AreEqual (2003, time.Year, "#C1");\r
821                         Assert.AreEqual (6, time.Month, "#C2");\r
822                         Assert.AreEqual (4, time.Day, "#C3");\r
823                         Assert.AreEqual (6, time.Hour, "#C4");\r
824                         Assert.AreEqual (4, time.Minute, "#C5");\r
825                         Assert.AreEqual (0, time.Second, "#C6");\r
826 \r
827                         time = Directory.GetCreationTimeUtc (path);\r
828                         Assert.AreEqual (2003, time.Year, "#D1");\r
829                         Assert.AreEqual (6, time.Month, "#D2");\r
830                         Assert.AreEqual (4, time.Day, "#D3");\r
831                         Assert.AreEqual (6, time.Hour, "#D4");\r
832                         Assert.AreEqual (4, time.Minute, "#D5");\r
833                         Assert.AreEqual (0, time.Second, "#D6");\r
834                 } finally {\r
835                         DeleteDirectory (path);\r
836                 }\r
837         }\r
838 \r
839         [Test]\r
840 #if TARGET_JVM\r
841     [Category("NotWorking")]\r
842 #endif\r
843         public void LastAccessTime ()\r
844         {\r
845                 string path = TempFolder + DSC + "DirectoryTest.AccessTime.1";\r
846                 DeleteDirectory (path);\r
847                 \r
848                 try {\r
849                         Directory.CreateDirectory (path);\r
850                         Directory.SetLastAccessTime (path, new DateTime (2003, 6, 4, 6, 4, 0));\r
851 \r
852                         DateTime time = Directory.GetLastAccessTime (path);\r
853                         Assert.AreEqual (2003, time.Year, "#A1");\r
854                         Assert.AreEqual (6, time.Month, "#A2");\r
855                         Assert.AreEqual (4, time.Day, "#A3");\r
856                         Assert.AreEqual (6, time.Hour, "#A4");\r
857                         Assert.AreEqual (4, time.Minute, "#A5");\r
858                         Assert.AreEqual (0, time.Second, "#A6");\r
859                 \r
860                         time = TimeZone.CurrentTimeZone.ToLocalTime (Directory.GetLastAccessTimeUtc (path));\r
861                         Assert.AreEqual (2003, time.Year, "#B1");\r
862                         Assert.AreEqual (6, time.Month, "#B2");\r
863                         Assert.AreEqual (4, time.Day, "#B3");\r
864                         Assert.AreEqual (6, time.Hour, "#B4");\r
865                         Assert.AreEqual (4, time.Minute, "#B5");\r
866                         Assert.AreEqual (0, time.Second, "#B6");\r
867 \r
868                         Directory.SetLastAccessTimeUtc (path, new DateTime (2003, 6, 4, 6, 4, 0));\r
869                         time = TimeZone.CurrentTimeZone.ToUniversalTime (Directory.GetLastAccessTime (path));\r
870                         Assert.AreEqual (2003, time.Year, "#C1");\r
871                         Assert.AreEqual (6, time.Month, "#C2");\r
872                         Assert.AreEqual (4, time.Day, "#C3");\r
873                         Assert.AreEqual (6, time.Hour, "#C4");\r
874                         Assert.AreEqual (4, time.Minute, "#C5");\r
875                         Assert.AreEqual (0, time.Second, "#C6");\r
876 \r
877                         time = Directory.GetLastAccessTimeUtc (path);\r
878                         Assert.AreEqual (2003, time.Year, "#D1");\r
879                         Assert.AreEqual (6, time.Month, "#D2");\r
880                         Assert.AreEqual (4, time.Day, "#D3");\r
881                         Assert.AreEqual (6, time.Hour, "#D4");\r
882                         Assert.AreEqual (4, time.Minute, "#D5");\r
883                         Assert.AreEqual (0, time.Second, "#D6");\r
884                 } finally {\r
885                         DeleteDirectory (path);\r
886                 }\r
887         }\r
888 \r
889         [Test]\r
890         public void LastWriteTime ()\r
891         {\r
892                 string path = TempFolder + DSC + "DirectoryTest.WriteTime.1";\r
893                 DeleteDirectory (path);\r
894                 \r
895                 try {\r
896                         Directory.CreateDirectory (path);\r
897                         Directory.SetLastWriteTime (path, new DateTime (2003, 6, 4, 6, 4, 0));\r
898 \r
899                         DateTime time = Directory.GetLastWriteTime (path);\r
900                         Assert.AreEqual (2003, time.Year, "#A1");\r
901                         Assert.AreEqual (6, time.Month, "#A2");\r
902                         Assert.AreEqual (4, time.Day, "#A3");\r
903                         Assert.AreEqual (6, time.Hour, "#A4");\r
904                         Assert.AreEqual (4, time.Minute, "#A5");\r
905                         Assert.AreEqual (0, time.Second, "#A6");\r
906                 \r
907                         time = TimeZone.CurrentTimeZone.ToLocalTime (Directory.GetLastWriteTimeUtc (path));\r
908                         Assert.AreEqual (2003, time.Year, "#B1");\r
909                         Assert.AreEqual (6, time.Month, "#B2");\r
910                         Assert.AreEqual (4, time.Day, "#B3");\r
911                         Assert.AreEqual (6, time.Hour, "#B4");\r
912                         Assert.AreEqual (4, time.Minute, "#B5");\r
913                         Assert.AreEqual (0, time.Second, "#B6");\r
914 \r
915                         Directory.SetLastWriteTimeUtc (path, new DateTime (2003, 6, 4, 6, 4, 0));\r
916                         time = TimeZone.CurrentTimeZone.ToUniversalTime (Directory.GetLastWriteTime (path));\r
917                         Assert.AreEqual (2003, time.Year, "#C1");\r
918                         Assert.AreEqual (6, time.Month, "#C2");\r
919                         Assert.AreEqual (4, time.Day, "#C3");\r
920                         Assert.AreEqual (6, time.Hour, "#C4");\r
921                         Assert.AreEqual (4, time.Minute, "#C5");\r
922                         Assert.AreEqual (0, time.Second, "#C6");\r
923 \r
924                         time = Directory.GetLastWriteTimeUtc (path);\r
925                         Assert.AreEqual (2003, time.Year, "#D1");\r
926                         Assert.AreEqual (6, time.Month, "#D2");\r
927                         Assert.AreEqual (4, time.Day, "#D3");\r
928                         Assert.AreEqual (6, time.Hour, "#D4");\r
929                         Assert.AreEqual (4, time.Minute, "#D5");\r
930                         Assert.AreEqual (0, time.Second, "#D6");\r
931                 } finally {\r
932                         DeleteDirectory (path);\r
933                 }\r
934         }\r
935 \r
936         [Test]\r
937         [ExpectedException(typeof(ArgumentNullException))]\r
938         public void SetLastWriteTimeException1 ()\r
939         {\r
940                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
941                 Directory.SetLastWriteTime (null as string, time);\r
942         }\r
943 \r
944         [Test]\r
945         [ExpectedException(typeof(ArgumentException))]  \r
946         public void SetLastWriteTimeException2 ()\r
947         {\r
948                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
949                 Directory.SetLastWriteTime ("", time);\r
950         }\r
951         \r
952         [Test]\r
953         [ExpectedException(typeof(FileNotFoundException))]\r
954         public void SetLastWriteTimeException3 ()\r
955         {\r
956                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
957                 string path = TempFolder + DSC + "DirectoryTest.SetLastWriteTime.2";\r
958                 DeleteDirectory (path);\r
959                 try {\r
960                         Directory.SetLastWriteTime (path, time);\r
961                 } finally {\r
962                         DeleteDirectory (path);\r
963                 }\r
964         }\r
965 \r
966         [Test]\r
967         [ExpectedException(typeof(ArgumentException))]\r
968         public void SetLastWriteTimeException4 ()\r
969         {\r
970                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
971                 Directory.SetLastWriteTime ("    ", time);\r
972         }\r
973 \r
974         [Test]\r
975         [ExpectedException(typeof(ArgumentException))]\r
976         public void SetLastWriteTimeException5 ()\r
977         {\r
978                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
979                 Directory.SetLastWriteTime (Path.InvalidPathChars [0].ToString (), time);\r
980         }\r
981 \r
982 //      [Test]\r
983 //      [ExpectedException(typeof(ArgumentOutOfRangeException))]\r
984 //      public void SetLastWriteTimeException6 ()\r
985 //      {\r
986 //              DateTime time = new DateTime (1003, 4, 6, 6, 4, 2);\r
987 //              string path = TempFolder + Path.DirectorySeparatorChar + "DirectoryTest.SetLastWriteTime.1";\r
988 //\r
989 //              try {\r
990 //                      if (!Directory.Exists (path))\r
991 //                              Directory.CreateDirectory (path);\r
992 //              \r
993 //                      Directory.SetLastWriteTime (path, time);\r
994 //              } finally {\r
995 //                      DeleteDirectory (path);\r
996 //              }\r
997 //\r
998 //      }\r
999 \r
1000         [Test]\r
1001         [ExpectedException(typeof(ArgumentNullException))]\r
1002         public void SetLastWriteTimeUtcException1 ()\r
1003         {\r
1004                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1005                 Directory.SetLastWriteTimeUtc (null as string, time);\r
1006         }\r
1007 \r
1008         [Test]\r
1009         [ExpectedException(typeof(ArgumentException))]\r
1010         public void SetLastWriteTimeUtcException2 ()\r
1011         {\r
1012                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1013                 Directory.SetLastWriteTimeUtc ("", time);\r
1014         }\r
1015         \r
1016         [Test]\r
1017         [ExpectedException(typeof(FileNotFoundException))]\r
1018         public void SetLastWriteTimeUtcException3 ()\r
1019         {\r
1020                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1021                 string path = TempFolder + DSC + "DirectoryTest.SetLastWriteTimeUtc.2";\r
1022                 DeleteDirectory (path);\r
1023                 try {\r
1024                         Directory.SetLastWriteTimeUtc (path, time);\r
1025                 } finally {\r
1026                         DeleteDirectory (path);\r
1027                 }\r
1028         }\r
1029 \r
1030         [Test]\r
1031         [ExpectedException(typeof(ArgumentException))]\r
1032         public void SetLastWriteTimeUtcException4 ()\r
1033         {\r
1034                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1035                 Directory.SetLastWriteTimeUtc ("    ", time);\r
1036         }\r
1037 \r
1038         [Test]\r
1039         [ExpectedException(typeof(ArgumentException))]\r
1040         public void SetLastWriteTimeUtcException5 ()\r
1041         {\r
1042                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1043                 Directory.SetLastWriteTimeUtc (Path.InvalidPathChars [0].ToString (), time);\r
1044         }\r
1045 \r
1046 //      [Test]\r
1047 //      [ExpectedException(typeof(ArgumentOutOfRangeException))]\r
1048 //      public void SetLastWriteTimeUtcException6 ()\r
1049 //      {\r
1050 //              DateTime time = new DateTime (1000, 4, 6, 6, 4, 2);\r
1051 //              string path = TempFolder + DSC + "DirectoryTest.SetLastWriteTimeUtc.1";\r
1052 //\r
1053 //              if (!Directory.Exists (path))\r
1054 //                      Directory.CreateDirectory (path);\r
1055 //              try {\r
1056 //                      Directory.SetLastWriteTimeUtc (path, time);\r
1057 //              } finally {\r
1058 //                      DeleteDirectory (path);\r
1059 //              }\r
1060 //      }\r
1061 \r
1062         [Test]\r
1063         [ExpectedException(typeof(ArgumentNullException))]\r
1064 #if TARGET_JVM\r
1065     [Category("NotWorking")]\r
1066 #endif\r
1067         public void SetLastAccessTimeException1 ()\r
1068         {\r
1069                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1070                 Directory.SetLastAccessTime (null as string, time);\r
1071         }\r
1072 \r
1073         [Test]\r
1074         [ExpectedException(typeof(ArgumentException))]\r
1075 #if TARGET_JVM\r
1076     [Category("NotWorking")]\r
1077 #endif\r
1078         public void SetLastAccessTimeException2 ()\r
1079         {\r
1080                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1081                 Directory.SetLastAccessTime ("", time);\r
1082         }\r
1083         \r
1084         [Test]\r
1085         [ExpectedException(typeof(FileNotFoundException))]\r
1086 #if TARGET_JVM\r
1087     [Category("NotWorking")]\r
1088 #endif\r
1089         public void SetLastAccessTimeException3 ()\r
1090         {\r
1091                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1092                 string path = TempFolder + DSC + "DirectoryTest.SetLastAccessTime.2";\r
1093                 DeleteDirectory (path);\r
1094                 try {\r
1095                         Directory.SetLastAccessTime (path, time);\r
1096                 } finally {\r
1097                         DeleteDirectory (path);\r
1098                 }\r
1099         }\r
1100 \r
1101         [Test]\r
1102         [ExpectedException(typeof(ArgumentException))]\r
1103 #if TARGET_JVM\r
1104     [Category("NotWorking")]\r
1105 #endif\r
1106         public void SetLastAccessTimeException4 ()\r
1107         {\r
1108                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1109                 Directory.SetLastAccessTime ("    ", time);\r
1110         }\r
1111 \r
1112         [Test]\r
1113         [ExpectedException(typeof(ArgumentException))]\r
1114 #if TARGET_JVM\r
1115     [Category("NotWorking")]\r
1116 #endif\r
1117         public void SetLastAccessTimeException5 ()\r
1118         {\r
1119                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1120                 Directory.SetLastAccessTime (Path.InvalidPathChars [0].ToString (), time);\r
1121         }\r
1122 \r
1123 //      [Test]\r
1124 //      [ExpectedException(typeof(ArgumentOutOfRangeException))]\r
1125 //      public void SetLastAccessTimeException6 ()\r
1126 //      {\r
1127 //              DateTime time = new DateTime (1003, 4, 6, 6, 4, 2);\r
1128 //              string path = TempFolder + DSC + "DirectoryTest.SetLastAccessTime.1";\r
1129 //\r
1130 //              if (!Directory.Exists (path))\r
1131 //                      Directory.CreateDirectory (path);\r
1132 //              try {\r
1133 //                      Directory.SetLastAccessTime (path, time);\r
1134 //              } finally {\r
1135 //                      DeleteDirectory (path);\r
1136 //              }\r
1137 //\r
1138 //      }\r
1139 \r
1140         [Test]\r
1141         [ExpectedException(typeof(ArgumentNullException))]\r
1142 #if TARGET_JVM\r
1143     [Category("NotWorking")]\r
1144 #endif\r
1145         public void SetLastAccessTimeUtcException1 ()\r
1146         {\r
1147                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1148                 Directory.SetLastAccessTimeUtc (null as string, time);\r
1149         }\r
1150 \r
1151         [Test]\r
1152         [ExpectedException(typeof(ArgumentException))]\r
1153 #if TARGET_JVM\r
1154     [Category("NotWorking")]\r
1155 #endif\r
1156         public void SetLastAccessTimeUtcException2 ()\r
1157         {\r
1158                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1159                 Directory.SetLastAccessTimeUtc ("", time);\r
1160         }\r
1161         \r
1162         [Test]\r
1163         [ExpectedException(typeof(FileNotFoundException))]\r
1164 #if TARGET_JVM\r
1165     [Category("NotWorking")]\r
1166 #endif\r
1167         public void SetLastAccessTimeUtcException3 ()\r
1168         {\r
1169                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1170                 string path = TempFolder + DSC + "DirectoryTest.SetLastAccessTimeUtc.2";\r
1171                 DeleteDirectory (path);\r
1172                 try {\r
1173                         Directory.SetLastAccessTimeUtc (path, time);\r
1174                 } finally {\r
1175                         DeleteDirectory (path);\r
1176                 }\r
1177         }\r
1178 \r
1179         [Test]\r
1180         [ExpectedException(typeof(ArgumentException))]\r
1181 #if TARGET_JVM\r
1182     [Category("NotWorking")]\r
1183 #endif\r
1184         public void SetLastAccessTimeUtcException4 ()\r
1185         {\r
1186                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1187                 Directory.SetLastAccessTimeUtc ("    ", time);\r
1188         }\r
1189 \r
1190         [Test]\r
1191         [ExpectedException(typeof(ArgumentException))]\r
1192 #if TARGET_JVM\r
1193     [Category("NotWorking")]\r
1194 #endif\r
1195         public void SetLastAccessTimeUtcException5 ()\r
1196         {\r
1197                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1198                 Directory.SetLastAccessTimeUtc (Path.InvalidPathChars [0].ToString (), time);\r
1199         }\r
1200 \r
1201 //      [Test]\r
1202 //      [ExpectedException(typeof(ArgumentOutOfRangeException))]\r
1203 //      public void SetLastAccessTimeUtcException6 ()\r
1204 //      {\r
1205 //              DateTime time = new DateTime (1000, 4, 6, 6, 4, 2);\r
1206 //              string path = TempFolder + DSC + "DirectoryTest.SetLastAccessTimeUtc.1";\r
1207 //\r
1208 //              if (!Directory.Exists (path))\r
1209 //                      Directory.CreateDirectory (path);\r
1210 //              try {\r
1211 //                      Directory.SetLastAccessTimeUtc (path, time);\r
1212 //              } finally {\r
1213 //                      DeleteDirectory (path);\r
1214 //              }\r
1215 //      }\r
1216 \r
1217         [Test]\r
1218         [ExpectedException(typeof(ArgumentNullException))]\r
1219 #if TARGET_JVM\r
1220     [Category("NotWorking")]\r
1221 #endif\r
1222         public void SetCreationTimeException1 ()\r
1223         {\r
1224                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1225                 Directory.SetCreationTime (null as string, time);\r
1226         }\r
1227 \r
1228         [Test]\r
1229         [ExpectedException(typeof(ArgumentException))]\r
1230 #if TARGET_JVM\r
1231     [Category("NotWorking")]\r
1232 #endif\r
1233         public void SetCreationTimeException2 ()\r
1234         {\r
1235                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1236                 Directory.SetCreationTime ("", time);\r
1237         }\r
1238         \r
1239         [Test]\r
1240         [ExpectedException(typeof(FileNotFoundException))]\r
1241 #if TARGET_JVM\r
1242     [Category("NotWorking")]\r
1243 #endif\r
1244         public void SetCreationTimeException3 ()\r
1245         {\r
1246                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1247                 string path = TempFolder + DSC + "DirectoryTest.SetCreationTime.2";\r
1248                 DeleteDirectory (path);\r
1249                 \r
1250                 try {\r
1251                         Directory.SetCreationTime (path, time);\r
1252                 } finally {\r
1253                         DeleteDirectory (path);\r
1254                 }\r
1255         }\r
1256 \r
1257         [Test]\r
1258         [ExpectedException(typeof(ArgumentException))]\r
1259 #if TARGET_JVM\r
1260     [Category("NotWorking")]\r
1261 #endif\r
1262         public void SetCreationTimeException4 ()\r
1263         {\r
1264                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1265                 Directory.SetCreationTime ("    ", time);\r
1266         }\r
1267 \r
1268         [Test]\r
1269         [ExpectedException(typeof(ArgumentException))]\r
1270 #if TARGET_JVM\r
1271     [Category("NotWorking")]\r
1272 #endif\r
1273         public void SetCreationTimeException5 ()\r
1274         {\r
1275                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1276                 Directory.SetCreationTime (Path.InvalidPathChars [0].ToString (), time);\r
1277         }\r
1278 \r
1279 //      [Test]\r
1280 //      [ExpectedException(typeof(ArgumentOutOfRangeException))]\r
1281 //      public void SetCreationTimeException6 ()\r
1282 //      {\r
1283 //              DateTime time = new DateTime (1003, 4, 6, 6, 4, 2);\r
1284 //              string path = TempFolder + DSC + "DirectoryTest.SetCreationTime.1";\r
1285 //\r
1286 //              if (!Directory.Exists (path))\r
1287 //                      Directory.CreateDirectory (path);\r
1288 //              try {\r
1289 //                      Directory.SetCreationTime (path, time);\r
1290 //                      DeleteDirectory (path);\r
1291 //              } finally {\r
1292 //                      DeleteDirectory (path);\r
1293 //              }\r
1294 //\r
1295 //      }\r
1296 \r
1297         [Test]\r
1298         [ExpectedException(typeof(ArgumentNullException))]\r
1299 #if TARGET_JVM\r
1300     [Category("NotWorking")]\r
1301 #endif\r
1302         public void SetCreationTimeUtcException1 ()\r
1303         {\r
1304                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1305                 Directory.SetCreationTimeUtc (null as string, time);\r
1306         }\r
1307 \r
1308         [Test]\r
1309         [ExpectedException(typeof(ArgumentException))]\r
1310 #if TARGET_JVM\r
1311     [Category("NotWorking")]\r
1312 #endif\r
1313         public void SetCreationTimeUtcException2 ()\r
1314         {\r
1315                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1316                 Directory.SetCreationTimeUtc ("", time);\r
1317         }\r
1318         \r
1319         [Test]\r
1320         [ExpectedException(typeof(FileNotFoundException))]\r
1321 #if TARGET_JVM\r
1322     [Category("NotWorking")]\r
1323 #endif\r
1324         public void SetCreationTimeUtcException3 ()\r
1325         {\r
1326                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1327                 string path = TempFolder + DSC + "DirectoryTest.SetLastAccessTimeUtc.2";\r
1328                 DeleteDirectory (path);\r
1329                 \r
1330                 try {\r
1331                         Directory.SetCreationTimeUtc (path, time);\r
1332                         DeleteDirectory (path);\r
1333                 } finally {\r
1334                         DeleteDirectory (path);\r
1335                 }\r
1336         }\r
1337 \r
1338         [Test]\r
1339         [ExpectedException(typeof(ArgumentException))]\r
1340 #if TARGET_JVM\r
1341     [Category("NotWorking")]\r
1342 #endif\r
1343         public void SetCreationTimeUtcException4 ()\r
1344         {\r
1345                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1346                 Directory.SetCreationTimeUtc ("    ", time);\r
1347         }\r
1348 \r
1349         [Test]\r
1350         [ExpectedException(typeof(ArgumentException))]\r
1351 #if TARGET_JVM\r
1352     [Category("NotWorking")]\r
1353 #endif\r
1354         public void SetCreationTimeUtcException5 ()\r
1355         {\r
1356                 DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
1357                 Directory.SetCreationTimeUtc (Path.InvalidPathChars [0].ToString (), time);\r
1358         }\r
1359 \r
1360 //      [Test]\r
1361 //      [ExpectedException(typeof(ArgumentOutOfRangeException))]\r
1362 //      public void SetCreationTimeUtcException6 ()\r
1363 //      {\r
1364 //              DateTime time = new DateTime (1000, 4, 6, 6, 4, 2);\r
1365 //              string path = TempFolder + DSC + "DirectoryTest.SetLastAccessTimeUtc.1";\r
1366 //\r
1367 //              if (!Directory.Exists (path))\r
1368 //                      Directory.CreateDirectory (path);\r
1369 //              try {\r
1370 //                      Directory.SetCreationTimeUtc (path, time);\r
1371 //                      DeleteDirectory (path);\r
1372 //              } finally {\r
1373 //                      DeleteDirectory (path);\r
1374 //              }\r
1375 //      }\r
1376 \r
1377         [Test]\r
1378         public void GetDirectories ()\r
1379         {\r
1380                 string path = TempFolder;\r
1381                 string DirPath = TempFolder + Path.DirectorySeparatorChar + ".GetDirectories";\r
1382                 DeleteDirectory (DirPath);\r
1383                 \r
1384                 try {\r
1385                         Directory.CreateDirectory (DirPath);\r
1386                 \r
1387                         string [] dirs = Directory.GetDirectories (path);\r
1388                 \r
1389                         foreach (string directory in dirs) {\r
1390                         \r
1391                                 if (directory == DirPath)\r
1392                                         return;\r
1393                         }\r
1394                 \r
1395                         Assert.Fail ("Directory Not Found");\r
1396                 } finally {\r
1397                         DeleteDirectory (DirPath);\r
1398                 }\r
1399         }\r
1400 \r
1401         [Test]\r
1402         public void GetParentOfRootDirectory ()\r
1403         {\r
1404                 DirectoryInfo info;\r
1405 \r
1406                 info = Directory.GetParent (Path.GetPathRoot (Path.GetTempPath ()));\r
1407                 Assert.IsNull (info);\r
1408         }\r
1409         \r
1410         [Test]\r
1411         public void GetFiles ()\r
1412         {\r
1413                 string path = TempFolder;\r
1414                 string DirPath = TempFolder + Path.DirectorySeparatorChar + ".GetFiles";\r
1415                 if (File.Exists (DirPath))\r
1416                         File.Delete (DirPath);\r
1417                 \r
1418                 try {\r
1419                         File.Create (DirPath).Close ();\r
1420                         string [] files = Directory.GetFiles (TempFolder);\r
1421                         foreach (string directory in files) {\r
1422                         \r
1423                                 if (directory == DirPath)\r
1424                                         return;\r
1425                         }\r
1426                 \r
1427                         Assert.Fail ("File Not Found");\r
1428                 } finally {\r
1429                         if (File.Exists (DirPath))\r
1430                                 File.Delete (DirPath);\r
1431                 }\r
1432         }\r
1433 \r
1434         [Test]\r
1435         [ExpectedException (typeof (ArgumentNullException))]\r
1436         public void SetCurrentDirectoryNull ()\r
1437         {\r
1438                 Directory.SetCurrentDirectory (null);\r
1439         }\r
1440 \r
1441         [Test]\r
1442         [ExpectedException (typeof (ArgumentException))]\r
1443         public void SetCurrentDirectoryEmpty ()\r
1444         {\r
1445                 Directory.SetCurrentDirectory (String.Empty);\r
1446         }\r
1447 \r
1448         [Test]\r
1449         [ExpectedException (typeof (ArgumentException))]\r
1450         public void SetCurrentDirectoryWhitespace ()\r
1451         {\r
1452                 Directory.SetCurrentDirectory (" ");\r
1453         }\r
1454 \r
1455 \r
1456         [Test]\r
1457         public void GetNoFiles () // Bug 58875. This throwed an exception on windows.\r
1458         {\r
1459                 DirectoryInfo dir = new DirectoryInfo (".");\r
1460                 dir.GetFiles ("*.nonext");\r
1461         }\r
1462 \r
1463         [Test]\r
1464         public void FilenameOnly () // bug 78209\r
1465         {\r
1466                 Directory.GetParent ("somefile");\r
1467         }\r
1468 \r
1469         private void DeleteDirectory (string path)\r
1470         {\r
1471                 if (Directory.Exists (path))\r
1472                         Directory.Delete (path, true);\r
1473         }\r
1474 \r
1475         private void DeleteFile (string path)\r
1476         {\r
1477                 if (File.Exists (path))\r
1478                         File.Delete (path);\r
1479         }\r
1480 }\r
1481 }\r