public void ShouldCreateRegion() { try { var regionManager = new MockRegionManager(); ServiceLocator.SetLocatorProvider(() => new MockServiceLocator(() => regionManager)); FrameworkElement hostControl = new MockFrameworkElement(); RegionPopupBehaviors.RegisterNewPopupRegion(hostControl, "MyPopupRegion"); Assert.IsTrue(regionManager.MockRegions.Regions.ContainsKey("MyPopupRegion")); Assert.IsNotNull(regionManager.MockRegions.Regions["MyPopupRegion"]); Assert.IsInstanceOfType(regionManager.MockRegions.Regions["MyPopupRegion"], typeof(SingleActiveRegion)); Assert.IsTrue(regionManager.MockRegions.Regions["MyPopupRegion"].Behaviors.ContainsKey(DialogActivationBehavior.BehaviorKey)); #if SILVERLIGHT Assert.IsInstanceOfType(regionManager.MockRegions.Regions["MyPopupRegion"].Behaviors[DialogActivationBehavior.BehaviorKey], typeof(PopupDialogActivationBehavior)); #else Assert.IsInstanceOfType(regionManager.MockRegions.Regions["MyPopupRegion"].Behaviors[DialogActivationBehavior.BehaviorKey], typeof(WindowDialogActivationBehavior)); #endif } finally { ServiceLocator.SetLocatorProvider(() => null); } }
public void ShouldCreateRegion() { try { var regionManager = new MockRegionManager(); ServiceLocator.SetLocatorProvider(() => new MockServiceLocator(() => regionManager)); FrameworkElement hostControl = new MockFrameworkElement(); RegionPopupBehaviors.RegisterNewPopupRegion(hostControl, "MyPopupRegion"); RegionPopupBehaviors.SetCreatePopupRegionWithName(hostControl, "MyPopupRegion"); Assert.AreEqual("MyPopupRegion", RegionPopupBehaviors.GetCreatePopupRegionWithName(hostControl)); var style = new Style(); RegionPopupBehaviors.SetContainerWindowStyle(hostControl, style); Assert.AreEqual(style, RegionPopupBehaviors.GetContainerWindowStyle(hostControl)); Assert.IsTrue(regionManager.MockRegions.Regions.ContainsKey("MyPopupRegion")); Assert.IsNotNull(regionManager.MockRegions.Regions["MyPopupRegion"]); Assert.IsInstanceOfType(regionManager.MockRegions.Regions["MyPopupRegion"], typeof(SingleActiveRegion)); Assert.IsTrue(regionManager.MockRegions.Regions["MyPopupRegion"].Behaviors.ContainsKey(DialogActivationBehavior.BehaviorKey)); Assert.IsInstanceOfType(regionManager.MockRegions.Regions["MyPopupRegion"].Behaviors[DialogActivationBehavior.BehaviorKey], typeof(WindowDialogActivationBehavior)); } finally { ServiceLocator.SetLocatorProvider(() => null); } }