Exemplo n.º 1
0
            public void ShouldInsertAnObjectToStore()
            {
                var model = new Model{Title ="title1", ThumbUrl="http://thumb.com/title1.jpg", Description="description1", Price=5.0F};
                BinaryRage.DB<Model>.Insert("myModel", model, "dbfile");

                var result = BinaryRage.DB<Model>.Get("myModel", "dbfile");

                Assert.AreEqual(model, result);
                BinaryRage.DB<Model>.Remove("myModel", "dbfile");
            }
Exemplo n.º 2
0
            public void ShouldInsertAnObjectToStoreWithAnyCompressionLevel(
                  [Values(CompressionLevel.Fastest, CompressionLevel.NoCompression, CompressionLevel.Optimal)] CompressionLevel compressionLevel)
            {
                var model = new Model{Title ="title1", ThumbUrl="http://thumb.com/title1.jpg", Description="description1", Price=5.0F};

                BinaryRage.DB.Insert<Model>("myModel", model, "dbfile", compressionLevel);

                var result = BinaryRage.DB.Get<Model>("myModel", "dbfile");

                Assert.AreEqual(model, result);
                BinaryRage.DB.WaitForCompletion();
                BinaryRage.DB.Remove("myModel", "dbfile");
            }
        public void ShouldWaitForIOCompletionWhenAsked()
        {
            var m = new Model { Description = "foobar" };
            for (int i = 0; i < 10; i++)
                BinaryRage.DB<Model>.Insert("key" + i, m, DB_NAME);

            // Without calling the wait method this test will fail every time
            // with a DirectoryNotFoundException
            BinaryRage.DB<Model>.WaitForCompletion();

            var readObjects = new Dictionary<string, Model>();
            for (int i = 0; i < 10; i++)
                readObjects.Add("key" + i, BinaryRage.DB<Model>.Get("key" + i, DB_NAME));

            Assert.AreEqual(m.Description, readObjects["key0"].Description);
            Assert.AreEqual(m.Description, readObjects["key9"].Description);
        }