2 // System.IO.Path Test Cases
5 // Marcin Szczepanski (marcins@zipworld.com.au)
6 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 // Ben Maurer (bmaurer@users.sf.net)
8 // Gilles Freart (gfr@skynet.be)
9 // Atsushi Enomoto (atsushi@ximian.com)
10 // Sebastien Pouliot <sebastien@ximian.com>
12 // (c) Marcin Szczepanski
13 // (c) 2002 Ximian, Inc. (http://www.ximian.com)
14 // (c) 2003 Ben Maurer
15 // (c) 2003 Gilles Freart
16 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
19 using NUnit.Framework;
24 namespace MonoTests.System.IO
39 static char DSC = Path.DirectorySeparatorChar;
46 path1 = "/foo/test.txt";
49 } else if ('\\' == DSC) {
51 path1 = "c:\\foo\\test.txt";
52 path2 = Environment.GetEnvironmentVariable ("SYSTEMROOT");
56 //FIXME: For Mac. figure this out when we need it
57 path1 = "foo:test.txt";
66 return OS == OsType.Windows;
73 return OS == OsType.Unix;
80 return OS == OsType.Mac;
85 public void ChangeExtension ()
87 string [] files = new string [3];
88 files [(int) OsType.Unix] = "/foo/test.doc";
89 files [(int) OsType.Windows] = "c:\\foo\\test.doc";
90 files [(int) OsType.Mac] = "foo:test.doc";
92 string testPath = Path.ChangeExtension (path1, "doc");
93 Assert.AreEqual (files [(int) OS], testPath, "ChangeExtension #01");
95 testPath = Path.ChangeExtension (String.Empty, ".extension");
96 Assert.AreEqual (String.Empty, testPath, "ChangeExtension #02");
98 testPath = Path.ChangeExtension (null, ".extension");
99 Assert.AreEqual (null, testPath, "ChangeExtension #03");
101 testPath = Path.ChangeExtension ("path", null);
102 Assert.AreEqual ("path", testPath, "ChangeExtension #04");
104 testPath = Path.ChangeExtension ("path.ext", "doc");
105 Assert.AreEqual ("path.doc", testPath, "ChangeExtension #05");
107 testPath = Path.ChangeExtension ("path.ext1.ext2", "doc");
108 Assert.AreEqual ("path.ext1.doc", testPath, "ChangeExtension #06");
110 testPath = Path.ChangeExtension ("hogehoge.xml", ".xsl");
111 Assert.AreEqual ("hogehoge.xsl", testPath, "ChangeExtension #07");
112 testPath = Path.ChangeExtension ("hogehoge", ".xsl");
113 Assert.AreEqual ("hogehoge.xsl", testPath, "ChangeExtension #08");
114 testPath = Path.ChangeExtension ("hogehoge.xml", "xsl");
115 Assert.AreEqual ("hogehoge.xsl", testPath, "ChangeExtension #09");
116 testPath = Path.ChangeExtension ("hogehoge", "xsl");
117 Assert.AreEqual ("hogehoge.xsl", testPath, "ChangeExtension #10");
118 testPath = Path.ChangeExtension ("hogehoge.xml", String.Empty);
119 Assert.AreEqual ("hogehoge.", testPath, "ChangeExtension #11");
120 testPath = Path.ChangeExtension ("hogehoge", String.Empty);
121 Assert.AreEqual ("hogehoge.", testPath, "ChangeExtension #12");
122 testPath = Path.ChangeExtension ("hogehoge.", null);
123 Assert.AreEqual ("hogehoge", testPath, "ChangeExtension #13");
124 testPath = Path.ChangeExtension ("hogehoge", null);
125 Assert.AreEqual ("hogehoge", testPath, "ChangeExtension #14");
126 testPath = Path.ChangeExtension (String.Empty, null);
127 Assert.AreEqual (String.Empty, testPath, "ChangeExtension #15");
128 testPath = Path.ChangeExtension (String.Empty, "bashrc");
129 Assert.AreEqual (String.Empty, testPath, "ChangeExtension #16");
130 testPath = Path.ChangeExtension (String.Empty, ".bashrc");
131 Assert.AreEqual (String.Empty, testPath, "ChangeExtension #17");
132 testPath = Path.ChangeExtension (null, null);
133 Assert.IsNull (testPath, "ChangeExtension #18");
137 public void ChangeExtension_Extension_InvalidPathChars ()
139 string fn = Path.ChangeExtension ("file.ext", "<");
140 Assert.AreEqual ("file.<", fn, "Invalid filename");
144 public void ChangeExtension_Path_InvalidPathChars ()
147 Path.ChangeExtension ("fi\0le.ext", ".extension");
149 } catch (ArgumentException ex) {
150 // Illegal characters in path
151 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
152 Assert.IsNull (ex.InnerException, "#3");
153 Assert.IsNotNull (ex.Message, "#4");
154 Assert.IsNull (ex.ParamName, "#5");
159 public void Combine ()
161 string [] files = new string [3];
162 files [(int) OsType.Unix] = "/etc/init.d";
163 files [(int) OsType.Windows] = Environment.GetEnvironmentVariable ("SYSTEMROOT") + @"\system32";
164 files [(int) OsType.Mac] = "foo:bar";
166 string testPath = Path.Combine (path2, path3);
167 Assert.AreEqual (files [(int) OS], testPath, "Combine #01");
169 testPath = Path.Combine ("one", String.Empty);
170 Assert.AreEqual ("one", testPath, "Combine #02");
172 testPath = Path.Combine (String.Empty, "one");
173 Assert.AreEqual ("one", testPath, "Combine #03");
175 string current = Directory.GetCurrentDirectory ();
176 testPath = Path.Combine (current, "one");
178 string expected = current + DSC + "one";
179 Assert.AreEqual (expected, testPath, "Combine #04");
181 testPath = Path.Combine ("one", current);
182 // LAMESPEC noted in Path.cs
183 Assert.AreEqual (current, testPath, "Combine #05");
185 testPath = Path.Combine (current, expected);
186 Assert.AreEqual (expected, testPath, "Combine #06");
188 testPath = DSC + "one";
189 testPath = Path.Combine (testPath, "two" + DSC);
190 expected = DSC + "one" + DSC + "two" + DSC;
191 Assert.AreEqual (expected, testPath, "Combine #06");
193 testPath = "one" + DSC;
194 testPath = Path.Combine (testPath, DSC + "two");
195 expected = DSC + "two";
196 Assert.AreEqual (expected, testPath, "Combine #06");
198 testPath = "one" + DSC;
199 testPath = Path.Combine (testPath, "two" + DSC);
200 expected = "one" + DSC + "two" + DSC;
201 Assert.AreEqual (expected, testPath, "Combine #07");
204 Assert.AreEqual ("a", Path.Combine (new [] { "a", "" }), "Combine #08");
209 public void Combine_Path1_InvalidPathChars ()
212 Path.Combine ("a\0", "one");
214 } catch (ArgumentException ex) {
215 // Illegal characters in path
216 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
217 Assert.IsNull (ex.InnerException, "#3");
218 Assert.IsNotNull (ex.Message, "#4");
219 Assert.IsNull (ex.ParamName, "#5");
224 public void Combine_Path1_Null ()
227 Path.Combine (null, "one");
229 } catch (ArgumentNullException ex) {
230 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
231 Assert.IsNull (ex.InnerException, "#3");
232 Assert.IsNotNull (ex.Message, "#4");
233 Assert.AreEqual ("path1", ex.ParamName, "#5");
238 public void Combine_Path2_InvalidPathChars ()
241 Path.Combine ("one", "a\0");
243 } catch (ArgumentException ex) {
244 // Illegal characters in path
245 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
246 Assert.IsNull (ex.InnerException, "#3");
247 Assert.IsNotNull (ex.Message, "#4");
248 Assert.IsNull (ex.ParamName, "#5");
253 public void Combine_Path2_Null ()
256 Path.Combine ("one", null);
258 } catch (ArgumentNullException ex) {
259 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
260 Assert.IsNull (ex.InnerException, "#3");
261 Assert.IsNotNull (ex.Message, "#4");
262 Assert.AreEqual ("path2", ex.ParamName, "#5");
267 public void GetDirectoryName ()
269 string [] files = new string [3];
270 files [(int) OsType.Unix] = "/foo";
271 files [(int) OsType.Windows] = "c:\\foo";
272 files [(int) OsType.Mac] = "foo";
274 string testDirName = Path.GetDirectoryName (path1);
275 Assert.AreEqual (files [(int) OS], testDirName, "#A1");
276 testDirName = Path.GetDirectoryName (files [(int) OS] + DSC);
277 Assert.AreEqual (files [(int) OS], testDirName, "#A2");
280 Assert.AreEqual ("C:\\foo", Path.GetDirectoryName ("C:\\foo\\foo.txt"), "#B1");
281 Assert.AreEqual (null, Path.GetDirectoryName ("C:"), "#B2");
282 Assert.AreEqual (null, Path.GetDirectoryName (@"C:\"), "#B3");
283 Assert.AreEqual (@"C:\", Path.GetDirectoryName (@"C:\dir"), "#B4");
284 Assert.AreEqual (@"C:\dir", Path.GetDirectoryName (@"C:\dir\"), "#B5");
285 Assert.AreEqual (@"C:\dir", Path.GetDirectoryName (@"C:\dir\dir"), "#B6");
286 Assert.AreEqual (@"C:\dir\dir", Path.GetDirectoryName (@"C:\dir\dir\"), "#B7");
287 Assert.AreEqual (@"C:", Path.GetDirectoryName (@"C:foo.txt"), "#B8");
288 Assert.AreEqual (@"C:dir", Path.GetDirectoryName (@"C:dir\"), "#B9");
290 Assert.AreEqual ("\\foo\\bar", Path.GetDirectoryName ("/foo//bar/dingus"), "#C1");
291 Assert.AreEqual ("foo\\bar", Path.GetDirectoryName ("foo/bar/"), "#C2");
292 Assert.AreEqual ("foo\\bar", Path.GetDirectoryName ("foo/bar\\xxx"), "#C3");
293 Assert.AreEqual ("\\\\host\\dir\\dir2", Path.GetDirectoryName ("\\\\host\\dir\\\\dir2\\path"), "#C4");
296 Assert.AreEqual (null, Path.GetDirectoryName (@"\\"), "#D1");
297 Assert.AreEqual (null, Path.GetDirectoryName (@"\\server"), "#D2");
298 Assert.AreEqual (null, Path.GetDirectoryName (@"\\server\share"), "#D3");
299 Assert.AreEqual (@"\\server\share", Path.GetDirectoryName (@"\\server\share\"), "#D4");
300 Assert.AreEqual (@"\\server\share", Path.GetDirectoryName (@"\\server\share\dir"), "#D5");
301 Assert.AreEqual (@"\\server\share\dir", Path.GetDirectoryName (@"\\server\share\dir\subdir"), "#D6");
303 Assert.AreEqual ("/etc", Path.GetDirectoryName ("/etc/hostname"), "#B1");
304 Assert.AreEqual ("/foo/bar", Path.GetDirectoryName ("/foo//bar/dingus"), "#B2");
305 Assert.AreEqual ("foo/bar", Path.GetDirectoryName ("foo/bar/"), "#B3");
306 Assert.AreEqual ("/", Path.GetDirectoryName ("/tmp"), "#B4");
307 Assert.IsNull (Path.GetDirectoryName ("/"), "#B5");
308 Assert.AreEqual ("a", Path.GetDirectoryName ("a//b"), "#B6");
313 public void GetDirectoryName_Path_Empty ()
316 Path.GetDirectoryName (String.Empty);
318 } catch (ArgumentException ex) {
319 // The path is not of a legal form
320 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
321 Assert.IsNull (ex.InnerException, "#3");
322 Assert.IsNotNull (ex.Message, "#4");
323 Assert.IsNull (ex.ParamName, "#5");
328 public void GetDirectoryName_Path_InvalidPathChars ()
331 Path.GetDirectoryName ("hi\0world");
333 } catch (ArgumentException ex) {
334 // Illegal characters in path
335 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
336 Assert.IsNull (ex.InnerException, "#3");
337 Assert.IsNotNull (ex.Message, "#4");
338 Assert.IsNull (ex.ParamName, "#5");
343 public void GetDirectoryName_Path_Null ()
345 Assert.IsNull (Path.GetDirectoryName (null));
349 public void GetDirectoryName_Path_Whitespace ()
352 Path.GetDirectoryName (" ");
354 } catch (ArgumentException ex) {
355 // The path is not of a legal form
356 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
357 Assert.IsNull (ex.InnerException, "#3");
358 Assert.IsNotNull (ex.Message, "#4");
359 Assert.IsNull (ex.ParamName, "#5");
364 public void GetExtension ()
366 string testExtn = Path.GetExtension (path1);
368 Assert.AreEqual (".txt", testExtn, "GetExtension #01");
370 testExtn = Path.GetExtension (path2);
371 Assert.AreEqual (String.Empty, testExtn, "GetExtension #02");
373 testExtn = Path.GetExtension (String.Empty);
374 Assert.AreEqual (String.Empty, testExtn, "GetExtension #03");
376 testExtn = Path.GetExtension (null);
377 Assert.AreEqual (null, testExtn, "GetExtension #04");
379 testExtn = Path.GetExtension (" ");
380 Assert.AreEqual (String.Empty, testExtn, "GetExtension #05");
382 testExtn = Path.GetExtension (path1 + ".doc");
383 Assert.AreEqual (".doc", testExtn, "GetExtension #06");
385 testExtn = Path.GetExtension (path1 + ".doc" + DSC + "a.txt");
386 Assert.AreEqual (".txt", testExtn, "GetExtension #07");
388 testExtn = Path.GetExtension (".");
389 Assert.AreEqual (String.Empty, testExtn, "GetExtension #08");
391 testExtn = Path.GetExtension ("end.");
392 Assert.AreEqual (String.Empty, testExtn, "GetExtension #09");
394 testExtn = Path.GetExtension (".start");
395 Assert.AreEqual (".start", testExtn, "GetExtension #10");
397 testExtn = Path.GetExtension (".a");
398 Assert.AreEqual (".a", testExtn, "GetExtension #11");
400 testExtn = Path.GetExtension ("a.");
401 Assert.AreEqual (String.Empty, testExtn, "GetExtension #12");
403 testExtn = Path.GetExtension ("a");
404 Assert.AreEqual (String.Empty, testExtn, "GetExtension #13");
406 testExtn = Path.GetExtension ("makefile");
407 Assert.AreEqual (String.Empty, testExtn, "GetExtension #14");
411 public void GetExtension_Path_InvalidPathChars ()
414 Path.GetExtension ("hi\0world.txt");
416 } catch (ArgumentException ex) {
417 // Illegal characters in path.
418 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
419 Assert.IsNull (ex.InnerException, "#3");
420 Assert.IsNotNull (ex.Message, "#4");
421 Assert.IsNull (ex.ParamName, "#5");
426 public void GetFileName ()
428 string testFileName = Path.GetFileName (path1);
430 Assert.AreEqual ("test.txt", testFileName, "#1");
431 testFileName = Path.GetFileName (null);
432 Assert.AreEqual (null, testFileName, "#2");
433 testFileName = Path.GetFileName (String.Empty);
434 Assert.AreEqual (String.Empty, testFileName, "#3");
435 testFileName = Path.GetFileName (" ");
436 Assert.AreEqual (" ", testFileName, "#4");
440 public void GetFileName_Path_InvalidPathChars ()
443 Path.GetFileName ("hi\0world");
445 } catch (ArgumentException ex) {
446 // Illegal characters in path
447 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
448 Assert.IsNull (ex.InnerException, "#3");
449 Assert.IsNotNull (ex.Message, "#4");
450 Assert.IsNull (ex.ParamName, "#5");
455 public void GetFileNameWithoutExtension ()
457 string testFileName = Path.GetFileNameWithoutExtension (path1);
459 Assert.AreEqual ("test", testFileName, "GetFileNameWithoutExtension #01");
461 testFileName = Path.GetFileNameWithoutExtension (null);
462 Assert.AreEqual (null, testFileName, "GetFileNameWithoutExtension #02");
464 testFileName = Path.GetFileNameWithoutExtension (String.Empty);
465 Assert.AreEqual (String.Empty, testFileName, "GetFileNameWithoutExtension #03");
469 public void GetFileNameWithoutExtension_Path_InvalidPathChars ()
472 Path.GetFileNameWithoutExtension ("hi\0world");
474 } catch (ArgumentException ex) {
475 // Illegal characters in path
476 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
477 Assert.IsNull (ex.InnerException, "#3");
478 Assert.IsNotNull (ex.Message, "#4");
479 Assert.IsNull (ex.ParamName, "#5");
484 public void GetFullPath ()
486 string current = Directory.GetCurrentDirectory ();
488 string testFullPath = Path.GetFullPath ("foo.txt");
489 string expected = current + DSC + "foo.txt";
490 Assert.AreEqual (expected, testFullPath, "GetFullPath #01");
492 testFullPath = Path.GetFullPath ("a//./.././foo.txt");
493 Assert.AreEqual (expected, testFullPath, "GetFullPath #02");
496 Assert.AreEqual ("/bin/bash", Path.GetFullPath ("/../bin/bash"));
502 public void GetFullPath_Unix ()
508 string [,] test = new string [,] {
509 {"root////././././././../root/././../root", "root"},
511 {"root/./", "root/"},
512 {"root/./", "root/"},
513 {"root/../", String.Empty},
514 {"root/../", String.Empty},
515 {"root/../..", String.Empty},
516 {"root/.hiddenfile", "root/.hiddenfile"},
517 {"root/. /", "root/. /"},
518 {"root/.. /", "root/.. /"},
519 {"root/..weirdname", "root/..weirdname"},
520 {"root/..", String.Empty},
521 {"root/../a/b/../../..", String.Empty},
522 {"root/./..", String.Empty},
523 {"..", String.Empty},
525 {"root//dir", "root/dir"},
526 {"root/. /", "root/. /"},
527 {"root/.. /", "root/.. /"},
528 {"root/ . /", "root/ . /"},
529 {"root/ .. /", "root/ .. /"},
530 {"root/./", "root/"},
531 //ERROR! Paths are trimmed
532 // I don't understand this comment^^.
533 // No trimming occurs but the paths are not equal. That's why the test fails. Commented out.
534 //{"root/.. /", "root/.. /"},
535 {".//", String.Empty}
538 for (int i = 0; i < test.GetUpperBound (0); i++) {
539 Assert.AreEqual (root + test [i, 1], Path.GetFullPath (root + test [i, 0]),
540 String.Format ("GetFullPathUnix #{0}", i));
543 Assert.AreEqual ("/", Path.GetFullPath ("/"), "#01");
544 Assert.AreEqual ("/hey", Path.GetFullPath ("/hey"), "#02");
545 Assert.AreEqual (Environment.CurrentDirectory, Path.GetFullPath ("."), "#03");
546 Assert.AreEqual (Path.Combine (Environment.CurrentDirectory, "hey"),
547 Path.GetFullPath ("hey"), "#04");
551 public void GetFullPath_Windows ()
556 string root = "C:\\";
557 string [,] test = new string [,] {
558 {"root////././././././../root/././../root", "root"},
560 {"root/./", "root\\"},
561 {"root/./", "root\\"},
565 {"root/.hiddenfile", "root\\.hiddenfile"},
566 {"root/. /", "root\\"},
568 {"root/..weirdname", "root\\..weirdname"},
570 {"root/../a/b/../../..", ""},
574 {"root//dir", "root\\dir"},
575 {"root/. /", "root\\"},
578 {"root/ . /", "root\\"},
581 {"root/./", "root\\"},
586 for (int i = 0; i < test.GetUpperBound (0); i++) {
588 Assert.AreEqual (root + test [i, 1], Path.GetFullPath (root + test [i, 0]),
589 String.Format ("GetFullPathWindows #{0}", i));
590 } catch (Exception ex) {
591 Assert.Fail (String.Format ("GetFullPathWindows #{0} (\"{1}\") failed: {2}",
592 i, root + test [i, 0], ex.GetType ()));
597 string root2 = @"\\server\share";
598 root = @"\\server\share\";
599 test = new string [,] {
600 {"root////././././././../root/././../root", "root"},
602 {"root/./", "root\\"},
603 {"root/./", "root\\"},
606 {"root/../..", null},
607 {"root/.hiddenfile", "root\\.hiddenfile"},
608 {"root/. /", "root\\"},
610 {"root/..weirdname", "root\\..weirdname"},
612 {"root/../a/b/../../..", null},
616 {"root//dir", "root\\dir"},
617 {"root/. /", "root\\"},
620 {"root/ . /", "root\\"},
623 {"root/./", "root\\"},
628 for (int i = 0; i < test.GetUpperBound (0); i++) {
629 // "null" means we have to compare against "root2"
630 string res = test [i, 1] != null
634 Assert.AreEqual (res, Path.GetFullPath (root + test [i, 0]),
635 String.Format ("GetFullPathWindows UNC #{0}", i));
636 } catch (AssertionException) {
638 } catch (Exception ex) {
639 Assert.Fail (String.Format ("GetFullPathWindows UNC #{0} (\"{1}\") failed: {2}",
640 i, root + test [i, 0], ex.GetType ()));
644 test = new string [,] {
645 {"root////././././././../root/././../root", "root"},
647 {"root/./", "root\\"},
648 {"root/./", "root\\"},
651 {"root/../..", null},
652 {"root/.hiddenfile", "root\\.hiddenfile"},
653 {"root/. /", "root\\"},
655 {"root/..weirdname", "root\\..weirdname"},
657 {"root/../a/b/../../..", null},
661 {"root//dir", "root\\dir"},
662 {"root/. /", "root\\"},
665 {"root/ . /", "root\\"},
668 {"root/./", "root\\"},
673 string root3 = @"//server/share";
674 root = @"//server/share/";
675 bool needSlashConvert = Path.DirectorySeparatorChar != '/';
677 for (int i = 0; i < test.GetUpperBound (0); i++) {
678 // "null" means we have to compare against "root2"
679 string res = test [i, 1] != null
682 if (needSlashConvert)
683 res = res.Replace ('/', Path.DirectorySeparatorChar);
685 Assert.AreEqual (res, Path.GetFullPath (root + test [i, 0]),
686 String.Format ("GetFullPathWindows UNC[2] #{0}", i));
687 } catch (AssertionException) {
689 } catch (Exception ex) {
690 Assert.Fail (String.Format ("GetFullPathWindows UNC[2] #{0} (\"{1}\") failed: {2}",
691 i, root + test [i, 0], ex.GetType ()));
697 public void GetFullPath_Path_Empty ()
700 Path.GetFullPath (String.Empty);
702 } catch (ArgumentException ex) {
703 // The path is not of a legal form
704 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
705 Assert.IsNull (ex.InnerException, "#3");
706 Assert.IsNotNull (ex.Message, "#4");
707 Assert.IsNull (ex.ParamName, "#5");
712 public void GetFullPath_Path_EndingSeparator ()
714 string fp = Path.GetFullPath ("something/");
715 char end = fp [fp.Length - 1];
716 Assert.IsTrue (end == Path.DirectorySeparatorChar);
720 public void GetFullPath_Path_InvalidPathChars ()
723 Path.GetFullPath ("hi\0world");
725 } catch (ArgumentException ex) {
726 // Illegal characters in path
727 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
728 Assert.IsNull (ex.InnerException, "#3");
729 Assert.IsNotNull (ex.Message, "#4");
730 Assert.IsNull (ex.ParamName, "#5");
735 public void GetFullPath_Path_Null ()
738 Path.GetFullPath (null);
740 } catch (ArgumentNullException ex) {
741 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
742 Assert.IsNull (ex.InnerException, "#3");
743 Assert.IsNotNull (ex.Message, "#4");
744 Assert.AreEqual ("path", ex.ParamName, "#5");
749 public void GetFullPath_Path_Whitespace ()
752 Path.GetFullPath (" ");
754 } catch (ArgumentException ex) {
755 // The path is not of a legal form
756 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
757 Assert.IsNull (ex.InnerException, "#3");
758 Assert.IsNotNull (ex.Message, "#4");
759 Assert.IsNull (ex.ParamName, "#5");
764 public void GetFullPath2 ()
767 Assert.AreEqual (@"Z:\", Path.GetFullPath ("Z:"), "GetFullPath w#01");
768 #if !TARGET_JVM // Java full (canonical) path always starts with caps drive letter
769 Assert.AreEqual (@"c:\abc\def", Path.GetFullPath (@"c:\abc\def"), "GetFullPath w#02");
771 Assert.IsTrue (Path.GetFullPath (@"\").EndsWith (@"\"), "GetFullPath w#03");
772 // "\\\\" is not allowed
773 Assert.IsTrue (Path.GetFullPath ("/").EndsWith (@"\"), "GetFullPath w#05");
774 // "//" is not allowed
775 Assert.IsTrue (Path.GetFullPath ("readme.txt").EndsWith (@"\readme.txt"), "GetFullPath w#07");
776 Assert.IsTrue (Path.GetFullPath ("c").EndsWith (@"\c"), "GetFullPath w#08");
777 Assert.IsTrue (Path.GetFullPath (@"abc\def").EndsWith (@"abc\def"), "GetFullPath w#09");
778 Assert.IsTrue (Path.GetFullPath (@"\abc\def").EndsWith (@"\abc\def"), "GetFullPath w#10");
779 Assert.AreEqual (@"\\abc\def", Path.GetFullPath (@"\\abc\def"), "GetFullPath w#11");
780 Assert.AreEqual (Directory.GetCurrentDirectory () + @"\abc\def", Path.GetFullPath (@"abc//def"), "GetFullPath w#12");
781 Assert.AreEqual (Directory.GetCurrentDirectory ().Substring (0, 2) + @"\abc\def", Path.GetFullPath ("/abc/def"), "GetFullPath w#13");
782 Assert.AreEqual (@"\\abc\def", Path.GetFullPath ("//abc/def"), "GetFullPath w#14");
784 Assert.AreEqual ("/", Path.GetFullPath ("/"), "#01");
785 Assert.AreEqual ("/hey", Path.GetFullPath ("/hey"), "#02");
786 Assert.AreEqual (Environment.CurrentDirectory, Path.GetFullPath ("."), "#03");
787 Assert.AreEqual (Path.Combine (Environment.CurrentDirectory, "hey"),
788 Path.GetFullPath ("hey"), "#04");
793 public void GetPathRoot ()
798 current = Directory.GetCurrentDirectory ();
799 expected = current [0].ToString ();
801 current = @"J:\Some\Strange Directory\Name";
805 string pathRoot = Path.GetPathRoot (current);
806 Assert.AreEqual (expected, pathRoot, "GetPathRoot #01");
810 public void GetPathRoot2 ()
812 // note: this method doesn't call Directory.GetCurrentDirectory so it can be
813 // reused for partial trust unit tests in PathCas.cs
817 pathRoot = Path.GetPathRoot ("hola");
818 Assert.AreEqual (String.Empty, pathRoot, "#A1");
819 pathRoot = Path.GetPathRoot (null);
820 Assert.AreEqual (null, pathRoot, "#A2");
823 Assert.AreEqual ("z:", Path.GetPathRoot ("z:"), "GetPathRoot w#01");
824 Assert.AreEqual ("c:\\", Path.GetPathRoot ("c:\\abc\\def"), "GetPathRoot w#02");
825 Assert.AreEqual ("\\", Path.GetPathRoot ("\\"), "GetPathRoot w#03");
826 Assert.AreEqual ("\\\\", Path.GetPathRoot ("\\\\"), "GetPathRoot w#04");
827 Assert.AreEqual ("\\", Path.GetPathRoot ("/"), "GetPathRoot w#05");
828 Assert.AreEqual ("\\\\", Path.GetPathRoot ("//"), "GetPathRoot w#06");
829 Assert.AreEqual (String.Empty, Path.GetPathRoot ("readme.txt"), "GetPathRoot w#07");
830 Assert.AreEqual (String.Empty, Path.GetPathRoot ("c"), "GetPathRoot w#08");
831 Assert.AreEqual (String.Empty, Path.GetPathRoot ("abc\\def"), "GetPathRoot w#09");
832 Assert.AreEqual ("\\", Path.GetPathRoot ("\\abc\\def"), "GetPathRoot w#10");
833 Assert.AreEqual ("\\\\abc\\def", Path.GetPathRoot ("\\\\abc\\def"), "GetPathRoot w#11");
834 Assert.AreEqual (String.Empty, Path.GetPathRoot ("abc//def"), "GetPathRoot w#12");
835 Assert.AreEqual ("\\", Path.GetPathRoot ("/abc/def"), "GetPathRoot w#13");
836 Assert.AreEqual ("\\\\abc\\def", Path.GetPathRoot ("//abc/def"), "GetPathRoot w#14");
837 Assert.AreEqual (@"C:\", Path.GetPathRoot (@"C:\"), "GetPathRoot w#15");
838 Assert.AreEqual (@"C:\", Path.GetPathRoot (@"C:\\"), "GetPathRoot w#16");
839 Assert.AreEqual ("\\\\abc\\def", Path.GetPathRoot ("\\\\abc\\def\\ghi"), "GetPathRoot w#17");
841 // TODO: Same tests for Unix.
846 public void GetPathRoot_Path_Empty ()
849 Path.GetPathRoot (String.Empty);
851 } catch (ArgumentException ex) {
852 // The path is not of a legal form
853 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
854 Assert.IsNull (ex.InnerException, "#3");
855 Assert.IsNotNull (ex.Message, "#4");
856 Assert.IsNull (ex.ParamName, "#5");
862 [Category ("NotWorking")] // we also throw ArgumentException on 1.0 profile
864 public void GetPathRoot_Path_InvalidPathChars ()
868 Path.GetPathRoot ("hi\0world");
870 } catch (ArgumentException ex) {
871 // Illegal characters in path
872 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
873 Assert.IsNull (ex.InnerException, "#3");
874 Assert.IsNotNull (ex.Message, "#4");
875 Assert.IsNull (ex.ParamName, "#5");
878 Assert.AreEqual (String.Empty, Path.GetPathRoot ("hi\0world"));
883 public void GetPathRoot_Path_Whitespace ()
886 Path.GetPathRoot (" ");
888 } catch (ArgumentException ex) {
889 // The path is not of a legal form
890 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
891 Assert.IsNull (ex.InnerException, "#3");
892 Assert.IsNotNull (ex.Message, "#4");
893 Assert.IsNull (ex.ParamName, "#5");
898 public void GetTempPath ()
900 string getTempPath = Path.GetTempPath ();
901 Assert.IsTrue (getTempPath != String.Empty, "GetTempPath #01");
902 Assert.IsTrue (Path.IsPathRooted (getTempPath), "GetTempPath #02");
903 Assert.AreEqual (Path.DirectorySeparatorChar, getTempPath [getTempPath.Length - 1], "GetTempPath #03");
907 public void GetTempFileName ()
909 string getTempFileName = null;
911 getTempFileName = Path.GetTempFileName ();
912 Assert.IsTrue (getTempFileName != String.Empty, "GetTempFileName #01");
913 Assert.IsTrue (File.Exists (getTempFileName), "GetTempFileName #02");
915 if (getTempFileName != null && getTempFileName != String.Empty){
916 File.Delete (getTempFileName);
922 public void HasExtension ()
924 Assert.AreEqual (true, Path.HasExtension ("foo.txt"), "HasExtension #01");
925 Assert.AreEqual (false, Path.HasExtension ("foo"), "HasExtension #02");
926 Assert.AreEqual (true, Path.HasExtension (path1), "HasExtension #03");
927 Assert.AreEqual (false, Path.HasExtension (path2), "HasExtension #04");
928 Assert.AreEqual (false, Path.HasExtension (null), "HasExtension #05");
929 Assert.AreEqual (false, Path.HasExtension (String.Empty), "HasExtension #06");
930 Assert.AreEqual (false, Path.HasExtension (" "), "HasExtension #07");
931 Assert.AreEqual (false, Path.HasExtension ("."), "HasExtension #08");
932 Assert.AreEqual (false, Path.HasExtension ("end."), "HasExtension #09");
933 Assert.AreEqual (true, Path.HasExtension (".start"), "HasExtension #10");
934 Assert.AreEqual (true, Path.HasExtension (".a"), "HasExtension #11");
935 Assert.AreEqual (false, Path.HasExtension ("a."), "HasExtension #12");
936 Assert.AreEqual (false, Path.HasExtension ("Makefile"), "HasExtension #13");
940 public void HasExtension_Path_InvalidPathChars ()
943 Path.HasExtension ("hi\0world.txt");
945 } catch (ArgumentException ex) {
946 // Illegal characters in path
947 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
948 Assert.IsNull (ex.InnerException, "#3");
949 Assert.IsNotNull (ex.Message, "#4");
950 Assert.IsNull (ex.ParamName, "#5");
955 public void IsPathRooted ()
957 Assert.IsTrue (Path.IsPathRooted (path2), "IsPathRooted #01");
958 Assert.IsTrue (!Path.IsPathRooted (path3), "IsPathRooted #02");
959 Assert.IsTrue (!Path.IsPathRooted (null), "IsPathRooted #03");
960 Assert.IsTrue (!Path.IsPathRooted (String.Empty), "IsPathRooted #04");
961 Assert.IsTrue (!Path.IsPathRooted (" "), "IsPathRooted #05");
962 Assert.IsTrue (Path.IsPathRooted ("/"), "IsPathRooted #06");
963 Assert.IsTrue (Path.IsPathRooted ("//"), "IsPathRooted #07");
964 Assert.IsTrue (!Path.IsPathRooted (":"), "IsPathRooted #08");
967 Assert.IsTrue (Path.IsPathRooted ("\\"), "IsPathRooted #09");
968 Assert.IsTrue (Path.IsPathRooted ("\\\\"), "IsPathRooted #10");
969 Assert.IsTrue (Path.IsPathRooted ("z:"), "IsPathRooted #11");
970 Assert.IsTrue (Path.IsPathRooted ("z:\\"), "IsPathRooted #12");
971 Assert.IsTrue (Path.IsPathRooted ("z:\\topdir"), "IsPathRooted #13");
972 // This looks MS BUG. It is treated as absolute path
973 Assert.IsTrue (Path.IsPathRooted ("z:curdir"), "IsPathRooted #14");
974 Assert.IsTrue (Path.IsPathRooted ("\\abc\\def"), "IsPathRooted #15");
976 if (Environment.GetEnvironmentVariable ("MONO_IOMAP") == "all"){
977 Assert.IsTrue (Path.IsPathRooted ("\\"), "IsPathRooted #16");
978 Assert.IsTrue (Path.IsPathRooted ("\\\\"), "IsPathRooted #17");
980 Assert.IsTrue (!Path.IsPathRooted ("\\"), "IsPathRooted #09");
981 Assert.IsTrue (!Path.IsPathRooted ("\\\\"), "IsPathRooted #10");
982 Assert.IsTrue (!Path.IsPathRooted ("z:"), "IsPathRooted #11");
988 public void IsPathRooted_Path_Empty ()
990 Assert.IsTrue (!Path.IsPathRooted (String.Empty));
994 public void IsPathRooted_Path_InvalidPathChars ()
997 Path.IsPathRooted ("hi\0world");
999 } catch (ArgumentException ex) {
1000 // Illegal characters in path.
1001 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
1002 Assert.IsNull (ex.InnerException, "#3");
1003 Assert.IsNotNull (ex.Message, "#4");
1004 Assert.IsNull (ex.ParamName, "#5");
1009 public void IsPathRooted_Path_Null ()
1011 Assert.IsTrue (!Path.IsPathRooted (null));
1015 public void IsPathRooted_Path_Whitespace ()
1017 Assert.IsTrue (!Path.IsPathRooted (" "));
1021 public void CanonicalizeDots ()
1023 string current = Path.GetFullPath (".");
1024 Assert.IsTrue (!current.EndsWith ("."), "TestCanonicalizeDotst #01");
1025 string parent = Path.GetFullPath ("..");
1026 Assert.IsTrue (!current.EndsWith (".."), "TestCanonicalizeDotst #02");
1030 public void WindowsSystem32_76191 ()
1032 // check for Unix platforms - see FAQ for more details
1033 // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
1034 int platform = (int) Environment.OSVersion.Platform;
1035 if ((platform == 4) || (platform == 128) || (platform == 6))
1038 string curdir = Directory.GetCurrentDirectory ();
1041 string system = "C:\\WINDOWS\\system32\\";
1043 string system = Environment.SystemDirectory;
1045 Directory.SetCurrentDirectory (system);
1046 string drive = system.Substring (0, 2);
1047 Assert.AreEqual (system, Path.GetFullPath (drive), "current dir");
1050 Directory.SetCurrentDirectory (curdir);
1055 public void WindowsSystem32_77007 ()
1057 // check for Unix platforms - see FAQ for more details
1058 // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
1059 int platform = (int) Environment.OSVersion.Platform;
1060 if ((platform == 4) || (platform == 128) || (platform == 6))
1063 string curdir = Directory.GetCurrentDirectory ();
1066 string system = "C:\\WINDOWS\\system32\\";
1068 string system = Environment.SystemDirectory;
1070 Directory.SetCurrentDirectory (system);
1071 // e.g. C:dir (no backslash) will return CurrentDirectory + dir
1072 string dir = system.Substring (0, 2) + "dir";
1073 Assert.AreEqual (Path.Combine (system, "dir"), Path.GetFullPath (dir), "current dir");
1076 Directory.SetCurrentDirectory (curdir);
1082 [Ignore("Java full (canonical) path always returns windows dir in caps")]
1084 public void WindowsDriveC14N_77058 ()
1086 // check for Unix platforms - see FAQ for more details
1087 // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
1088 int platform = (int) Environment.OSVersion.Platform;
1089 if ((platform == 4) || (platform == 128) || (platform == 6))
1092 Assert.AreEqual (@"C:\Windows\dir", Path.GetFullPath (@"C:\Windows\System32\..\dir"), "1");
1093 Assert.AreEqual (@"C:\dir", Path.GetFullPath (@"C:\Windows\System32\..\..\dir"), "2");
1094 Assert.AreEqual (@"C:\dir", Path.GetFullPath (@"C:\Windows\System32\..\..\..\dir"), "3");
1095 Assert.AreEqual (@"C:\dir", Path.GetFullPath (@"C:\Windows\System32\..\..\..\..\dir"), "4");
1096 Assert.AreEqual (@"C:\dir\", Path.GetFullPath (@"C:\Windows\System32\..\.\..\.\..\dir\"), "5");
1100 public void InvalidPathChars_Values ()
1102 char[] invalid = Path.InvalidPathChars;
1105 Assert.AreEqual (36, invalid.Length, "Length");
1107 Assert.AreEqual (15, invalid.Length, "Length");
1109 foreach (char c in invalid) {
1115 if ((i == 0) || (i == 8) || ((i > 15) && (i < 19)) || ((i > 19) && (i < 26)))
1118 // in both 1.1 SP1 and 2.0
1119 if ((i == 34) || (i == 60) || (i == 62) || (i == 124))
1121 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1124 foreach (char c in invalid) {
1128 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1134 public void InvalidPathChars_Modify ()
1136 char[] expected = Path.InvalidPathChars;
1137 char[] invalid = Path.InvalidPathChars;
1138 char original = invalid[0];
1142 Assert.IsTrue (expected[0] == 'a', "expected");
1143 Assert.AreEqual (expected[0], Path.InvalidPathChars[0], "readonly");
1145 invalid[0] = original;
1151 public void GetInvalidFileNameChars_Values ()
1153 char[] invalid = Path.GetInvalidFileNameChars ();
1155 Assert.AreEqual (41, invalid.Length);
1156 foreach (char c in invalid) {
1160 if ((i == 34) || (i == 60) || (i == 62) || (i == 124))
1162 // ':', '*', '?', '\', '/'
1163 if ((i == 58) || (i == 42) || (i == 63) || (i == 92) || (i == 47))
1165 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1168 foreach (char c in invalid) {
1171 if ((i == 0) || (i == 47))
1173 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1179 public void GetInvalidFileNameChars_Modify ()
1181 char[] expected = Path.GetInvalidFileNameChars ();
1182 char[] invalid = Path.GetInvalidFileNameChars ();
1184 Assert.IsTrue (expected[0] != 'a', "expected");
1185 Assert.AreEqual (expected[0], Path.GetInvalidFileNameChars ()[0], "readonly");
1189 public void GetInvalidPathChars_Values ()
1191 char[] invalid = Path.GetInvalidPathChars ();
1193 Assert.AreEqual (36, invalid.Length);
1194 foreach (char c in invalid) {
1198 if ((i == 34) || (i == 60) || (i == 62) || (i == 124))
1200 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1203 foreach (char c in invalid) {
1207 Assert.Fail (String.Format ("'{0}' (#{1}) is invalid", c, i));
1213 public void GetInvalidPathChars_Order ()
1216 char [] invalid = Path.GetInvalidPathChars ();
1217 char [] expected = new char [36] { '\x22', '\x3C', '\x3E', '\x7C', '\x00', '\x01', '\x02',
1218 '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\x09', '\x0A', '\x0B', '\x0C', '\x0D',
1219 '\x0E', '\x0F', '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18',
1220 '\x19', '\x1A', '\x1B', '\x1C', '\x1D', '\x1E', '\x1F' };
1221 Assert.AreEqual (expected.Length, invalid.Length);
1222 for (int i = 0; i < expected.Length; i++ ) {
1223 Assert.AreEqual (expected [i], invalid [i], "Character at position " + i);
1229 public void GetInvalidPathChars_Modify ()
1231 char[] expected = Path.GetInvalidPathChars ();
1232 char[] invalid = Path.GetInvalidPathChars ();
1234 Assert.IsTrue (expected[0] != 'a', "expected");
1235 Assert.AreEqual (expected[0], Path.GetInvalidPathChars ()[0], "readonly");
1239 public void GetRandomFileName ()
1241 string s = Path.GetRandomFileName ();
1242 Assert.AreEqual (12, s.Length, "Length");
1243 char[] invalid = Path.GetInvalidFileNameChars ();
1244 for (int i=0; i < s.Length; i++) {
1246 Assert.AreEqual ('.', s[i], "8");
1248 Assert.IsTrue (Array.IndexOf (invalid, s[i]) == -1, i.ToString ());
1253 public void GetRandomFileNameIsAlphaNumerical ()
1255 string [] names = new string [1000];
1256 for (int i = 0; i < names.Length; i++)
1257 names [i] = Path.GetRandomFileName ();
1259 foreach (string name in names) {
1260 Assert.AreEqual (12, name.Length);
1261 Assert.AreEqual ('.', name [8]);
1263 for (int i = 0; i < 12; i++) {
1268 Assert.IsTrue (('a' <= c && c <= 'z') || ('0' <= c && c <= '9'));
1274 string Concat (string sep, params string [] parms)
1276 return String.Join (sep, parms);
1280 public void Combine_3Params ()
1282 string sep = Path.DirectorySeparatorChar.ToString ();
1285 Path.Combine (null, "two", "three");
1286 Assert.Fail ("#A1-1");
1292 Path.Combine ("one", null, "three");
1293 Assert.Fail ("#A1-2");
1299 Path.Combine ("one", "two", null);
1300 Assert.Fail ("#A1-3");
1305 Assert.AreEqual (Concat (sep, "one", "two", "three"), Path.Combine ("one", "two", "three"), "#A2-1");
1306 Assert.AreEqual (Concat (sep, sep + "one", "two", "three"), Path.Combine (sep + "one", "two", "three"), "#A2-2");
1307 Assert.AreEqual (Concat (sep, sep + "one", "two", "three"), Path.Combine (sep + "one" + sep, "two", "three"), "#A2-3");
1308 Assert.AreEqual (Concat (sep, sep + "two", "three"), Path.Combine (sep + "one" + sep, sep + "two", "three"), "#A2-4");
1309 Assert.AreEqual (Concat (sep, sep + "three"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three"), "#A2-5");
1311 Assert.AreEqual (Concat (sep, sep + "one" + sep, "two", "three"), Path.Combine (sep + "one" + sep + sep, "two", "three"), "#A3");
1313 Assert.AreEqual ("", Path.Combine ("", "", ""), "#A4");
1317 public void Combine_4Params ()
1319 string sep = Path.DirectorySeparatorChar.ToString ();
1322 Path.Combine (null, "two", "three", "four");
1323 Assert.Fail ("#A1-1");
1329 Path.Combine ("one", null, "three", "four");
1330 Assert.Fail ("#A1-2");
1336 Path.Combine ("one", "two", null, "four");
1337 Assert.Fail ("#A1-3");
1343 Path.Combine ("one", "two", "three", null);
1344 Assert.Fail ("#A1-4");
1349 Assert.AreEqual (Concat (sep, "one", "two", "three", "four"), Path.Combine ("one", "two", "three", "four"), "#A2-1");
1350 Assert.AreEqual (Concat (sep, sep + "one", "two", "three", "four"), Path.Combine (sep + "one", "two", "three", "four"), "#A2-2");
1351 Assert.AreEqual (Concat (sep, sep + "one", "two", "three", "four"), Path.Combine (sep + "one" + sep, "two", "three", "four"), "#A2-3");
1352 Assert.AreEqual (Concat (sep, sep + "two", "three", "four"), Path.Combine (sep + "one" + sep, sep + "two", "three", "four"), "#A2-4");
1353 Assert.AreEqual (Concat (sep, sep + "three", "four"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", "four"), "#A2-5");
1354 Assert.AreEqual (Concat (sep, sep + "four"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", sep + "four"), "#A2-6");
1356 Assert.AreEqual (Concat (sep, sep + "one" + sep, "two", "three", "four"), Path.Combine (sep + "one" + sep + sep, "two", "three", "four"), "#A3");
1358 Assert.AreEqual ("", Path.Combine ("", "", "", ""), "#A4");
1362 public void Combine_ManyParams ()
1364 string sep = Path.DirectorySeparatorChar.ToString ();
1367 Path.Combine (null, "two", "three", "four", "five");
1368 Assert.Fail ("#A1-1");
1374 Path.Combine ("one", null, "three", "four", "five");
1375 Assert.Fail ("#A1-2");
1381 Path.Combine ("one", "two", null, "four", "five");
1382 Assert.Fail ("#A1-3");
1388 Path.Combine ("one", "two", "three", null, "five");
1389 Assert.Fail ("#A1-4");
1395 Path.Combine ("one", "two", "three", "four", null);
1396 Assert.Fail ("#A1-5");
1401 Assert.AreEqual (Concat (sep, "one", "two", "three", "four", "five"), Path.Combine ("one", "two", "three", "four", "five"), "#A2-1");
1402 Assert.AreEqual (Concat (sep, sep + "one", "two", "three", "four", "five"), Path.Combine (sep + "one", "two", "three", "four", "five"), "#A2-2");
1403 Assert.AreEqual (Concat (sep, sep + "one", "two", "three", "four", "five"), Path.Combine (sep + "one" + sep, "two", "three", "four", "five"), "#A2-3");
1404 Assert.AreEqual (Concat (sep, sep + "two", "three", "four", "five"), Path.Combine (sep + "one" + sep, sep + "two", "three", "four", "five"), "#A2-4");
1405 Assert.AreEqual (Concat (sep, sep + "three", "four", "five"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", "four", "five"), "#A2-5");
1406 Assert.AreEqual (Concat (sep, sep + "four", "five"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", sep + "four", "five"), "#A2-6");
1407 Assert.AreEqual (Concat (sep, sep + "five"), Path.Combine (sep + "one" + sep, sep + "two", sep + "three", sep + "four", sep + "five"), "#A2-6");
1409 Assert.AreEqual (Concat (sep, sep + "one" + sep, "two", "three", "four", "five"), Path.Combine (sep + "one" + sep + sep, "two", "three", "four", "five"), "#A3");
1411 Assert.AreEqual ("", Path.Combine ("", "", "", "", ""), "#A4");