public void CreatePath() { Assert.IsFalse(Long.CreatePath(@"g:")); // "G:" is non-existing!!!!! On my maschine!!!! Assert.IsFalse(Long.CreatePath(@"\\?\c:")); // return false because it's not a dir Assert.IsTrue(Long.CreatePath(@"f:")); // "{Driveletter}:" ... is a dir --> ok Assert.IsTrue(Long.CreatePath(@"f:\")); // "{Driveletter}:\" ... is a dir --> ok Assert.IsFalse(Long.CreatePath(@"cc:")); // "invalid parameter" Assert.IsTrue(Long.CreatePath(@"\")); // is a dir Assert.IsFalse(Long.CreatePath(@"\\?\")); Assert.IsFalse(Long.CreatePath(@"\\?\\")); Assert.IsFalse(Long.CreatePath(@"\\?\C")); internal_CreatePath(@"f:\jucksi\xxx", "", PRE_DIR_ACTION.DELETE); internal_CreatePath(@"f:\jucksi", "", PRE_DIR_ACTION.DELETE); internal_CreatePath(@"f:\flupsi", "", PRE_DIR_ACTION.DELETE); internal_CreatePath(@"c:\temp\a", "", PRE_DIR_ACTION.DELETE); internal_CreatePath(@"c:\temp\b", "", PRE_DIR_ACTION.CREATE); internal_CreatePath(@"c:\temp\c", "b", PRE_DIR_ACTION.DELETE); internal_CreatePath(@"c:\temp\d", @"b\aaa\ggg\eee", PRE_DIR_ACTION.DELETE); internal_CreatePath(@"\\?\c:\temp\e", "", PRE_DIR_ACTION.DELETE); internal_CreatePath(@"\\?\c:\temp\f", @"spindi\bumsti\1", PRE_DIR_ACTION.DELETE); internal_CreatePath(@"\\?\c:\temp\g", @"spindi\bumsti\1", PRE_DIR_ACTION.CREATE); internal_CreatePath(@"\\localhost\c$\spindi\h", "", PRE_DIR_ACTION.DELETE); internal_CreatePath(@"\\localhost\c$\spindi\i", @"jucksi\flucksi", PRE_DIR_ACTION.DELETE); internal_CreatePath(@"\\?\UNC\localhost\c$\spindi\j", "", PRE_DIR_ACTION.DELETE); internal_CreatePath(@"\\?\UNC\localhost\c$\spindi\k", @"ramsi\wamsi\gamsi", PRE_DIR_ACTION.DELETE); internal_CreatePath(@"\\?\UNC\localhost\c$\spindi", "", PRE_DIR_ACTION.CREATE); internal_CreatePath(@"\\?\UNC\localhost\c$\spindi", "", PRE_DIR_ACTION.DELETE); }
private void internal_CreatePath(string baseDir, string dirsToTest, PRE_DIR_ACTION action) { if (baseDir.EndsWith(@":\")) { Assert.Fail("this would delete [{0}]. not good", baseDir); return; } string CompleteDir = baseDir + (String.IsNullOrEmpty(dirsToTest) ? "" : System.IO.Path.DirectorySeparatorChar + dirsToTest); string Shortname = RemoveLongnameNotation(CompleteDir); switch (action) { case PRE_DIR_ACTION.CREATE: System.IO.Directory.CreateDirectory(Shortname); break; case PRE_DIR_ACTION.DELETE: DelDir(baseDir); break; default: throw new Exception("illegal enum value for PRE_DIR_ACTION"); } // // THE TEST!!! // Assert.IsTrue(Long.CreatePath(CompleteDir)); Assert.IsTrue(System.IO.Directory.Exists(Shortname)); DelDir(baseDir); }