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


C# IUnitOfWork.Stub方法代码示例

本文整理汇总了C#中IUnitOfWork.Stub方法的典型用法代码示例。如果您正苦于以下问题:C# IUnitOfWork.Stub方法的具体用法?C# IUnitOfWork.Stub怎么用?C# IUnitOfWork.Stub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IUnitOfWork的用法示例。


在下文中一共展示了IUnitOfWork.Stub方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
        {
            _session = MockRepository.GenerateMock<ISession>();
            _unitOfWork = MockRepository.GenerateMock<IUnitOfWork>();

            _unitOfWork.Stub(x => x.Session).Return(_session).Repeat.Any();
        }
开发者ID:marektihkan,项目名称:Arc,代码行数:7,代码来源:RepositoryTests.cs

示例3: Setup

        public void Setup()
        {
            _routeCreator = MockRepository.GenerateStub<IRouteCreator>();
            _heightMapImageBuilder = MockRepository.GenerateStub<IHeightMapImageBuilder>();
            _heightMapImageCache = MockRepository.GenerateStub<IHeightMapImageCache>();
            _geographicRouteLocator = MockRepository.GenerateStub<IGeographicRouteLocator>();
            _routeToRouteResultMapper = MockRepository.GenerateStub<IRouteToRouteResultMapper>();
            _unitOfWork = MockRepository.GenerateStub<IUnitOfWork>();
            _sortSecurity = MockRepository.GenerateStub<ISortSecurity>();
            _routeFileCreator = MockRepository.GenerateStub<IRouteFileCreator>();
            _routeRepository = MockRepository.GenerateStub<IRepository<Route>>();
            _unitOfWork.Stub(s => s.GetRepository<Route>()).Return(_routeRepository);

            _routeService = new RouteService(_routeCreator,
                                                         _heightMapImageBuilder,
                                                         _heightMapImageCache,
                                                         _geographicRouteLocator,
                                                         _routeToRouteResultMapper,
                                                         _unitOfWork,
                                                         _sortSecurity,
                                                         _routeFileCreator);
        }
开发者ID:JamesRandall,项目名称:CycleCycleCycle.com,代码行数:22,代码来源:RouteServiceTests.cs

示例4: 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


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