コード例 #1
0
        public void CanFetchValueExpectValidRow()
        {
            Dev2BinaryStorage <BinaryDataListRow> dic = new Dev2BinaryStorage <BinaryDataListRow>(Guid.NewGuid().ToString(), 1024);

            BinaryDataListRow row1 = new BinaryDataListRow(5);

            row1.UpdateValue("col1", 0, 5);
            row1.UpdateValue("col2", 1, 5);
            row1.UpdateValue("col3", 2, 5);
            row1.UpdateValue("col4", 3, 5);
            row1.UpdateValue("col5", 4, 5);

            BinaryDataListRow row3 = new BinaryDataListRow(5);

            row3.UpdateValue("col3", 2, 5);
            row3.UpdateValue("col4", 3, 5);
            row3.UpdateValue("col5", 4, 5);


            string key1 = Guid.NewGuid().ToString();
            string key2 = Guid.NewGuid().ToString();
            string key3 = Guid.NewGuid().ToString();

            dic.Remove(key2);
            dic[key3] = row3;
            dic[key1] = row1;

            dic.Remove(key2);
            //dic.Compact();

            BinaryDataListRow fetchedRow1 = dic[key1];
            BinaryDataListRow fetchedRow3 = dic[key3];

            Assert.AreEqual("col1", fetchedRow1.FetchValue(0, 5));
            Assert.AreEqual("col2", fetchedRow1.FetchValue(1, 5));
            Assert.AreEqual("col3", fetchedRow1.FetchValue(2, 5));
            Assert.AreEqual("col4", fetchedRow1.FetchValue(3, 5));
            Assert.AreEqual("col5", fetchedRow1.FetchValue(4, 5));


            Assert.AreEqual("col3", fetchedRow3.FetchValue(2, 5));
            Assert.AreEqual("col4", fetchedRow3.FetchValue(3, 5));
            Assert.AreEqual("col5", fetchedRow3.FetchValue(4, 5));
        }
コード例 #2
0
        public void Dev2BinaryStorage_BasicUsage_WhenAddingRemovingAtVolumn_AllDataFetched()
        {
            //------------Setup for test--------------------------
            Dev2BinaryStorage <BinaryDataListRow> dic = new Dev2BinaryStorage <BinaryDataListRow>(Guid.NewGuid().ToString(), 4194304); // 4MB buffer ;)

            const int cnt = 50000;

            IList <BinaryDataListRow> rows = new List <BinaryDataListRow>(cnt);
            IList <string>            keys = new List <string>();


            for (int i = 0; i < cnt; i++)
            {
                BinaryDataListRow row = new BinaryDataListRow(5);
                row.UpdateValue("col1" + Guid.NewGuid() + " " + Guid.NewGuid() + " " + Guid.NewGuid() + " " + Guid.NewGuid(), 0, 5);
                row.UpdateValue("col2", 1, 5);
                row.UpdateValue("col3" + Guid.NewGuid(), 2, 5);
                row.UpdateValue("col4", 3, 5);
                row.UpdateValue("col5" + Guid.NewGuid(), 4, 5);

                rows.Add(row);
                keys.Add(Guid.NewGuid().ToString());
            }

            //------------Execute Test---------------------------

            // add rows
            for (int i = 0; i < cnt; i++)
            {
                dic[keys[i]] = rows[i];

                // fake removals ;)
                if ((i + 1) % 100 == 0)
                {
                    dic.Remove(keys[i]);
                }

                // fake compact
                //if((i + 1) % 200 == 0)
                //{
                //    dic.Compact();
                //}
            }


            // check first and 2nd to last row, since last was removed ;)
            BinaryDataListRow fetchedRow1 = dic[keys[0]];
            BinaryDataListRow fetchedRow2 = dic[keys[cnt - 2]];

            //------------Assert Results-------------------------
            Assert.AreEqual("col2", fetchedRow1.FetchValue(1, 5));
            Assert.AreEqual("col4", fetchedRow1.FetchValue(3, 5));

            Assert.AreEqual("col2", fetchedRow2.FetchValue(1, 5));
            Assert.AreEqual("col4", fetchedRow2.FetchValue(3, 5));
        }
