public async Task ConflictsFeedSetsPartitionKeyRangeIdentity() { CosmosContainerCore container = CosmosConflictTests.GetMockedContainer((request, cancellationToken) => { Assert.IsNotNull(request.DocumentServiceRequest.PartitionKeyRangeIdentity); return(TestHandler.ReturnSuccess()); }); FeedIterator iterator = container.GetConflicts().GetConflictsStreamIterator(); while (iterator.HasMoreResults) { CosmosResponseMessage responseMessage = await iterator.FetchNextSetAsync(); } }
public void ReadConflictContentDeserializesContent() { CosmosContainerCore container = CosmosConflictTests.GetMockedContainer((request, cancellationToken) => { return(TestHandler.ReturnSuccess()); }); JObject someJsonObject = new JObject(); someJsonObject["id"] = Guid.NewGuid().ToString(); someJsonObject["someInt"] = 2; CosmosConflictSettings conflictSettings = new CosmosConflictSettings(); conflictSettings.Content = someJsonObject.ToString(); Assert.AreEqual(someJsonObject.ToString(), container.GetConflicts().ReadConflictContent <JObject>(conflictSettings).ToString()); }
public async Task DeleteSendsCorrectPayload() { const string expectedId = "something"; Cosmos.PartitionKey partitionKey = new Cosmos.PartitionKey("pk"); Uri expectedRequestUri = new Uri($"/dbs/conflictsDb/colls/conflictsColl/conflicts/{expectedId}", UriKind.Relative); CosmosContainerCore container = CosmosConflictTests.GetMockedContainer((request, cancellationToken) => { Assert.AreEqual(OperationType.Delete, request.OperationType); Assert.AreEqual(ResourceType.Conflict, request.ResourceType); Assert.AreEqual(expectedRequestUri, request.RequestUri); return(TestHandler.ReturnSuccess()); }); CosmosConflictSettings conflictSettings = new CosmosConflictSettings(); conflictSettings.Id = expectedId; await container.GetConflicts().DeleteConflictAsync(partitionKey, conflictSettings); }
public async Task ReadCurrentGetsCorrectRID() { const string expectedRID = "something"; Cosmos.PartitionKey partitionKey = new Cosmos.PartitionKey("pk"); // Using "test" as container name because the Mocked DocumentClient has it hardcoded Uri expectedRequestUri = new Uri($"dbs/conflictsDb/colls/test/docs/{expectedRID}", UriKind.Relative); CosmosContainerCore container = CosmosConflictTests.GetMockedContainer((request, cancellationToken) => { Assert.AreEqual(OperationType.Read, request.OperationType); Assert.AreEqual(ResourceType.Document, request.ResourceType); Assert.AreEqual(expectedRequestUri, request.RequestUri); return(TestHandler.ReturnSuccess()); }); CosmosConflictSettings conflictSettings = new CosmosConflictSettings(); conflictSettings.SourceResourceId = expectedRID; await container.GetConflicts().ReadCurrentAsync <JObject>(partitionKey, conflictSettings); }