Exemple #1
0
        public void WhenRegionManagerChangesToNotNullValue_ThenChildViewsRegionManagerIsNotCleared()
        {
            var regionManager = new MockRegionManager();

            var region = new Region();

            region.RegionManager = regionManager;

            var behavior = new ClearChildViewsRegionBehavior();

            behavior.Region = region;
            behavior.Attach();

            var childView = new MockFrameworkElement();

            region.Add(childView);

            childView.SetValue(ClearChildViewsRegionBehavior.ClearChildViewsProperty, true);

            Assert.AreEqual(regionManager, childView.GetValue(RegionManager.RegionManagerProperty));

            region.RegionManager = new MockRegionManager();

            Assert.IsNotNull(childView.GetValue(RegionManager.RegionManagerProperty));
        }
Exemple #2
0
        public void WhenClearChildViewsPropertyIsTrue_ThenChildViewsRegionManagerIsCleared()
        {
            var regionManager = new MockRegionManager();

            var region = new Region();

            region.RegionManager = regionManager;

            var behavior = new ClearChildViewsRegionBehavior();

            behavior.Region = region;
            behavior.Attach();

            var childView = new MockFrameworkElement();

            region.Add(childView);

            ClearChildViewsRegionBehavior.SetClearChildViews(childView, true);

            Assert.Equal(regionManager, childView.GetValue(RegionManager.RegionManagerProperty));

            region.RegionManager = null;

            Assert.Null(childView.GetValue(RegionManager.RegionManagerProperty));
        }