Ejemplo n.º 1
0
        public void KeysCountIndexTest()
        {
            Action Control = () =>
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(index.Count == control_index.Count);
                var keys = index.Keys.Distinct().ToArray();
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(keys.Length == control_index.Count);
                foreach (var key in keys)
                    Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(control_index.ContainsKey(key));
            };

            using (index = CreateNewIndex(true))
            {
                Set(0, 1, 3, 4);
                Control();
                Remove(4);
                Set(5, true);
                Set(0, false);
                Get(0, 1,2,3,4,5,6);
                Control();
                index.Flush();
            }

            using (index = CreateNewIndex(false))
            {
                Control();
                Remove(2);
                Remove(0);
                Control();
                Set(0, 1);
                Control();
                index.Flush();
            }
        }
Ejemplo n.º 2
0
        public void KeysCountIndexTest()
        {
            Action Control = () =>
            {
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(index.Count == control_index.Count);
                var keys = index.Keys.Distinct().ToArray();
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(keys.Length == control_index.Count);
                foreach (var key in keys)
                {
                    Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(control_index.ContainsKey(key));
                }
            };

            using (index = CreateNewIndex(true))
            {
                Set(0, 1, 3, 4);
                Control();
                Remove(4);
                Set(5, true);
                Set(0, false);
                Get(0, 1, 2, 3, 4, 5, 6);
                Control();
                index.Flush();
            }

            using (index = CreateNewIndex(false))
            {
                Control();
                Remove(2);
                Remove(0);
                Control();
                Set(0, 1);
                Control();
                index.Flush();
            }
        }
Ejemplo n.º 3
0
        public void SimpleGetSaveRemoveIndexTest()
        {
            using (index = CreateNewIndex(true))
            {
                for (int i = 0; i < N; ++i)
                {
                    int key = rnd.Next(10);
                    if (i < 20 || i % 5 == 0)
                    {
                        Set(key, rnd.Next() % 5 == 0);
                    }
                    else if (i % 5 == 1)
                    {
                        Remove(key);
                    }
                    else
                    {
                        Get(key);
                    }

                    if (i % 1000 == 0)
                    {
                        index.Flush();
                    }
                }

                Get(200);
                Set(200, false);
                Get(200);
                Set(200, true);
                Get(200);
                Remove(200);
                Get(200);
                Set(200, true);
                Get(200);
                Set(200, false);
                Get(200);
                index.Flush();
            }

            using (index = CreateNewIndex(false))
            {
                for (int i = 0; i < N; ++i)
                {
                    int key = rnd.Next(1000);
                    if (i < 2000 || i % 5 == 0)
                    {
                        Set(key, rnd.Next() % 5 == 0);
                    }
                    else if (i % 5 == 1)
                    {
                        Remove(key);
                    }
                    else
                    {
                        Get(key);
                    }

                    if (i % 1000 == 0)
                    {
                        index.Flush();
                    }
                }
                index.Flush();
            }
        }
Ejemplo n.º 4
0
        public void SimpleGetSaveRemoveIndexTest()
        {
            using (index = CreateNewIndex(true))
            {

                for (int i = 0; i < N; ++i)
                {
                    int key = rnd.Next(10);
                    if (i < 20 || i%5 == 0) Set(key, rnd.Next()%5 == 0);
                    else if (i%5 == 1) Remove(key);
                    else Get(key);

                    if (i%1000 == 0) index.Flush();
                }

                Get(200);
                Set(200, false);
                Get(200);
                Set(200, true);
                Get(200);
                Remove(200);
                Get(200);
                Set(200, true);
                Get(200);
                Set(200, false);
                Get(200);
                index.Flush();

            }

            using (index = CreateNewIndex(false))
            {
                for (int i = 0; i < N; ++i)
                {
                    int key = rnd.Next(1000);
                    if (i < 2000 || i%5 == 0) Set(key, rnd.Next()%5 == 0);
                    else if (i%5 == 1) Remove(key);
                    else Get(key);

                    if (i%1000 == 0) index.Flush();
                }
                index.Flush();

            }
        }