Esempio n. 1
0
        public void EmptyTrie()
        {
            var trie = new NumericTrie<string, string>();

            var get = trie.Values("43").SingleOrDefault();
            Assert.Null(get);
        }
Esempio n. 2
0
        public void SaveTrie()
        {
            var trie = new NumericTrie <string, FakeData>();

            trie.Add("123", new FakeData {
                Id = 1, Name = "123", Description = "D 123"
            });
            trie.Add("1234", new FakeData {
                Id = 2, Name = "1234", Description = "D 1234"
            });
            trie.Add("45", new FakeData {
                Id = 3, Name = "45", Description = "D 45"
            });

            var origSave = new MemoryStream();

            trie.Save(origSave);
            origSave.Position = 0;

            var reload = new NumericTrie <string, FakeData>();

            reload.Load(origSave);

            var reloadSave = new MemoryStream();

            reload.Save(reloadSave);

            Assert.Equal(origSave.ToArray(), reloadSave.ToArray());
        }
Esempio n. 3
0
        public void EmptyTrie()
        {
            var trie = new NumericTrie <string, string>();

            var get = trie.Values("43").SingleOrDefault();

            Assert.Null(get);
        }
Esempio n. 4
0
        public void TrieOnce()
        {
            var trie = new NumericTrie<string, string>();
            trie.Add("123", "hello");

            var get = trie.Values("123").Single();
            Assert.Equal("hello", get);
        }
Esempio n. 5
0
        public void NoKey()
        {
            var trie = new NumericTrie<string, string>();
            trie.Add("123", "hello");

            var get = trie.Values("43").SingleOrDefault();
            Assert.Null(get);
        }
Esempio n. 6
0
        public void TrieOnce()
        {
            var trie = new NumericTrie <string, string>();

            trie.Add("123", "hello");

            var get = trie.Values("123").Single();

            Assert.Equal("hello", get);
        }
Esempio n. 7
0
        public void NoKey()
        {
            var trie = new NumericTrie <string, string>();

            trie.Add("123", "hello");

            var get = trie.Values("43").SingleOrDefault();

            Assert.Null(get);
        }
Esempio n. 8
0
        public void Twice()
        {
            var trie = new NumericTrie<string, string>();
            trie.Add("123", "hello");
            trie.Add("123","bye");

            var get = trie.Values("123");
            Assert.Equal("bye", get.First());
            Assert.Equal("hello", get.Last());
        }
Esempio n. 9
0
        public void TwiceOnTrieCorrect()
        {
            var trie = new NumericTrie <string, string>();

            trie.Add("123", "hello");
            trie.Add("123", "bye");

            var get = trie.Values("1234");

            Assert.Equal(new[] { "bye", "hello" }, get.ToArray());
        }
Esempio n. 10
0
        public void TwiceOnNearTrieCorrect()
        {
            var trie = new NumericTrie <string, string>();

            trie.Add("1233", "hello");
            trie.Add("123", "bye");

            var get = trie.Values("1234");

            Assert.Equal("bye", get.Single());
        }
Esempio n. 11
0
        public void TwiceOnNearTrieIncorrect()
        {
            var trie = new NumericTrie <string, string>();

            trie.Add("1233", "hello");
            trie.Add("123", "bye");

            var get = trie.Values("12");

            Assert.True(!get.Any());
        }
Esempio n. 12
0
        public void Twice()
        {
            var trie = new NumericTrie <string, string>();

            trie.Add("123", "hello");
            trie.Add("123", "bye");

            var get = trie.Values("123");

            Assert.Equal("bye", get.First());
            Assert.Equal("hello", get.Last());
        }
Esempio n. 13
0
        public void SaveTrie()
        {
            var trie=new NumericTrie<string,FakeData>();
            trie.Add("123",new FakeData{Id=1,Name="123", Description="D 123"});
            trie.Add("1234", new FakeData { Id = 2, Name = "1234", Description = "D 1234" });
            trie.Add("45", new FakeData { Id = 3, Name = "45", Description = "D 45" });

            var origSave=new MemoryStream();
            trie.Save(origSave);
            origSave.Position = 0;

            var reload=new NumericTrie<string,FakeData>();
            reload.Load(origSave);

            var reloadSave=new MemoryStream();
            reload.Save(reloadSave);

            Assert.Equal(origSave.ToArray(),reloadSave.ToArray());
        }
Esempio n. 14
0
        public void TwiceOnNearTrieIncorrect()
        {
            var trie = new NumericTrie<string, string>();
            trie.Add("1233", "hello");
            trie.Add("123", "bye");

            var get = trie.Values("12");
            Assert.True(!get.Any());
        }
Esempio n. 15
0
        public void TwiceOnNearTrieCorrect()
        {
            var trie = new NumericTrie<string, string>();
            trie.Add("1233", "hello");
            trie.Add("123", "bye");

            var get = trie.Values("1234");
            Assert.Equal("bye", get.Single());
        }
Esempio n. 16
0
        public void TwiceOnTrieCorrect()
        {
            var trie = new NumericTrie<string, string>();
            trie.Add("123", "hello");
            trie.Add("123", "bye");

            var get = trie.Values("1234");
            Assert.Equal(new[]{"bye","hello"}, get.ToArray());
        }