Ejemplo n.º 1
0
        public void CreateDataSet()
        {
            var start = DateTime.UtcNow;

            _testInitializeTime = DateTime.UtcNow - start;
            Utils.CheckFileExists(DataFile);
            var file = new FileInfo(DataFile);

            try
            {
                var array = new byte[file.Length];
                using (var stream = file.OpenRead())
                {
                    stream.Read(array, 0, (int)file.Length);
                }
                _provider = TrieFactory.Create(array);
            }
            catch (OutOfMemoryException)
            {
                Assert.Inconclusive(
                    "Not enough memory to perform memory test on data file '{0}' of size '{1}'MB",
                    file.Name,
                    file.Length / (1024 * 1024));
            }
            _testInitializeTime = DateTime.UtcNow - start;
        }
Ejemplo n.º 2
0
        public void CreateDataSet()
        {
            var start = DateTime.UtcNow;

            Utils.CheckFileExists(DataFile);
            _provider           = TrieFactory.Create(DataFile);
            _testInitializeTime = DateTime.UtcNow - start;
        }
Ejemplo n.º 3
0
        public void InsertIntoTrie()
        {
            Trie trie = TrieFactory.Create();
            Tuple <string, int> tuple = new Tuple <string, int>("bogus", 99);

            trie.Insert(tuple.Item1, tuple.Item2);
            Assert.AreEqual(trie.Count(), 1);
            Assert.AreEqual(trie.Get(tuple.Item1), tuple.Item2);
        }
Ejemplo n.º 4
0
        public void TraverseTriePreOrder()
        {
            Trie trie = TrieFactory.Create();
            List <Tuple <string, int> > tuples = new List <Tuple <string, int> >()
            {
                new Tuple <string, int>("bogus", 99),
                new Tuple <string, int>("aack", 88),
                new Tuple <string, int>("zebra", 77),
                new Tuple <string, int>("kangaroo", 66),
                new Tuple <string, int>("donkey", 55),
                new Tuple <string, int>("dog", 44)
            };

            foreach (Tuple <string, int> tuple in tuples)
            {
                trie.Insert(tuple.Item1, tuple.Item2);
            }
            Assert.AreEqual(trie.Count(), tuples.Count);

            TestVisitor testVisitor = new TestVisitor();

            trie.Traverse(TraversalType.PreOrder, testVisitor);
            Console.WriteLine(testVisitor.ToString());
        }
Ejemplo n.º 5
0
 public void CreateDataSet()
 {
     Utils.CheckFileExists(DataFile);
     _provider = TrieFactory.Create(DataFile);
 }
 public void CreateDataSet()
 {
     _memory = new Utils.MemoryMonitor();
     Utils.CheckFileExists(DataFile);
     _provider = TrieFactory.Create(DataFile);
 }
Ejemplo n.º 7
0
 public void GetFromEmptyTrie()
 {
     Trie   trie  = TrieFactory.Create();
     string key   = "bogus";
     int    value = trie.Get(key);
 }