public void CreateSubdirectory() { string path = Path.Combine(Path.GetTempPath(), "CadruTest"); if (Directory.Exists(path)) { Directory.Delete(path, true); } Assert.IsFalse(Directory.Exists(path), "Unable to delete the test directory."); ExtendedDirectoryInfo edi = new ExtendedDirectoryInfo(path); Assert.IsNotNull(edi); string path2 = edi.CreateSubdirectory("Subdir").FullName; Assert.IsTrue(Directory.Exists(path2)); }
public void CreateSubdirectory1() { string path = Path.Combine(Path.GetTempPath(), "CadruTest"); if (Directory.Exists(path)) { Directory.Delete(path, true); } Assert.IsFalse(Directory.Exists(path), "Unable to delete the test directory."); ExtendedDirectoryInfo edi = new ExtendedDirectoryInfo(path); Assert.IsNotNull(edi); path = Path.Combine(path, "Subdir"); DirectorySecurity directorySecurity = new DirectorySecurity(); directorySecurity.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.FullControl, AccessControlType.Allow)); string path2 = edi.CreateSubdirectory("Subdir", directorySecurity).FullName; Assert.IsTrue(Directory.Exists(path2)); DirectorySecurity actualDirectorySecurity = Directory.GetAccessControl(path2); AuthorizationRuleCollection rules = actualDirectorySecurity.GetAccessRules(true, true, typeof(NTAccount)); foreach (AuthorizationRule rule in rules) { FileSystemAccessRule accessRule = (FileSystemAccessRule)rule; if (accessRule.IdentityReference.Value == "Everyone") { Assert.IsTrue(accessRule.AccessControlType == AccessControlType.Allow); Assert.IsTrue(accessRule.FileSystemRights == FileSystemRights.FullControl); } } }
public void Delete1() { string path = Path.Combine(Path.GetTempPath(), "CadruTest"); if (Directory.Exists(path)) { Directory.Delete(path, true); } Assert.IsFalse(Directory.Exists(path), "Unable to delete the test directory."); ExtendedDirectoryInfo edi = new ExtendedDirectoryInfo(path); Assert.IsNotNull(edi); string path2 = edi.CreateSubdirectory("Subdir").FullName; Assert.IsTrue(Directory.Exists(path)); File.WriteAllText(Path.Combine(path2, "testfile.txt"), "This is a test."); edi.Delete(true); Assert.IsFalse(Directory.Exists(path), "Unable to delete the test directory."); }