public void DeleteSubTree()
        {
            var container = new DirectoryAttributes("CN=DeleteContainer,CN=Employees,DC=Northwind,DC=local");

            container.Set("objectClass", new[] { "top", "container" });

            _context.Add(container);

            var attributes = new DirectoryAttributes("CN=IntegrationTest," + container.DistinguishedName);

            attributes.SetNull("AccountExpires");
            attributes.Set("objectclass", "user");

            _context.AddAndGet(attributes);

            _context.Delete(container.DistinguishedName, new TreeDeleteControl());

            Executing.This(() => _context.GetByDN(container.DistinguishedName))
            .Should().Throw <DirectoryOperationException>().And.Exception.Message
            .Should().Contain("does not exist");
        }
 /// <summary>
 /// Executes <see cref="DirectoryContext.Add(DirectoryAttributes)"/>
 /// </summary>
 /// <param name="context">The <see cref="DirectoryContext"/>.</param>
 /// <param name="entry">The attributes for the entry</param>
 public static Task AddAsync(this IDirectoryContext context, DirectoryAttributes entry)
 {
     return(Task.Factory.StartNew(() => context.Add(entry)));
 }
 /// <summary>
 /// Executes <see cref="DirectoryContext.Add{T}(T,string,DirectoryControl[])"/>
 /// </summary>
 /// <typeparam name="T">The type of entry.</typeparam>
 /// <param name="context">The <see cref="DirectoryContext"/>.</param>
 /// <param name="entry">The object to save.</param>
 /// <param name="distinguishedName">The distinguished name for the entry.</param>
 /// <param name="controls">Any <see cref="DirectoryControl"/>s to be sent with the request</param>
 public static Task AddAsync <T>(this IDirectoryContext context, T entry, string distinguishedName = null,
                                 DirectoryControl[] controls = null) where T : class
 {
     return(Task.Factory.StartNew(() => context.Add(entry, distinguishedName, controls)));
 }