Esempio n. 1
0
        public void WhenViewHasBeenRemovedAndRegionManagerPropertyCleared_ThenItCanBeAddedAgainToARegion()
        {
            var regionManagerMock = new Mock <IRegionManager>();

            regionManagerMock.Setup(x => x.CreateRegionManager())
            .Returns(Mock.Of <IRegionManager>());
            IRegion region = new Region {
                RegionManager = regionManagerMock.Object
            };

            var view = new ContentView();

            var scopedRegionManager = region.Add(view, null, true);

            Assert.Equal(view, region.Views.First());

            region.Remove(view);

            view.ClearValue(Prism.Regions.Xaml.RegionManager.RegionManagerProperty);

            Assert.Empty(region.Views);

            var newScopedRegion = region.Add(view, null, true);

            Assert.Equal(view, region.Views.First());

            Assert.Same(newScopedRegion, view.GetValue(Prism.Regions.Xaml.RegionManager.RegionManagerProperty));
        }
Esempio n. 2
0
        public void RemoveInexistentViewThrows()
        {
            IRegion region = new Region();
            object view = new object();

            region.Remove(view);

            Assert.AreEqual(0, region.Views.Cast<object>().Count());
        }
Esempio n. 3
0
        public void CanRemoveContentFromRegion()
        {
            IRegion region = new Region();
            var     view   = new ContentView();

            region.Add(view);
            region.Remove(view);

            Assert.Empty(region.Views);
        }
Esempio n. 4
0
        public void GetViewReturnsNullAfterRemovingViewFromRegion()
        {
            IRegion region = new Region();
            var     myView = new ContentView();

            region.Add(myView, "MyView");
            region.Remove(myView);

            Assert.Null(region.GetView("MyView"));
        }
Esempio n. 5
0
        public void CanRemoveContentFromRegion()
        {
            IRegion region = new Region();
            object view = new object();

            region.Add(view);
            region.Remove(view);

            Assert.AreEqual(0, region.Views.Cast<object>().Count());
        }
Esempio n. 6
0
        public void RemoveInexistentViewThrows()
        {
            var ex = Assert.Throws <ArgumentException>(() =>
            {
                IRegion region = new Region();
                var view       = new ContentView();

                region.Remove(view);

                Assert.Empty(region.Views);
            });
        }
Esempio n. 7
0
        public void RemovingViewAlsoRemovesItFromActiveViews()
        {
            IRegion region = new Region();
            var     model  = new ContentView();

            region.Add(model);
            region.Activate(model);
            Assert.True(region.ActiveViews.Contains(model));

            region.Remove(model);

            Assert.False(region.ActiveViews.Contains(model));
        }
Esempio n. 8
0
        public void ViewRemovedEventPassesTheViewRemovedInTheEventArgs()
        {
            VisualElement removedView = null;

            IRegion region = new Region();

            region.Views.CollectionChanged += (sender, e) =>
            {
                if (e.Action == NotifyCollectionChangedAction.Remove)
                {
                    removedView = (VisualElement)e.OldItems[0];
                }
            };
            var model = new ContentView();

            region.Add(model);
            Assert.Null(removedView);

            region.Remove(model);

            Assert.Same(model, removedView);
        }
Esempio n. 9
0
        public void RemoveViewFiresViewRemovedEvent()
        {
            bool viewRemoved = false;

            IRegion region = new Region();
            var     model  = new ContentView();

            region.Views.CollectionChanged += (sender, e) =>
            {
                if (e.Action == NotifyCollectionChangedAction.Remove)
                {
                    viewRemoved = true;
                }
            };

            region.Add(model);
            Assert.False(viewRemoved);

            region.Remove(model);

            Assert.True(viewRemoved);
        }
Esempio n. 10
0
        public void WhenViewHasBeenRemovedAndRegionManagerPropertyCleared_ThenItCanBeAddedAgainToARegion()
        {
            IRegion region = new Region { RegionManager = new MockRegionManager() };

            var view = new MockFrameworkElement();

            var scopedRegionManager = region.Add(view, null, true);

            Assert.AreEqual(view, region.Views.First());

            region.Remove(view);

            view.ClearValue(RegionManager.RegionManagerProperty);

            Assert.AreEqual(0, region.Views.Cast<object>().Count());

            var newScopedRegion = region.Add(view, null, true);

            Assert.AreEqual(view, region.Views.First());

            Assert.AreSame(newScopedRegion, view.GetValue(RegionManager.RegionManagerProperty));
        }
Esempio n. 11
0
        public void ViewRemovedEventPassesTheViewRemovedInTheEventArgs()
        {
            object removedView = null;

            IRegion region = new Region();
            region.Views.CollectionChanged += (sender, e) =>
                                                  {
                                                      if (e.Action == NotifyCollectionChangedAction.Remove)
                                                          removedView = e.OldItems[0];
                                                  };
            object model = new object();
            region.Add(model);
            Assert.IsNull(removedView);

            region.Remove(model);

            Assert.AreSame(model, removedView);
        }
Esempio n. 12
0
        public void RemovingViewAlsoRemovesItFromActiveViews()
        {
            IRegion region = new Region();
            object model = new object();
            region.Add(model);
            region.Activate(model);
            Assert.IsTrue(region.ActiveViews.Contains(model));

            region.Remove(model);

            Assert.IsFalse(region.ActiveViews.Contains(model));
        }
Esempio n. 13
0
        public void RemoveViewFiresViewRemovedEvent()
        {
            bool viewRemoved = false;

            IRegion region = new Region();
            object model = new object();
            region.Views.CollectionChanged += (sender, e) =>
                                                  {
                                                      if (e.Action == NotifyCollectionChangedAction.Remove)
                                                          viewRemoved = true;
                                                  };

            region.Add(model);
            Assert.IsFalse(viewRemoved);

            region.Remove(model);

            Assert.IsTrue(viewRemoved);
        }
Esempio n. 14
0
        public void GetViewReturnsNullAfterRemovingViewFromRegion()
        {
            IRegion region = new Region();
            object myView = new object();
            region.Add(myView, "MyView");
            region.Remove(myView);

            Assert.IsNull(region.GetView("MyView"));
        }