public void TestMidPointV2() { PartitionKeyDefinition partitionKey = new PartitionKeyDefinition(); partitionKey.Kind = PartitionKind.Hash; partitionKey.Version = PartitionKeyDefinitionVersion.V2; string middle1 = PartitionKeyInternal.GetMiddleRangeEffectivePartitionKey( PartitionKeyInternal.MinimumInclusiveEffectivePartitionKey, PartitionKeyInternal.MaximumExclusiveEffectivePartitionKey, partitionKey); string expected1 = PartitionKeyInternal.GetMaxExclusiveEffectivePartitionKey(0, 2, partitionKey); Assert.AreEqual(expected1, middle1); // Because of the way ParttitionKeyInternal.GetMaxExclusvieEffectivePartiitonKey calculates // range bounds, we cannot compare exactly - compare approximately. string middle2 = PartitionKeyInternal.GetMiddleRangeEffectivePartitionKey( PartitionKeyInternal.GetMinInclusiveEffectivePartitionKey(3, 8, partitionKey), PartitionKeyInternal.GetMinInclusiveEffectivePartitionKey(3, 8, partitionKey), partitionKey); string middle2Left = PartitionKeyInternal.GetMinInclusiveEffectivePartitionKey(384, 1024, partitionKey); string middle2Right = PartitionKeyInternal.GetMaxExclusiveEffectivePartitionKey(384, 1024, partitionKey); Assert.IsTrue(StringComparer.Ordinal.Compare(middle2, middle2Left) >= 0); Assert.IsTrue(StringComparer.Ordinal.Compare(middle2, middle2Right) < 0); string middle3 = PartitionKeyInternal.GetMiddleRangeEffectivePartitionKey( PartitionKeyInternal.GetMinInclusiveEffectivePartitionKey(24, 25, partitionKey), PartitionKeyInternal.GetMaxExclusiveEffectivePartitionKey(24, 25, partitionKey), partitionKey); //Assert.AreEqual("05C1EFAF0B1F46", middle3); Assert.IsTrue(StringComparer.Ordinal.Compare(middle3, PartitionKeyInternal.GetMinInclusiveEffectivePartitionKey(24, 25, partitionKey)) > 0); Assert.IsTrue(StringComparer.Ordinal.Compare(middle3, PartitionKeyInternal.GetMaxExclusiveEffectivePartitionKey(24, 25, partitionKey)) < 0); }