コード例 #1
0
ファイル: EditableItemTest.cs プロジェクト: johants/n2cms
        private static Control AddEditorAndInit(DecoratedItem item, EditableItemAttribute editable, Page page, ItemEditor enclosingEditor)
        {
            page.Controls.Add(enclosingEditor);
            enclosingEditor.Page        = page;
            enclosingEditor.CurrentItem = item;
            var editor = editable.AddTo(enclosingEditor);

            page.InitRecursive();
            return(editor);
        }
コード例 #2
0
        public void AssignedChildren_AreAddedAsChildren_BeforeSaving_UnproxiedInstance()
        {
            var item = new DecoratedItem();

            item.GenericChildren = new [] { new BaseItem(), new SuperficialItem() };

            var proxyFactory = engine.Resolve <IProxyFactory>();

            proxyFactory.OnSaving(item);

            item.Children.Count.ShouldBe(2);
            item.Children.All(c => c.ZoneName == "GenericChildren").ShouldBe(true);
        }
コード例 #3
0
ファイル: EditableItemTest.cs プロジェクト: johants/n2cms
        public void NewChild_IsSaved()
        {
            var item       = new DecoratedItem();
            var definition = new DefinitionMap().GetOrCreateDefinition(item);
            var editable   = (EditableItemAttribute)definition.Properties["TheItem"].Editable;

            var page            = new Page();
            var enclosingEditor = new ItemEditor();
            var editor          = AddEditorAndInit(item, editable, page, enclosingEditor);

            editable.UpdateEditor(item, editor);

            var ctx = new N2.Edit.Workflow.CommandContext(definition, item, Interfaces.Editing, engine.RequestContext.User);

            enclosingEditor.UpdateObject(ctx);

            ctx.GetItemsToSave().ShouldContain(item.TheItem);
        }
コード例 #4
0
ファイル: EditableItemTest.cs プロジェクト: johants/n2cms
        public void ItemEditor_AddsNewChild()
        {
            var item       = new DecoratedItem();
            var definition = new DefinitionMap().GetOrCreateDefinition(item);
            var editable   = (EditableItemAttribute)definition.Properties["TheItem"].Editable;

            var page            = new Page();
            var enclosingEditor = new ItemEditor();
            var editor          = AddEditorAndInit(item, editable, page, enclosingEditor);

            editable.UpdateEditor(item, editor);

            ItemUtility.FindInChildren <N2.Web.UI.WebControls.NameEditor>(editor).Single().Text = "Hello child";

            enclosingEditor.UpdateObject(new N2.Edit.Workflow.CommandContext(definition, item, Interfaces.Editing, engine.RequestContext.User));

            item.Children.Single().ShouldBe(item.TheItem);
        }