示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testRandomTest()
        public virtual void TestRandomTest()
        {
            Random                      random   = new Random(DateTimeHelper.CurrentUnixTimeMillis());
            DynamicArrayStore           store    = CreateDynamicArrayStore();
            List <long>                 idsTaken = new List <long>();
            IDictionary <long, sbyte[]> byteData = new Dictionary <long, sbyte[]>();
            float       deleteIndex  = 0.2f;
            float       closeIndex   = 0.1f;
            int         currentCount = 0;
            int         maxCount     = 128;
            ISet <long> set          = new HashSet <long>();

            while (currentCount < maxCount)
            {
                float rIndex = random.nextFloat();
                if (rIndex < deleteIndex && currentCount > 0)
                {
                    long blockId = idsTaken.Remove(random.Next(currentCount));
                    store.GetRecords(blockId, NORMAL);
                    sbyte[] bytes = ( sbyte[] )store.GetArrayFor(store.GetRecords(blockId, NORMAL));
                    ValidateData(bytes, byteData.Remove(blockId));
                    ICollection <DynamicRecord> records = store.GetRecords(blockId, NORMAL);
                    foreach (DynamicRecord record in records)
                    {
                        record.InUse = false;
                        store.UpdateRecord(record);
                        set.remove(record.Id);
                    }
                    currentCount--;
                }
                else
                {
                    sbyte[] bytes = CreateRandomBytes(random);
                    ICollection <DynamicRecord> records = new List <DynamicRecord>();
                    store.AllocateRecords(records, bytes);
                    foreach (DynamicRecord record in records)
                    {
                        Debug.Assert(!set.Contains(record.Id));
                        store.UpdateRecord(record);
                        set.Add(record.Id);
                    }
                    long blockId = Iterables.first(records).Id;
                    idsTaken.Add(blockId);
                    byteData[blockId] = bytes;
                    currentCount++;
                }
                if (rIndex > (1.0f - closeIndex) || rIndex < closeIndex)
                {
                    _neoStores.close();
                    store = CreateDynamicArrayStore();
                }
            }
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testClose()
        public virtual void TestClose()
        {
            DynamicArrayStore           store   = CreateDynamicArrayStore();
            ICollection <DynamicRecord> records = new List <DynamicRecord>();

            store.AllocateRecordsFromBytes(records, new sbyte[10]);
            long blockId = Iterables.first(records).Id;

            foreach (DynamicRecord record in records)
            {
                store.UpdateRecord(record);
            }
            _neoStores.close();
            _neoStores = null;
            try
            {
                store.GetArrayFor(store.GetRecords(blockId, NORMAL));
                fail("Closed store should throw exception");
            }
            catch (Exception)
            {               // good
            }
            try
            {
                store.GetRecords(0, NORMAL);
                fail("Closed store should throw exception");
            }
            catch (Exception)
            {               // good
            }
        }
示例#3
0
        private long Create(DynamicArrayStore store, object arrayToStore)
        {
            ICollection <DynamicRecord> records = new List <DynamicRecord>();

            store.AllocateRecords(records, arrayToStore);
            foreach (DynamicRecord record in records)
            {
                store.UpdateRecord(record);
            }
            return(Iterables.first(records).Id);
        }
示例#4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testStoreGetCharsFromString()
        public virtual void TestStoreGetCharsFromString()
        {
            const string      str   = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
            DynamicArrayStore store = CreateDynamicArrayStore();

            char[] chars = new char[str.Length];
            str.CopyTo(0, chars, 0, str.Length - 0);
            ICollection <DynamicRecord> records = new List <DynamicRecord>();

            store.AllocateRecords(records, chars);
            foreach (DynamicRecord record in records)
            {
                store.UpdateRecord(record);
            }
            // assertEquals( STR, new String( store.getChars( blockId ) ) );
        }
示例#5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testAddDeleteSequenceEmptyStringArray()
        public virtual void TestAddDeleteSequenceEmptyStringArray()
        {
            DynamicArrayStore store = CreateDynamicArrayStore();
            long blockId            = Create(store, new string[0]);

            store.GetRecords(blockId, NORMAL);
            string[] readBack = ( string[] )store.GetArrayFor(store.GetRecords(blockId, NORMAL));
            assertEquals(0, readBack.Length);

            ICollection <DynamicRecord> records = store.GetRecords(blockId, NORMAL);

            foreach (DynamicRecord record in records)
            {
                record.InUse = false;
                store.UpdateRecord(record);
            }
        }
示例#6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testAddDeleteSequenceEmptyNumberArray()
        public virtual void TestAddDeleteSequenceEmptyNumberArray()
        {
            DynamicArrayStore store = CreateDynamicArrayStore();

            sbyte[] emptyToWrite = CreateBytes(0);
            long    blockId      = Create(store, emptyToWrite);

            store.GetRecords(blockId, NORMAL);
            sbyte[] bytes = ( sbyte[] )store.GetArrayFor(store.GetRecords(blockId, NORMAL));
            assertEquals(0, bytes.Length);

            ICollection <DynamicRecord> records = store.GetRecords(blockId, NORMAL);

            foreach (DynamicRecord record in records)
            {
                record.InUse = false;
                store.UpdateRecord(record);
            }
        }