public void AttachShouldNotThrowWhenHostControlNull() { MockPresentationRegion region = new MockPresentationRegion(); SyncRegionContextWithHostBehavior behavior = new SyncRegionContextWithHostBehavior(); behavior.Region = region; behavior.Attach(); }
public void AttachShouldNotThrowWhenHostControlNullAndRegionContextSet() { MockRegion region = new MockRegion(); SyncRegionContextWithHostBehavior behavior = new SyncRegionContextWithHostBehavior(); behavior.Region = region; behavior.Attach(); region.Context = "Changed"; }
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; }); }
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); }
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)); }
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); }
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); }