コード例 #1
0
        public async Task ShouldConvertBagToDto()
        {
            var bagItem = await BagItemHelper.CreateBagItem();

            var bagItemDto = bagItem.ToDto <BagItemDto>();

            Assert.Equal(2, bagItemDto.Items.ContentItems.Count);
        }
コード例 #2
0
        public async Task ShouldConvertBarsToDtos()
        {
            var bagItem = await BagItemHelper.CreateBagItem();

            var bagItemDto = bagItem.ToDto <BagItemDto>();
            var barItems   = bagItemDto.Items.ContentItems.OfDtoType <BarItemDto>();

            Assert.Single(barItems);
        }
コード例 #3
0
        public async Task ShouldConvertBarToDto()
        {
            var bagItem = await BagItemHelper.CreateBagItem();

            var bagItemDto     = bagItem.ToDto <BagItemDto>();
            var contentItemDto = bagItemDto.Items.ContentItems.FirstOrDefault(x => x.ContentType == "Bar");
            var barItemDto     = contentItemDto.ToDto <BarItemDto>();

            Assert.Equal("html", barItemDto.HtmlBodyPart.Html);
        }
コード例 #4
0
        public async Task ShouldAlterBarItemAsSameObjectReference()
        {
            var bagItem = await BagItemHelper.CreateBagItem();

            var bagItemDto = bagItem.ToDto <BagItemDto>();
            var barItemDto = bagItemDto.Items.ContentItems.OfDtoType <BarItemDto>().FirstOrDefault();

            barItemDto.HtmlBodyPart.Html = "altered";
            bagItem.FromDto(bagItemDto);
            var html = bagItem.Content.Items.ContentItems[0].HtmlBodyPart.Html.ToString();

            Assert.Equal("altered", html);
        }
コード例 #5
0
        public async Task ShouldCreateBag()
        {
            var bagItem = await BagItemHelper.CreateBagItem();

            var bagItems = bagItem.Content.Items.ContentItems.ToObject <List <ContentItem> >() as List <ContentItem>;
            var fooItem  = bagItems.FirstOrDefault(x => x.ContentType == "Foo");
            var html     = fooItem.Content.MarkdownBodyPart.Markdown.ToString();

            Assert.Equal("markdown", html);

            var barItem  = bagItems.FirstOrDefault(x => x.ContentType == "Bar");
            var markdown = barItem.Content.HtmlBodyPart.Html.ToString();

            Assert.Equal("html", markdown);
        }
コード例 #6
0
        public async Task ShouldAlterBagItemFromDto()
        {
            // Never do this. Always use ContentManager.NewAsync();
            var bagItem = await BagItemHelper.CreateBagItem();

            var bagItemDto = bagItem.ToDto <BagItemDto>();

            bagItemDto.Items.ContentItems.Add(
                await TestContentManager.ContentManager
                .NewDtoAsync <FooItemDto>("Foo", ci =>
            {
                ci.MarkdownBodyPart = new MarkdownBodyPartDto
                {
                    Markdown = "markdown"
                };
            })
                );

            bagItem.FromDto(bagItemDto);

            var markdown = bagItem.Content.Items.ContentItems[2].MarkdownBodyPart.Markdown.ToString();

            Assert.Equal("markdown", markdown);
        }