fixed tests
[mono.git] / mcs / class / corlib / Test / System.IO / FileInfoTest.cs
1 // FileInfoTest.cs - NUnit Test Cases for System.IO.FileInfo class
2 //
3 // Ville Palo (vi64pa@koti.soon.fi)
4 // 
5 // (C) 2003 Ville Palo
6 // 
7
8
9 using NUnit.Framework;
10 using System;
11 using System.IO;
12
13 namespace MonoTests.System.IO
14 {
15         [TestFixture]
16         public class FileInfoTest : Assertion
17         {
18                 string TempFolder = Path.Combine (Path.GetTempPath (), "MonoTests.System.IO.Tests");
19                 static readonly char DSC = Path.DirectorySeparatorChar;
20
21                 [SetUp]
22                 protected void SetUp() {
23                         if (Directory.Exists (TempFolder))
24                                 Directory.Delete (TempFolder, true);
25                         Directory.CreateDirectory (TempFolder);
26                 }
27                 
28                 [TearDown]
29                 protected void TearDown() {
30                         if (Directory.Exists (TempFolder))
31                                 Directory.Delete (TempFolder, true);
32                 }
33                 
34                 [Test]
35                 public void Ctr ()
36                 {
37                         string path = TempFolder + DSC + "FIT.Ctr.Test";
38                         DeleteFile (path);
39                         
40                         FileInfo info = new FileInfo (path);
41                         AssertEquals ("test#01", true, info.DirectoryName.EndsWith (".Tests"));
42                         AssertEquals ("test#02", false, info.Exists);
43                         AssertEquals ("test#03", ".Test", info.Extension);
44                         AssertEquals ("test#05", "FIT.Ctr.Test", info.Name);                    
45                 }
46                 
47                 [Test]
48                 [ExpectedException(typeof(ArgumentNullException))]
49                 public void CtorArgumentNullException ()
50                 {
51                         FileInfo info = new FileInfo (null);                    
52                 }
53                 
54                 [Test]
55                 [ExpectedException(typeof(ArgumentException))]
56                 public void CtorArgumentException1 ()
57                 {
58                         FileInfo info = new FileInfo ("");                      
59                 }
60                 
61                 [Test]
62                 [ExpectedException(typeof(ArgumentException))]
63                 public void CtorArgumentException2 ()
64                 {
65                         FileInfo info = new FileInfo ("      ");                        
66                 }
67
68                 [Test]
69                 [ExpectedException(typeof(ArgumentException))]
70                 public void CtorArgumentException3 ()
71                 {
72                         string path = "";
73                         foreach (char c in Path.InvalidPathChars) {
74                                 path += c;
75                         }
76                         FileInfo info = new FileInfo (path);                    
77                 }
78                                
79                 [Test]
80                 public void DirectoryTest ()
81                 {
82                         string path = TempFolder + DSC + "FIT.Directory.Test";
83                         DeleteFile (path);
84                         
85                         FileInfo info = new FileInfo (path);
86                         DirectoryInfo dir = info.Directory;
87                         AssertEquals ("test#01", "MonoTests.System.IO.Tests", dir.Name);
88                 }
89                 
90                 [Test]
91                 public void Exists ()
92                 {
93                         string path = TempFolder + DSC + "FIT.Exists.Test";
94                         DeleteFile (path);
95                         
96                         try {
97                                 FileInfo info = new FileInfo (path);
98                                 AssertEquals ("test#01", false, info.Exists);
99                         
100                                 File.Create (path).Close ();
101                                 AssertEquals ("test#02", false, info.Exists);
102                                 info = new FileInfo (path);
103                                 AssertEquals ("test#03", true, info.Exists);                    
104                         } finally {
105                                 DeleteFile (path);
106                         }
107                 }
108
109 #if NET_2_0
110                 
111                 [Test, Category ("NotWorking")]
112                 public void IsReadOnly ()
113                 {
114                         string path = TempFolder + DSC + "FIT.IsReadOnly.Test";
115                         DeleteFile (path);
116                         
117                         try {
118                                 FileStream stream = File.Create (path);
119                                 stream.WriteByte (12);
120                                 stream.Close ();
121
122                                 FileInfo info1 = new FileInfo (path);
123                                 AssertEquals ("test#01", false, info1.IsReadOnly);
124
125                                 FileInfo info2 = new FileInfo (path);
126                                 info2.IsReadOnly = true;
127                                 AssertEquals ("test#02", true, info1.IsReadOnly);
128
129                                 FileInfo info3 = new FileInfo (path);
130                                 info2.IsReadOnly = false;
131                                 AssertEquals ("test#03", false, info1.IsReadOnly);
132                         } finally {
133                                 DeleteFile (path);
134                         }
135                 }
136 #endif
137                 
138                 [Test]
139                 public void Length ()
140                 {
141                         string path = TempFolder + DSC + "FIT.Length.Test";
142                         DeleteFile (path);
143                         
144                         try {
145                                 FileStream stream = File.Create (path);
146                                 FileInfo info = new FileInfo (path);
147                                 AssertEquals ("test#01", 0, info.Length);
148                                 stream.WriteByte (12);
149                                 stream.Flush ();
150                                 AssertEquals ("test#02", 0, info.Length);
151                                 info = new FileInfo (path);
152                                 AssertEquals ("test#03", 1, info.Length);
153                                 stream.Close ();
154                         } finally {
155                                 DeleteFile (path);
156                         }
157                 }
158                 
159                 [Test]
160                 [ExpectedException (typeof (FileNotFoundException))]
161                 public void LengthException ()
162                 {
163                         string path = TempFolder + DSC + "FIT.LengthException.Test";
164                         DeleteFile (path);
165                         FileInfo info = new FileInfo (path);
166                         long l = info.Length;
167                 }
168                 
169                 [Test]
170                 public void AppendText ()
171                 {
172                         string path = TempFolder + DSC + "FIT.AppendText.Test";
173                         DeleteFile (path);
174                         
175                         try {
176                                 FileInfo info = new FileInfo (path);
177                         
178                                 AssertEquals ("test#01", false, info.Exists);
179                         
180                                 StreamWriter writer = info.AppendText ();
181                                 info = new FileInfo (path);
182                                 AssertEquals ("test#02", true, info.Exists );
183                                 
184                                 writer.Write ("aaa");
185                                 writer.Flush ();
186                                 writer.Close ();
187                         
188                                 AssertEquals ("test#03", 0, info.Length);
189                                 info = new FileInfo (path);
190                                 AssertEquals ("test#04", 3, info.Length);
191                         } finally {
192                                 DeleteFile (path);
193                         }
194                         
195                 }
196                 
197                 [Test]
198                 public void CopyTo ()
199                 {
200                         string path1 = TempFolder + DSC + "FIT.CopyTo.Source.Test";
201                         string path2 = TempFolder + DSC + "FIT.CopyTo.Dest.Test";
202                         DeleteFile (path1);
203                         DeleteFile (path2);
204                         try {
205                                 File.Create (path1).Close ();
206                         
207                                 FileInfo info = new FileInfo (path1);
208                                 AssertEquals ("test#01", true, info.Exists);
209                                                 
210                                 FileInfo info2 = info.CopyTo (path2);
211                                 info = new FileInfo (path1);
212                                 AssertEquals ("test#02", true, info2.Exists);
213                         } finally {
214                                 DeleteFile (path1);
215                                 DeleteFile (path2);                     
216                         }
217                 }
218                 
219                 [Test]
220                 public void CopyTo2 ()
221                 {
222                         string path1 = TempFolder + DSC + "FIT.CopyTo2.Source.Test";
223                         string path2 = TempFolder + DSC + "FIT.CopyTo2.Dest.Test";
224                         DeleteFile (path1);
225                         DeleteFile (path2);
226                         try {
227                                 File.Create (path1).Close ();
228                                 File.Create (path2).Close ();           
229                                 FileInfo info = new FileInfo (path1);
230                         
231                                 FileInfo info2 = info.CopyTo (path2, true);
232                                 info = new FileInfo (path1);
233                                 AssertEquals ("test#01", true, info.Exists);
234                                 AssertEquals ("test#02", true, info2.Exists);
235                         } finally {
236                                 DeleteFile (path1);
237                                 DeleteFile (path2);
238                         }
239                 }
240                 
241                 [Test]
242                 [ExpectedException (typeof (IOException))]
243                 public void CopyToIOException ()
244                 {
245                         string path1 = TempFolder + DSC + "FIT.CopyToException.Source.Test";
246                         string path2 = TempFolder + DSC + "FIT.CopyToException.Dest.Test";
247
248                         try {
249                                 DeleteFile (path1);
250                                 DeleteFile (path2);
251                                 File.Create (path1).Close ();
252                                 File.Create (path2).Close ();           
253                                 FileInfo info = new FileInfo (path1);                   
254                                 FileInfo info2 = info.CopyTo (path2);                   
255                         } finally {
256                                 DeleteFile (path1);
257                                 DeleteFile (path2);
258                         }
259                 }
260
261                 [Test]
262                 [ExpectedException (typeof (IOException))]
263                 public void CopyToIOException2 ()
264                 {
265                         string path1 = TempFolder + DSC + "FIT.CopyToException.Source.Test";
266                         string path2 = TempFolder + DSC + "FIT.CopyToException.Dest.Test";
267
268                         try {
269                                 DeleteFile (path1);
270                                 DeleteFile (path2);
271                                 File.Create (path1).Close ();
272                                 File.Create (path2).Close ();           
273                                 FileInfo info = new FileInfo (path1);                   
274                                 FileInfo info2 = info.CopyTo (path2, false);
275                         } finally {
276                                 DeleteFile (path1);
277                                 DeleteFile (path2);
278                         }
279                 }
280                 
281                 [Test]
282                 [ExpectedException (typeof (ArgumentNullException))]
283                 public void CopyToArgumentNullException ()
284                 {
285                         string path = TempFolder + DSC + "FIT.CopyToArgumentNullException.Test";
286                         DeleteFile (path);
287                         try {
288                                 File.Create (path).Close ();
289                                 FileInfo info = new FileInfo (path);
290                                 info.CopyTo (null, false);
291                         } finally {
292                                 DeleteFile (path);
293                         }
294                 }
295
296                 [Test]
297                 [ExpectedException (typeof (ArgumentException))]
298                 public void CopyToArgumentException1 ()
299                 {
300                         string path = TempFolder + DSC + "FIT.CopyToArgument1Exception.Test";
301                         DeleteFile (path);
302                         
303                         try {
304                                 File.Create (path).Close ();
305                                 FileInfo info = new FileInfo (path);
306                                 info.CopyTo ("", false);
307                         } finally {
308                                 DeleteFile (path);
309                         }
310                 }
311
312                 [Test]
313                 [ExpectedException (typeof (ArgumentException))]
314                 public void CopyToArgumentException2 ()
315                 {
316                         string path = TempFolder + DSC + "FIT.CopyToArgument2Exception.Test";
317                         DeleteFile (path);
318                         
319                         try {
320                                 File.Create (path).Close ();
321                                 FileInfo info = new FileInfo (path);
322                                 info.CopyTo ("    ", false);
323                         } finally {
324                                 DeleteFile (path);
325                         }
326                 }
327
328                 [Test]
329                 [ExpectedException (typeof (ArgumentException))]
330                 public void CopyToArgumentException3 ()
331                 {
332                         string path = TempFolder + DSC + "FIT.CopyToArgument3Exception.Test";
333                         DeleteFile (path);
334                         
335                         try {
336                                 File.Create (path).Close ();
337                                 FileInfo info = new FileInfo (path);
338                                 info.CopyTo ("    ", false);
339                         } finally {
340                                 DeleteFile (path);
341                         }
342                 }
343
344                 [Test]
345                 [ExpectedException (typeof (ArgumentException))]
346                 public void CopyToArgumentException4 ()
347                 {
348                         string path = TempFolder + DSC + "FIT.CopyToArgument4Exception.Test";
349                         string path2 = "";
350                         DeleteFile (path);
351                         
352                         try {
353                                 File.Create (path).Close ();
354                                 FileInfo info = new FileInfo (path);
355                         
356                                 foreach (char c in Path.InvalidPathChars) {
357                                         path2 += c;
358                                 }
359                                 info.CopyTo (path2, false);
360                         } finally {
361                                 DeleteFile (path);
362                         }
363                 }
364                 
365                 [Test]
366                 public void Create ()
367                 {
368                         string path = TempFolder + DSC + "FIT.Create.Test";
369                         DeleteFile (path);
370                         
371                         try {
372                                 FileInfo info = new FileInfo (path);
373                                 AssertEquals ("test#01", false, info.Exists);
374                                 FileStream stream = info.Create ();                             
375                                 AssertEquals ("test#02", false, info.Exists);
376                                 info = new FileInfo (path);
377                                 AssertEquals ("test#03", true, info.Exists);
378                                 AssertEquals ("test#04", true, stream.CanRead);
379                                 AssertEquals ("test#05", true, stream.CanWrite);
380                                 AssertEquals ("test#06", true, stream.CanSeek);
381                                 stream.Close ();
382                         } finally {
383                                 DeleteFile (path);
384                         }
385                 }
386                 
387                 [Test]
388                 public void CreateText ()
389                 {
390                         string path = TempFolder + DSC + "FIT.CreateText.Test";
391                         DeleteFile (path);
392                         
393                         try {
394                                 FileInfo info = new FileInfo (path);
395                                 AssertEquals ("test#01", false, info.Exists);
396                                 StreamWriter writer = info.CreateText ();
397                                 writer.WriteLine ("test");
398                                 writer.Close ();
399                                 info = new FileInfo (path);
400                                 AssertEquals ("test#02", true, info.Exists);
401                         } finally {
402                                 DeleteFile (path);
403                         }
404                 }
405                 
406                 [Test]
407                 [ExpectedException (typeof (UnauthorizedAccessException))]
408                 public void CreateTextUnauthorizedAccessException ()
409                 {
410                         string path = TempFolder;
411                         
412                         FileInfo info = new FileInfo (path);
413                         AssertEquals ("test#01", false, info.Exists);
414                         StreamWriter writer = info.CreateText ();
415                         
416                 }
417                 
418                 [Test]
419                 public void Delete ()
420                 {
421                         string path = TempFolder + DSC + "FIT.Delete.Test";
422                         DeleteFile (path);
423                         
424                         try {
425                                 FileInfo info = new FileInfo (path);
426                                 AssertEquals ("test#01", false, info.Exists);
427                                 info.Create ().Close ();
428                                 info = new FileInfo (path);
429                                 AssertEquals ("test#02", true, info.Exists);
430                                 info.Delete ();
431                                 AssertEquals ("test#03", true, info.Exists);
432                                 info = new FileInfo (path);
433                                 AssertEquals ("test#04", false, info.Exists);                                                           
434                         } finally {
435                                 DeleteFile (path);
436                         }
437                 }
438                 
439                 [Test]
440                 [ExpectedException (typeof (UnauthorizedAccessException))]
441                 public void DeleteUnauthorizedAccessException ()
442                 {
443                         string path = TempFolder;
444                         FileInfo info = new FileInfo (path);
445                         info.Delete ();                 
446                 }
447                 
448                 [Test]
449                 public void MoveTo ()
450                 {
451                         string path1 = TempFolder + DSC + "FIT.MoveTo.Source.Test";
452                         string path2 = TempFolder + DSC + "FIT.MoveTo.Dest.Test";
453                         DeleteFile (path1);
454                         DeleteFile (path2);
455                         
456                         try {
457                                 File.Create (path1).Close ();
458                                 FileInfo info = new FileInfo (path1);
459                                 FileInfo info2 = new FileInfo (path2);
460                                 AssertEquals ("test#01", false, info2.Exists);
461                                 
462                                 info.MoveTo (path2);
463                                 info2 = new FileInfo (path2);
464                                 AssertEquals ("test#02", true, info2.Exists);   
465                         } finally {
466                                 DeleteFile (path1);
467                                 DeleteFile (path2);                     
468                         }                       
469                 }
470                 
471                 [Test]
472                 [ExpectedException (typeof (IOException))]
473                 public void MoveToIOException ()
474                 {
475                         string path1 = TempFolder + DSC + "FIT.MoveToIOException.Source.Test";
476                         string path2 = TempFolder + DSC + "FIT.MoveToIOException.Dest.Test";
477                         DeleteFile (path1);
478                         DeleteFile (path2);
479
480                         try {
481                                 File.Create (path1).Close ();
482                                 File.Create (path2).Close ();
483                                 
484                                 FileInfo info = new FileInfo (path1);
485                                 info.MoveTo (path2);
486                         } finally {
487                                 DeleteFile (path1);
488                                 DeleteFile (path2);
489                         }
490                 }
491
492                 [Test]
493                 [ExpectedException (typeof (ArgumentNullException))]
494                 public void MoveToArgumentNullException ()
495                 {
496                         string path = TempFolder + DSC + "FIT.MoveToArgumentNullException.Test";
497                         DeleteFile (path);
498
499                         try {
500                                 File.Create (path).Close ();                            
501                                 FileInfo info = new FileInfo (path);
502                                 info.MoveTo (null);
503                         } finally {
504                                 DeleteFile (path);
505                         }
506                 }
507
508                 [Test]
509                 [ExpectedException (typeof (ArgumentException))]
510                 public void MoveToArgumentException ()
511                 {
512                         string path = TempFolder + DSC + "FIT.MoveToArgumentException.Test";
513                         DeleteFile (path);
514
515                         try {
516                                 File.Create (path).Close ();                            
517                                 FileInfo info = new FileInfo (path);
518                                 info.MoveTo ("   ");
519                         } finally {
520                                 DeleteFile (path);
521                         }
522                 }
523
524                 /// <summary>
525                 /// msdn says this should throw UnauthorizedAccessException, byt
526                 /// it throws IOException.
527                 /// </summary>
528                 [Test]
529                 [ExpectedException (typeof (IOException))]
530                 public void MoveToUnauthorizedAccessException ()
531                 {
532                         string path = TempFolder + DSC + "FIT.UnauthorizedAccessException.Test";
533                         DeleteFile (path);
534
535                         try {
536                                 File.Create (path).Close ();
537                                 FileInfo info = new FileInfo (path);
538                                 info.MoveTo (TempFolder);
539                         } finally {
540                                 DeleteFile (path);
541                         }
542                 }
543                 
544                 [Test]
545                 [ExpectedException (typeof (FileNotFoundException))]
546                 public void MoveToFileNotFoundException ()
547                 {
548                         string path1 = TempFolder + DSC + "FIT.MoveToFileNotFoundException.Src";
549                         string path2 = TempFolder + DSC + "FIT.MoveToFileNotFoundException.Dst";
550                         DeleteFile (path1);
551                         DeleteFile (path2);
552                         
553                         try {
554                                 FileInfo info = new FileInfo (path1);
555                                 info.MoveTo (path2);
556                         } finally {
557                                 DeleteFile (path1);
558                                 DeleteFile (path2);
559                         }
560                 }
561                                 
562                 [Test]
563                 public void Open ()
564                 {
565                         string path = TempFolder + DSC + "FIT.Open.Test";
566                         DeleteFile (path);
567                         FileStream stream = null;
568                         try {
569                                 FileInfo info = new FileInfo (path);
570                                 stream = info.Open (FileMode.CreateNew);
571                                 AssertEquals ("test#01", true, stream.CanRead);
572                                 AssertEquals ("test#02", true, stream.CanSeek);
573                                 AssertEquals ("test#03", true, stream.CanWrite);                                
574                                 stream.Close ();
575                                 
576                                 stream = info.Open (FileMode.Open);                             
577                                 AssertEquals ("test#04", true, stream.CanRead);
578                                 AssertEquals ("test#05", true, stream.CanSeek);
579                                 AssertEquals ("test#06", true, stream.CanWrite);                                
580                                 stream.Close ();
581                                 
582                                 stream = info.Open (FileMode.Append, FileAccess.Write);
583                                 AssertEquals ("test#07", false, stream.CanRead);
584                                 AssertEquals ("test#08", true, stream.CanSeek);
585                                 AssertEquals ("test#09", true, stream.CanWrite);                                
586                                 stream.Close ();                                
587
588                                 stream = info.Open (FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
589                                 AssertEquals ("test#10", true, stream.CanRead);
590                                 AssertEquals ("test#11", true, stream.CanSeek);
591                                 AssertEquals ("test#12", true, stream.CanWrite);                                
592                                 stream.Close ();                                                                                                
593                         } finally {
594                                 if (stream != null)
595                                         stream.Close ();
596                                 DeleteFile (path);
597                         }
598                 }
599                 
600                 [Test]
601                 [ExpectedException(typeof(FileNotFoundException))]
602                 public void OpenFileNotFoundException ()
603                 {
604                         string path = TempFolder + DSC + "FIT.OpenFileNotFoundException.Test";
605                         DeleteFile (path);
606                         
607                         FileInfo info = new FileInfo (path);
608                         info.Open (FileMode.Open);
609                 }
610                 
611                 [Test]
612                 public void OpenRead ()
613                 {
614                         string path = TempFolder + DSC + "FIT.OpenRead.Test";
615                         DeleteFile (path);
616                         FileStream stream = null;
617                         try {
618                                 File.Create (path).Close ();
619                                 FileInfo info = new FileInfo (path);
620                                 stream = info.OpenRead ();
621                                 AssertEquals ("test#01", true, stream.CanRead);
622                                 AssertEquals ("test#02", true, stream.CanSeek);
623                                 AssertEquals ("test#03", false, stream.CanWrite);
624                                 stream.Close ();
625                                 
626                         } finally {
627                                 if (stream != null)
628                                         stream.Close ();
629                                 DeleteFile (path);
630                         }
631                 }
632                 
633                 [Test]
634                 [ExpectedException(typeof (IOException))]
635 #if TARGET_JVM
636         [Category("NotWorking")]
637 #endif
638                 public void OpenReadIOException ()
639                 {
640                         string path = TempFolder + DSC + "FIT.OpenReadIOException.Test";
641                         DeleteFile (path);
642                         FileStream stream = null;
643                         
644                         try {
645                                 stream = File.Create (path);
646                                 FileInfo info = new FileInfo (path);
647                                 info.OpenRead ();
648                         } finally {
649                                 if (stream != null)
650                                         stream.Close ();
651                                 DeleteFile (path);
652                         }
653                 }
654
655                 [Test]
656                 [ExpectedException(typeof (UnauthorizedAccessException))]
657                 public void OpenReadUnauthorizedAccessException ()
658                 {
659                         string path = TempFolder;
660                         
661                         FileInfo info = new FileInfo (path);
662                         info.OpenRead ();
663                 }
664                 
665                 [Test]
666                 public void OpenText ()
667                 {
668                         string path = TempFolder + DSC + "FIT.OpenText.Test";
669                         DeleteFile (path);
670                         StreamReader reader = null;
671                         try {
672                                 File.Create (path).Close ();
673                                 FileInfo info = new FileInfo (path);
674                                 reader = info.OpenText ();
675                                 AssertEquals ("test#01", -1, reader.Peek ());           
676                         } finally {
677                                 
678                                 if (reader != null)
679                                         reader.Close ();
680                                 DeleteFile (path);
681                         }
682                 }
683                 
684                 [Test]
685                 [ExpectedException(typeof (FileNotFoundException))]
686                 public void OpenTextFileNotFoundException ()
687                 {
688                         string path = TempFolder + DSC + "FIT.OpenTextFileNotFoundException.Test";
689                         DeleteFile (path);
690                         FileInfo info = new FileInfo (path);
691                         info.OpenText ();
692                 }
693
694                 [Test]
695                 [ExpectedException(typeof (UnauthorizedAccessException))]
696                 public void OpenTextUnauthorizedAccessException ()
697                 {
698                         string path = TempFolder;
699                         
700                         FileInfo info = new FileInfo (path);
701                         info.OpenText ();
702                 }
703
704                 [Test]
705                 public void OpenWrite ()
706                 {
707                         string path = TempFolder + DSC + "FIT.OpenWrite.Test";
708                         DeleteFile (path);
709                         FileStream stream = null;
710                         try {
711                                 File.Create (path).Close ();
712                                 FileInfo info = new FileInfo (path);
713                                 stream = info.OpenWrite ();
714                                 AssertEquals ("test#01", false, stream.CanRead);
715                                 AssertEquals ("test#02", true, stream.CanSeek);
716                                 AssertEquals ("test#03", true, stream.CanWrite);
717                         } finally {
718                                 
719                                 if (stream != null)
720                                         stream.Close ();
721                                 DeleteFile (path);
722                         }
723                 }
724                 
725                 [Test]
726                 [ExpectedException(typeof (UnauthorizedAccessException))]
727                 public void OpenWriteUnauthorizedAccessException ()
728                 {
729                         string path = TempFolder;
730                         
731                         FileInfo info = new FileInfo (path);
732                         info.OpenWrite ();
733                 }
734
735                 private void DeleteFile (string path)
736                 {
737                         if (File.Exists (path))
738                                 File.Delete (path);
739                 }
740
741                 [Test]
742                 public void ToStringVariety ()
743                 {
744                         AssertEquals ("foo", new FileInfo ("foo").ToString ());
745                         AssertEquals ("c:/foo", new FileInfo ("c:/foo").ToString ());
746                         AssertEquals ("/usr/local/foo", new FileInfo ("/usr/local/foo").ToString ());
747                         AssertEquals ("c:\\foo", new FileInfo ("c:\\foo").ToString ());
748                         AssertEquals ("/usr/local\\foo", new FileInfo ("/usr/local\\foo").ToString ());
749                         AssertEquals ("foo/BAR/baz", new FileInfo ("foo/BAR/baz").ToString ());
750                         AssertEquals ("c:/documents and settings", new FileInfo ("c:/documents and settings").ToString ());
751                         AssertEquals ("c:/docUme~1", new FileInfo ("c:/docUme~1").ToString ());
752                 }
753         }
754 }
755