Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
 public void SetContainerWindowStyleShouldThrowExceptionWhenOwnerIsNull()
 {
     RegionPopupBehaviors.SetContainerWindowStyle(null, new Style());
 }