コード例 #1
0
ファイル: StringIndexKeyTest.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldDereferenceByteArrayWhenMaterializingValue()
        internal virtual void ShouldDereferenceByteArrayWhenMaterializingValue()
        {
            // given
            StringIndexKey key = new StringIndexKey();

            key.BytesLength = 20;
            sbyte[] first = key.Bytes;

            // when
            key.AsValue();
            key.BytesLength = 25;
            sbyte[] second = key.Bytes;

            // then
            assertNotSame(first, second);
        }
コード例 #2
0
ファイル: StringIndexKeyTest.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReuseByteArrayForFairlySimilarSizedKeys()
        internal virtual void ShouldReuseByteArrayForFairlySimilarSizedKeys()
        {
            // given
            StringIndexKey key = new StringIndexKey();

            key.BytesLength = 20;
            sbyte[] first = key.Bytes;

            // when
            key.BytesLength = 25;
            sbyte[] second = key.Bytes;

            // then
            assertSame(first, second);
            assertThat(first.Length, greaterThanOrEqualTo(25));
        }
コード例 #3
0
ファイル: StringIndexKeyTest.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldCreateNewByteArrayForVastlyDifferentKeySizes()
        internal virtual void ShouldCreateNewByteArrayForVastlyDifferentKeySizes()
        {
            // given
            StringIndexKey key = new StringIndexKey();

            key.BytesLength = 20;
            sbyte[] first = key.Bytes;

            // when
            key.BytesLength = 100;
            sbyte[] second = key.Bytes;

            // then
            assertNotSame(first, second);
            assertThat(first.Length, greaterThanOrEqualTo(20));
            assertThat(second.Length, greaterThanOrEqualTo(100));
        }
コード例 #4
0
ファイル: StringIndexKeyTest.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void minimalSplitterForSameValueShouldDivideLeftAndRight()
        internal virtual void MinimalSplitterForSameValueShouldDivideLeftAndRight()
        {
            // Given
            StringLayout   layout          = new StringLayout();
            StringIndexKey left            = layout.NewKey();
            StringIndexKey right           = layout.NewKey();
            StringIndexKey minimalSplitter = layout.NewKey();

            // keys with same value but different entityId
            TextValue value = _random.randomValues().nextTextValue();

            left.Initialize(1);
            right.Initialize(2);
            left.initFromValue(0, value, NEUTRAL);
            right.initFromValue(0, value, NEUTRAL);

            // When creating minimal splitter
            layout.MinimalSplitter(left, right, minimalSplitter);

            // Then that minimal splitter need to correctly divide left and right
            assertTrue(layout.Compare(left, minimalSplitter) < 0, "Expected minimal splitter to be strictly greater than left but wasn't for value " + value);
            assertTrue(layout.Compare(minimalSplitter, right) <= 0, "Expected right to be greater than or equal to minimal splitter but wasn't for value " + value);
        }
コード例 #5
0
ファイル: StringIndexKeyTest.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void minimalSplitterShouldRemoveEntityIdIfPossible()
        internal virtual void MinimalSplitterShouldRemoveEntityIdIfPossible()
        {
            // Given
            StringLayout   layout          = new StringLayout();
            StringIndexKey left            = layout.NewKey();
            StringIndexKey right           = layout.NewKey();
            StringIndexKey minimalSplitter = layout.NewKey();

            string    @string    = _random.nextString();
            TextValue leftValue  = Values.stringValue(@string);
            TextValue rightValue = Values.stringValue(@string + _random.randomValues().nextCharRaw());

            // keys with unique values
            left.Initialize(1);
            left.initFromValue(0, leftValue, NEUTRAL);
            right.Initialize(2);
            right.initFromValue(0, rightValue, NEUTRAL);

            // When creating minimal splitter
            layout.MinimalSplitter(left, right, minimalSplitter);

            // Then that minimal splitter should have entity id shaved off
            assertEquals(NO_ENTITY_ID, minimalSplitter.EntityId, "Expected minimal splitter to have entityId removed when constructed from keys with unique values: " + "left=" + leftValue + ", right=" + rightValue);
        }