Example #1
0
        public void UserManagedDisposeTest()
        {
            Sop.ObjectServer server = Sop.ObjectServer.OpenWithTransaction("c:\\SopBin\\OServer.dta");
            var           df        = new Sop.StoreFactory();// {AutoDisposeItem = false};
            const int     ItemCount = 50000;
            List <FooBar> fooBars   = new List <FooBar>(ItemCount);
            string        s         = string.Format("Collection{0}", 1);
            var           sortDict  = df.Get <int, FooBar>(server.SystemFile.Store, s);//, null, false);    // FooBar is disposable, IsDataInKeySegment = false.

            //sortDict.AutoDisposeItem = true;
            for (int i = 0; i < ItemCount; i++)
            {
                var v = new FooBar()
                {
                    Foo = string.Format("Hello World {0}", i)
                };
                sortDict.Add(i, v);
                fooBars.Add(v);
            }
            server.Commit();
            foreach (FooBar fb in fooBars)
            {
                fb.Dispose();
            }
        }
Example #2
0
        public void IncorrectValueTypeTest()
        {
            Sop.ObjectServer server  = Sop.ObjectServer.OpenWithTransaction("c:\\SopBin\\OServer.dta");
            var       df             = new Sop.StoreFactory();
            const int ItemCount      = 50000;
            int       StoreItemCount = 0;

            for (int i = 0; i < ItemCount; i++)
            {
                string s = string.Format("Collection{0}", i);
                using (var sortDict = df.Get <int, int>(server.SystemFile.Store, s))  //, null, false))
                {
                    if (StoreItemCount == 0)
                    {
                        StoreItemCount = sortDict.Count;
                    }
                    else if (sortDict.Count != StoreItemCount)
                    {
                        Assert.Fail(string.Format("sortDict.Count {0}, expected {1}", sortDict.Count, StoreItemCount));
                    }
                    sortDict.MoveFirst();
                    do
                    {
                        int i2  = sortDict.CurrentKey;
                        int sss = sortDict.CurrentValue;
                    } while (sortDict.MoveNext());
                }
            }
        }
Example #3
0
 public void LicenseKeyTestRead()
 {
     Sop.ObjectServer.LicenseKey = "TestKey";
     Sop.IObjectServer server = Sop.ObjectServer.OpenReadOnly("c:\\SopBin\\OServer.dta");
     Sop.StoreFactory  df     = new Sop.StoreFactory();
     var sortDict             = df.Get <int, int>(server.SystemFile.Store, "Collection", createIfNotExist: false);
     var v = sortDict[1];
 }
Example #4
0
        public void TestBTree()
        {
            Sop.ObjectServer server = Sop.ObjectServer.OpenWithTransaction("OServer.dta");
            Sop.StoreFactory df     = new Sop.StoreFactory();
            var sortedDict          = df.Get <int, int>(server.SystemFile.Store, "Collection");

            sortedDict.Flush();
            sortedDict.Transaction.Commit();
        }
Example #5
0
        public void GeneralPurposeStoreTest()
        {
            Sop.ObjectServer server = Sop.ObjectServer.OpenWithTransaction("c:\\SopBin\\OServer.dta");
            var df       = new Sop.StoreFactory();
            var sortDict = df.Get <int, int>(server.SystemFile.Store, "Collection");

            sortDict.Add(1, 1);
            sortDict.Transaction.Commit();
        }
Example #6
0
        public void LicenseKeyTestCreate()
        {
            Sop.ObjectServer.LicenseKey = "TestKey";
            Sop.ObjectServer server = Sop.ObjectServer.OpenWithTransaction("c:\\SopBin\\OServer.dta");

            Sop.StoreFactory df = new Sop.StoreFactory();
            var sortDict        = df.Get <int, int>(server.SystemFile.Store, "Collection");

            sortDict.Add(1, 1);
            sortDict.Transaction.Commit();
        }
