Beispiel #1
0
        public void TestMultipleColumns2()
        {
            var dm = DataMap.FromDictionary(new OrderedDictionary()
            {
                { "cat1", new int[]    { 1, 2, 1, 1, 3 } },
                { "cat2", new string[] { "a", "b", "c", "a", "a" } },
                { "value1", new int[]  { 1, 2, 3, 4, 5 } }
            });

            var g = new GroupBy(dm, new string[] { "cat1", "cat2" });

            var groups = g.Groups().ToArray();

            Assert.Equal(4, groups.Length);

            Assert.Equal(new[] { "cat1", "cat2", "value1" }, groups[0].ColumnNames);
            Assert.Equal(new[] { 1, 1 }, groups[0]["cat1"].Values);
            Assert.Equal(new[] { "a", "a" }, groups[0]["cat2"].Values);
            Assert.Equal(new[] { 1, 4 }, groups[0]["value1"].Values);

            Assert.Equal(new[] { "cat1", "cat2", "value1" }, groups[3].ColumnNames);
            Assert.Equal(new[] { 3 }, groups[3]["cat1"].Values);
            Assert.Equal(new[] { "a" }, groups[3]["cat2"].Values);
            Assert.Equal(new[] { 5 }, groups[3]["value1"].Values);
        }