0
我有一些NHibernate存储库,我希望我的SpecFlow测试覆盖它们。如何使用NSubstitute在使用实际实现时模拟属性
我有工作人员信息库,像这样:
public class StaffRepository : NHibernateRepository<IStaff>,
{
public IEnumerable<IStaff> GetByStaffId(string staffId)
{
return Repository.Where(ab => ab.StaffId == staffId);
}
}
哪里Repository
是住在基本类型的属性 - 这是我想嘲笑财产。我使用结构图来注入我所有的类,然后嘲讽像这样的StaffRepository:
pmsRepository = Substitute.For<StaffRepository>();
ApplicationContext.Register<IStaffRepository, StaffRepository>(pmsRepository);
我的问题是,当我嘲笑Repository
属性,像这样:
pmsRepository.Query.Returns(ListOfStaffes.AsQueryable());
我总是收到以下错误信息:
NSubstitute.Exceptions.CouldNotSetReturnDueToNoLastCallException: 'Could not find a call to return from.
我在做什么错在这里?