public T GetByProperty<T>(string property, object value)
{
return (T)
this.Session.CreateCriteria(typeof(T))
.Add(NHibernate.Criterion.Restrictions.Eq(property, value))
.SetCacheable(RepositoryFactory.CanCache<T>()).SetCacheMode(CacheMode.Normal)
.UniqueResult();
}
I've never worked with Nhibernate before and I am not sure whether I need to Moq Session or somehow I can Moq the whole method or what?
I've tried this but it always returns null:
Mock mockRepository = new Mock<IRepository>();
mockRepository.Setup(x => x.GetByProperty<Account>(“UserName”, “MyUserName”))
.Returns(new Account { UserName = “MyUserName” });
I appreciate for you suggestions, thanks.
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+u...@googlegroups.com.
To post to this group, send email to nhu...@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
mockRepository.Setup(x => x.GetByProperty<Account>(“UserName”, (object)“MyUserName”))
.Returns(new Account { UserName = “MyUserName”});