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


C# BlogPost.UpdateSeries方法代码示例

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


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

示例1: ImageReference

        public void BlogPostController_Edit_GIVEN_BlogPostRepository_Contains_BlogPost_With_ID_1_WHEN_blogPostId_Is_1_THEN_Returns_ViewModel_For_BlogPost()
        {
            const int BlogPostId = 1;

            var imageReference = new ImageReference(1, "/noimage.jpg");
            var author = new BlogUser { Id = 1, Forenames = "Joe", Surname = "Blogs" };

            var blogPost = new BlogPost("Test", "This is the description", "Not much in this article", imageReference, DateTime.Now, author);
            blogPost.SetProperty("Id", BlogPostId);
            blogPost.UpdateSeries(new Series { Name = "Series A" });
            blogPost.UpdateTags(new Tag[] { new Tag { Text = "Tag 1" } });

            var mockedBlogPostRepository = new Mock<IBlogPostRepository>();
            mockedBlogPostRepository.Setup(r => r.Load(BlogPostId)).Returns(blogPost);

            var controller = MockCreators.CreateBlogPostController(blogPostRepository: mockedBlogPostRepository.Object);
            var result = controller.Edit(blogPost.Id.Value) as ViewResult;

            result.ShouldNotBeNull();
            result.Model.ShouldBeInstanceOfType(typeof(CreateEditModel));

            var model = (CreateEditModel)result.Model;

            model.BlogPostId.ShouldEqual(blogPost.Id);
            model.PublishedDate.ShouldEqual(blogPost.PublishedDate);
            model.Title.ShouldEqual(blogPost.Title);
            model.Description.ShouldEqual(blogPost.Description);
            model.FullArticle.ShouldEqual(blogPost.FullArticle);
            model.ImageId.ShouldEqual(blogPost.ImageReference.Id.Value);
            model.SeriesName.ShouldEqual(blogPost.Series.Name);
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:31,代码来源:EditArticleTests.cs

示例2: ImageReference

        public void BlogPostController_List_GIVEN_BlogPost_Has_1_Item_THEN_Returns_1_ArticleListingViewModel_With_Data_From_Post()
        {
            const int BlogPostId = 1;

            var imageReference = new ImageReference(1, "/noimage.jpg");
            var author = new BlogUser { Id = 1, Forenames = "Joe", Surname = "Blogs" };

            var blogPost = new BlogPost("Test", "This is the description", "Not much in this article", imageReference, DateTime.Now, author);
            blogPost.SetProperty("Id", BlogPostId);
            blogPost.UpdateSeries(new Series { Name = "Series A" });
            blogPost.UpdateTags(new Tag[] { new Tag { Text = "Tag 1" } });

            var mockedBlogPostRepository = new Mock<IBlogPostRepository>();

            mockedBlogPostRepository.Setup(r => r.LoadAll()).Returns(new BlogPost[] { blogPost });

            var controller = MockCreators.CreateBlogPostController(blogPostRepository: mockedBlogPostRepository.Object);
            var result = controller.List() as ViewResult;

            result.ShouldNotBeNull();
            result.Model.ShouldBeInstanceOfType(typeof(IEnumerable<BlogPostListingItemModel>));

            var viewModelForPost = ((IEnumerable<BlogPostListingItemModel>)result.Model).First();

            viewModelForPost.BlogPostId.ShouldEqual(blogPost.Id.Value);
            viewModelForPost.Title.ShouldEqual(blogPost.Title);
            viewModelForPost.PublishedDate.ShouldEqual(blogPost.PublishedDate);
            viewModelForPost.AuthorsName.ShouldEqual(blogPost.Author.FullName);
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:29,代码来源:ListArticleTests.cs

示例3: BlogPostController_Edit_Returns_ViewResult

        public void BlogPostController_Edit_Returns_ViewResult()
        {
            const int BlogPostId = 1;

            var imageReference = new ImageReference(1, "/noimage.jpg");
            var author = new BlogUser { Id = 1, Forenames = "Joe", Surname = "Blogs" };

            var blogPost = new BlogPost("Test", "This is the description", "Not much in this article", imageReference, DateTime.Now, author);
            blogPost.SetProperty("Id", BlogPostId);
            blogPost.UpdateSeries(new Series { Name = "Series A" });
            blogPost.UpdateTags(new Tag[] { new Tag { Text = "Tag 1" } });

            var mockedBlogPostRepository = new Mock<IBlogPostRepository>();

            mockedBlogPostRepository.Setup(r => r.Load(BlogPostId)).Returns(blogPost);

            var controller = MockCreators.CreateBlogPostController(blogPostRepository: mockedBlogPostRepository.Object);

            var result = controller.Edit(1);

            result.ShouldBeInstanceOfType(typeof(ViewResult));
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:22,代码来源:EditArticleTests.cs

示例4: UpdateSeries_WHEN_series_parameter_Is_Null_THEN_Throws_ArgumentNullException

        public void UpdateSeries_WHEN_series_parameter_Is_Null_THEN_Throws_ArgumentNullException()
        {
            var imageReference = GetImageReference();
            var post = new BlogPost("ABC", "description", "fullText", imageReference, DateTime.Now, new BlogUser());

            post.UpdateSeries(null);
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:7,代码来源:BlogPostTests.cs

示例5: UpdateSeries_Sets_Series_Property_To_series_parameter

        public void UpdateSeries_Sets_Series_Property_To_series_parameter()
        {
            var series = new Series { Name = "Test" };

            var imageReference = GetImageReference();
            var post = new BlogPost("ABC", "description", "fullText", imageReference, DateTime.Now, new BlogUser());

            post.UpdateSeries(series);
            post.Series.ShouldEqual(series);
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:10,代码来源:BlogPostTests.cs

示例6: UpdateSeriesOnBlogPost

        private void UpdateSeriesOnBlogPost(BlogPost blogPost, string seriesName)
        {
            if (!String.IsNullOrWhiteSpace(seriesName) && !blogPost.SeriesNameEqual(seriesName))
            {
                Series seriesFound = LookupRepository.LoadForDescription<Series>(s => s.Name, seriesName);

                if (seriesFound == null)
                    seriesFound = new Series { Name = seriesName };

                blogPost.UpdateSeries(seriesFound);
            }
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:12,代码来源:BlogPostController.cs


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