Exemplo n.º 1
0
        public void AttachShouldNotThrowWhenHostControlNull()
        {
            MockPresentationRegion region = new MockPresentationRegion();

            SyncRegionContextWithHostBehavior behavior = new SyncRegionContextWithHostBehavior();

            behavior.Region = region;
            behavior.Attach();
        }
Exemplo n.º 2
0
        public void AttachShouldNotThrowWhenHostControlNullAndRegionContextSet()
        {
            MockRegion region = new MockRegion();

            SyncRegionContextWithHostBehavior behavior = new SyncRegionContextWithHostBehavior();

            behavior.Region = region;
            behavior.Attach();
            region.Context = "Changed";
        }
Exemplo n.º 3
0
        public void SettingHostControlAfterAttachThrows()
        {
            SyncRegionContextWithHostBehavior behavior = new SyncRegionContextWithHostBehavior();
            DependencyObject hostControl1 = new MockDependencyObject();

            behavior.HostControl = hostControl1;

            behavior.Attach();
            DependencyObject hostControl2 = new MockDependencyObject();

            behavior.HostControl = hostControl2;
        }
        public void SettingHostControlAfterAttachThrows()
        {
            var ex = Assert.Throws <InvalidOperationException>(() =>
            {
                SyncRegionContextWithHostBehavior behavior = new SyncRegionContextWithHostBehavior();
                DependencyObject hostControl1 = new MockDependencyObject();
                behavior.HostControl          = hostControl1;

                behavior.Attach();
                DependencyObject hostControl2 = new MockDependencyObject();
                behavior.HostControl          = hostControl2;
            });
        }
Exemplo n.º 5
0
        public void ShouldGetInitialValueFromHostAndSetOnRegion()
        {
            MockPresentationRegion region = new MockPresentationRegion();

            SyncRegionContextWithHostBehavior behavior = new SyncRegionContextWithHostBehavior();

            behavior.Region = region;
            DependencyObject mockDependencyObject = new MockDependencyObject();

            behavior.HostControl = mockDependencyObject;

            RegionContext.GetObservableContext(mockDependencyObject).Value = "NewValue";

            Assert.IsNull(region.Context);
            behavior.Attach();
            Assert.AreEqual("NewValue", region.Context);
        }
Exemplo n.º 6
0
        public void AttachShouldChangeRegionContextDependencyProperty()
        {
            MockPresentationRegion region = new MockPresentationRegion();

            SyncRegionContextWithHostBehavior behavior = new SyncRegionContextWithHostBehavior();

            behavior.Region = region;
            DependencyObject hostControl = new MockDependencyObject();

            behavior.HostControl = hostControl;

            RegionContext.GetObservableContext(hostControl).Value = "NewValue";

            Assert.IsNull(RegionManager.GetRegionContext(hostControl));
            behavior.Attach();
            Assert.AreEqual("NewValue", RegionManager.GetRegionContext(hostControl));
        }
Exemplo n.º 7
0
        public void ShouldForwardRegionContextValueToHostControl()
        {
            MockPresentationRegion region = new MockPresentationRegion();

            SyncRegionContextWithHostBehavior behavior = new SyncRegionContextWithHostBehavior();

            behavior.Region = region;
            Visual mockDependencyObject = new MockDependencyObject();

            behavior.HostControl = mockDependencyObject;

            behavior.Attach();
            Assert.IsNull(region.Context);
            RegionContext.GetObservableContext(mockDependencyObject).Value = "NewValue";

            Assert.AreEqual("NewValue", region.Context);
        }
Exemplo n.º 8
0
        public void ShouldUpdateHostControlRegionContextValueWhenContextOfRegionChanges()
        {
            MockPresentationRegion region = new MockPresentationRegion();

            SyncRegionContextWithHostBehavior behavior = new SyncRegionContextWithHostBehavior();

            behavior.Region = region;
            DependencyObject mockDependencyObject = new MockDependencyObject();

            behavior.HostControl = mockDependencyObject;

            ObservableObject <object> observableRegionContext = RegionContext.GetObservableContext(mockDependencyObject);

            behavior.Attach();
            Assert.IsNull(observableRegionContext.Value);
            region.Context = "NewValue";

            Assert.AreEqual("NewValue", observableRegionContext.Value);
        }