public ChangeFeedIteratorCore( ContainerInternal container, ChangeFeedStartFrom changeFeedStartFrom, ChangeFeedRequestOptions changeFeedRequestOptions) { this.container = container ?? throw new ArgumentNullException(nameof(container)); this.clientContext = container.ClientContext; this.changeFeedOptions = changeFeedRequestOptions ?? new ChangeFeedRequestOptions(); this.lazyContainerRid = new AsyncLazy <TryCatch <string> >(valueFactory: (innerCancellationToken) => { return(this.TryInitializeContainerRIdAsync(innerCancellationToken)); }); this.hasMoreResults = true; this.changeFeedStartFrom = changeFeedStartFrom; if (this.changeFeedStartFrom is ChangeFeedStartFromContinuation startFromContinuation) { if (!FeedRangeContinuation.TryParse(startFromContinuation.Continuation, out FeedRangeContinuation feedRangeContinuation)) { throw new ArgumentException(string.Format(ClientResources.FeedToken_UnknownFormat, startFromContinuation.Continuation)); } this.FeedRangeContinuation = feedRangeContinuation; FeedRange feedRange = feedRangeContinuation.GetFeedRange(); string etag = feedRangeContinuation.GetContinuation(); this.changeFeedStartFrom = new ChangeFeedStartFromContinuationAndFeedRange(etag, (FeedRangeInternal)feedRange); } }
public async Task SingleTaskScheduler_ExecutorTest() { CosmosClientContext context = this.MockClientContext(); DatabaseInternal db = new DatabaseInlineCore(context, "test"); List <Task <ContainerInternal> > tasks = new List <Task <ContainerInternal> >(); for (int i = 0; i < 20; i++) { tasks.Add( Task.Factory.StartNew(() => (ContainerInternal) new ContainerInlineCore(context, db, "test"), CancellationToken.None, TaskCreationOptions.None, new SingleTaskScheduler())); } await Task.WhenAll(tasks); BatchAsyncContainerExecutor firstExecutor = tasks[0].Result.BatchExecutor; Assert.IsNotNull(firstExecutor); for (int i = 1; i < 20; i++) { BatchAsyncContainerExecutor otherExecutor = tasks[i].Result.BatchExecutor; Assert.AreEqual(firstExecutor, otherExecutor); } }
public async Task ValidateActivityIdWithSynchronizationContext() { Mock <SynchronizationContext> mockSynchronizationContext = new Mock <SynchronizationContext>() { CallBase = true }; using CosmosClient cosmosClient = MockCosmosUtil.CreateMockCosmosClient(); CosmosClientContext clientContext = ClientContextCore.Create( cosmosClient, new MockDocumentClient(), new CosmosClientOptions()); try { SynchronizationContext.SetSynchronizationContext(mockSynchronizationContext.Object); Guid result = await clientContext.OperationHelperAsync <Guid>( nameof(ValidateActivityIdWithSynchronizationContext), new RequestOptions(), (diagnostics) => { return(this.ValidateActivityIdHelper()); }); Assert.AreEqual(Guid.Empty, Trace.CorrelationManager.ActivityId, "ActivityScope was not disposed of"); } finally { SynchronizationContext.SetSynchronizationContext(null); } }
public async Task AllowBatchingRequestsSendsToExecutor_ReadStream() { CosmosClientContext cosmosClientContext = this.CreateMockBulkCosmosClientContext(); DatabaseCore db = new DatabaseCore(cosmosClientContext, "test"); ExecutorContainerCore container = new ExecutorContainerCore(cosmosClientContext, db, "test"); dynamic testItem = new { id = Guid.NewGuid().ToString(), pk = "FF627B77-568E-4541-A47E-041EAC10E46F", }; using (Stream itemStream = MockCosmosUtil.Serializer.ToStream <dynamic>(testItem)) { ItemRequestOptions itemRequestOptions = new ItemRequestOptions(); Cosmos.PartitionKey partitionKey = new Cosmos.PartitionKey(testItem.pk); using (ResponseMessage streamResponse = await container.ReadItemStreamAsync( partitionKey: partitionKey, id: testItem.id)) { container.MockedExecutor.Verify(c => c.AddAsync(It.IsAny <ItemBatchOperation>(), It.IsAny <ItemRequestOptions>(), It.IsAny <CancellationToken>()), Times.Once); } } }
internal ScriptsCore( ContainerInternal container, CosmosClientContext clientContext) { this.container = container; this.clientContext = clientContext; }
private static CosmosClientContext GetMockedClientContext( Func <RequestMessage, CancellationToken, Task <ResponseMessage> > handlerFunc) { CosmosClient client = MockCosmosUtil.CreateMockCosmosClient(); CosmosClientContext clientContext = ClientContextCore.Create( client, new MockDocumentClient(), new CosmosClientOptions()); Mock <PartitionRoutingHelper> partitionRoutingHelperMock = MockCosmosUtil.GetPartitionRoutingHelperMock("0"); PartitionKeyRangeHandler partitionKeyRangeHandler = new PartitionKeyRangeHandler(client, partitionRoutingHelperMock.Object); TestHandler testHandler = new TestHandler(handlerFunc); partitionKeyRangeHandler.InnerHandler = testHandler; RequestHandler handler = clientContext.RequestHandler.InnerHandler; while (handler != null) { if (handler.InnerHandler is RouterHandler) { handler.InnerHandler = new RouterHandler(partitionKeyRangeHandler, testHandler); break; } handler = handler.InnerHandler; } return(clientContext); }
public ClientConfigurationTraceDatum(CosmosClientContext cosmosClientContext, DateTime startTime) { this.ClientCreatedDateTimeUtc = startTime; this.UserAgentContainer = cosmosClientContext.DocumentClient.ConnectionPolicy.UserAgentContainer; this.GatewayConnectionConfig = new GatewayConnectionConfig(cosmosClientContext.ClientOptions.GatewayModeMaxConnectionLimit, cosmosClientContext.ClientOptions.RequestTimeout, cosmosClientContext.ClientOptions.WebProxy, cosmosClientContext.ClientOptions.HttpClientFactory); this.RntbdConnectionConfig = cosmosClientContext.DocumentClient.RecordTcpSettings(this); this.OtherConnectionConfig = new OtherConnectionConfig(cosmosClientContext.ClientOptions.LimitToEndpoint, cosmosClientContext.ClientOptions.AllowBulkExecution); this.ConsistencyConfig = new ConsistencyConfig(cosmosClientContext.ClientOptions.ConsistencyLevel, cosmosClientContext.ClientOptions.ApplicationPreferredRegions, cosmosClientContext.ClientOptions.ApplicationRegion); this.cachedNumberOfClientCreated = CosmosClient.numberOfClientsCreated; this.cachedNumberOfActiveClient = CosmosClient.NumberOfActiveClients; this.cachedUserAgentString = this.UserAgentContainer.UserAgent; this.cachedMachineId = VmMetadataApiHandler.GetMachineId(); this.cachedSerializedJson = this.GetSerializedDatum(); this.ProcessorCount = Environment.ProcessorCount; this.ConnectionMode = cosmosClientContext.ClientOptions.ConnectionMode; this.cachedVMRegion = VmMetadataApiHandler.GetMachineRegion(); }
internal ScriptsInlineCore( ContainerInternal container, CosmosClientContext clientContext) : base( container, clientContext) { }
public async Task ChangeFeedIteratorCore_HandlesSplitsThroughPipeline() { int executionCount = 0; CosmosClientContext cosmosClientContext = GetMockedClientContext((RequestMessage requestMessage, CancellationToken cancellationToken) => { // Force OnBeforeRequestActions call requestMessage.ToDocumentServiceRequest(); if (executionCount++ == 0) { return(TestHandler.ReturnStatusCode(HttpStatusCode.Gone, Documents.SubStatusCodes.PartitionKeyRangeGone)); } return(TestHandler.ReturnStatusCode(HttpStatusCode.OK)); }); ContainerInternal containerCore = Mock.Of <ContainerInternal>(); Mock.Get(containerCore) .Setup(c => c.ClientContext) .Returns(cosmosClientContext); Mock.Get(containerCore) .Setup(c => c.LinkUri) .Returns(new Uri("https://dummy.documents.azure.com:443/dbs")); FeedRangeInternal range = Mock.Of <FeedRangeInternal>(); Mock.Get(range) .Setup(f => f.Accept(It.IsAny <FeedRangeVisitor>())); FeedRangeContinuation feedToken = Mock.Of <FeedRangeContinuation>(); Mock.Get(feedToken) .Setup(f => f.Accept(It.IsAny <FeedRangeVisitor>(), It.IsAny <Action <RequestMessage, string> >())); Mock.Get(feedToken) .Setup(f => f.FeedRange) .Returns(range); Mock.Get(feedToken) .Setup(f => f.Accept(It.IsAny <FeedRangeVisitor>(), It.IsAny <Action <RequestMessage, string> >())); Mock.Get(feedToken) .Setup(f => f.HandleSplitAsync(It.Is <ContainerInternal>(c => c == containerCore), It.IsAny <ResponseMessage>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult(Documents.ShouldRetryResult.NoRetry())); Mock.Get(feedToken) .Setup(f => f.HandleChangeFeedNotModified(It.IsAny <ResponseMessage>())) .Returns(Documents.ShouldRetryResult.NoRetry()); ChangeFeedIteratorCore changeFeedIteratorCore = new ChangeFeedIteratorCore(containerCore, feedToken, null); ResponseMessage response = await changeFeedIteratorCore.ReadNextAsync(); Assert.AreEqual(1, executionCount, "PartitionKeyRangeGoneRetryHandler handled the Split"); Assert.AreEqual(HttpStatusCode.Gone, response.StatusCode); Mock.Get(feedToken) .Verify(f => f.ReplaceContinuation(It.IsAny <string>()), Times.Never); Mock.Get(feedToken) .Verify(f => f.HandleSplitAsync(It.Is <ContainerInternal>(c => c == containerCore), It.IsAny <ResponseMessage>(), It.IsAny <CancellationToken>()), Times.Once); Mock.Get(feedToken) .Verify(f => f.HandleChangeFeedNotModified(It.IsAny <ResponseMessage>()), Times.Once); }
public MockCosmosQueryClient( CosmosClientContext clientContext, ContainerInternal cosmosContainerCore, bool forceQueryPlanGatewayElseServiceInterop) : base( clientContext, cosmosContainerCore) { this.forceQueryPlanGatewayElseServiceInterop = forceQueryPlanGatewayElseServiceInterop; }
public void Null_When_OptionsOff() { CosmosClientContext context = this.MockClientContext(allowBulkExecution: false); DatabaseInternal db = new DatabaseInlineCore(context, "test"); ContainerInternal container = new ContainerInlineCore(context, db, "test"); Assert.IsNull(container.BatchExecutor); }
public ExecutorContainerCore( CosmosClientContext clientContext, DatabaseCore database, string containerId) : base(clientContext, database, containerId) { this.MockedExecutor .Setup(e => e.AddAsync(It.IsAny <ItemBatchOperation>(), It.IsAny <ItemRequestOptions>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new TransactionalBatchOperationResult(HttpStatusCode.OK)); }
private ChangeFeedPartitionKeyResultSetIteratorCore( ContainerInternal container, ChangeFeedStartFrom changeFeedStartFrom, ChangeFeedRequestOptions options) { this.container = container ?? throw new ArgumentNullException(nameof(container)); this.changeFeedStartFrom = changeFeedStartFrom ?? throw new ArgumentNullException(nameof(changeFeedStartFrom)); this.clientContext = this.container.ClientContext; this.changeFeedOptions = options; }
public ExecutorWithThrottlingContainerCore( CosmosClientContext clientContext, DatabaseCore database, string containerId) : base(clientContext, database, containerId) { this.MockedExecutor .SetupSequence(e => e.AddAsync(It.IsAny <ItemBatchOperation>(), It.IsAny <ItemRequestOptions>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new BatchOperationResult((HttpStatusCode)StatusCodes.TooManyRequests)) .ReturnsAsync(new BatchOperationResult(HttpStatusCode.OK)); }
public void InitializeBatchExecutorForContainer_Null_WhenAllowBulk_False() { string databaseId = "db1234"; string crId = "cr42"; CosmosClientContext context = this.CreateMockClientContext(); DatabaseInternal db = new DatabaseInlineCore(context, databaseId); ContainerInternal container = new ContainerInlineCore(context, db, crId); Assert.IsNull(container.BatchExecutor); }
internal ContainerBuilder( Database cosmosContainers, CosmosClientContext clientContext, string name, string partitionKeyPath = null) : base(name, partitionKeyPath) { this.database = cosmosContainers; this.clientContext = clientContext; this.containerUri = UriFactory.CreateDocumentCollectionUri(this.database.Id, name); }
public ChangeFeedPartitionKeyResultSetIteratorCore( CosmosClientContext clientContext, ContainerInternal container, ChangeFeedStartFrom changeFeedStartFrom, ChangeFeedRequestOptions options) { this.clientContext = clientContext ?? throw new ArgumentNullException(nameof(clientContext)); this.container = container ?? throw new ArgumentNullException(nameof(container)); this.changeFeedStartFrom = changeFeedStartFrom; this.changeFeedOptions = options; }
public void InitializeBatchExecutorForContainer_NotNull_WhenAllowBulk_True() { string databaseId = "db1234"; string crId = "cr42"; CosmosClientContext context = this.CreateMockClientContext(allowBulkExecution: true); DatabaseCore db = new DatabaseCore(context, databaseId); ContainerCore container = new ContainerCore(context, db, crId); Assert.IsNotNull(container.BatchExecutor); }
/// <summary> /// Creates an instance of ContainerBuilder . /// </summary> /// <param name="database"> The Microsoft.Azure.Cosmos.Database object.</param> /// <param name="name"> Azure Cosmos container name to create. </param> /// <param name="partitionKeyPath"> The path to the partition key. Example: /partitionKey </param> public ContainerBuilder( Database database, string name, string partitionKeyPath) : base( string.IsNullOrEmpty(name) ? throw new ArgumentNullException(nameof(name)) : name, string.IsNullOrEmpty(partitionKeyPath) ? throw new ArgumentNullException(nameof(partitionKeyPath)) : partitionKeyPath) { this.database = database ?? throw new ArgumentNullException(nameof(database)); this.clientContext = database.Client.ClientContext; this.containerUri = UriFactory.CreateDocumentCollectionUri(this.database.Id, name); }
public ItemBatchOperation( OperationType operationType, int operationIndex, PartitionKey partitionKey, T resource, string id = null, TransactionalBatchItemRequestOptions requestOptions = null, CosmosClientContext cosmosClientContext = null) : base(operationType, operationIndex, partitionKey: partitionKey, id: id, requestOptions: requestOptions, cosmosClientContext: cosmosClientContext) { this.Resource = resource; }
public void ClientConfigWithOptionsTest() { CosmosClientOptions options = new CosmosClientOptions { RequestTimeout = TimeSpan.FromSeconds(50), OpenTcpConnectionTimeout = TimeSpan.FromSeconds(30), GatewayModeMaxConnectionLimit = 20, MaxRequestsPerTcpConnection = 30, MaxTcpConnectionsPerEndpoint = 30, LimitToEndpoint = true, ConsistencyLevel = ConsistencyLevel.Session }; CosmosClient cosmosClient = TestCommon.CreateCosmosClient(options); RntbdConnectionConfig tcpconfig = cosmosClient.ClientConfigurationTraceDatum.RntbdConnectionConfig; Assert.AreEqual(tcpconfig.ConnectionTimeout, 30); Assert.AreEqual(tcpconfig.IdleConnectionTimeout, -1); Assert.AreEqual(tcpconfig.MaxRequestsPerChannel, 30); Assert.AreEqual(tcpconfig.TcpEndpointRediscovery, true); GatewayConnectionConfig gwConfig = cosmosClient.ClientConfigurationTraceDatum.GatewayConnectionConfig; Assert.AreEqual(gwConfig.UserRequestTimeout, 50); Assert.AreEqual(gwConfig.MaxConnectionLimit, 20); ConsistencyConfig consistencyConfig = cosmosClient.ClientConfigurationTraceDatum.ConsistencyConfig; Assert.AreEqual(consistencyConfig.ConsistencyLevel.Value, ConsistencyLevel.Session); CosmosClientOptions clientOptions = new CosmosClientOptions { ApplicationRegion = "East US" }; CosmosClientContext context = ClientContextCore.Create( cosmosClient, clientOptions); ClientConfigurationTraceDatum clientConfig = new ClientConfigurationTraceDatum(context, DateTime.UtcNow); Assert.AreEqual(clientConfig.ConsistencyConfig.ApplicationRegion, "East US"); Assert.IsNull(clientConfig.ConsistencyConfig.PreferredRegions); Assert.AreEqual(clientConfig.ConnectionMode, ConnectionMode.Direct); clientOptions.ConnectionMode = ConnectionMode.Gateway; context = ClientContextCore.Create( cosmosClient, clientOptions); clientConfig = new ClientConfigurationTraceDatum(context, DateTime.UtcNow); Assert.AreEqual(clientConfig.ConnectionMode, ConnectionMode.Gateway); }
public NetworkAttachedDocumentContainer( ContainerCore container, CosmosQueryClient cosmosQueryClient, CosmosClientContext cosmosClientContext, CosmosDiagnosticsContext diagnosticsContext, QueryRequestOptions queryRequestOptions = null) { this.container = container ?? throw new ArgumentNullException(nameof(container)); this.cosmosQueryClient = cosmosQueryClient ?? throw new ArgumentNullException(nameof(cosmosQueryClient)); this.cosmosClientContext = cosmosClientContext ?? throw new ArgumentNullException(nameof(cosmosClientContext)); this.diagnosticsContext = diagnosticsContext; this.queryRequestOptions = queryRequestOptions; }
private QueryIterator( CosmosQueryContextCore cosmosQueryContext, CosmosQueryExecutionContext cosmosQueryExecutionContext, CosmosSerializationFormatOptions cosmosSerializationFormatOptions, RequestOptions requestOptions, CosmosClientContext clientContext) { this.cosmosQueryContext = cosmosQueryContext ?? throw new ArgumentNullException(nameof(cosmosQueryContext)); this.cosmosQueryExecutionContext = cosmosQueryExecutionContext ?? throw new ArgumentNullException(nameof(cosmosQueryExecutionContext)); this.cosmosSerializationFormatOptions = cosmosSerializationFormatOptions; this.requestOptions = requestOptions; this.clientContext = clientContext ?? throw new ArgumentNullException(nameof(clientContext)); }
private QueryIterator( CosmosQueryContextCore cosmosQueryContext, IQueryPipelineStage cosmosQueryExecutionContext, CosmosSerializationFormatOptions cosmosSerializationFormatOptions, RequestOptions requestOptions, CosmosClientContext clientContext) { this.cosmosQueryContext = cosmosQueryContext ?? throw new ArgumentNullException(nameof(cosmosQueryContext)); this.queryPipelineStage = cosmosQueryExecutionContext ?? throw new ArgumentNullException(nameof(cosmosQueryExecutionContext)); this.cosmosSerializationFormatOptions = cosmosSerializationFormatOptions; this.requestOptions = requestOptions; this.clientContext = clientContext ?? throw new ArgumentNullException(nameof(clientContext)); this.hasMoreResults = true; }
public void ValidateUriGenerationForResources() { string databaseId = "db1234"; string crId = "cr42"; CosmosClientContext context = this.CreateMockClientContext(); DatabaseInternal db = new DatabaseInlineCore(context, databaseId); Assert.AreEqual(db.LinkUri, "dbs/" + databaseId); ContainerInternal container = new ContainerInlineCore(context, db, crId); Assert.AreEqual(container.LinkUri, "dbs/" + databaseId + "/colls/" + crId); }
public async Task ValidateActivityId() { using CosmosClient cosmosClient = MockCosmosUtil.CreateMockCosmosClient(); CosmosClientContext clientContext = ClientContextCore.Create( cosmosClient, new MockDocumentClient(), new CosmosClientOptions()); Guid result = await clientContext.OperationHelperAsync <Guid>( nameof(ValidateActivityId), new RequestOptions(), (trace) => this.ValidateActivityIdHelper()); Assert.AreEqual(Guid.Empty, System.Diagnostics.Trace.CorrelationManager.ActivityId, "ActivityScope was not disposed of"); }
internal StandByFeedIteratorCore( CosmosClientContext clientContext, ContainerCore container, ChangeFeedStartFrom changeFeedStartFrom, ChangeFeedRequestOptions options) { if (container == null) { throw new ArgumentNullException(nameof(container)); } this.clientContext = clientContext; this.container = container; this.changeFeedStartFrom = changeFeedStartFrom ?? throw new ArgumentNullException(nameof(changeFeedStartFrom)); this.changeFeedOptions = options; }
/// <summary> /// System Level and Client level attributes /// </summary> /// <param name="operationName"></param> /// <param name="clientContext"></param> public void Record(string operationName, CosmosClientContext clientContext) { // Other information this.scope.AddAttribute(OpenTelemetryAttributeKeys.DbSystemName, OpenTelemetryCoreRecorder.CosmosDb); this.scope.AddAttribute(OpenTelemetryAttributeKeys.DbOperation, operationName); this.scope.AddAttribute(OpenTelemetryAttributeKeys.MachineId, VmMetadataApiHandler.GetMachineId()); string netPeerName = clientContext.DocumentClient?.accountServiceConfiguration?.AccountProperties?.AccountNameWithCloudInformation; this.scope.AddAttribute(OpenTelemetryAttributeKeys.NetPeerName, netPeerName); // Client Information this.scope.AddAttribute(OpenTelemetryAttributeKeys.ClientId, clientContext.Client.Id); this.scope.AddAttribute(OpenTelemetryAttributeKeys.UserAgent, clientContext.UserAgent); this.scope.AddAttribute(OpenTelemetryAttributeKeys.ConnectionMode, clientContext.ClientOptions.ConnectionMode); }
private (ContainerInternal, Mock <BatchAsyncContainerExecutor>) CreateMockBulkCosmosClientContext() { CosmosClientContext context = MockCosmosUtil.CreateMockCosmosClient( builder => builder.WithBulkExecution(true)).ClientContext; Mock <CosmosClientContext> mockContext = new Mock <CosmosClientContext>(); mockContext.Setup(x => x.CreateLink(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())) .Returns <string, string, string>((x, y, z) => context.CreateLink(x, y, z)); mockContext.Setup(x => x.ClientOptions).Returns(context.ClientOptions); mockContext.Setup(x => x.ResponseFactory).Returns(context.ResponseFactory); mockContext.Setup(x => x.SerializerCore).Returns(context.SerializerCore); mockContext.Setup(x => x.DocumentClient).Returns(context.DocumentClient); mockContext.Setup(x => x.ProcessResourceOperationStreamAsync( It.IsAny <Uri>(), It.IsAny <ResourceType>(), It.IsAny <OperationType>(), It.IsAny <RequestOptions>(), It.IsAny <ContainerInternal>(), It.IsAny <Cosmos.PartitionKey?>(), It.IsAny <string>(), It.IsAny <Stream>(), It.IsAny <Action <RequestMessage> >(), It.IsAny <CosmosDiagnosticsContext>(), It.IsAny <CancellationToken>())).Returns <Uri, ResourceType, OperationType, RequestOptions, ContainerInternal, Cosmos.PartitionKey, string, Stream, Action <RequestMessage>, CosmosDiagnosticsContext, CancellationToken>( (uri, resourceType, operationType, requestOptions, containerInternal, pk, itemId, stream, requestEnricher, diagnostics, cancellationToken) => context.ProcessResourceOperationStreamAsync( uri, resourceType, operationType, requestOptions, containerInternal, pk, itemId, stream, requestEnricher, diagnostics, cancellationToken)); Mock <BatchAsyncContainerExecutor> mockedExecutor = this.GetMockedBatchExcecutor(); mockContext.Setup(x => x.GetExecutorForContainer(It.IsAny <ContainerInternal>())).Returns(mockedExecutor.Object); DatabaseInternal db = new DatabaseInlineCore(mockContext.Object, "test"); ContainerInternal container = new ContainerInlineCore(mockContext.Object, db, "test"); return(container, mockedExecutor); }
public async Task ReadFeedIteratorCore_HandlesSplitsThroughPipeline() { int executionCount = 0; CosmosClientContext cosmosClientContext = GetMockedClientContext((RequestMessage requestMessage, CancellationToken cancellationToken) => { // Force OnBeforeRequestActions call requestMessage.ToDocumentServiceRequest(); if (executionCount++ == 0) { return(TestHandler.ReturnStatusCode(HttpStatusCode.Gone, Documents.SubStatusCodes.PartitionKeyRangeGone)); } return(TestHandler.ReturnStatusCode(HttpStatusCode.OK)); }); ContainerInternal containerCore = Mock.Of <ContainerInternal>(); Mock.Get(containerCore) .Setup(c => c.ClientContext) .Returns(cosmosClientContext); Mock.Get(containerCore) .Setup(c => c.LinkUri) .Returns("/dbs/db/colls/colls"); FeedRangeInternal range = Mock.Of <FeedRangeInternal>(); Mock.Get(range) .Setup(f => f.Accept(It.IsAny <FeedRangeVisitor>())); FeedRangeContinuation feedToken = Mock.Of <FeedRangeContinuation>(); Mock.Get(feedToken) .Setup(f => f.FeedRange) .Returns(range); Mock.Get(feedToken) .Setup(f => f.Accept(It.IsAny <FeedRangeVisitor>(), It.IsAny <Action <RequestMessage, string> >())); Mock.Get(feedToken) .Setup(f => f.HandleSplitAsync(It.Is <ContainerInternal>(c => c == containerCore), It.IsAny <ResponseMessage>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult(Documents.ShouldRetryResult.NoRetry())); FeedRangeIteratorCore changeFeedIteratorCore = new FeedRangeIteratorCore(containerCore, feedToken, new QueryRequestOptions(), Documents.ResourceType.Document, queryDefinition: null); ResponseMessage response = await changeFeedIteratorCore.ReadNextAsync(); Assert.AreEqual(1, executionCount, "Pipeline handled the Split"); Assert.AreEqual(HttpStatusCode.Gone, response.StatusCode); }