示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDetectAndAbortPropertyChainLoadingOnCircularReference() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldDetectAndAbortPropertyChainLoadingOnCircularReference()
        {
            // given
            NeoStores neoStores = StoresRule.builder().build();

            // Create property chain 1 --> 2 --> 3 --> 4
            //                             ↑           │
            //                             └───────────┘
            PropertyStore  propertyStore = neoStores.PropertyStore;
            PropertyRecord record        = propertyStore.NewRecord();

            // 1
            record.Id = 1;
            record.Initialize(true, -1, 2);
            propertyStore.UpdateRecord(record);
            // 2
            record.Id = 2;
            record.Initialize(true, 1, 3);
            propertyStore.UpdateRecord(record);
            // 3
            record.Id = 3;
            record.Initialize(true, 2, 4);
            propertyStore.UpdateRecord(record);
            // 4
            record.Id = 4;
            record.Initialize(true, 3, 2);                 // <-- completing the circle
            propertyStore.UpdateRecord(record);

            // when
            PropertyReader reader = new PropertyReader(new StoreAccess(neoStores));

            try
            {
                reader.GetPropertyRecordChain(1);
                fail("Should have detected circular reference");
            }
            catch (PropertyReader.CircularPropertyRecordChainException e)
            {
                // then good
                assertEquals(4, e.PropertyRecordClosingTheCircle().Id);
            }
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void useFixedReferenceFormatWhenRecordCanFitInRecordSizeRecord()
        public virtual void UseFixedReferenceFormatWhenRecordCanFitInRecordSizeRecord()
        {
            PropertyRecord source = new PropertyRecord(1);
            PropertyRecord target = new PropertyRecord(1);

            source.Initialize(true, RandomFixedReference(), RandomFixedReference());

            WriteReadRecord(source, target, PropertyRecordFormat.FixedFormatRecordSize);

            assertTrue("Record should use fixed reference if can fit in format record.", target.UseFixedReferences);
            VerifySameReferences(source, target);
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void useVariableLengthFormatWhenRecordSizeIsTooSmall()
        public virtual void UseVariableLengthFormatWhenRecordSizeIsTooSmall()
        {
            PropertyRecord source = new PropertyRecord(1);
            PropertyRecord target = new PropertyRecord(1);

            source.Initialize(true, RandomFixedReference(), RandomFixedReference());

            WriteReadRecord(source, target, PropertyRecordFormat.FixedFormatRecordSize - 1);

            assertFalse("Record should use variable length reference if format record is too small.", target.UseFixedReferences);
            VerifySameReferences(source, target);
        }
示例#4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void useVariableLengthFormatWhenNextPropertyReferenceTooBig()
        public virtual void UseVariableLengthFormatWhenNextPropertyReferenceTooBig()
        {
            PropertyRecord source = new PropertyRecord(1);
            PropertyRecord target = new PropertyRecord(1);

            source.Initialize(true, RandomFixedReference(), _tooBigReference);

            WriteReadRecord(source, target);

            assertFalse("Record should use variable length reference format.", target.UseFixedReferences);
            VerifySameReferences(source, target);
        }
示例#5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void useFixedReferenceFormatWhenPreviousPropertyIsMissing()
        public virtual void UseFixedReferenceFormatWhenPreviousPropertyIsMissing()
        {
            PropertyRecord source = new PropertyRecord(1);
            PropertyRecord target = new PropertyRecord(1);

            source.Initialize(true, Record.NULL_REFERENCE.intValue(), RandomFixedReference());

            WriteReadRecord(source, target);

            assertTrue("Record should use fixed reference format.", target.UseFixedReferences);
            VerifySameReferences(source, target);
        }
示例#6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void readWriteFixedReferencesRecord()
        public virtual void ReadWriteFixedReferencesRecord()
        {
            PropertyRecord source = new PropertyRecord(1);
            PropertyRecord target = new PropertyRecord(1);

            source.Initialize(true, RandomFixedReference(), RandomFixedReference());

            WriteReadRecord(source, target);

            assertTrue("Record should use fixed reference format.", target.UseFixedReferences);
            VerifySameReferences(source, target);
        }
示例#7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void inUseRecordEquality()
        public virtual void InUseRecordEquality()
        {
            PropertyRecord record1 = new PropertyRecord(1);

            record1.Initialize(true, 1, 2);
            record1.SecondaryUnitId = 42;

            PropertyRecord record2 = record1.Clone();

            PropertyCheckType check = new PropertyCheckType();

            assertTrue(check.Equal(record1, record2));
        }
示例#8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void readSingleUnitRecordStoredNotInFixedReferenceFormat()
        public virtual void ReadSingleUnitRecordStoredNotInFixedReferenceFormat()
        {
            PropertyRecord oldFormatRecord = new PropertyRecord(1);
            PropertyRecord newFormatRecord = new PropertyRecord(1);

            oldFormatRecord.Initialize(true, RandomFixedReference(), RandomFixedReference());

            WriteRecordWithOldFormat(oldFormatRecord);

            assertFalse("This should be single unit record.", oldFormatRecord.HasSecondaryUnitId());
            assertFalse("Old format is not aware about fixed references.", oldFormatRecord.UseFixedReferences);

            _recordFormat.read(newFormatRecord, _pageCursor, RecordLoad.NORMAL, PropertyRecordFormat.RECORD_SIZE);
            VerifySameReferences(oldFormatRecord, newFormatRecord);
        }
示例#9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void notInUseRecordEquality()
        public virtual void NotInUseRecordEquality()
        {
            PropertyRecord record1 = new PropertyRecord(1);

            record1.Initialize(false, 1, 2);
            record1.SecondaryUnitId = 42;

            PropertyRecord record2 = new PropertyRecord(1);

            record2.Initialize(false, 11, 22);
            record2.SecondaryUnitId = 24;

            PropertyCheckType check = new PropertyCheckType();

            assertTrue(check.Equal(record1, record2));
        }