mardi 27 octobre 2015

How to unit test a method with dynamic return values?

I have a method like this:

public List<string> GetAllDomains()
{
       List<string> domains = new List<string>();

      DirectoryContext directoryContext = new DirectoryContext(DirectoryContextType.Domain);

      using (Domain currentDomain = Domain.GetDomain(directoryContext))
      using (Forest forest = currentDomain.Forest)
      {
          DomainCollection addDomainsInForest = forest.Domains;
          foreach (Domain domain in addDomainsInForest)
          {
              domains.Add(domain.Name);
          }
      }

      return domains; 

}

How can I write an unit test for this method? Thanks.

Aucun commentaire:

Enregistrer un commentaire