Exemple #1
0
        public void ContentShouldStoreFields()
        {
            var contentItem = new ContentItem();
            contentItem.Weld<MyPart>();
            contentItem.Alter<MyPart>(x => x.Text = "test");
            contentItem.Alter<MyPart>(x =>
            {
                x.Weld<MyField>("myField");
                x.Alter<MyField>("myField", f => f.Value = 123);
            });

            var json = JsonConvert.SerializeObject(contentItem);

            Assert.Contains(@"""MyPart"":{""Text"":""test"",""myField"":{""Value"":123}}", json);
        }
Exemple #2
0
        public void ContentShouldOnlyContainParts()
        {
            var contentItem = new ContentItem();
            contentItem.Weld<MyPart>();
            contentItem.Alter<MyPart>(x => x.Text = "test");

            var json = JsonConvert.SerializeObject(contentItem);

            Assert.Contains(@"""MyPart"":{""Text"":""test""}", json);
        }
        public override async Task<IDisplayResult> UpdateAsync(ContentItem model, IUpdateModel updater)
        {
            var viewModel = new EditContainedPartViewModel();

            if (await updater.TryUpdateModelAsync(viewModel, "ListPart"))
            {
                model.Weld<ContainedPart>();
                model.Alter<ContainedPart>(x => x.ListContentItemId = viewModel.ContainerId);
            }

            return await base.UpdateAsync(model, updater);
        }
Exemple #4
0
        public void ShouldAlterPart()
        {
            var contentItem = new ContentItem();
            contentItem.Weld<MyPart>();
            contentItem.Alter<MyPart>(x => x.Text = "test");

            var json = JsonConvert.SerializeObject(contentItem);

            var contentItem2 = JsonConvert.DeserializeObject<ContentItem>(json);

            Assert.NotNull(contentItem.Content.MyPart);
            Assert.Equal("test", (string)contentItem.Content.MyPart.Text);
        }