Exemplo n.º 1
0
        public void PivotData_Slice()
        {
            var testData   = generateData();
            var pvtData    = new PivotData(new string[] { "name", "date", "qty", "total" }, new CountAggregatorFactory(), testData);
            var slice1Data = pvtData.Slice(new string[] { "name", "qty" }, false);

            Assert.Equal(2, slice1Data.Dimensions.Length);

            var vk = new ValueKey("Test0", 0);

            Assert.Equal(pvtData["Test0", Key.Empty, 0, Key.Empty].Value, slice1Data[vk].Value);

            Assert.Equal(pvtData[Key.Empty, Key.Empty, Key.Empty, Key.Empty].Value, slice1Data[Key.Empty, Key.Empty].Value);

            var slice2Data = pvtData.Slice(new string[] { "name", "qty" }, false, (v) => {
                return(v.Key.DimKeys[0].Equals("Test0"));
            });

            Assert.Equal(((uint)pvtData[Key.Empty, Key.Empty, Key.Empty, Key.Empty].Value) / 2, slice2Data[Key.Empty, Key.Empty].Value);

            // check zero-dim slice
            var sliceZeroDimData = slice2Data.Slice(null, false);

            Assert.Equal(slice2Data[Key.Empty, Key.Empty].Value, sliceZeroDimData[new object[0]].Value);
        }