本文整理汇总了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);
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
}