public async Task FeedRangePKRangeId_GetEffectiveRangesAsync_Null() { Documents.PartitionKeyRange partitionKeyRange = new Documents.PartitionKeyRange() { Id = Guid.NewGuid().ToString(), MinInclusive = "AA", MaxExclusive = "BB" }; FeedRangePartitionKeyRange feedRangePartitionKeyRange = new FeedRangePartitionKeyRange(partitionKeyRange.Id); Routing.IRoutingMapProvider routingProvider = Mock.Of <Routing.IRoutingMapProvider>(); Mock.Get(routingProvider) .SetupSequence(f => f.TryGetPartitionKeyRangeByIdAsync(It.IsAny <string>(), It.IsAny <string>(), It.Is <bool>(b => true))) .ReturnsAsync((Documents.PartitionKeyRange)null) .ReturnsAsync((Documents.PartitionKeyRange)null); List <Documents.Routing.Range <string> > ranges = await feedRangePartitionKeyRange.GetEffectiveRangesAsync(routingProvider, null, null); }
public async Task FeedRangePKRangeId_GetEffectiveRangesAsync() { Documents.PartitionKeyRange partitionKeyRange = new Documents.PartitionKeyRange() { Id = Guid.NewGuid().ToString(), MinInclusive = "AA", MaxExclusive = "BB" }; FeedRangePartitionKeyRange feedRangePartitionKeyRange = new FeedRangePartitionKeyRange(partitionKeyRange.Id); Routing.IRoutingMapProvider routingProvider = Mock.Of <Routing.IRoutingMapProvider>(); Mock.Get(routingProvider) .Setup(f => f.TryGetPartitionKeyRangeByIdAsync(It.IsAny <string>(), It.Is <string>(s => s == partitionKeyRange.Id), It.IsAny <bool>())) .ReturnsAsync(partitionKeyRange); List <Documents.Routing.Range <string> > ranges = await feedRangePartitionKeyRange.GetEffectiveRangesAsync(routingProvider, null, null); Assert.AreEqual(1, ranges.Count); Assert.AreEqual(partitionKeyRange.ToRange().Min, ranges[0].Min); Assert.AreEqual(partitionKeyRange.ToRange().Max, ranges[0].Max); }
public async Task FeedRangePKRangeId_GetEffectiveRangesAsync_Null() { Documents.PartitionKeyRange partitionKeyRange = new Documents.PartitionKeyRange() { Id = Guid.NewGuid().ToString(), MinInclusive = "AA", MaxExclusive = "BB" }; FeedRangePartitionKeyRange feedRangePartitionKeyRange = new FeedRangePartitionKeyRange(partitionKeyRange.Id); IRoutingMapProvider routingProvider = Mock.Of <IRoutingMapProvider>(); Mock.Get(routingProvider) .SetupSequence(f => f.TryGetPartitionKeyRangeByIdAsync(It.IsAny <string>(), It.IsAny <string>(), It.Is <bool>(b => true))) .ReturnsAsync((Documents.PartitionKeyRange)null) .ReturnsAsync((Documents.PartitionKeyRange)null); CosmosException exception = await Assert.ThrowsExceptionAsync <CosmosException>(() => feedRangePartitionKeyRange.GetEffectiveRangesAsync(routingProvider, null, null)); Assert.AreEqual(HttpStatusCode.Gone, exception.StatusCode); Assert.AreEqual((int)Documents.SubStatusCodes.PartitionKeyRangeGone, exception.SubStatusCode); }