当前位置: 首页>>代码示例>>C#>>正文


C# IUnitOfWorkFactory.Stub方法代码示例

本文整理汇总了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])());
        }
开发者ID:JamesRandall,项目名称:Insanely-Simple-Blog,代码行数:11,代码来源:CategoriesServiceTests.cs

示例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());
        }
开发者ID:JamesRandall,项目名称:Insanely-Simple-Blog,代码行数:19,代码来源:PostsServiceTests.cs

示例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);
        }
开发者ID:markm11,项目名称:fluent-nhibernate-unitofwork,代码行数:11,代码来源:UnitOfWorkImplementorTests.cs


注:本文中的IUnitOfWorkFactory.Stub方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。