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