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


C# IPostRepository.Stub方法代码示例

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


在下文中一共展示了IPostRepository.Stub方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Init

        private static void Init()
        {
            posts = (new List<Post>() {
                new Post("title", "content", "#", "J", DateTime.UtcNow),
                new Post("title 2", "content z", "#", "M", DateTime.UtcNow.AddDays(2)){PostId = 2, Tags = new List<Tag>(){new Tag("aa"),new Tag("bb")}},
                new Post("fan roosh", "content k", "#", "F", DateTime.UtcNow.AddDays(-1))
            }).AsQueryable();
            postRepository = MockRepository.GenerateStub<IPostRepository>();

            postRepository.Stub(x => x.RecentPosts(Arg<int>.Is.Anything))
                .WhenCalled(x => x.ReturnValue = posts.Where(y => y.PublishDate <= DateTime.UtcNow).Take((int)x.Arguments[0]));
            postRepository.Stub(x => x.Find(Arg<long>.Is.Anything))
                .WhenCalled(x => x.ReturnValue = posts.FirstOrDefault(y => y.PostId == (long)x.Arguments[0]))
                .Return(new Post());
        }
开发者ID:Codiato,项目名称:codiato.home,代码行数:15,代码来源:FakePostRepository.cs

示例2: SetUp

 public void SetUp()
 {
     TestData.Init();
     _repository = MockRepository.GenerateStub<IPostRepository>();
     _service = new SyndicationService(_repository);
     _repository.Stub(m => m.FindAll()).Return(new[] {TestData.PublishedPost});
     _feed = _service.GetPostsAsSyndicationFeed(new Uri("http://test.com/testrss"));
 }
开发者ID:lg31415,项目名称:Graphite,代码行数:8,代码来源:SyndicationServiceTests.cs

示例3: Before

        public void Before()
        {
            var builder = new TestControllerBuilder();
            _postRepository = MockRepository.GenerateStub<IPostRepository>();
            _postRepository.Stub(x => x.GetAllPost()).Return(new List<Post>());
            // using real automapper
            AutomapperConfiguration.Configure();

            _sut = new HomeController(_postRepository, new AutomapperWrapper());
            builder.InitializeController(_sut);
        }
开发者ID:blanciq,项目名称:TDD.Blog,代码行数:11,代码来源:HomeControllerTests.cs

示例4: Setup

        public static void Setup(TestContext testContext)
        {
            // generate a mock repository
            _repository = MockRepository.GenerateStub<IPostRepository>();
            // the subject under test
            Sut = new PostController(_repository);

            // a random id to test
            postId = new Random().Next();

            // set a dumy post
            ExpectedModel = new Post(postId, "","","",0,"",DateTime.Now, DateTime.MinValue);

            // stub the repo to return a post when it is called GetById with a id is PostId
            _repository.Stub(repo => repo.GetById(postId)).Return(ExpectedModel);

            // the result returned by calling Edit to the controller
            Actual = Sut.Edit(postId).Model;
        }
开发者ID:mlunin,项目名称:AuctionSiteMvc,代码行数:19,代码来源:When_request_edit_a_post.cs

示例5: InitTest

 public void InitTest()
 {
     _postRepository = MockRepository.GenerateMock<IPostRepository>();
     _postRepository.Stub(pr => pr.RecentPosts(10)).IgnoreArguments()
         .Return(new List<Post>().AsQueryable());
 }
开发者ID:Codiato,项目名称:codiato.home,代码行数:6,代码来源:IndexTests.cs

示例6: InitTest

 public void InitTest()
 {
     _postRepository = MockRepository.GenerateMock<IPostRepository>();
     _postRepository.Stub(pr => pr.Find("my_first_test")).Return(new Post());
 }
开发者ID:Codiato,项目名称:codiato.home,代码行数:5,代码来源:ArchiveTests.cs


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