public void AdapterAddsSelectorItemsSourceSyncBehavior()
        {
            var control = new ListBox();
            IRegionAdapter adapter = new TestableSelectorRegionAdapter();

            IRegion region = adapter.Initialize(control, "Region1");
            Assert.IsNotNull(region);

            Assert.IsInstanceOfType(region.Behaviors["SelectorItemsSourceSyncBehavior"], typeof(SelectorItemsSourceSyncBehavior));
        }
        public void AdapterAssociatesSelectorWithRegion()
        {
            var control = new TabControl();
            IRegionAdapter adapter = new TestableSelectorRegionAdapter();

            IRegion region = adapter.Initialize(control);
            Assert.IsNotNull(region);

            Assert.AreSame(control.ItemsSource, region.Views);
        }
Example #3
0
        public void AdapterAddsSelectorItemsSourceSyncBehavior()
        {
            var            control = new ListBox();
            IRegionAdapter adapter = new TestableSelectorRegionAdapter();

            IRegion region = adapter.Initialize(control, "Region1");

            Assert.NotNull(region);

            Assert.IsType <SelectorItemsSourceSyncBehavior>(region.Behaviors["SelectorItemsSourceSyncBehavior"]);
        }
        public void AdapterAssociatesSelectorWithRegion()
        {
            var            control = new TabControl();
            IRegionAdapter adapter = new TestableSelectorRegionAdapter();

            IRegion region = adapter.Initialize(control);

            Assert.IsNotNull(region);

            Assert.AreSame(control.ItemsSource, region.Views);
        }
        public void ShouldMoveAlreadyExistingContentInControlToRegion()
        {
            var control = new TabControl();
            var view = new object();
            control.Items.Add(view);
            IRegionAdapter adapter = new TestableSelectorRegionAdapter();

            var region = (MockRegion)adapter.Initialize(control);

            Assert.AreEqual(1, region.MockViews.Count());
            Assert.AreSame(view, region.MockViews.ElementAt(0));
            Assert.AreSame(view, control.Items[0]);
        }
        public async Task AdapterAddsSelectorItemsSourceSyncBehavior()
        {
            await ExecuteOnUIThread(() =>
                {
                    var control = new ListBox();
                    IRegionAdapter adapter = new TestableSelectorRegionAdapter();

                    IRegion region = adapter.Initialize(control, "Region1");
                    Assert.IsNotNull(region);

                    Assert.IsInstanceOfType(region.Behaviors["SelectorItemsSourceSyncBehavior"], typeof(SelectorItemsSourceSyncBehavior));
                });
        }
        public void ShouldMoveAlreadyExistingContentInControlToRegion()
        {
            var control = new TabControl();
            var view    = new object();

            control.Items.Add(view);
            IRegionAdapter adapter = new TestableSelectorRegionAdapter();

            var region = (MockRegion)adapter.Initialize(control);

            Assert.AreEqual(1, region.MockViews.Count());
            Assert.AreSame(view, region.MockViews.ElementAt(0));
            Assert.AreSame(view, control.Items[0]);
        }
        public void ControlWithExistingItemSourceThrows()
        {
            TabControl tabControl = new TabControl() { ItemsSource = new List<string>() };

            IRegionAdapter adapter = new TestableSelectorRegionAdapter();

            try
            {
                var region = (MockRegion)adapter.Initialize(tabControl);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(InvalidOperationException));
                StringAssert.Contains(ex.Message, "ItemsControl's ItemsSource property is not empty.");
            }
        }
        public void ControlWithExistingItemSourceThrows()
        {
            TabControl tabControl = new TabControl()
            {
                ItemsSource = new List <string>()
            };

            IRegionAdapter adapter = new TestableSelectorRegionAdapter();

            try
            {
                var region = (MockRegion)adapter.Initialize(tabControl);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(InvalidOperationException));
                StringAssert.Contains(ex.Message, "ItemsControl's ItemsSource property is not empty.");
            }
        }
        public void ControlWithExistingBindingOnItemsSourceWithNullValueThrows()
        {
            TabControl tabControl = new TabControl();
            Binding    binding    = new Binding("Enumerable");

            binding.Source = new SimpleModel()
            {
                Enumerable = null
            };
            BindingOperations.SetBinding(tabControl, TabControl.ItemsSourceProperty, binding);

            IRegionAdapter adapter = new TestableSelectorRegionAdapter();

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

            IRegionAdapter adapter = new TestableSelectorRegionAdapter();

            try
            {
                var region = (MockRegion)adapter.Initialize(tabControl);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(InvalidOperationException));
                StringAssert.Contains(ex.Message, "ItemsControl's ItemsSource property is not empty.");
            }
        }