title: Unit testing recursive functions
body: <p>Using Moq and the native VS test framework. I'm trying to test a recursive function where values passed in:</p>
  
  <pre><code>public bool AuthenticateByDomain(string domainName, string password, string username, string email)
      {
  </code></pre>
  
  <p>are used to find an entity:</p>
  
  <pre><code>// look for an existent domain name.
  var matchFound = this.FindDomainPasswordMatch(domainName, password);
  </code></pre>
  
  <p>If found, look for existent <em>UserName</em> (the account already exists):</p>
  
  <pre><code>        if (matchFound)
          {
              var account = this.GetByEmail(null, email);
              if (account != null)
              {
  </code></pre>
  
  <p>If <em>not</em> found, create the account based on the email and username provided:</p>
  
  <pre><code>var uAccount = this.CreateAccount(username, password, email, domainName);
  </code></pre>
  
  <p>and then recursively call itself where (presumably) the call to <code>GetByEmail()</code> is satisfied and the authenticating branch is invoked.</p>
  
  <p>I've found a couple examples of Moq interacting with repository but haven't been able to see exactly how to approach my specific problem - testing that the repository gets updated and the recursion succeeds. I _am able to unit get each of the methods found in the top-level - do I declare that good enough and move on? Is this a persistence test?</p>