コード例 #3
0
        public void Dev2BinaryStorage_BasicUsage_WhenAddingRemovingAndCompacting_AllDataFetched()
        {
            //------------Setup for test--------------------------
            Dev2BinaryStorage <BinaryDataListRow> dic = new Dev2BinaryStorage <BinaryDataListRow>(Guid.NewGuid().ToString(), 756);

            BinaryDataListRow row1 = new BinaryDataListRow(5);

            row1.UpdateValue("col1", 0, 5);
            row1.UpdateValue("col2", 1, 5);
            row1.UpdateValue("col3", 2, 5);
            row1.UpdateValue("col4", 3, 5);
            row1.UpdateValue("col5", 4, 5);

            BinaryDataListRow row3 = new BinaryDataListRow(5);

            row3.UpdateValue("col3", 2, 5);
            row3.UpdateValue("col4", 3, 5);
            row3.UpdateValue("col5", 4, 5);


            BinaryDataListRow row2 = new BinaryDataListRow(5);

            row1.UpdateValue("col1", 0, 5);
            row1.UpdateValue("col2", 1, 5);
            row1.UpdateValue("col3", 2, 5);
            row1.UpdateValue("col4", 3, 5);
            row1.UpdateValue("col5", 4, 5);

            string key1 = Guid.NewGuid().ToString();
            string key2 = Guid.NewGuid().ToString();
            string key3 = Guid.NewGuid().ToString();

            //------------Execute Test---------------------------
            dic[key3] = row3;
            dic[key2] = row2;
            dic[key1] = row1;

            dic.Remove(key2);
            dic.Compact();

            BinaryDataListRow fetchedRow1 = dic[key1];
            BinaryDataListRow fetchedRow3 = dic[key3];

            //------------Assert Results-------------------------
            Assert.AreEqual("col1", fetchedRow1.FetchValue(0, 5));
            Assert.AreEqual("col2", fetchedRow1.FetchValue(1, 5));
            Assert.AreEqual("col3", fetchedRow1.FetchValue(2, 5));
            Assert.AreEqual("col4", fetchedRow1.FetchValue(3, 5));
            Assert.AreEqual("col5", fetchedRow1.FetchValue(4, 5));


            Assert.AreEqual("col3", fetchedRow3.FetchValue(2, 5));
            Assert.AreEqual("col4", fetchedRow3.FetchValue(3, 5));
            Assert.AreEqual("col5", fetchedRow3.FetchValue(4, 5));
        }
コード例 #4
0
        public void CanRemoveFromFileExpectNoEntries()
        {
            Dev2BinaryStorage <BinaryDataListRow> dic = new Dev2BinaryStorage <BinaryDataListRow>(Guid.NewGuid().ToString(), 1024);

            BinaryDataListRow row = new BinaryDataListRow(5);

            row.UpdateValue("col1", 0, 5);
            row.UpdateValue("col2", 1, 5);
            row.UpdateValue("col3", 2, 5);
            row.UpdateValue("col4", 3, 5);
            row.UpdateValue("col5", 4, 5);

            string key = Guid.NewGuid().ToString();

            dic.Add(key, row);

            dic.Remove(key);

            Assert.AreEqual(0, dic.Count);
        }
コード例 #5
0
        public void Dev2BinaryStorage_BasicUsage_WhenAddingRemovingAtVolumn_AllDataFetched()
        {

            //------------Setup for test--------------------------
            Dev2BinaryStorage<BinaryDataListRow> dic = new Dev2BinaryStorage<BinaryDataListRow>(Guid.NewGuid().ToString(), 4194304); // 4MB buffer ;)

            const int cnt = 50000;

            IList<BinaryDataListRow> rows = new List<BinaryDataListRow>(cnt);
            IList<string> keys = new List<string>();


            for(int i = 0; i < cnt; i++)
            {
                BinaryDataListRow row = new BinaryDataListRow(5);
                row.UpdateValue("col1" + Guid.NewGuid() + " " + Guid.NewGuid() + " " + Guid.NewGuid() + " " + Guid.NewGuid(), 0, 5);
                row.UpdateValue("col2", 1, 5);
                row.UpdateValue("col3" + Guid.NewGuid(), 2, 5);
                row.UpdateValue("col4", 3, 5);
                row.UpdateValue("col5" + Guid.NewGuid(), 4, 5);

                rows.Add(row);
                keys.Add(Guid.NewGuid().ToString());
            }

            //------------Execute Test---------------------------

            // add rows
            for(int i = 0; i < cnt; i++)
            {
                dic[keys[i]] = rows[i];

                // fake removals ;)
                if((i + 1) % 100 == 0)
                {
                    dic.Remove(keys[i]);
                }

                // fake compact
                //if((i + 1) % 200 == 0)
                //{
                //    dic.Compact();
                //}
            }


            // check first and 2nd to last row, since last was removed ;)
            BinaryDataListRow fetchedRow1 = dic[keys[0]];
            BinaryDataListRow fetchedRow2 = dic[keys[cnt - 2]];

            //------------Assert Results-------------------------
            Assert.AreEqual("col2", fetchedRow1.FetchValue(1, 5));
            Assert.AreEqual("col4", fetchedRow1.FetchValue(3, 5));

            Assert.AreEqual("col2", fetchedRow2.FetchValue(1, 5));
            Assert.AreEqual("col4", fetchedRow2.FetchValue(3, 5));

        }
