public void AdapterAssociatesSelectorWithRegion() { var control = new TabControl(); IRegionAdapter adapter = new TestableTabControlRegionAdapter(); IRegion region = adapter.Initialize(control, "region"); Assert.IsNotNull(region); }
public void ControlWithExistingItemSourceThrows() { var tabControl = new TabControl() { ItemsSource = new List<string>() }; IRegionAdapter adapter = new TestableTabControlRegionAdapter(); try { var region = (MockRegion)adapter.Initialize(tabControl, "region"); Assert.Fail(); } catch (Exception ex) { Assert.IsInstanceOfType(ex, typeof(InvalidOperationException)); StringAssert.Contains(ex.Message, "ItemsControl's ItemsSource property is not empty."); } }
public void ControlWithExistingItemSourceThrows() { var tabControl = new TabControl() { ItemsSource = new List <string>() }; IRegionAdapter adapter = new TestableTabControlRegionAdapter(); try { var region = (MockRegion)adapter.Initialize(tabControl, "region"); Assert.Fail(); } catch (Exception ex) { Assert.IsInstanceOfType(ex, typeof(InvalidOperationException)); StringAssert.Contains(ex.Message, "ItemsControl's ItemsSource property is not empty."); } }
public void ControlWithExistingBindingOnItemsSourceWithNullValueThrows() { var tabControl = new TabControl(); Binding binding = new Binding("Enumerable"); binding.Source = new SimpleModel() { Enumerable = null }; tabControl.SetBinding(ItemsControl.ItemsSourceProperty, binding); IRegionAdapter adapter = new TestableTabControlRegionAdapter(); try { var region = (MockRegion)adapter.Initialize(tabControl, "region"); Assert.Fail(); } catch (Exception ex) { Assert.IsInstanceOfType(ex, typeof(InvalidOperationException)); StringAssert.Contains(ex.Message, "ItemsControl's ItemsSource property is not empty."); } }