public void PivotTableMD_SortAxisKeys()
        {
            var pvtData = getSamplePivotData(true);
            var pvtTbl  = new PivotTableMD(
                new string[][] {
                new[] { "B" },
                new[] { "A" }
            }, pvtData);

            pvtTbl.SortAxisKeys(0, new int?[] { null, 0 }, ListSortDirection.Ascending);
            Assert.Equal("B3", pvtTbl.AxesKeys[0][0].DimKeys[0]);
            Assert.Equal("B2", pvtTbl.AxesKeys[0][1].DimKeys[0]);
            Assert.Equal("B1", pvtTbl.AxesKeys[0][2].DimKeys[0]);

            pvtTbl.SortAxisKeys(0, null, ListSortDirection.Descending);
            Assert.Equal("B2", pvtTbl.AxesKeys[0][0].DimKeys[0]);

            pvtTbl = new PivotTableMD(
                new string[][] {
                new[] { "C" },
                new[] { "B" }
            }, pvtData);
            pvtTbl.SortAxisKeys(1, new int?[] { 2, null }, ListSortDirection.Descending);
            Assert.Equal("B3", pvtTbl.AxesKeys[1][0].DimKeys[0]);
            Assert.Equal("B2", pvtTbl.AxesKeys[1][1].DimKeys[0]);
            Assert.Equal("B1", pvtTbl.AxesKeys[1][2].DimKeys[0]);

            pvtTbl.SortAxisKeys(1, null, ListSortDirection.Ascending);
            Assert.Equal("B2", pvtTbl.AxesKeys[1][2].DimKeys[0]);
        }
        public void PivotTableMD_2D()
        {
            var pvtData = getSamplePivotData();
            var pvtTbl  = new PivotTableMD(
                new string[][] {
                new[] { "B" },
                new[] { "A" }
            }, pvtData);

            Assert.Equal(3, pvtTbl.AxesKeys[1].Length);
            Assert.Equal(3, pvtTbl.AxesKeys[0].Length);
            Assert.Equal("A1", pvtTbl.AxesKeys[1][0].DimKeys[0]);
            Assert.Equal("B1", pvtTbl.AxesKeys[0][0].DimKeys[0]);

            Assert.Equal(54, Convert.ToInt32(pvtTbl[null, null].Value));              // global totals
            Assert.Equal(6, Convert.ToInt32(pvtTbl[0, 0].Value));
            Assert.Equal(18, Convert.ToInt32(pvtTbl[0, null].Value));

            var pvtData2 = getSamplePivotData(true);
            var pvtTbl2  = new PivotTableMD(
                new string[][] {
                new [] { "A", "B" },
                new [] { "C" }
            }, pvtData2
                );

            Assert.Equal(6, pvtTbl2.AxesKeys[0].Length);
            Assert.Equal("A1", pvtTbl2.AxesKeys[0][0].DimKeys[0]);
            Assert.Equal("B1", pvtTbl2.AxesKeys[0][0].DimKeys[1]);
            Assert.Equal(20, Convert.ToInt32(pvtTbl2[null, null].Value));              // global totals
            Assert.Equal(2, Convert.ToInt32(pvtTbl2[5, null].Value));
        }
        public void PivotTableMD_3D()
        {
            var pvtData = getSamplePivotData();
            var pvtTbl  = new PivotTableMD(
                new string[][] {
                new[] { "B" },
                new[] { "A" },
                new[] { "C" }
            }, pvtData);

            Assert.Equal(54, Convert.ToInt32(pvtTbl[null, null].Value));              // global totals
            Assert.Equal(18, Convert.ToInt32(pvtTbl[0, null, null].Value));
            Assert.Equal(6, Convert.ToInt32(pvtTbl[0, 0, null].Value));
        }
        public void PivotTableMD_CustomKeysComparer()
        {
            var pvtData = getSamplePivotData();
            var pvtTbl  = new PivotTableMD(
                new string[][] {
                new[] { "B" },
                new[] { "A" },
                new[] { "C" }
            }, pvtData, new IComparer <ValueKey>[] {
                null,
                NaturalSortKeyComparer.ReverseInstance,
                null
            });

            Assert.Equal("B1", pvtTbl.AxesKeys[0][0].DimKeys[0]);
            Assert.Equal("A3", pvtTbl.AxesKeys[1][0].DimKeys[0]);
            Assert.Equal("C1", pvtTbl.AxesKeys[2][0].DimKeys[0]);
        }