public void Materialize_Should_Create_Containers() { var items = new[] { "foo", "bar", "baz" }; var owner = new Decorator(); var target = new ItemContainerGenerator(owner); var containers = target.Materialize(0, items, null); var result = containers.OfType<TextBlock>().Select(x => x.Text).ToList(); Assert.Equal(items, result); }
public void Dematerialize_Should_Return_Removed_Containers() { var items = new[] { "foo", "bar", "baz" }; var owner = new Decorator(); var target = new ItemContainerGenerator(owner); var containers = target.Materialize(0, items, null); var expected = target.Containers.Take(2).ToList(); var result = target.Dematerialize(0, 2); Assert.Equal(expected, result); }
public void IndexFromContainer_Should_Return_Index() { var items = new[] { "foo", "bar", "baz" }; var owner = new Decorator(); var target = new ItemContainerGenerator(owner); var containers = target.Materialize(0, items, null).ToList(); Assert.Equal(0, target.IndexFromContainer(containers[0].ContainerControl)); Assert.Equal(1, target.IndexFromContainer(containers[1].ContainerControl)); Assert.Equal(2, target.IndexFromContainer(containers[2].ContainerControl)); }
public void ContainerFromIndex_Should_Return_Materialized_Containers() { var items = new[] { "foo", "bar", "baz" }; var owner = new Decorator(); var target = new ItemContainerGenerator(owner); var containers = target.Materialize(0, items, null).ToList(); Assert.Equal(containers[0].ContainerControl, target.ContainerFromIndex(0)); Assert.Equal(containers[1].ContainerControl, target.ContainerFromIndex(1)); Assert.Equal(containers[2].ContainerControl, target.ContainerFromIndex(2)); }
public void RemoveRange_Should_Alter_Successive_Container_Indexes() { var items = new[] { "foo", "bar", "baz" }; var owner = new Decorator(); var target = new ItemContainerGenerator(owner); var containers = target.Materialize(0, items, null).ToList(); var removed = target.RemoveRange(1, 1).Single(); Assert.Equal(containers[0], target.ContainerFromIndex(0)); Assert.Equal(containers[2], target.ContainerFromIndex(1)); Assert.Equal(containers[1], removed); }
public void Dematerialize_Should_Remove_Container() { var items = new[] { "foo", "bar", "baz" }; var owner = new Decorator(); var target = new ItemContainerGenerator(owner); var containers = target.Materialize(0, items, null).ToList(); target.Dematerialize(1, 1); Assert.Equal(containers[0], target.ContainerFromIndex(0)); Assert.Equal(null, target.ContainerFromIndex(1)); Assert.Equal(containers[2], target.ContainerFromIndex(2)); }
public void Materialize_Should_Create_Containers() { var items = new[] { "foo", "bar", "baz" }; var owner = new Decorator(); var target = new ItemContainerGenerator<ListBoxItem>(owner, ListBoxItem.ContentProperty); var containers = target.Materialize(0, items, null); var result = containers .Select(x => x.ContainerControl) .OfType<ListBoxItem>() .Select(x => x.Content) .ToList(); Assert.Equal(items, result); }