Пример #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);
            }
        }