Exemple #1
0
 public static GroupByIndexQuery <TRecord, TIndexType> Group <TRecord, TIndexType>(
     // Can only use indexName on Group on a TABLE, not any arbitrary sequence
     this ITableQuery <TRecord> table,
     IIndex <TRecord, TIndexType> index
     )
 {
     return(table.Group <TRecord, TIndexType>(index.Name));
 }
        public void GroupByIndex()
        {
            var query = testTable.Group(nameIndex);

            int count = 0;

            foreach (var record in connection.Run(query))
            {
                var groupName = record.Key;
                var objects   = record.Value;

                switch (groupName)
                {
                case "1":
                case "3":
                case "6":
                    Assert.That(objects.Count(), Is.EqualTo(2));
                    break;

                case "2":
                    Assert.That(objects.Count(), Is.EqualTo(3));
                    break;

                case "4":
                case "5":
                case "7":
                    Assert.That(objects.Count(), Is.EqualTo(1));
                    break;

                default:
                    Assert.Fail("Unexpected group name: {0}", groupName);
                    break;
                }

                ++count;
            }

            Assert.That(count, Is.EqualTo(7));
        }