1
Moq:在不可重写成员上的无效设置:x => x.GetByTitle(“ asdf”)
不确定如何解决此问题,尝试对方法“ GetByTitle”进行单元测试 这是我的定义: public class ArticleDAO : GenericNHibernateDAO(IArticle, int>, IArticleDAO { public IArticle GetByTitle(string title) { IQuery query = Session.CreateQuery("...") return query.UniqueResult<IArticle>(); } } public interface IArticleDAO { IArticle GetByTitle(string title); } 单元测试: [Test] public void can_load_by_title() { _mockDaoFactory.Setup(x => x.GetArticleDao()) .Returns(_mockArticleDao.Object); _mockArticleDao.Setup(x => x.GetByTitle("some title")) .Returns(article1.Object); _articleManager.LoadArticle("some title"); Assert.IsNotNull(_articleManager.Article); …
111
c#
nhibernate
nunit
resharper
moq