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()
        {
            ContainerCore container = CosmosConflictTests.GetMockedContainer((request, cancellationToken) => {
                return(TestHandler.ReturnSuccess());
            });

            JObject someJsonObject = new JObject();

            someJsonObject["id"]      = Guid.NewGuid().ToString();
            someJsonObject["someInt"] = 2;

            ConflictProperties conflictSettings = new ConflictProperties();

            conflictSettings.Content = someJsonObject.ToString();

            Assert.AreEqual(someJsonObject.ToString(), container.Conflicts.ReadConflictContent <JObject>(conflictSettings).ToString());
        }
        public async Task DeleteSendsCorrectPayload()
        {
            const string        expectedId         = "something";
            const string        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.Conflicts.DeleteConflictAsync(partitionKey, conflictSettings);
        }
        public async Task ReadCurrentGetsCorrectRID()
        {
            const string expectedRID  = "something";
            const string 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.Conflicts.ReadCurrentAsync <JObject>(partitionKey, conflictSettings);
        }
 private static ContainerCore GetMockedContainer(Func <RequestMessage,
                                                       CancellationToken, Task <ResponseMessage> > handlerFunc)
 {
     return(new ContainerCore(CosmosConflictTests.GetMockedClientContext(handlerFunc), MockCosmosUtil.CreateMockDatabase("conflictsDb").Object, "conflictsColl"));
 }