コード例 #1
0
ファイル: EditableChildrenTest.cs プロジェクト: jhang/n2cms
        public void CreatedEditor_Has_ParentItem()
        {
            var attribute = typeof(DecoratedItem).GetProperty("EditableChildren").GetCustomAttributes(typeof(IEditable), false).First() as IEditable;
            attribute.Name = "EditableChildren";

            FakeEditorContainer p = new FakeEditorContainer();
            p.CurrentItem = new DecoratedItem();

            var editor = attribute.AddTo(p) as ItemEditorList;
            Assert.That(editor.ParentItem, Is.EqualTo(p.CurrentItem));
        }
コード例 #2
0
        public void CreatedEditor_Is_ItemEditorList()
        {
            var attribute = typeof(DecoratedItem).GetProperty("EditableChildren").GetCustomAttributes(typeof(IEditable), false).First() as IEditable;

            attribute.Name = "EditableChildren";

            FakeEditorContainer p = new FakeEditorContainer();

            p.CurrentItem = new DecoratedItem();
            var editor = attribute.AddTo(p);

            Assert.That(editor, Is.TypeOf <ItemEditorList>());
        }
コード例 #3
0
ファイル: EditableChildrenTest.cs プロジェクト: jhang/n2cms
        public void CreatedEditor_UsesDefinitions()
        {
            var attribute = typeof(DecoratedItem).GetProperty("EditableChildren").GetCustomAttributes(typeof(IEditable), false).First() as IEditable;
            attribute.Name = "EditableChildren";

            FakeEditorContainer p = new FakeEditorContainer();
            p.CurrentItem = new DecoratedItem();

            var editor = attribute.AddTo(p) as ItemEditorList;
            editor.Parts = new FakePartsAdapter();

            editor.GetType()
                .GetMethod("CreateChildControls", BindingFlags.NonPublic | BindingFlags.Instance)
                .Invoke(editor, null);
            
            Assert.That(editor.Types.Items.Count, Is.EqualTo(3));
        }
コード例 #4
0
        public void CreatedEditor_UsesDefinitions()
        {
            var attribute = typeof(DecoratedItem).GetProperty("EditableChildren").GetCustomAttributes(typeof(IEditable), false).First() as IEditable;

            attribute.Name = "EditableChildren";

            FakeEditorContainer p = new FakeEditorContainer();

            p.CurrentItem = new DecoratedItem();

            var editor = attribute.AddTo(p) as ItemEditorList;

            editor.Parts = new FakePartsAdapter();

            editor.GetType()
            .GetMethod("CreateChildControls", BindingFlags.NonPublic | BindingFlags.Instance)
            .Invoke(editor, null);

            Assert.That(editor.AddButtons.Count(), Is.EqualTo(3));
        }
コード例 #5
0
        public void CreatedEditor_FiltersDefinitions_ByPropertyGenericType()
        {
            var attribute = typeof(DecoratedItem).GetProperty("GenericChildren").GetCustomAttributes(typeof(IEditable), false).First() as IEditable;
            attribute.Name = "GenericChildren";

            FakeEditorContainer p = new FakeEditorContainer();
            p.CurrentItem = new DecoratedItem();

            var editor = attribute.AddTo(p) as ItemEditorList;
            editor.Parts = new FakePartsAdapter(map);
            attribute.UpdateEditor(p.CurrentItem, editor);

            editor.GetType()
                .GetMethod("CreateChildControls", BindingFlags.NonPublic | BindingFlags.Instance)
                .Invoke(editor, null);

            Assert.That(editor.AddButtons.Count(), Is.EqualTo(2));
        }