public void Create1() { 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); DirectorySecurity directorySecurity = new DirectorySecurity(); directorySecurity.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.FullControl, AccessControlType.Allow)); edi.Create(directorySecurity); Assert.IsTrue(Directory.Exists(path)); DirectorySecurity actualDirectorySecurity = Directory.GetAccessControl(path); 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 Create() { 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); edi.Create(); Assert.IsTrue(Directory.Exists(path)); }