示例#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));
        }