示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void comparePointsMustOnlyReturnZeroForEqualPoints()
        internal virtual void ComparePointsMustOnlyReturnZeroForEqualPoints()
        {
            PointValue firstPoint             = _random.randomValues().nextPointValue();
            PointValue equalPoint             = Values.point(firstPoint);
            CoordinateReferenceSystem crs     = firstPoint.CoordinateReferenceSystem;
            SpaceFillingCurve         curve   = _noSpecificIndexSettings.forCrs(crs, false);
            long?      spaceFillingCurveValue = curve.DerivedValueFor(firstPoint.Coordinate());
            PointValue centerPoint            = Values.pointValue(crs, curve.CenterPointFor(spaceFillingCurveValue.Value));

            GenericKey firstKey = NewKeyState();

            firstKey.WriteValue(firstPoint, NEUTRAL);
            GenericKey equalKey = NewKeyState();

            equalKey.WriteValue(equalPoint, NEUTRAL);
            GenericKey centerKey = NewKeyState();

            centerKey.WriteValue(centerPoint, NEUTRAL);
            GenericKey noCoordsKey = NewKeyState();

            noCoordsKey.WriteValue(equalPoint, NEUTRAL);
            GeometryType.NoCoordinates = noCoordsKey;

            assertEquals(0, firstKey.CompareValueTo(equalKey), "expected keys to be equal");
            assertEquals(firstPoint.CompareTo(centerPoint) != 0, firstKey.CompareValueTo(centerKey) != 0, "expected keys to be equal if and only if source points are equal");
            assertEquals(0, firstKey.CompareValueTo(noCoordsKey), "expected keys to be equal");
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void copyShouldCopyExtremeValues()
        internal virtual void CopyShouldCopyExtremeValues()
        {
            // Given
            GenericKey extreme = NewKeyState();
            GenericKey copy    = NewKeyState();

            foreach (ValueGroup valueGroup in ValueGroup.values())
            {
                if (valueGroup != ValueGroup.NO_VALUE)
                {
                    extreme.InitValueAsLowest(valueGroup);
                    copy.CopyFrom(extreme);
                    assertEquals(0, extreme.CompareValueTo(copy), "states not equals after copy, valueGroup=" + valueGroup);
                    extreme.InitValueAsHighest(valueGroup);
                    copy.CopyFrom(extreme);
                    assertEquals(0, extreme.CompareValueTo(copy), "states not equals after copy, valueGroup=" + valueGroup);
                }
            }
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void comparePointArraysMustOnlyReturnZeroForEqualArrays()
        internal virtual void ComparePointArraysMustOnlyReturnZeroForEqualArrays()
        {
            PointArray firstArray = _random.randomValues().nextPointArray();

            PointValue[] sourcePointValues = firstArray.AsObjectCopy();
            PointArray   equalArray        = Values.pointArray(sourcePointValues);

            PointValue[] centerPointValues = new PointValue[sourcePointValues.Length];
            for (int i = 0; i < sourcePointValues.Length; i++)
            {
                PointValue sourcePointValue     = sourcePointValues[i];
                CoordinateReferenceSystem crs   = sourcePointValue.CoordinateReferenceSystem;
                SpaceFillingCurve         curve = _noSpecificIndexSettings.forCrs(crs, false);
                long?spaceFillingCurveValue     = curve.DerivedValueFor(sourcePointValue.Coordinate());
                centerPointValues[i] = Values.pointValue(crs, curve.CenterPointFor(spaceFillingCurveValue.Value));
            }
            PointArray centerArray = Values.pointArray(centerPointValues);

            GenericKey firstKey = NewKeyState();

            firstKey.WriteValue(firstArray, NEUTRAL);
            GenericKey equalKey = NewKeyState();

            equalKey.WriteValue(equalArray, NEUTRAL);
            GenericKey centerKey = NewKeyState();

            centerKey.WriteValue(centerArray, NEUTRAL);
            GenericKey noCoordsKey = NewKeyState();

            noCoordsKey.WriteValue(equalArray, NEUTRAL);
            GeometryType.NoCoordinates = noCoordsKey;

            assertEquals(0, firstKey.CompareValueTo(equalKey), "expected keys to be equal");
            assertEquals(firstArray.compareToSequence(centerArray, AnyValues.COMPARATOR) != 0, firstKey.CompareValueTo(centerKey) != 0, "expected keys to be equal if and only if source points are equal");
            assertEquals(0, firstKey.CompareValueTo(noCoordsKey), "expected keys to be equal");
        }
示例#4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ParameterizedTest @MethodSource("validValueGenerators") void copyShouldCopy(ValueGenerator valueGenerator)
        internal virtual void CopyShouldCopy(ValueGenerator valueGenerator)
        {
            // Given
            GenericKey from  = NewKeyState();
            Value      value = valueGenerator();

            from.WriteValue(value, NEUTRAL);
            GenericKey to = GenericKeyStateWithSomePreviousState(valueGenerator);

            // When
            to.CopyFrom(from);

            // Then
            assertEquals(0, from.CompareValueTo(to), "states not equals after copy");
        }
示例#5
0
        /* TESTS FOR SLOT STATE (not including entityId) */

//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ParameterizedTest @MethodSource("validValueGenerators") void readWhatIsWritten(ValueGenerator valueGenerator)
        internal virtual void ReadWhatIsWritten(ValueGenerator valueGenerator)
        {
            // Given
            PageCursor cursor     = NewPageCursor();
            GenericKey writeState = NewKeyState();
            Value      value      = valueGenerator();
            int        offset     = cursor.Offset;

            // When
            writeState.WriteValue(value, NEUTRAL);
            writeState.Put(cursor);

            // Then
            GenericKey readState = NewKeyState();
            int        size      = writeState.Size();

            cursor.Offset = offset;
            assertTrue(readState.Get(cursor, size), "failed to read");
            assertEquals(0, readState.CompareValueTo(writeState), "key states are not equal");
            Value readValue = readState.AsValue();

            assertEquals(value, readValue, "deserialized values are not equal");
        }