Exemple #1
0
        public void ViewRemovedEventPassesTheViewRemovedInTheEventArgs()
        {
            object removedView = null;

            var     regionManager = new MockRegionManager();
            var     control       = new MockControl();
            IRegion region        = new RegionBase(control);

            region.RegionManager = regionManager;
            IView myView = new MockView();

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

            region.Remove(myView);

            Assert.AreSame(myView, removedView);
        }
Exemple #2
0
        public void RemoveViewFiresViewRemovedEvent()
        {
            bool viewRemoved = false;

            var     regionManager = new MockRegionManager();
            var     control       = new MockControl();
            IRegion region        = new RegionBase(control);

            region.RegionManager = regionManager;
            IView myView = new MockView();

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

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

            region.Remove(myView);

            Assert.IsTrue(viewRemoved);
        }
Exemple #3
0
        public void RemoveNonexistViewNothingHappen()
        {
            var     control = new MockControl();
            IRegion region  = new RegionBase(control);
            IView   view    = new MockView();

            region.Remove(view);
            Assert.AreEqual(0, region.Views.Cast <object>().Count());
        }
Exemple #4
0
        public void CanRemoveContentFromRegion()
        {
            var     control = new MockControl();
            IRegion region  = new RegionBase(control);
            IView   view    = new MockView();

            region.Add(view);
            region.Remove(view);
            Assert.AreEqual(0, region.Views.Cast <object>().Count());
        }
Exemple #5
0
        public void GetViewReturnsNullAfterRemovingViewFromRegion()
        {
            var     control = new MockControl();
            IRegion region  = new RegionBase(control);
            IView   myView  = new MockView();

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

            Assert.IsNull(region.GetView("MyView"));
        }
Exemple #6
0
        public void RemovingViewAlsoRemovesItFromActiveViews()
        {
            var     regionManager = new MockRegionManager();
            var     control       = new MockControl();
            IRegion region        = new RegionBase(control);

            region.RegionManager = regionManager;
            IView myView = new MockView();

            region.Add(myView);
            region.Activate(myView);
            Assert.IsTrue(region.ActiveViews.Contains(myView));

            region.Remove(myView);

            Assert.IsFalse(region.ActiveViews.Contains(myView));
        }