Esempio n. 1
0
        public void TabsWithViewSortHintAreSortedProperly()
        {
            var tabControl = new TabControl();
            var view1      = new MockSortableView1();
            var view2      = new MockSortableView2();
            var view3      = new MockSortableView3();

            IRegionAdapter adapter = new TabControlRegionAdapter(null);

            var region = adapter.Initialize(tabControl, "region");

            Assert.AreEqual(0, region.Views.Count());

            region.Add(view2);
            Assert.AreEqual(1, tabControl.Items.Count);
            Assert.AreSame(view2, ((TabItem)tabControl.Items[0]).Content);

            region.Add(view1);
            Assert.AreEqual(2, tabControl.Items.Count);
            Assert.AreSame(view1, ((TabItem)tabControl.Items[0]).Content);
            Assert.AreSame(view2, ((TabItem)tabControl.Items[1]).Content);

            region.Add(view3);
            Assert.AreEqual(3, tabControl.Items.Count);
            Assert.AreSame(view1, ((TabItem)tabControl.Items[0]).Content);
            Assert.AreSame(view2, ((TabItem)tabControl.Items[1]).Content);
            Assert.AreSame(view3, ((TabItem)tabControl.Items[2]).Content);
        }
        public void ChangingSortComparisonCausesResortingOfCollection()
        {
            var             originalCollection = new ObservableCollection <ItemMetadata>();
            ViewsCollection viewsCollection    = new ViewsCollection(originalCollection, (i) => true);

            var view1 = new MockSortableView1();
            var view2 = new MockSortableView2();
            var view3 = new MockSortableView3();

            originalCollection.Add(new ItemMetadata(view2));
            originalCollection.Add(new ItemMetadata(view3));
            originalCollection.Add(new ItemMetadata(view1));

            // ensure items are in original order
            Assert.AreSame(view2, viewsCollection.ElementAt(0));
            Assert.AreSame(view3, viewsCollection.ElementAt(1));
            Assert.AreSame(view1, viewsCollection.ElementAt(2));

            // change sort comparison
            viewsCollection.SortComparison = Region.DefaultSortComparison;

            // ensure items are properly sorted
            Assert.AreSame(view1, viewsCollection.ElementAt(0));
            Assert.AreSame(view2, viewsCollection.ElementAt(1));
            Assert.AreSame(view3, viewsCollection.ElementAt(2));
        }
        public void ViewsCollectionSortedAfterAddingItemToOriginalCollection()
        {
            var             originalCollection = new ObservableCollection <ItemMetadata>();
            ViewsCollection viewsCollection    = new ViewsCollection(originalCollection, (i) => true);

            viewsCollection.SortComparison = Region.DefaultSortComparison;

            var view1 = new MockSortableView1();
            var view2 = new MockSortableView2();
            var view3 = new MockSortableView3();

            originalCollection.Add(new ItemMetadata(view2));
            originalCollection.Add(new ItemMetadata(view3));
            originalCollection.Add(new ItemMetadata(view1));

            Assert.AreSame(view1, viewsCollection.ElementAt(0));
            Assert.AreSame(view2, viewsCollection.ElementAt(1));
            Assert.AreSame(view3, viewsCollection.ElementAt(2));
        }
        public void IfViewsHaveSortHintThenViewsAreProperlySorted()
        {
            SelectorItemsSourceSyncBehavior behavior = CreateBehavior();

            var v1 = new MockSortableView1();
            var v2 = new MockSortableView2();
            var v3 = new MockSortableView3();
            behavior.Attach();

            behavior.Region.Add(v3);
            behavior.Region.Add(v2);
            behavior.Region.Add(v1);
            
            Assert.AreEqual(3, (behavior.HostControl as Selector).Items.Count);

            Assert.AreSame(v1, (behavior.HostControl as Selector).Items[0]);
            Assert.AreSame(v2, (behavior.HostControl as Selector).Items[1]);
            Assert.AreSame(v3, (behavior.HostControl as Selector).Items[2]);
        }
