title: Unit test using Moq doesn't pass, object is null, did I miss something?
body: <p>The class I want to test is my ArticleManager class, specifically the LoadArticle method:</p>
  
  <pre><code>public class ArticleManager : IArticleManager
  {
        private IArticle _article;
  
        public ArticleManger(IDBFactory dbFactory)
        {
              _dbFactory = dbFactory;
        }
  
        public void LoadArticle(string title)
        {
              _article = _dbFactory.GetArticleDAO().GetByTitle(title);
  
        }
  }
  </code></pre>
  
  <p>My ArticleDAO looks like:</p>
  
  <pre><code>public class ArticleDAO : GenericNHibernateDAO&lt;IArticle, int&gt;, IArticleDAO
  {
         public virtual Article GetByTitle(string title)
         {
             return Session.CreateCriteria(typeof(Article))
                 .Add(Expression.Eq("Title", title))
                 .UniqueResult&lt;Article&gt;();
         }
  }
  </code></pre>
  
  <p>My test code using <a href="http://en.wikipedia.org/wiki/NUnit" rel="nofollow noreferrer">NUnit</a> and <a href="http://en.wikipedia.org/wiki/Moq" rel="nofollow noreferrer">Moq</a>:</p>
  
  <pre><code>[SetUp]
  public void SetUp()
  {
          _mockDbFactory = new Mock&lt;IDBFactory&gt;();
          _mockArticleDao = new Mock&lt;ArticleDAO&gt;();
  
          _mockDbFactory.Setup(x =&gt; x.GetArticleDAO()).Returns(_mockArticleDao.Object);
  
          _articleManager = new ArticleManager(_mockDbFactory.Object);
  }
  
  
  [Test]
  public void load_article_by_title()
  {
       var article1 = new Mock&lt;IArticle&gt;();
  
       _mockArticleDao.Setup(x =&gt; x.GetByTitle(It.IsAny&lt;string&gt;())).Returns(article1.Object);
  
       _articleManager.LoadArticle("some title");
  
       Assert.IsNotNull(_articleManager.Article);
  }
  </code></pre>
  
  <p>The unit test is failing, the object _articleManager.Article is returning NULL.</p>
  
  <p>Have I done everything correctly?</p>
  
  <p>This is one of my first unit tests so I am probably missing something obvious?</p>
  
  <p>One issue I had, was that I wanted to mock IArticleDao but since the class ArticleDao also inherits from the abstract class, if I just mocked IArticleDao then the methods in GenericNHibernateDao are not available?</p>