Beispiel #1
0
        public async Task ShouldCreateBlogPost()
        {
            var post = await BlogPostItemHelper.CreateBlogItem();

            var markdown          = post.Content.MarkdownBodyPart.Markdown.ToString() as string;
            var listContentItemId = post.Content.ContainedPart.ListContentItemId.ToString() as string;

            Assert.Equal("markdown", markdown);
            Assert.Equal("blogid", listContentItemId);
        }
Beispiel #2
0
        public async Task ShouldConvertBlogPostToDto()
        {
            var post = await BlogPostItemHelper.CreateBlogItem();

            var postDto = post.ToDto <BlogPostItemDto>();

            Assert.Equal("markdown", postDto.MarkdownBodyPart.Markdown);

            var containedPart = (postDto.AdditionalProperties["ContainedPart"] as JObject).ToObject <ContainedPart>();

            Assert.Equal("blogid", containedPart.ListContentItemId);
        }
Beispiel #3
0
        public async Task ShouldAlterBlogPostFromDto()
        {
            var blogPost = await BlogPostItemHelper.CreateBlogItem();

            var blogPostItemDto = blogPost.ToDto <BlogPostItemDto>();

            var newContainedPart = new ContainedPartDto
            {
                ListContentItemId = "newid"
            };
            var jContainedPart = JObject.FromObject(newContainedPart);

            // This should change to 'containedPart' when we resolve 'code' content types.
            // i.e. types that are not list and are generally welded on.
            // TODO camelcase this in the converter?
            blogPostItemDto.AdditionalProperties["ContainedPart"] = jContainedPart;

            blogPost.FromDto(blogPostItemDto);

            var newListContentItemId = blogPost.Content.ContainedPart.ListContentItemId.ToString() as string;

            Assert.Equal("newid", newListContentItemId);
        }