Пример #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));
        }
Пример #2
0
 protected string GetValue(object node, string propertyName)
 {
     if (node is Node)
     {
         var content = SN.Content.Load(((Node)node).Id);
         return(ContentView.GetValue(propertyName, content));
     }
     return(string.Concat(node, " is not type of Node"));
 }
Пример #3
0
        public void AddViewPassesDiferentScopeWhenAdding()
        {
            var     regionManager = Mock.Of <IRegionManager>();
            IRegion region        = new Region
            {
                RegionManager = regionManager
            };
            var myView = new ContentView();

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

            Assert.NotSame(regionManager, myView.GetValue(Prism.Regions.Xaml.RegionManager.RegionManagerProperty));
        }
Пример #4
0
        public void AddViewPassesSameScopeByDefaultToNamedView()
        {
            var     regionManager = Mock.Of <IRegionManager>();
            IRegion region        = new Region
            {
                RegionManager = regionManager
            };
            var myView = new ContentView();

            region.Add(myView, "MyView");

            Assert.Same(regionManager, myView.GetValue(Prism.Regions.Xaml.RegionManager.RegionManagerProperty));
        }
 public static View GetContent(ContentView target)
 {
     return((View)target.GetValue(ContentProperty));
 }