private static TryCatch <PartitionMapping <CompositeContinuationToken> > TryGetPartitionKeyRangeToCompositeContinuationToken(
            IReadOnlyList <PartitionKeyRange> partitionKeyRanges,
            CosmosElement continuationToken)
        {
            if (continuationToken == null)
            {
                Dictionary <PartitionKeyRange, CompositeContinuationToken> dictionary = new Dictionary <PartitionKeyRange, CompositeContinuationToken>();
                foreach (PartitionKeyRange partitionKeyRange in partitionKeyRanges)
                {
                    dictionary.Add(key: partitionKeyRange, value: null);
                }

                return(TryCatch <PartitionMapping <CompositeContinuationToken> > .FromResult(
                           new PartitionMapping <CompositeContinuationToken>(
                               partitionsLeftOfTarget : new Dictionary <PartitionKeyRange, CompositeContinuationToken>(),
                               targetPartition : dictionary,
                               partitionsRightOfTarget : new Dictionary <PartitionKeyRange, CompositeContinuationToken>())));
            }

            TryCatch <IReadOnlyList <CompositeContinuationToken> > tryParseCompositeContinuationTokens = TryParseCompositeContinuationList(continuationToken);

            if (!tryParseCompositeContinuationTokens.Succeeded)
            {
                return(TryCatch <PartitionMapping <CompositeContinuationToken> > .FromException(tryParseCompositeContinuationTokens.Exception));
            }

            return(CosmosCrossPartitionQueryExecutionContext.TryGetInitializationInfo <CompositeContinuationToken>(
                       partitionKeyRanges,
                       tryParseCompositeContinuationTokens.Result));
        }
        private static void RunTryGetInitializationInfo(
            IReadOnlyDictionary <PartitionKeyRange, IPartitionedToken> expectedMappingLeftPartitions,
            IReadOnlyDictionary <PartitionKeyRange, IPartitionedToken> expectedMappingTargetPartition,
            IReadOnlyDictionary <PartitionKeyRange, IPartitionedToken> expectedMappingRightPartitions,
            IEnumerable <PartitionKeyRange> partitionKeyRanges,
            IEnumerable <IPartitionedToken> partitionedTokens)
        {
            TryCatch <PartitionMapping <IPartitionedToken> > tryGetInitializationInfo = CosmosCrossPartitionQueryExecutionContext.TryGetInitializationInfo(
                partitionKeyRanges.OrderBy(x => Guid.NewGuid()).ToArray(),
                partitionedTokens.OrderBy(x => Guid.NewGuid()).ToList());

            Assert.IsTrue(tryGetInitializationInfo.Succeeded);
            PartitionMapping <IPartitionedToken> partitionMapping = tryGetInitializationInfo.Result;

            AssertPartitionMappingAreEqual(expectedMappingLeftPartitions, partitionMapping.PartitionsLeftOfTarget);
            AssertPartitionMappingAreEqual(expectedMappingTargetPartition, partitionMapping.TargetPartition);
            AssertPartitionMappingAreEqual(expectedMappingRightPartitions, partitionMapping.PartitionsRightOfTarget);
        }