本文整理汇总了C#中IUnitOfWorkFactory.Stub方法的典型用法代码示例。如果您正苦于以下问题:C# IUnitOfWorkFactory.Stub方法的具体用法?C# IUnitOfWorkFactory.Stub怎么用?C# IUnitOfWorkFactory.Stub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUnitOfWorkFactory
的用法示例。
在下文中一共展示了IUnitOfWorkFactory.Stub方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
public void Setup()
{
_unitOfWorkFactory = MockRepository.GenerateStub<IUnitOfWorkFactory>();
_unitOfWork = MockRepository.GenerateStub<IUnitOfWork>();
_repository = MockRepository.GenerateStub<IRepository<Category>>();
_mapper = MockRepository.GenerateStub<IMapper<Category, CategoryViewModel>>();
_unitOfWorkFactory.Stub(x => x.Create()).Return(_unitOfWork);
_unitOfWork.Stub(x => x.GetRepository<Category>()).Return(_repository);
_unitOfWork.Stub(x => x.Execute(Arg<Action>.Is.Anything)).WhenCalled(x => ((Action)x.Arguments[0])());
}
示例2: Setup
public void Setup()
{
_category1 = new Category {CategoryID = 1};
_category2 = new Category {CategoryID = 2};
_post1 = new Post { PostID = 1, PostedAt = DateTime.Now.Subtract(TimeSpan.FromDays(50)), Categories = new Collection<Category>{_category1}};
_post2 = new Post { PostID = 2, PostedAt = DateTime.Now, Categories = new Collection<Category>{ _category2}};
List<Post> posts = new List<Post> { _post1, _post2 };
_unitOfWorkFactory = MockRepository.GenerateStub<IUnitOfWorkFactory>();
_unitOfWork = MockRepository.GenerateStub<IUnitOfWork>();
_postRepository = MockRepository.GenerateStub<IRepository<Post>>();
_mapper = MockRepository.GenerateStub<IMapper<Post, PostViewModel>>();
_unitOfWorkFactory.Stub(x => x.Create()).Return(_unitOfWork);
_unitOfWork.Stub(x => x.GetRepository<Post>()).Return(_postRepository);
_unitOfWork.Stub(x => x.Execute(Arg<Action>.Is.Anything)).WhenCalled(x => ((Action)x.Arguments[0])());
_postRepository.Stub(y => y.AllIncluding(Arg<Expression<Func<Post, object>>>.Is.Anything)).Return(posts.AsQueryable());
}
示例3: Initialize
public void Initialize()
{
// Arrange
_factory = MockRepository.GenerateMock<IUnitOfWorkFactory>();
_sessionFactory = MockRepository.GenerateMock<ISessionFactory>();
_unitOfWork = MockRepository.GenerateMock<TestUnitOfWork>(_sessionFactory);
_session = MockRepository.GenerateMock<ISession>();
_factory.Stub(f => f.CreateUnitOfWork()).Return(_unitOfWork);
_unitOfWork.Stub(u => u.Session).Return(_session);
}