Example #7
0
        public void RollbackTest()
        {
            Sop.ObjectServer server  = Sop.ObjectServer.OpenWithTransaction("c:\\SopBin\\OServer.dta");
            var       df             = new Sop.StoreFactory();
            const int ItemCount      = 50000;
            int       StoreItemCount = 0;

            for (int i = 0; i < ItemCount; i++)
            {
                string s = string.Format("Collection{0}", i);
                using (var sortDict = df.Get <int, int>(server.SystemFile.Store, s))  //, null, false))
                {
                    if (StoreItemCount == 0)
                    {
                        StoreItemCount = sortDict.Count;
                    }
                    else if (sortDict.Count != StoreItemCount)
                    {
                        Assert.Fail(string.Format("sortDict.Count {0}, expected {1}", sortDict.Count, StoreItemCount));
                    }
                    for (int i2 = 0; i2 < ItemCount / 10; i2++)
                    {
                        sortDict.Add(i2, i2);
                    }
                }
            }
            StoreItemCount = 0;
            for (int i = 0; i < ItemCount; i++)
            {
                string s = string.Format("Collection{0}", i);
                using (var sortDict = df.Get <int, int>(server.SystemFile.Store, s)) //, null, false))
                {
                    if (StoreItemCount == 0)
                    {
                        StoreItemCount = sortDict.Count;
                    }
                    else if (sortDict.Count != StoreItemCount)
                    {
                        Assert.Fail(string.Format("sortDict.Count {0}, expected {1}", sortDict.Count, StoreItemCount));
                    }
                    for (int i2 = 0; i2 < ItemCount / 10; i2++)
                    {
                        sortDict.Add(i2, i2);
                    }
                }
            }

            server.Commit();
        }
Example #8
0
        public void IterationTest()
        {
            Sop.ObjectServer server = Sop.ObjectServer.OpenWithTransaction("c:\\SopBin\\OServer.dta");
            var       df            = new Sop.StoreFactory();
            const int ItemCount     = 50000;

            for (int i = 0; i < ItemCount; i++)
            {
                string s = string.Format("Collection{0}", i);
                using (var sortDict = df.Get <int, int>(server.SystemFile.Store, s))  //, null, false))
                {
                    sortDict.MoveFirst();
                    do
                    {
                        Console.WriteLine(string.Format("key = {0}, value = {1}", sortDict.CurrentKey, sortDict.CurrentValue));
                    } while (sortDict.MoveNext());
                }
            }
        }
Example #9
0
        public void NullValueInStoreTest()
        {
            Sop.ObjectServer server = Sop.ObjectServer.OpenWithTransaction("c:\\SopBin\\OServer.dta");
            var df       = new Sop.StoreFactory();
            var sortDict = df.Get <int, FooBar>(server.SystemFile.Store, "Collection");

            if (sortDict.Count > 0)
            {
                do
                {
                    int    i   = sortDict.CurrentKey;
                    FooBar bar = sortDict.CurrentValue;
                } while (sortDict.MoveNext());
            }
            sortDict.Add(1, new FooBar()
            {
                Foo = "Hello World."
            });
            sortDict.Add(1, null);
            server.Commit();
        }
Example #10
0
 public void TestSimpleWrite()
 {
     Sop.Log.Logger.DefaultLogDirectory = "\\\\MyBookLive\\Public\\SopBin2/";
     Sop.Log.Logger.Instance.LogLevel   = Sop.Log.LogLevels.Verbose;
     Console.WriteLine("Start");
     try
     {
         Sop.ObjectServer server = Sop.ObjectServer.OpenWithTransaction("\\\\MyBookLive\\Public\\SopBin2\\OServer.dta");
         var df       = new Sop.StoreFactory();
         var sortDict = df.Get <int, int>(server.SystemFile.Store, "Collection");
         for (int i = 0; i < 10000; i++)
         {
             sortDict.Add(i, i);
         }
         Sop.Log.Logger.Instance.Verbose("Record Count: {0}", sortDict.Count);
         server.Commit();
         Console.WriteLine("End");
     }
     catch (Exception exc)
     {
         Console.WriteLine("Error: {0}", exc.ToString());
         Sop.Log.Logger.Instance.Error(exc);
     }
 }