Ejemplo n.º 1
0
        private static void GenerateGroups(int level, int aggregatesLevel, IList <TestGroup> groups, int totalLevelCount, int childCount, int totalsCount, TotalsPosition totalsPosition, bool showAggregatesValueInline)
        {
            if (level < totalLevelCount)
            {
                aggregatesLevel = totalsCount > 1 ? aggregatesLevel : -1;
                int end = (level == aggregatesLevel && totalsCount > 1) ? totalsCount : childCount;
                for (int i = 1; i <= end; i++)
                {
                    var group = new TestGroup(string.Format("Level: {0}, Group: {1}", level, i));
                    if (level == (totalLevelCount - 1))
                    {
                        group.Type = GroupType.BottomLevel;
                    }
                    else if (level < (totalLevelCount - 1))
                    {
                        group.Type = GroupType.Subheading;
                    }

                    groups.Add(group);

                    GenerateGroups(level + 1, aggregatesLevel, group, totalLevelCount, childCount, totalsCount, totalsPosition, showAggregatesValueInline);
                }

                TestGroup tg = groups as TestGroup;
                if (tg != null && tg.Type == GroupType.Subheading && (level - 1) != aggregatesLevel)
                {
                    if ((!showAggregatesValueInline || level != aggregatesLevel) && !(totalLevelCount - 1 == aggregatesLevel && level == totalLevelCount - 1))
                    {
                        int aggCount = totalsCount;
                        if (aggregatesLevel == -1)
                        {
                            aggCount = 1;
                        }
                        else if (aggregatesLevel < level)
                        {
                            aggCount = 1;
                        }

                        for (int i = 1; i <= aggCount; i++)
                        {
                            var type     = level == totalLevelCount - 1 ? GroupType.BottomLevel : GroupType.Subtotal;
                            var subTotal = new TestGroup(string.Format("Level: {0}, SubTotal: {1}", level, i))
                            {
                                Type = type
                            };
                            if (totalsPosition == TotalsPosition.First || (totalsPosition == TotalsPosition.Inline && aggCount > 1))
                            {
                                tg.Insert(0, subTotal);
                            }
                            else if (totalsPosition == TotalsPosition.Last)
                            {
                                tg.Add(subTotal);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void Collapsed_Event_Should_Not_Fire_On_Group_With_Type_BottomLevel()
        {
            var group = new TestGroup("item")
            {
                Type = GroupType.BottomLevel
            };

            Layout.AssertEventFired("Collapsed", () => Layout.Collapse(group), false);
        }
        public void ResultsProperty_WhenProviderHasCompletedRefreshing_HasCorrectColumnGroupsData()
        {
            this.ConfigureProviderToProduceResults();
            IGroup expectedColumnGroup = new TestGroup("Grand Total")
            {
                new TestGroup("1 Free with 10"),
                new TestGroup("Extra Discount"),
            };

            this.provider.Refresh();
            this.provider.BlockUntilRefreshCompletes();
            var results = ((IDataProvider)this.provider).Results;

            bool equal = GroupTestsHelper.AreGroupsEqual(expectedColumnGroup, results.Root.ColumnGroup);

            Assert.IsTrue(equal);
        }
        public void ResultsProperty_WhenProviderHasCompletedRefreshing_HasCorrectRowGroupsData()
        {
            this.ConfigureProviderToProduceResults();
            IGroup expectedRowGroup = new TestGroup("Grand Total")
            {
                new TestGroup("Copy holder"),
                new TestGroup("Glare filter"),
                new TestGroup("Mouse pad"),
                new TestGroup("Printer stand"),
            };

            this.provider.Refresh();
            this.provider.BlockUntilRefreshCompletes();
            var results = ((IDataProvider)this.provider).Results;

            bool equal = GroupTestsHelper.AreGroupsEqual(expectedRowGroup, results.Root.RowGroup);

            Assert.IsTrue(equal);
        }
Ejemplo n.º 5
0
        public void TestInitialize()
        {
            this.Layout = new OutlineLayout(new GroupHierarchyAdapter(), 10);

            root = new TestGroup("Grand Total")
            {
                new TestGroup("Direct mail")
                {
                    new TestGroup("1 Free with 10"),
                    new TestGroup("Extra Discount")
                },
                new TestGroup("Magazine")
                {
                    new TestGroup("1 Free with 10"),
                    new TestGroup("Extra Discount")
                },
                new TestGroup("Newspaper")
                {
                    new TestGroup("1 Free with 10"),
                    new TestGroup("Extra Discount")
                }
            };
        }
Ejemplo n.º 6
0
        public void Collapsed_Event_Should_Not_Fire_On_Group_Without_Children()
        {
            var group = new TestGroup("item");

            Layout.AssertEventFired("Collapsed", () => Layout.Collapse(group), false);
        }