Esempio n. 5
0
        public void IfViewsHaveSortHintThenViewsAreProperlySorted()
        {
            SelectorItemsSourceSyncBehavior behavior = CreateBehavior();

            var v1 = new MockSortableView1();
            var v2 = new MockSortableView2();
            var v3 = new MockSortableView3();

            behavior.Attach();

            behavior.Region.Add(v3);
            behavior.Region.Add(v2);
            behavior.Region.Add(v1);

            Assert.AreEqual(3, (behavior.HostControl as Selector).Items.Count);

            Assert.AreSame(v1, (behavior.HostControl as Selector).Items[0]);
            Assert.AreSame(v2, (behavior.HostControl as Selector).Items[1]);
            Assert.AreSame(v3, (behavior.HostControl as Selector).Items[2]);
        }
        public void ChangingSortComparisonCausesResortingOfCollection()
        {
            var originalCollection = new ObservableCollection<ItemMetadata>();
            ViewsCollection viewsCollection = new ViewsCollection(originalCollection, (i) => true);

            var view1 = new MockSortableView1();
            var view2 = new MockSortableView2();
            var view3 = new MockSortableView3();

            originalCollection.Add(new ItemMetadata(view2));
            originalCollection.Add(new ItemMetadata(view3));
            originalCollection.Add(new ItemMetadata(view1));

            // ensure items are in original order
            Assert.AreSame(view2, viewsCollection.ElementAt(0));
            Assert.AreSame(view3, viewsCollection.ElementAt(1));
            Assert.AreSame(view1, viewsCollection.ElementAt(2));

            // change sort comparison
            viewsCollection.SortComparison = Region.DefaultSortComparison;

            // ensure items are properly sorted
            Assert.AreSame(view1, viewsCollection.ElementAt(0));
            Assert.AreSame(view2, viewsCollection.ElementAt(1));
            Assert.AreSame(view3, viewsCollection.ElementAt(2));
        }
        public void ViewsCollectionSortedAfterAddingItemToOriginalCollection()
        {
            var originalCollection = new ObservableCollection<ItemMetadata>();
            ViewsCollection viewsCollection = new ViewsCollection(originalCollection, (i) => true);
            viewsCollection.SortComparison = Region.DefaultSortComparison;

            var view1 = new MockSortableView1();
            var view2 = new MockSortableView2();
            var view3 = new MockSortableView3();

            originalCollection.Add(new ItemMetadata(view2));
            originalCollection.Add(new ItemMetadata(view3));
            originalCollection.Add(new ItemMetadata(view1));

            Assert.AreSame(view1, viewsCollection.ElementAt(0));
            Assert.AreSame(view2, viewsCollection.ElementAt(1));
            Assert.AreSame(view3, viewsCollection.ElementAt(2));
        }
        public async Task ViewsCollectionSortedAfterAddingItemToOriginalCollection()
        {
            await ExecuteOnUIThread(() =>
                {
                    var originalCollection = new ObservableCollection<ItemMetadata>();
                    ViewsCollection viewsCollection = new ViewsCollection(originalCollection, (i) => true)
                    {
                        SortComparison = Region.DefaultSortComparison
                    };

                    var view1 = new MockSortableView1();
                    var view2 = new MockSortableView2();
                    var view3 = new MockSortableView3();

                    originalCollection.Add(new ItemMetadata(view2));
                    originalCollection.Add(new ItemMetadata(view3));
                    originalCollection.Add(new ItemMetadata(view1));

                    Assert.AreSame(view1, viewsCollection.ElementAt(0));
                    Assert.AreSame(view2, viewsCollection.ElementAt(1));
                    Assert.AreSame(view3, viewsCollection.ElementAt(2));
                });
        }
        public void TabsWithViewSortHintAreSortedProperly()
        {
            var tabControl = new TabControl();
            var view1 = new MockSortableView1();
            var view2 = new MockSortableView2();
            var view3 = new MockSortableView3();

            IRegionAdapter adapter = new TabControlRegionAdapter(null);

            var region = adapter.Initialize(tabControl, "region");
            Assert.AreEqual(0, region.Views.Count());

            region.Add(view2);
            Assert.AreEqual(1, tabControl.Items.Count);
            Assert.AreSame(view2, ((TabItem)tabControl.Items[0]).Content);

            region.Add(view1);
            Assert.AreEqual(2, tabControl.Items.Count);
            Assert.AreSame(view1, ((TabItem)tabControl.Items[0]).Content);
            Assert.AreSame(view2, ((TabItem)tabControl.Items[1]).Content);
            
            region.Add(view3);
            Assert.AreEqual(3, tabControl.Items.Count);
            Assert.AreSame(view1, ((TabItem)tabControl.Items[0]).Content);
            Assert.AreSame(view2, ((TabItem)tabControl.Items[1]).Content);
            Assert.AreSame(view3, ((TabItem)tabControl.Items[2]).Content);
            
        }