Example #1
0
        private static Dictionary <string, List <ushort> > GetColumnIndexAsDictionary(IColumn <object> column)
        {
            IndexedColumn indexedColumn = FindColumnComponent <IndexedColumn>(column);

            if (indexedColumn == null)
            {
                return(null);
            }
            else
            {
                return(indexedColumn.ConvertToDictionary());
            }
        }
Example #2
0
        public void IndexedColumn_DictionaryConversion()
        {
            IndexedColumn c = new IndexedColumn(ColumnFactory.CreateSortedColumn <ByteBlock>(new ByteBlockColumn(ByteBlock.Zero), 0), new DefaultWordSplitter());

            c.SetSize(4);
            c[0] = "First Value";
            c[1] = "Second Value";
            c[2] = "this is a different value";
            ColumnTests.AssertConsistent(c);

            // Verify Dictionary conversion
            Dictionary <string, List <ushort> > dictionary = c.ConvertToDictionary();

            Assert.AreEqual(7, dictionary.Keys.Count);
            Assert.AreEqual("0, 1, 2", String.Join(", ", dictionary["value"]));
            Assert.AreEqual("0", String.Join(", ", dictionary["first"]));
            Assert.AreEqual("1", String.Join(", ", dictionary["second"]));
            Assert.AreEqual("2", String.Join(", ", dictionary["this"]));
            Assert.AreEqual("2", String.Join(", ", dictionary["is"]));
            Assert.AreEqual("2", String.Join(", ", dictionary["a"]));
            Assert.AreEqual("2", String.Join(", ", dictionary["different"]));
        }