예제 #1
0
        public void TestInitialize()
        {
            this.Layout = new StackedCompactLayout(new GroupHierarchyAdapter(), 10, 2);

            root = new TestGroup("Grand Total")
            {
                new TestGroup("Direct mail"),
                new TestGroup("Magazine")
            };
        }
예제 #2
0
        public void RemovingItem_WhenGrouped2Levels_ShouldUpdateLayoutCorrectly()
        {
            int groupLevel = 2;
            var list       = new List <TestGroup>(from c in Enumerable.Range(0, 10) select new TestGroup("group " + c));

            foreach (var group in list)
            {
                var childGroup = new TestGroup("SubGroup of" + group.Name);

                childGroup.Add(group.Name + "data11");
                childGroup.Add(group.Name + "data12");
                childGroup.Add(group.Name + "data13");

                group.Add(childGroup);
            }

            Layout.SetSource(list, groupLevel, 0, 0, 0, true);

            Assert.AreEqual(40, Layout.TotalSlotCount);
            Assert.AreEqual(40, Layout.VisibleLineCount);

            var targetGroup = (TestGroup)list.First().First();

            var firstItem = targetGroup.First();

            targetGroup.Remove(firstItem);
            Layout.RemoveItem(targetGroup, firstItem, 0);

            Assert.AreEqual(39, Layout.TotalSlotCount);
            Assert.AreEqual(39, Layout.VisibleLineCount);
            Assert.AreEqual(Layout.TotalSlotCount, Layout.RenderInfoCount);

            firstItem = targetGroup.First();
            targetGroup.Remove(firstItem);
            Layout.RemoveItem(targetGroup, firstItem, 0);

            Assert.AreEqual(39, Layout.TotalSlotCount);
            Assert.AreEqual(39, Layout.VisibleLineCount);
            Assert.AreEqual(Layout.TotalSlotCount, Layout.RenderInfoCount);
        }
예제 #3
0
        public void GetFirstStackSlotOnRow_WhenGrouped2LevelWith3Leaves_ShouldReturnCorrectSlot()
        {
            int groupLevel = 2;
            var list       = new List <TestGroup>(from c in Enumerable.Range(0, 5) select new TestGroup("group " + c));

            foreach (var group in list)
            {
                var childGroup = new TestGroup("SubGroup of" + group.Name);

                childGroup.Add(group.Name + "data11");
                childGroup.Add(group.Name + "data12");
                childGroup.Add(group.Name + "data13");

                group.Add(childGroup);
            }

            Layout.SetSource(list, groupLevel, 0, 0, 0, true);

            Assert.AreEqual(20, Layout.TotalSlotCount);
            Assert.AreEqual(20, Layout.VisibleLineCount);

            var totalSlotCount = Layout.TotalSlotCount;

            var slot = Layout.GetFirstStackSlotOnRow(0, totalSlotCount);

            Assert.AreEqual(0, slot);

            slot = Layout.GetFirstStackSlotOnRow(2, totalSlotCount);

            Assert.AreEqual(2, slot);

            slot = Layout.GetFirstStackSlotOnRow(4, totalSlotCount);

            Assert.AreEqual(5, slot);

            slot = Layout.GetFirstStackSlotOnRow(15, totalSlotCount);

            Assert.AreEqual(19, slot);
        }
예제 #4
0
        public void AddingGroup_WhenGrouped1Level_ShouldUpdateLayoutCorrectly()
        {
            var rootGroup = new TestGroup("Root");

            var newGroup = new TestGroup("new group");

            newGroup.Add(newGroup.Name + "data3");

            var list = new List <TestGroup>(from c in Enumerable.Range(0, 10) select new TestGroup("group " + c));

            foreach (var group in list)
            {
                group.Add(group.Name + "data11");
            }

            Layout.SetSource(list, 1, 0, 0, 0, true);

            Assert.AreEqual(20, Layout.TotalSlotCount);
            Assert.AreEqual(20, Layout.VisibleLineCount);


            list.Insert(0, newGroup);
            Layout.AddItem(rootGroup, newGroup, 0);

            Assert.AreEqual(22, Layout.TotalSlotCount);
            Assert.AreEqual(22, Layout.VisibleLineCount);
            Assert.AreEqual(Layout.TotalSlotCount, Layout.RenderInfoCount);

            newGroup = new TestGroup("new group 1");
            newGroup.Add(newGroup.Name + "new data");

            list.Insert(0, newGroup);
            Layout.AddItem(rootGroup, newGroup, 0);

            Assert.AreEqual(24, Layout.TotalSlotCount);
            Assert.AreEqual(24, Layout.VisibleLineCount);
            Assert.AreEqual(Layout.RenderInfoCount, Layout.TotalSlotCount);
        }
예제 #5
0
        public void RemovingGroup_WhenGrouped2Level_ShouldUpdateLayoutCorrectly()
        {
            int groupLevel = 2;
            var rootGroup  = new Group("Root");
            var list       = new List <TestGroup>(from c in Enumerable.Range(0, 10) select new TestGroup("group " + c));

            foreach (var group in list)
            {
                var childGroup = new TestGroup("SubGroup of" + group.Name);

                childGroup.Add(childGroup.Name + "data11");

                group.Add(childGroup);
            }

            Layout.SetSource(list, groupLevel, 0, 0, 0, true);

            Assert.AreEqual(30, Layout.TotalSlotCount);
            Assert.AreEqual(30, Layout.VisibleLineCount);

            var oldgroup = list.First();

            list.Remove(list.First());
            Layout.RemoveItem(rootGroup, oldgroup, 0);

            Assert.AreEqual(27, Layout.TotalSlotCount);
            Assert.AreEqual(27, Layout.VisibleLineCount);
            Assert.AreEqual(Layout.TotalSlotCount, Layout.RenderInfoCount);

            oldgroup = list.First();
            list.Remove(list.First());
            Layout.RemoveItem(rootGroup, oldgroup, 0);

            Assert.AreEqual(24, Layout.TotalSlotCount);
            Assert.AreEqual(24, Layout.VisibleLineCount);
            Assert.AreEqual(Layout.TotalSlotCount, Layout.RenderInfoCount);
        }