示例#1
0
        public void CanAddAndRemove_From_BarLinksOwnerCollectionUIAdapter()
        {
            // Looking at the Adapter, the prerequisite setup is that the BarItem passed to the
            // BarItemWrapper constructor, must have already been added to the BarManager

            Bar bar = new Bar {
                Manager = new BarManager()
            };
            BarItem editItem = new BarEditItem(bar.Manager);

            bar.ItemLinks.Add(editItem);                // add before passing to BarItemWrapper

            var barItemWrapper        = new BarItemWrapper(bar.ItemLinks, editItem);
            IUIElementAdapter adapter = new XtraBarUIAdapterFactory().GetAdapter(barItemWrapper);

            Assert.IsType(typeof(BarLinksOwnerCollectionUIAdapter), adapter);

            //add
            BarItem buttonItem  = new BarButtonItem(bar.Manager, "test2");
            var     objectAdded = adapter.Add(buttonItem);

            Assert.Equal(buttonItem, objectAdded as BarButtonItem);
            Assert.Equal(2, barItemWrapper.ItemLinks.Count);

            //remove
            adapter.Remove(buttonItem);
            Assert.Equal(1, barItemWrapper.ItemLinks.Count);

            adapter.Remove(editItem);
            Assert.Equal(0, barItemWrapper.ItemLinks.Count);
        }
示例#2
0
        public void CanAddAndRemove_From_BarsUIAdapter()
        {
            var barManager            = new BarManager();
            IUIElementAdapter adapter = new XtraBarUIAdapterFactory().GetAdapter(barManager);

            Assert.IsType(typeof(BarsUIAdapter), adapter);

            //add
            Bar bar      = new Bar(barManager);
            var addedBar = adapter.Add(bar);

            Assert.Equal(bar, addedBar as Bar);
            Assert.Equal(1, barManager.Bars.Count);

            //remove
            adapter.Remove(bar);
            Assert.Equal(0, barManager.Bars.Count);

            adapter.Remove(new Bar(barManager));                // ensure that attempting to remove a non-added object, does nothing
            Assert.Equal(0, barManager.Bars.Count);
        }