public void ApplyTemplate_Should_Create_Panel()
        {
            var target = new CarouselPresenter
            {
                ItemsPanel = new FuncTemplate<IPanel>(() => new Panel()),
            };

            target.ApplyTemplate();

            Assert.IsType<Panel>(target.Panel);
        }
        public void Setting_SelectedIndex_Should_Show_Page()
        {
            var target = new CarouselPresenter
            {
                Items = new[] { "foo", "bar" },
                SelectedIndex = 0,
            };

            target.ApplyTemplate();

            Assert.IsType<ContentPresenter>(target.Panel.Children[0]);
            Assert.Equal("foo", ((ContentPresenter)target.Panel.Children[0]).Content);
        }
        public void Should_Not_Remove_NonCurrent_Page_When_IsVirtualized_False()
        {
            var target = new CarouselPresenter
            {
                Items = new[] { "foo", "bar" },
                IsVirtualized = false,
                SelectedIndex = 0,
            };

            target.ApplyTemplate();
            Assert.Equal(1, target.ItemContainerGenerator.Containers.Count());
            Assert.Equal(1, target.Panel.Children.Count);
            target.SelectedIndex = 1;
            Assert.Equal(2, target.ItemContainerGenerator.Containers.Count());
            Assert.Equal(2, target.Panel.Children.Count);
            target.SelectedIndex = 0;
            Assert.Equal(2, target.ItemContainerGenerator.Containers.Count());
            Assert.Equal(2, target.Panel.Children.Count);
        }
        public void Should_Have_Correct_ItemsContainer_Index()
        {
            ObservableCollection<string> items = new ObservableCollection<string>();

            var target = new CarouselPresenter
            {
                Items = items,
                SelectedIndex = 0,
                IsVirtualized = false,
            };

            target.ApplyTemplate();
            target.SelectedIndex = 0;
            items.Add("foo");
            target.SelectedIndex = 0;

            Assert.Equal(1, target.ItemContainerGenerator.Containers.Count());
            Assert.Equal(1, target.Panel.Children.Count);

            items.Add("bar");
            Assert.Equal(1, target.ItemContainerGenerator.Containers.Count());
            Assert.Equal(1, target.Panel.Children.Count);

            target.SelectedIndex = 1;
            Assert.Equal(2, target.ItemContainerGenerator.Containers.Count());
            Assert.Equal(2, target.Panel.Children.Count);
            Assert.Equal(0, target.ItemContainerGenerator.Containers.First().Index);

            items.Remove(items[0]);
            Assert.Equal(1, target.ItemContainerGenerator.Containers.Count());
            Assert.Equal(1, target.Panel.Children.Count);
            Assert.Equal(0, target.ItemContainerGenerator.Containers.First().Index);

            items.Remove(items[0]);
            Assert.Equal(0, target.ItemContainerGenerator.Containers.Count());
            Assert.Equal(0, target.Panel.Children.Count);            
        }