コード例 #6
0
        public void Dev2BinaryStorage_BasicUsage_WhenAddingRemovingAndCompacting_AllDataFetched()
        {

            //------------Setup for test--------------------------
            Dev2BinaryStorage<BinaryDataListRow> dic = new Dev2BinaryStorage<BinaryDataListRow>(Guid.NewGuid().ToString(), 756);

            BinaryDataListRow row1 = new BinaryDataListRow(5);
            row1.UpdateValue("col1", 0, 5);
            row1.UpdateValue("col2", 1, 5);
            row1.UpdateValue("col3", 2, 5);
            row1.UpdateValue("col4", 3, 5);
            row1.UpdateValue("col5", 4, 5);

            BinaryDataListRow row3 = new BinaryDataListRow(5);
            row3.UpdateValue("col3", 2, 5);
            row3.UpdateValue("col4", 3, 5);
            row3.UpdateValue("col5", 4, 5);


            BinaryDataListRow row2 = new BinaryDataListRow(5);
            row1.UpdateValue("col1", 0, 5);
            row1.UpdateValue("col2", 1, 5);
            row1.UpdateValue("col3", 2, 5);
            row1.UpdateValue("col4", 3, 5);
            row1.UpdateValue("col5", 4, 5);

            string key1 = Guid.NewGuid().ToString();
            string key2 = Guid.NewGuid().ToString();
            string key3 = Guid.NewGuid().ToString();

            //------------Execute Test---------------------------
            dic[key3] = row3;
            dic[key2] = row2;
            dic[key1] = row1;

            dic.Remove(key2);
            dic.Compact();

            BinaryDataListRow fetchedRow1 = dic[key1];
            BinaryDataListRow fetchedRow3 = dic[key3];

            //------------Assert Results-------------------------
            Assert.AreEqual("col1", fetchedRow1.FetchValue(0, 5));
            Assert.AreEqual("col2", fetchedRow1.FetchValue(1, 5));
            Assert.AreEqual("col3", fetchedRow1.FetchValue(2, 5));
            Assert.AreEqual("col4", fetchedRow1.FetchValue(3, 5));
            Assert.AreEqual("col5", fetchedRow1.FetchValue(4, 5));


            Assert.AreEqual("col3", fetchedRow3.FetchValue(2, 5));
            Assert.AreEqual("col4", fetchedRow3.FetchValue(3, 5));
            Assert.AreEqual("col5", fetchedRow3.FetchValue(4, 5));


        }
コード例 #7
0
        public void CanFetchValueExpectValidRow()
        {
            Dev2BinaryStorage<BinaryDataListRow> dic = new Dev2BinaryStorage<BinaryDataListRow>(Guid.NewGuid().ToString(), 1024);

            BinaryDataListRow row1 = new BinaryDataListRow(5);
            row1.UpdateValue("col1", 0, 5);
            row1.UpdateValue("col2", 1, 5);
            row1.UpdateValue("col3", 2, 5);
            row1.UpdateValue("col4", 3, 5);
            row1.UpdateValue("col5", 4, 5);

            BinaryDataListRow row3 = new BinaryDataListRow(5);
            row3.UpdateValue("col3", 2, 5);
            row3.UpdateValue("col4", 3, 5);
            row3.UpdateValue("col5", 4, 5);


            string key1 = Guid.NewGuid().ToString();
            string key2 = Guid.NewGuid().ToString();
            string key3 = Guid.NewGuid().ToString();

            dic.Remove(key2);
            dic[key3] = row3;
            dic[key1] = row1;

            dic.Remove(key2);
            //dic.Compact();

            BinaryDataListRow fetchedRow1 = dic[key1];
            BinaryDataListRow fetchedRow3 = dic[key3];

            Assert.AreEqual("col1", fetchedRow1.FetchValue(0, 5));
            Assert.AreEqual("col2", fetchedRow1.FetchValue(1, 5));
            Assert.AreEqual("col3", fetchedRow1.FetchValue(2, 5));
            Assert.AreEqual("col4", fetchedRow1.FetchValue(3, 5));
            Assert.AreEqual("col5", fetchedRow1.FetchValue(4, 5));


            Assert.AreEqual("col3", fetchedRow3.FetchValue(2, 5));
            Assert.AreEqual("col4", fetchedRow3.FetchValue(3, 5));
            Assert.AreEqual("col5", fetchedRow3.FetchValue(4, 5));
        }
コード例 #8
0
        public void CanRemoveFromFileExpectNoEntries()
        {
            Dev2BinaryStorage<BinaryDataListRow> dic = new Dev2BinaryStorage<BinaryDataListRow>(Guid.NewGuid().ToString(), 1024);

            BinaryDataListRow row = new BinaryDataListRow(5);
            row.UpdateValue("col1", 0, 5);
            row.UpdateValue("col2", 1, 5);
            row.UpdateValue("col3", 2, 5);
            row.UpdateValue("col4", 3, 5);
            row.UpdateValue("col5", 4, 5);

            string key = Guid.NewGuid().ToString();

            dic.Add(key, row);

            dic.Remove(key);

            Assert.AreEqual(0, dic.Count);

        }