2 // FileTest.cs: Test cases for System.IO.File
5 // Duncan Mak (duncan@ximian.com)
6 // Ville Palo (vi64pa@kolumbus.fi)
8 // (C) 2002 Ximian, Inc. http://www.ximian.com
10 // TODO: Find out why ArgumentOutOfRangeExceptions does not manage to close streams properly
12 using NUnit.Framework;
15 using System.Globalization;
16 using System.Threading;
18 namespace MonoTests.System.IO
21 public class FileTest : Assertion
23 static string TempFolder = Path.Combine (Path.GetTempPath (), "MonoTests.System.IO.Tests");
28 if (Directory.Exists (TempFolder))
29 Directory.Delete (TempFolder, true);
30 Directory.CreateDirectory (TempFolder);
32 Thread.CurrentThread.CurrentCulture = new CultureInfo ("EN-us");
36 public void TearDown ()
38 if (Directory.Exists (TempFolder))
39 Directory.Delete (TempFolder, true);
43 public void TestExists ()
47 string path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt";
49 Assert ("null filename should not exist", !File.Exists (null));
51 Assert ("empty filename should not exist", !File.Exists (""));
53 Assert ("whitespace filename should not exist", !File.Exists (" \t\t \t \n\t\n \n"));
56 s = File.Create (path);
58 Assert ("File " + path + " should exists", File.Exists (path));
60 Assert ("File resources" + Path.DirectorySeparatorChar + "doesnotexist should not exist", !File.Exists (TempFolder + Path.DirectorySeparatorChar + "doesnotexist"));
61 } catch (Exception e) {
62 Fail ("Unexpected exception at i = " + i + ". e=" + e);
71 public void Exists_InvalidFileName ()
73 Assert ("><|", !File.Exists ("><|"));
74 Assert ("?*", !File.Exists ("?*"));
78 public void Exists_InvalidDirectory ()
80 Assert ("InvalidDirectory", !File.Exists (Path.Combine ("does not exist", "file.txt")));
84 [ExpectedException(typeof (ArgumentNullException))]
85 public void CtorArgumentNullException1 ()
87 FileStream stream = File.Create (null);
91 [ExpectedException(typeof (ArgumentException))]
92 public void CtorArgumentException1 ()
94 FileStream stream = File.Create ("");
98 [ExpectedException(typeof (ArgumentException))]
99 public void CtorArgumentException2 ()
101 FileStream stream = File.Create (" ");
105 [ExpectedException(typeof (DirectoryNotFoundException))]
106 public void CtorDirectoryNotFoundException ()
108 FileStream stream = null;
109 string path = TempFolder + Path.DirectorySeparatorChar + "directory_does_not_exist" + Path.DirectorySeparatorChar + "foo";
112 stream = File.Create (path);
121 public void TestCreate ()
123 FileStream stream = null;
125 /* positive test: create resources/foo */
127 path = TempFolder + Path.DirectorySeparatorChar + "foo";
128 stream = File.Create (path);
129 Assert ("File should exist", File.Exists (path));
131 } catch (Exception e) {
132 Fail ("File.Create(resources/foo) unexpected exception caught: e=" + e.ToString());
142 /* positive test: repeat test above again to test for overwriting file */
144 path = TempFolder + Path.DirectorySeparatorChar + "foo";
145 stream = File.Create (path);
146 Assert ("File should exist", File.Exists (path));
148 } catch (Exception e) {
149 Fail ("File.Create(resources/foo) unexpected exception caught: e=" + e.ToString());
158 [ExpectedException(typeof(ArgumentNullException))]
159 public void CopyArgumentNullException1 ()
161 File.Copy (null, "b");
165 [ExpectedException(typeof(ArgumentNullException))]
166 public void CopyArgumentNullException2 ()
168 File.Copy ("a", null);
172 [ExpectedException(typeof(ArgumentException))]
173 public void CopyArgumentException1 ()
179 [ExpectedException(typeof(ArgumentException))]
180 public void CopyArgumentException2 ()
186 [ExpectedException(typeof(ArgumentException))]
187 public void CopyArgumentException3 ()
189 File.Copy (" ", "b");
193 [ExpectedException(typeof(ArgumentException))]
194 public void CopyArgumentException4 ()
196 File.Copy ("a", " ");
200 [ExpectedException(typeof(FileNotFoundException))]
201 public void CopyFileNotFoundException ()
203 File.Copy ("doesnotexist", "b");
206 [ExpectedException(typeof(IOException))]
207 public void CopyIOException ()
209 DeleteFile (TempFolder + Path.DirectorySeparatorChar + "bar");
210 DeleteFile (TempFolder + Path.DirectorySeparatorChar + "AFile.txt");
212 File.Create (TempFolder + Path.DirectorySeparatorChar + "AFile.txt").Close ();
213 File.Copy (TempFolder + Path.DirectorySeparatorChar + "AFile.txt", TempFolder + Path.DirectorySeparatorChar + "bar");
214 File.Copy (TempFolder + Path.DirectorySeparatorChar + "AFile.txt", TempFolder + Path.DirectorySeparatorChar + "bar");
216 DeleteFile (TempFolder + Path.DirectorySeparatorChar + "bar");
217 DeleteFile (TempFolder + Path.DirectorySeparatorChar + "AFile.txt");
222 public void TestCopy ()
224 string path1 = TempFolder + Path.DirectorySeparatorChar + "bar";
225 string path2 = TempFolder + Path.DirectorySeparatorChar + "AFile.txt";
226 /* positive test: copy resources/AFile.txt to resources/bar */
232 File.Create (path2).Close ();
233 File.Copy (path2, path1);
234 Assert ("File AFile.txt should still exist", File.Exists (path2));
235 Assert ("File bar should exist after File.Copy", File.Exists (path1));
236 } catch (Exception e) {
237 Fail ("#1 File.Copy('resources/AFile.txt', 'resources/bar') unexpected exception caught: e=" + e.ToString());
240 /* positive test: copy resources/AFile.txt to resources/bar, overwrite */
242 Assert ("File bar should exist before File.Copy", File.Exists (path1));
243 File.Copy (path2, path1, true);
244 Assert ("File AFile.txt should still exist", File.Exists (path2));
245 Assert ("File bar should exist after File.Copy", File.Exists (path1));
246 } catch (Exception e) {
247 Fail ("File.Copy('resources/AFile.txt', 'resources/bar', true) unexpected exception caught: e=" + e.ToString());
256 [ExpectedException (typeof (ArgumentNullException))]
257 public void DeleteArgumentNullException ()
263 [ExpectedException (typeof (ArgumentException))]
264 public void DeleteArgumentException1 ()
270 [ExpectedException (typeof (ArgumentException))]
271 public void DeleteArgumentException2 ()
277 [ExpectedException (typeof (DirectoryNotFoundException))]
278 public void DeleteDirectoryNotFoundException ()
280 string path = TempFolder + Path.DirectorySeparatorChar + "directory_does_not_exist" + Path.DirectorySeparatorChar + "foo";
281 if (Directory.Exists (path))
282 Directory.Delete (path, true);
288 public void TestDelete ()
290 string foopath = TempFolder + Path.DirectorySeparatorChar + "foo";
291 DeleteFile (foopath);
293 File.Create (foopath).Close ();
296 File.Delete (foopath);
297 } catch (Exception e) {
298 Fail ("Unable to delete " + foopath + " e=" + e.ToString());
300 Assert ("File " + foopath + " should not exist after File.Delete", !File.Exists (foopath));
302 DeleteFile (foopath);
307 [ExpectedException(typeof (IOException))]
308 [Category("NotWorking")]
309 public void DeleteOpenStreamException ()
311 string path = TempFolder + Path.DirectorySeparatorChar + "DeleteOpenStreamException";
313 FileStream stream = null;
315 stream = new FileStream (path, FileMode.OpenOrCreate, FileAccess.ReadWrite);
325 [ExpectedException(typeof (ArgumentNullException))]
326 public void MoveException1 ()
328 File.Move (null, "b");
332 [ExpectedException(typeof (ArgumentNullException))]
333 public void MoveException2 ()
335 File.Move ("a", null);
339 [ExpectedException(typeof (ArgumentException))]
340 public void MoveException3 ()
346 [ExpectedException(typeof (ArgumentException))]
347 public void MoveException4 ()
353 [ExpectedException(typeof (ArgumentException))]
354 public void MoveException5 ()
356 File.Move (" ", "b");
360 [ExpectedException(typeof (ArgumentException))]
361 public void MoveException6 ()
363 File.Move ("a", " ");
367 [ExpectedException(typeof (FileNotFoundException))]
368 public void MoveException7 ()
370 DeleteFile (TempFolder + Path.DirectorySeparatorChar + "doesnotexist");
371 File.Move (TempFolder + Path.DirectorySeparatorChar + "doesnotexist", "b");
375 [ExpectedException(typeof (DirectoryNotFoundException))]
376 public void MoveException8 ()
378 string path = TempFolder + Path.DirectorySeparatorChar + "foo";
381 File.Create (TempFolder + Path.DirectorySeparatorChar + "AFile.txt").Close ();
382 File.Copy(TempFolder + Path.DirectorySeparatorChar + "AFile.txt", path, true);
383 DeleteFile (TempFolder + Path.DirectorySeparatorChar + "doesnotexist" + Path.DirectorySeparatorChar + "b");
384 File.Move (TempFolder + Path.DirectorySeparatorChar + "foo", TempFolder + Path.DirectorySeparatorChar + "doesnotexist" + Path.DirectorySeparatorChar + "b");
386 DeleteFile (TempFolder + Path.DirectorySeparatorChar + "AFile.txt");
392 [ExpectedException(typeof (IOException))]
393 public void MoveException9 ()
395 File.Create (TempFolder + Path.DirectorySeparatorChar + "foo").Close ();
397 File.Move (TempFolder + Path.DirectorySeparatorChar + "foo", TempFolder);
399 DeleteFile (TempFolder + Path.DirectorySeparatorChar + "foo");
404 public void TestMove ()
406 string bar = TempFolder + Path.DirectorySeparatorChar + "bar";
407 string baz = TempFolder + Path.DirectorySeparatorChar + "baz";
408 if (!File.Exists (bar)) {
409 FileStream f = File.Create(bar);
413 Assert ("File " + TempFolder + Path.DirectorySeparatorChar + "bar should exist", File.Exists (bar));
414 File.Move (bar, baz);
415 Assert ("File " + TempFolder + Path.DirectorySeparatorChar + "bar should not exist", !File.Exists (bar));
416 Assert ("File " + TempFolder + Path.DirectorySeparatorChar + "baz should exist", File.Exists (baz));
418 // Test moving of directories
419 string dir = Path.Combine (TempFolder, "dir");
420 string dir2 = Path.Combine (TempFolder, "dir2");
421 string dir_foo = Path.Combine (dir, "foo");
422 string dir2_foo = Path.Combine (dir2, "foo");
424 if (Directory.Exists (dir))
425 Directory.Delete (dir, true);
427 Directory.CreateDirectory (dir);
428 Directory.CreateDirectory (dir2);
429 File.Create (dir_foo).Close ();
430 File.Move (dir_foo, dir2_foo);
431 Assert (File.Exists (dir2_foo));
433 Directory.Delete (dir, true);
434 Directory.Delete (dir2, true);
435 DeleteFile (dir_foo);
436 DeleteFile (dir2_foo);
440 public void TestOpen ()
443 FileStream stream = null;
445 path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt";
446 if (!File.Exists (path))
447 stream = File.Create (path);
449 stream = File.Open (path, FileMode.Open);
451 } catch (Exception e) {
452 Fail ("Unable to open " + TempFolder + Path.DirectorySeparatorChar + "AFile.txt: e=" + e.ToString());
461 /* Exception tests */
463 path = TempFolder + Path.DirectorySeparatorChar + "filedoesnotexist";
464 stream = File.Open (path, FileMode.Open);
465 Fail ("File 'filedoesnotexist' should not exist");
466 } catch (FileNotFoundException) {
467 // do nothing, this is what we expect
468 } catch (Exception e) {
469 Fail ("Unexpect exception caught: e=" + e.ToString());
480 string path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt";
481 if (!File.Exists (path))
482 File.Create (path).Close ();
483 FileStream stream = null;
486 stream = File.Open (path, FileMode.Open);
488 Assertion.AssertEquals ("test#01", true, stream.CanRead);
489 Assertion.AssertEquals ("test#02", true, stream.CanSeek);
490 Assertion.AssertEquals ("test#03", true, stream.CanWrite);
493 stream = File.Open (path, FileMode.Open, FileAccess.Write);
494 Assertion.AssertEquals ("test#04", false, stream.CanRead);
495 Assertion.AssertEquals ("test#05", true, stream.CanSeek);
496 Assertion.AssertEquals ("test#06", true, stream.CanWrite);
499 stream = File.Open (path, FileMode.Open, FileAccess.Read);
500 Assertion.AssertEquals ("test#04", true, stream.CanRead);
501 Assertion.AssertEquals ("test#05", true, stream.CanSeek);
502 Assertion.AssertEquals ("test#06", false, stream.CanWrite);
513 [ExpectedException(typeof(ArgumentException))]
514 public void OpenException1 ()
516 string path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt";
517 FileStream stream = null;
518 // CreateNew + Read throws an exceptoin
520 stream = File.Open (TempFolder + Path.DirectorySeparatorChar + "AFile.txt", FileMode.CreateNew, FileAccess.Read);
529 [ExpectedException(typeof(ArgumentException))]
530 public void OpenException2 ()
532 string path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt";
534 // Append + Read throws an exceptoin
535 if (!File.Exists (path))
536 File.Create (path).Close ();
538 s = File.Open (path, FileMode.Append, FileAccess.Read);
547 public void OpenRead ()
549 string path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt";
550 if (!File.Exists (path))
551 File.Create (path).Close ();
552 FileStream stream = null;
555 stream = File.OpenRead (path);
557 Assertion.AssertEquals ("test#01", true, stream.CanRead);
558 Assertion.AssertEquals ("test#02", true, stream.CanSeek);
559 Assertion.AssertEquals ("test#03", false, stream.CanWrite);
569 public void OpenWrite ()
571 string path = TempFolder + Path.DirectorySeparatorChar + "AFile.txt";
572 if (!File.Exists (path))
573 File.Create (path).Close ();
574 FileStream stream = null;
577 stream = File.OpenWrite (path);
578 Assertion.AssertEquals ("test#01", false, stream.CanRead);
579 Assertion.AssertEquals ("test#02", true, stream.CanSeek);
580 Assertion.AssertEquals ("test#03", true, stream.CanWrite);
590 [Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM
591 public void TestGetCreationTime ()
593 string path = TempFolder + Path.DirectorySeparatorChar + "baz";
597 File.Create (path).Close();
598 DateTime time = File.GetCreationTime (path);
599 Assert ("GetCreationTime incorrect", (DateTime.Now - time).TotalSeconds < 10);
605 // Setting the creation time on Unix is not possible
607 [Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM
608 public void CreationTime ()
610 int platform = (int) Environment.OSVersion.Platform;
611 if ((platform == 4) || (platform == 128))
614 string path = Path.GetTempFileName ();
617 File.SetCreationTime (path, new DateTime (2002, 4, 6, 4, 6, 4));
618 DateTime time = File.GetCreationTime (path);
619 Assertion.AssertEquals ("test#01", 2002, time.Year);
620 Assertion.AssertEquals ("test#02", 4, time.Month);
621 Assertion.AssertEquals ("test#03", 6, time.Day);
622 Assertion.AssertEquals ("test#04", 4, time.Hour);
623 Assertion.AssertEquals ("test#05", 4, time.Second);
625 time = TimeZone.CurrentTimeZone.ToLocalTime (File.GetCreationTimeUtc (path));
626 Assertion.AssertEquals ("test#06", 2002, time.Year);
627 Assertion.AssertEquals ("test#07", 4, time.Month);
628 Assertion.AssertEquals ("test#08", 6, time.Day);
629 Assertion.AssertEquals ("test#09", 4, time.Hour);
630 Assertion.AssertEquals ("test#10", 4, time.Second);
632 File.SetCreationTimeUtc (path, new DateTime (2002, 4, 6, 4, 6, 4));
633 time = File.GetCreationTimeUtc (path);
634 Assertion.AssertEquals ("test#11", 2002, time.Year);
635 Assertion.AssertEquals ("test#12", 4, time.Month);
636 Assertion.AssertEquals ("test#13", 6, time.Day);
637 Assertion.AssertEquals ("test#14", 4, time.Hour);
638 Assertion.AssertEquals ("test#15", 4, time.Second);
640 time = TimeZone.CurrentTimeZone.ToUniversalTime (File.GetCreationTime (path));
641 Assertion.AssertEquals ("test#16", 2002, time.Year);
642 Assertion.AssertEquals ("test#17", 4, time.Month);
643 Assertion.AssertEquals ("test#18", 6, time.Day);
644 Assertion.AssertEquals ("test#19", 4, time.Hour);
645 Assertion.AssertEquals ("test#20", 4, time.Second);
652 [Category("TargetJvmNotSupported")] // GetLastAccessTime not supported for TARGET_JVM
653 public void LastAccessTime ()
655 string path = TempFolder + Path.DirectorySeparatorChar + "lastAccessTime";
656 if (File.Exists (path))
658 FileStream stream = null;
660 stream = File.Create (path);
663 File.SetLastAccessTime (path, new DateTime (2002, 4, 6, 4, 6, 4));
664 DateTime time = File.GetLastAccessTime (path);
665 Assertion.AssertEquals ("test#01", 2002, time.Year);
666 Assertion.AssertEquals ("test#02", 4, time.Month);
667 Assertion.AssertEquals ("test#03", 6, time.Day);
668 Assertion.AssertEquals ("test#04", 4, time.Hour);
669 Assertion.AssertEquals ("test#05", 4, time.Second);
671 time = TimeZone.CurrentTimeZone.ToLocalTime (File.GetLastAccessTimeUtc (path));
672 Assertion.AssertEquals ("test#06", 2002, time.Year);
673 Assertion.AssertEquals ("test#07", 4, time.Month);
674 Assertion.AssertEquals ("test#08", 6, time.Day);
675 Assertion.AssertEquals ("test#09", 4, time.Hour);
676 Assertion.AssertEquals ("test#10", 4, time.Second);
678 File.SetLastAccessTimeUtc (path, new DateTime (2002, 4, 6, 4, 6, 4));
679 time = File.GetLastAccessTimeUtc (path);
680 Assertion.AssertEquals ("test#11", 2002, time.Year);
681 Assertion.AssertEquals ("test#12", 4, time.Month);
682 Assertion.AssertEquals ("test#13", 6, time.Day);
683 Assertion.AssertEquals ("test#14", 4, time.Hour);
684 Assertion.AssertEquals ("test#15", 4, time.Second);
686 time = TimeZone.CurrentTimeZone.ToUniversalTime (File.GetLastAccessTime (path));
687 Assertion.AssertEquals ("test#16", 2002, time.Year);
688 Assertion.AssertEquals ("test#17", 4, time.Month);
689 Assertion.AssertEquals ("test#18", 6, time.Day);
690 Assertion.AssertEquals ("test#19", 4, time.Hour);
691 Assertion.AssertEquals ("test#20", 4, time.Second);
700 public void LastWriteTime ()
702 string path = TempFolder + Path.DirectorySeparatorChar + "lastWriteTime";
703 if (File.Exists (path))
705 FileStream stream = null;
707 stream = File.Create (path);
710 File.SetLastWriteTime (path, new DateTime (2002, 4, 6, 4, 6, 4));
711 DateTime time = File.GetLastWriteTime (path);
712 Assertion.AssertEquals ("test#01", 2002, time.Year);
713 Assertion.AssertEquals ("test#02", 4, time.Month);
714 Assertion.AssertEquals ("test#03", 6, time.Day);
715 Assertion.AssertEquals ("test#04", 4, time.Hour);
716 Assertion.AssertEquals ("test#05", 4, time.Second);
718 time = TimeZone.CurrentTimeZone.ToLocalTime (File.GetLastWriteTimeUtc (path));
719 Assertion.AssertEquals ("test#06", 2002, time.Year);
720 Assertion.AssertEquals ("test#07", 4, time.Month);
721 Assertion.AssertEquals ("test#08", 6, time.Day);
722 Assertion.AssertEquals ("test#09", 4, time.Hour);
723 Assertion.AssertEquals ("test#10", 4, time.Second);
725 File.SetLastWriteTimeUtc (path, new DateTime (2002, 4, 6, 4, 6, 4));
726 time = File.GetLastWriteTimeUtc (path);
727 Assertion.AssertEquals ("test#11", 2002, time.Year);
728 Assertion.AssertEquals ("test#12", 4, time.Month);
729 Assertion.AssertEquals ("test#13", 6, time.Day);
730 Assertion.AssertEquals ("test#14", 4, time.Hour);
731 Assertion.AssertEquals ("test#15", 4, time.Second);
733 time = TimeZone.CurrentTimeZone.ToUniversalTime (File.GetLastWriteTime (path));
734 Assertion.AssertEquals ("test#16", 2002, time.Year);
735 Assertion.AssertEquals ("test#17", 4, time.Month);
736 Assertion.AssertEquals ("test#18", 6, time.Day);
737 Assertion.AssertEquals ("test#19", 4, time.Hour);
738 Assertion.AssertEquals ("test#20", 4, time.Second);
747 [ExpectedException(typeof(ArgumentNullException))]
748 [Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM
749 public void GetCreationTimeException1 ()
751 File.GetCreationTime (null as string);
755 [ExpectedException(typeof(ArgumentException))]
756 [Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM
757 public void GetCreationTimeException2 ()
759 File.GetCreationTime ("");
764 [ExpectedException(typeof(IOException))]
766 [Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM
767 public void GetCreationTime_NonExistingPath ()
769 string path = TempFolder + Path.DirectorySeparatorChar + "GetCreationTimeException3";
771 DateTime time = File.GetCreationTime (path);
774 DateTime expectedTime = (new DateTime (1601, 1, 1)).ToLocalTime ();
775 Assertion.AssertEquals ("#1", expectedTime.Year, time.Year);
776 Assertion.AssertEquals ("#2", expectedTime.Month, time.Month);
777 Assertion.AssertEquals ("#3", expectedTime.Day, time.Day);
778 Assertion.AssertEquals ("#4", expectedTime.Hour, time.Hour);
779 Assertion.AssertEquals ("#5", expectedTime.Second, time.Second);
780 Assertion.AssertEquals ("#6", expectedTime.Millisecond, time.Millisecond);
785 [ExpectedException(typeof(ArgumentException))]
786 [Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM
787 public void GetCreationTimeException4 ()
789 File.GetCreationTime (" ");
793 [ExpectedException(typeof(ArgumentException))]
794 [Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM
795 public void GetCreationTimeException5 ()
797 File.GetCreationTime (Path.InvalidPathChars [0].ToString ());
801 [ExpectedException(typeof(ArgumentNullException))]
802 [Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM
803 public void GetCreationTimeUtcException1 ()
805 File.GetCreationTimeUtc (null as string);
809 [ExpectedException(typeof(ArgumentException))]
810 [Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM
811 public void GetCreationTimeUtcException2 ()
813 File.GetCreationTimeUtc ("");
818 [ExpectedException (typeof (IOException))]
820 [Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM
821 public void GetCreationTimeUtc_NonExistingPath ()
823 string path = TempFolder + Path.DirectorySeparatorChar + "GetCreationTimeUtcException3";
825 DateTime time = File.GetCreationTimeUtc (path);
828 Assertion.AssertEquals ("#1", 1601, time.Year);
829 Assertion.AssertEquals ("#2", 1, time.Month);
830 Assertion.AssertEquals ("#3", 1, time.Day);
831 Assertion.AssertEquals ("#4", 0, time.Hour);
832 Assertion.AssertEquals ("#5", 0, time.Second);
833 Assertion.AssertEquals ("#6", 0, time.Millisecond);
838 [ExpectedException(typeof(ArgumentException))]
839 [Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM
840 public void GetCreationTimeUtcException4 ()
842 File.GetCreationTimeUtc (" ");
846 [ExpectedException(typeof(ArgumentException))]
847 [Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM
848 public void GetCreationTimeUtcException5 ()
850 File.GetCreationTime (Path.InvalidPathChars [0].ToString ());
854 [ExpectedException(typeof(ArgumentNullException))]
855 [Category("TargetJvmNotSupported")] // GetLastAccessTime not supported for TARGET_JVM
856 public void GetLastAccessTimeException1 ()
858 File.GetLastAccessTime (null as string);
862 [ExpectedException(typeof(ArgumentException))]
863 [Category("TargetJvmNotSupported")] // GetLastAccessTime not supported for TARGET_JVM
864 public void GetLastAccessTimeException2 ()
866 File.GetLastAccessTime ("");
871 [ExpectedException (typeof (IOException))]
873 [Category("TargetJvmNotSupported")] // GetLastAccessTime not supported for TARGET_JVM
874 public void GetLastAccessTime_NonExistingPath ()
876 string path = TempFolder + Path.DirectorySeparatorChar + "GetLastAccessTimeException3";
878 DateTime time = File.GetLastAccessTime (path);
881 DateTime expectedTime = (new DateTime (1601, 1, 1)).ToLocalTime ();
882 Assertion.AssertEquals ("#1", expectedTime.Year, time.Year);
883 Assertion.AssertEquals ("#2", expectedTime.Month, time.Month);
884 Assertion.AssertEquals ("#3", expectedTime.Day, time.Day);
885 Assertion.AssertEquals ("#4", expectedTime.Hour, time.Hour);
886 Assertion.AssertEquals ("#5", expectedTime.Second, time.Second);
887 Assertion.AssertEquals ("#6", expectedTime.Millisecond, time.Millisecond);
892 [ExpectedException(typeof(ArgumentException))]
893 [Category("TargetJvmNotSupported")] // GetLastAccessTime not supported for TARGET_JVM
894 public void GetLastAccessTimeException4 ()
896 File.GetLastAccessTime (" ");
900 [ExpectedException(typeof(ArgumentException))]
901 [Category("TargetJvmNotSupported")] // GetLastAccessTime not supported for TARGET_JVM
902 public void GetLastAccessTimeException5 ()
904 File.GetLastAccessTime (Path.InvalidPathChars [0].ToString ());
908 [ExpectedException(typeof(ArgumentNullException))]
909 [Category("TargetJvmNotSupported")] // GetLastAccessTime not supported for TARGET_JVM
910 public void GetLastAccessTimeUtcException1 ()
912 File.GetLastAccessTimeUtc (null as string);
916 [ExpectedException(typeof(ArgumentException))]
917 [Category("TargetJvmNotSupported")] // GetLastAccessTime not supported for TARGET_JVM
918 public void GetLastAccessTimeUtcException2 ()
920 File.GetLastAccessTimeUtc ("");
925 [ExpectedException (typeof (IOException))]
927 [Category("TargetJvmNotSupported")] // GetLastAccessTime not supported for TARGET_JVM
928 public void GetLastAccessTimeUtc_NonExistingPath ()
930 string path = TempFolder + Path.DirectorySeparatorChar + "GetLastAccessTimeUtcException3";
932 DateTime time = File.GetLastAccessTimeUtc (path);
935 Assertion.AssertEquals ("#1", 1601, time.Year);
936 Assertion.AssertEquals ("#2", 1, time.Month);
937 Assertion.AssertEquals ("#3", 1, time.Day);
938 Assertion.AssertEquals ("#4", 0, time.Hour);
939 Assertion.AssertEquals ("#5", 0, time.Second);
940 Assertion.AssertEquals ("#6", 0, time.Millisecond);
945 [ExpectedException(typeof(ArgumentException))]
946 [Category("TargetJvmNotSupported")] // GetLastAccessTime not supported for TARGET_JVM
947 public void GetLastAccessTimeUtcException4 ()
949 File.GetLastAccessTimeUtc (" ");
953 [ExpectedException(typeof(ArgumentException))]
954 [Category("TargetJvmNotSupported")] // GetLastAccessTime not supported for TARGET_JVM
955 public void GetLastAccessTimeUtcException5 ()
957 File.GetLastAccessTimeUtc (Path.InvalidPathChars [0].ToString ());
961 [ExpectedException(typeof(ArgumentNullException))]
962 public void GetLastWriteTimeException1 ()
964 File.GetLastWriteTime (null as string);
968 [ExpectedException(typeof(ArgumentException))]
969 public void GetLastWriteTimeException2 ()
971 File.GetLastWriteTime ("");
976 [ExpectedException (typeof (IOException))]
978 public void GetLastWriteTime_NonExistingPath ()
980 string path = TempFolder + Path.DirectorySeparatorChar + "GetLastAccessTimeUtcException3";
982 DateTime time = File.GetLastWriteTime (path);
985 DateTime expectedTime = (new DateTime (1601, 1, 1)).ToLocalTime ();
986 Assertion.AssertEquals ("#1", expectedTime.Year, time.Year);
987 Assertion.AssertEquals ("#2", expectedTime.Month, time.Month);
988 Assertion.AssertEquals ("#3", expectedTime.Day, time.Day);
989 Assertion.AssertEquals ("#4", expectedTime.Hour, time.Hour);
990 Assertion.AssertEquals ("#5", expectedTime.Second, time.Second);
991 Assertion.AssertEquals ("#6", expectedTime.Millisecond, time.Millisecond);
996 [ExpectedException(typeof(ArgumentException))]
997 public void GetLastWriteTimeException4 ()
999 File.GetLastWriteTime (" ");
1003 [ExpectedException(typeof(ArgumentException))]
1004 public void GetLastWriteTimeException5 ()
1006 File.GetLastWriteTime (Path.InvalidPathChars [0].ToString ());
1010 [ExpectedException(typeof(ArgumentNullException))]
1011 public void GetLastWriteTimeUtcException1 ()
1013 File.GetLastWriteTimeUtc (null as string);
1017 [ExpectedException(typeof(ArgumentException))]
1018 public void GetLastWriteTimeUtcException2 ()
1020 File.GetLastWriteTimeUtc ("");
1025 [ExpectedException (typeof (IOException))]
1027 public void GetLastWriteTimeUtc_NonExistingPath ()
1029 string path = TempFolder + Path.DirectorySeparatorChar + "GetLastWriteTimeUtcException3";
1031 DateTime time = File.GetLastWriteTimeUtc (path);
1034 Assertion.AssertEquals ("#1", 1601, time.Year);
1035 Assertion.AssertEquals ("#2", 1, time.Month);
1036 Assertion.AssertEquals ("#3", 1, time.Day);
1037 Assertion.AssertEquals ("#4", 0, time.Hour);
1038 Assertion.AssertEquals ("#5", 0, time.Second);
1039 Assertion.AssertEquals ("#6", 0, time.Millisecond);
1044 [ExpectedException(typeof(ArgumentException))]
1045 public void GetLastWriteTimeUtcException4 ()
1047 File.GetLastWriteTimeUtc (" ");
1051 [ExpectedException(typeof(ArgumentException))]
1052 public void GetLastWriteTimeUtcException5 ()
1054 File.GetLastWriteTimeUtc (Path.InvalidPathChars [0].ToString ());
1058 public void FileStreamClose ()
1060 string path = TempFolder + Path.DirectorySeparatorChar + "FileStreamClose";
1061 FileStream stream = null;
1063 stream = File.Create (path);
1073 // SetCreationTime and SetCreationTimeUtc exceptions
1076 [ExpectedException(typeof (ArgumentNullException))]
1077 [Category("TargetJvmNotSupported")] // SetCreationTime not supported for TARGET_JVM
1078 public void SetCreationTimeArgumentNullException1 ()
1080 File.SetCreationTime (null as string, new DateTime (2000, 12, 12, 11, 59, 59));
1084 [ExpectedException(typeof (ArgumentException))]
1085 [Category("TargetJvmNotSupported")] // SetCreationTime not supported for TARGET_JVM
1086 public void SetCreationTimeArgumenException1 ()
1088 File.SetCreationTime ("", new DateTime (2000, 12, 12, 11, 59, 59));
1092 [ExpectedException(typeof (ArgumentException))]
1093 [Category("TargetJvmNotSupported")] // SetCreationTime not supported for TARGET_JVM
1094 public void SetCreationTimeArgumenException2 ()
1096 File.SetCreationTime (" ", new DateTime (2000, 12, 12, 11, 59, 59));
1100 // On Unix there are no invalid path chars.
1101 [Category("TargetJvmNotSupported")] // SetCreationTime not supported for TARGET_JVM
1102 public void SetCreationTimeArgumenException3 ()
1104 if (Path.InvalidPathChars.Length > 1) {
1107 File.SetCreationTime (Path.InvalidPathChars [1].ToString (), new DateTime (2000, 12, 12, 11, 59, 59));
1108 } catch (ArgumentException) {
1112 Assertion.Assert ("#01", pass);
1117 [ExpectedException(typeof (FileNotFoundException))]
1118 [Category("TargetJvmNotSupported")] // SetCreationTime not supported for TARGET_JVM
1119 public void SetCreationTimeFileNotFoundException1 ()
1121 string path = TempFolder + Path.DirectorySeparatorChar + "SetCreationTimeFileNotFoundException1";
1124 File.SetCreationTime (path, new DateTime (2000, 12, 12, 11, 59, 59));
1128 // [ExpectedException(typeof (ArgumentOutOfRangeException))]
1129 // public void SetCreationTimeArgumentOutOfRangeException1 ()
1131 // string path = TempFolder + Path.DirectorySeparatorChar + "SetCreationTimeArgumentOutOfRangeException1";
1132 // FileStream stream = null;
1133 // DeleteFile (path);
1135 // stream = File.Create (path);
1137 // File.SetCreationTime (path, new DateTime (1000, 12, 12, 11, 59, 59));
1139 // if (stream != null)
1141 // DeleteFile (path);
1146 [ExpectedException(typeof (IOException))]
1147 [Category("TargetJvmNotSupported")] // SetCreationTime not supported for TARGET_JVM
1148 public void SetCreationTimeIOException1 ()
1150 string path = TempFolder + Path.DirectorySeparatorChar + "CreationTimeIOException1";
1152 FileStream stream = null;
1154 stream = File.Create (path);
1155 File.SetCreationTime (path, new DateTime (1000, 12, 12, 11, 59, 59));
1164 [ExpectedException(typeof (ArgumentNullException))]
1165 [Category("TargetJvmNotSupported")] // SetCreationTime not supported for TARGET_JVM
1166 public void SetCreationTimeUtcArgumentNullException1 ()
1168 File.SetCreationTimeUtc (null as string, new DateTime (2000, 12, 12, 11, 59, 59));
1172 [ExpectedException(typeof (ArgumentException))]
1173 [Category("TargetJvmNotSupported")] // SetCreationTime not supported for TARGET_JVM
1174 public void SetCreationTimeUtcArgumenException1 ()
1176 File.SetCreationTimeUtc ("", new DateTime (2000, 12, 12, 11, 59, 59));
1180 [ExpectedException(typeof (ArgumentException))]
1181 [Category("TargetJvmNotSupported")] // SetCreationTime not supported for TARGET_JVM
1182 public void SetCreationTimeUtcArgumenException2 ()
1184 File.SetCreationTimeUtc (" ", new DateTime (2000, 12, 12, 11, 59, 59));
1188 // On Unix there are no invalid path chars.
1189 [Category("TargetJvmNotSupported")] // SetCreationTime not supported for TARGET_JVM
1190 public void SetCreationTimeUtcArgumentException3 ()
1192 if (Path.InvalidPathChars.Length > 1) {
1195 File.SetCreationTimeUtc (Path.InvalidPathChars [1].ToString (), new DateTime (2000, 12, 12, 11, 59, 59));
1196 } catch (ArgumentException) {
1200 Assertion.Assert ("#01", pass);
1205 [ExpectedException(typeof (FileNotFoundException))]
1206 [Category("TargetJvmNotSupported")] // SetCreationTime not supported for TARGET_JVM
1207 public void SetCreationTimeUtcFileNotFoundException1 ()
1209 string path = TempFolder + Path.DirectorySeparatorChar + "SetCreationTimeUtcFileNotFoundException1";
1212 File.SetCreationTimeUtc (path, new DateTime (2000, 12, 12, 11, 59, 59));
1216 // [ExpectedException(typeof (ArgumentOutOfRangeException))]
1217 // public void SetCreationTimeUtcArgumentOutOfRangeException1 ()
1219 // string path = TempFolder + Path.DirectorySeparatorChar + "SetCreationTimeUtcArgumentOutOfRangeException1";
1220 // DeleteFile (path);
1221 // FileStream stream = null;
1223 // stream = File.Create (path);
1225 // File.SetCreationTimeUtc (path, new DateTime (1000, 12, 12, 11, 59, 59));
1227 // if (stream != null)
1229 // DeleteFile (path);
1234 [ExpectedException(typeof (IOException))]
1235 [Category("TargetJvmNotSupported")] // SetCreationTime not supported for TARGET_JVM
1236 public void SetCreationTimeUtcIOException1 ()
1238 string path = TempFolder + Path.DirectorySeparatorChar + "SetCreationTimeUtcIOException1";
1240 FileStream stream = null;
1242 stream = File.Create (path);
1243 File.SetCreationTimeUtc (path, new DateTime (1000, 12, 12, 11, 59, 59));
1251 // SetLastAccessTime and SetLastAccessTimeUtc exceptions
1254 [ExpectedException(typeof (ArgumentNullException))]
1255 [Category("TargetJvmNotSupported")] // SetLastAccessTime not supported for TARGET_JVM
1256 public void SetLastAccessTimeArgumentNullException1 ()
1258 File.SetLastAccessTime (null as string, new DateTime (2000, 12, 12, 11, 59, 59));
1262 [ExpectedException(typeof (ArgumentException))]
1263 [Category("TargetJvmNotSupported")] // SetLastAccessTime not supported for TARGET_JVM
1264 public void SetLastAccessTimeArgumenException1 ()
1266 File.SetLastAccessTime ("", new DateTime (2000, 12, 12, 11, 59, 59));
1270 [ExpectedException(typeof (ArgumentException))]
1271 [Category("TargetJvmNotSupported")] // SetLastAccessTime not supported for TARGET_JVM
1272 public void SetLastAccessTimeArgumenException2 ()
1274 File.SetLastAccessTime (" ", new DateTime (2000, 12, 12, 11, 59, 59));
1278 // On Unix there are no invalid path chars.
1279 [Category("TargetJvmNotSupported")] // SetLastAccessTime not supported for TARGET_JVM
1280 public void SetLastAccessTimeArgumenException3 ()
1282 if (Path.InvalidPathChars.Length > 1) {
1285 File.SetLastAccessTime (Path.InvalidPathChars [1].ToString (), new DateTime (2000, 12, 12, 11, 59, 59));
1286 } catch (ArgumentException) {
1290 Assertion.Assert ("#01", pass);
1295 [ExpectedException(typeof (FileNotFoundException))]
1296 [Category("TargetJvmNotSupported")] // SetLastAccessTime not supported for TARGET_JVM
1297 public void SetLastAccessTimeFileNotFoundException1 ()
1299 string path = TempFolder + Path.DirectorySeparatorChar + "SetLastAccessTimeFileNotFoundException1";
1302 File.SetLastAccessTime (path, new DateTime (2000, 12, 12, 11, 59, 59));
1306 // [ExpectedException(typeof (ArgumentOutOfRangeException))]
1307 // public void SetLastAccessTimeArgumentOutOfRangeException1 ()
1309 // string path = TempFolder + Path.DirectorySeparatorChar + "SetLastTimeArgumentOutOfRangeException1";
1310 // DeleteFile (path);
1311 // FileStream stream = null;
1313 // stream = File.Create (path);
1315 // File.SetLastAccessTime (path, new DateTime (1000, 12, 12, 11, 59, 59));
1317 // if (stream != null)
1319 // DeleteFile (path);
1324 [ExpectedException(typeof (IOException))]
1325 [Category("TargetJvmNotSupported")] // SetLastAccessTime not supported for TARGET_JVM
1326 public void SetLastAccessTimeIOException1 ()
1328 string path = TempFolder + Path.DirectorySeparatorChar + "LastAccessIOException1";
1330 FileStream stream = null;
1332 stream = File.Create (path);
1333 File.SetLastAccessTime (path, new DateTime (1000, 12, 12, 11, 59, 59));
1342 [ExpectedException(typeof (ArgumentNullException))]
1343 [Category("TargetJvmNotSupported")] // SetLastAccessTime not supported for TARGET_JVM
1344 public void SetLastAccessTimeUtcArgumentNullException1 ()
1346 File.SetLastAccessTimeUtc (null as string, new DateTime (2000, 12, 12, 11, 59, 59));
1350 [ExpectedException(typeof (ArgumentException))]
1351 [Category("TargetJvmNotSupported")] // SetLastAccessTime not supported for TARGET_JVM
1352 public void SetCLastAccessTimeUtcArgumenException1 ()
1354 File.SetLastAccessTimeUtc ("", new DateTime (2000, 12, 12, 11, 59, 59));
1358 [ExpectedException(typeof (ArgumentException))]
1359 [Category("TargetJvmNotSupported")] // SetLastAccessTime not supported for TARGET_JVM
1360 public void SetLastAccessTimeUtcArgumenException2 ()
1362 File.SetLastAccessTimeUtc (" ", new DateTime (2000, 12, 12, 11, 59, 59));
1366 // On Unix there are no invalid path chars.
1367 [Category("TargetJvmNotSupported")] // SetLastAccessTime not supported for TARGET_JVM
1368 public void SetLastAccessTimeUtcArgumenException3 ()
1370 if (Path.InvalidPathChars.Length > 1) {
1373 File.SetLastAccessTimeUtc (Path.InvalidPathChars [1].ToString (), new DateTime (2000, 12, 12, 11, 59, 59));
1374 } catch (ArgumentException) {
1378 Assertion.Assert ("#01", pass);
1383 [ExpectedException(typeof (FileNotFoundException))]
1384 [Category("TargetJvmNotSupported")] // SetLastAccessTime not supported for TARGET_JVM
1385 public void SetLastAccessTimeUtcFileNotFoundException1 ()
1387 string path = TempFolder + Path.DirectorySeparatorChar + "SetLastAccessTimeUtcFileNotFoundException1";
1390 File.SetLastAccessTimeUtc (path, new DateTime (2000, 12, 12, 11, 59, 59));
1394 // [ExpectedException(typeof (ArgumentOutOfRangeException))]
1395 // public void SetLastAccessTimeUtcArgumentOutOfRangeException1 ()
1397 // string path = TempFolder + Path.DirectorySeparatorChar + "SetLastAccessTimeUtcArgumentOutOfRangeException1";
1398 // DeleteFile (path);
1399 // FileStream stream = null;
1401 // stream = File.Create (path);
1403 // File.SetLastAccessTimeUtc (path, new DateTime (1000, 12, 12, 11, 59, 59));
1405 // if (stream != null)
1407 // DeleteFile (path);
1412 [ExpectedException(typeof (IOException))]
1413 [Category("TargetJvmNotSupported")] // SetLastAccessTime not supported for TARGET_JVM
1414 public void SetLastAccessTimeUtcIOException1 ()
1416 string path = TempFolder + Path.DirectorySeparatorChar + "SetLastAccessTimeUtcIOException1";
1418 FileStream stream = null;
1420 stream = File.Create (path);
1421 File.SetLastAccessTimeUtc (path, new DateTime (1000, 12, 12, 11, 59, 59));
1429 // SetLastWriteTime and SetLastWriteTimeUtc exceptions
1432 [ExpectedException(typeof (ArgumentNullException))]
1433 public void SetLastWriteTimeArgumentNullException1 ()
1435 File.SetLastWriteTime (null as string, new DateTime (2000, 12, 12, 11, 59, 59));
1439 [ExpectedException(typeof (ArgumentException))]
1440 public void SetLastWriteTimeArgumenException1 ()
1442 File.SetLastWriteTime ("", new DateTime (2000, 12, 12, 11, 59, 59));
1446 [ExpectedException(typeof (ArgumentException))]
1447 public void SetLastWriteTimeArgumenException2 ()
1449 File.SetLastWriteTime (" ", new DateTime (2000, 12, 12, 11, 59, 59));
1453 // On Unix there are no invalid path chars.
1454 public void SetLastWriteTimeArgumenException3 ()
1456 if (Path.InvalidPathChars.Length > 1) {
1459 File.SetLastWriteTime (Path.InvalidPathChars [1].ToString (), new DateTime (2000, 12, 12, 11, 59, 59));
1460 } catch (ArgumentException) {
1464 Assertion.Assert ("#01", pass);
1469 [ExpectedException(typeof (FileNotFoundException))]
1470 public void SetLastWriteTimeFileNotFoundException1 ()
1472 string path = TempFolder + Path.DirectorySeparatorChar + "SetLastWriteTimeFileNotFoundException1";
1475 File.SetLastWriteTime (path, new DateTime (2000, 12, 12, 11, 59, 59));
1479 // [ExpectedException(typeof (ArgumentOutOfRangeException))]
1480 // public void SetLastWriteTimeArgumentOutOfRangeException1 ()
1482 // string path = TempFolder + Path.DirectorySeparatorChar + "SetLastWriteTimeArgumentOutOfRangeException1";
1483 // DeleteFile (path);
1484 // FileStream stream = null;
1486 // stream = File.Create (path);
1488 // File.SetLastWriteTime (path, new DateTime (1000, 12, 12, 11, 59, 59));
1490 // if (stream != null)
1492 // DeleteFile (path);
1497 [ExpectedException(typeof (IOException))]
1498 public void SetLastWriteTimeIOException1 ()
1500 string path = TempFolder + Path.DirectorySeparatorChar + "LastWriteTimeIOException1";
1502 FileStream stream = null;
1504 stream = File.Create (path);
1505 File.SetLastWriteTime (path, new DateTime (1000, 12, 12, 11, 59, 59));
1514 [ExpectedException(typeof (ArgumentNullException))]
1515 public void SetLastWriteTimeUtcArgumentNullException1 ()
1517 File.SetLastWriteTimeUtc (null as string, new DateTime (2000, 12, 12, 11, 59, 59));
1521 [ExpectedException(typeof (ArgumentException))]
1522 public void SetCLastWriteTimeUtcArgumenException1 ()
1524 File.SetLastWriteTimeUtc ("", new DateTime (2000, 12, 12, 11, 59, 59));
1528 [ExpectedException(typeof (ArgumentException))]
1529 public void SetLastWriteTimeUtcArgumenException2 ()
1531 File.SetLastWriteTimeUtc (" ", new DateTime (2000, 12, 12, 11, 59, 59));
1535 // On Unix there are no invalid path chars.
1536 public void SetLastWriteTimeUtcArgumenException3 ()
1538 if (Path.InvalidPathChars.Length > 1) {
1541 File.SetLastWriteTimeUtc (Path.InvalidPathChars [1].ToString (), new DateTime (2000, 12, 12, 11, 59, 59));
1542 } catch (ArgumentException) {
1546 Assertion.Assert ("#01", pass);
1551 [ExpectedException(typeof (FileNotFoundException))]
1552 public void SetLastWriteTimeUtcFileNotFoundException1 ()
1554 string path = TempFolder + Path.DirectorySeparatorChar + "SetLastWriteTimeUtcFileNotFoundException1";
1557 File.SetLastWriteTimeUtc (path, new DateTime (2000, 12, 12, 11, 59, 59));
1561 // [ExpectedException(typeof (ArgumentOutOfRangeException))]
1562 // public void SetLastWriteTimeUtcArgumentOutOfRangeException1 ()
1564 // string path = TempFolder + Path.DirectorySeparatorChar + "SetLastWriteTimeUtcArgumentOutOfRangeException1";
1565 // DeleteFile (path);
1566 // FileStream stream = null;
1568 // stream = File.Create (path);
1570 // File.SetLastWriteTimeUtc (path, new DateTime (1000, 12, 12, 11, 59, 59));
1572 // if (stream != null)
1574 // DeleteFile (path);
1579 [ExpectedException(typeof (IOException))]
1580 public void SetLastWriteTimeUtcIOException1 ()
1582 string path = TempFolder + Path.DirectorySeparatorChar + "SetLastWriteTimeUtcIOException1";
1584 FileStream stream = null;
1586 stream = File.Create (path);
1587 File.SetLastWriteTimeUtc (path, new DateTime (1000, 12, 12, 11, 59, 59));
1596 public void OpenAppend ()
1598 string fn = Path.GetTempFileName ();
1599 using (FileStream s = File.Open (fn, FileMode.Append))
1606 void TestRWAT (string s)
1608 string f = Path.GetTempFileName ();
1610 File.WriteAllText (f, s);
1611 string r = File.ReadAllText (f);
1612 AssertEquals (r, s);
1618 public void ReadWriteAllText ()
1620 // The MSDN docs said something about
1621 // not including a final new line. it looks
1622 // like that was not true. I'm not sure what
1623 // that was talking about
1633 TestRWAT ("a\r\na");
1637 TestRWAT ("\r\n\r\n");
1641 private void DeleteFile (string path)
1643 if (File.Exists (path))