-
Notifications
You must be signed in to change notification settings - Fork 498
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wired up try get overlapping ranges * update changelog * fixed build issues * could not build * Removed document client method to fix unit test * Added TryGetOverlappingRangesAsync tests * updated changelog
- Loading branch information
1 parent
df298c4
commit 65444de
Showing
3 changed files
with
83 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...soft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosQueryClientCoreTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Azure.Cosmos.Query.Core.QueryClient; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
[TestClass] | ||
public class CosmosQueryClientCoreTest : BaseCosmosClientHelper | ||
{ | ||
private ContainerCore Container = null; | ||
private CosmosQueryClientCore queryClientCore = null; | ||
|
||
[TestInitialize] | ||
public async Task TestInitialize() | ||
{ | ||
await base.TestInit(); | ||
// Throughput needs to be large enough for multiple partitions | ||
ContainerResponse response = await this.database.CreateContainerAsync( | ||
Guid.NewGuid().ToString(), | ||
"/id", | ||
15000, | ||
cancellationToken: this.cancellationToken); | ||
Assert.IsNotNull(response); | ||
Assert.IsNotNull(response.Container); | ||
Assert.IsNotNull(response.Resource); | ||
this.Container = (ContainerCore)response; | ||
this.queryClientCore = new CosmosQueryClientCore(this.Container.ClientContext, this.Container); | ||
} | ||
|
||
[TestCleanup] | ||
public async Task Cleanup() | ||
{ | ||
await base.TestCleanup(); | ||
} | ||
|
||
[TestMethod] | ||
public async Task TryGetOverlappingRangesAsyncTest() | ||
{ | ||
ContainerQueryProperties containerProperties = await this.queryClientCore.GetCachedContainerQueryPropertiesAsync( | ||
containerLink: this.Container.LinkUri, | ||
partitionKey: new PartitionKey("Test"), | ||
cancellationToken: default); | ||
|
||
Assert.IsNotNull(containerProperties); | ||
Assert.IsNotNull(containerProperties.ResourceId); | ||
Assert.IsNotNull(containerProperties.EffectivePartitionKeyString); | ||
|
||
IReadOnlyList<Documents.PartitionKeyRange> pkRange = await this.queryClientCore.TryGetOverlappingRangesAsync( | ||
collectionResourceId: containerProperties.ResourceId, | ||
range: new Documents.Routing.Range<string>("AA", "AB", true, false), | ||
forceRefresh: false); | ||
|
||
Assert.IsNotNull(pkRange); | ||
Assert.AreEqual(1, pkRange.Count); | ||
|
||
IReadOnlyList<Documents.PartitionKeyRange> pkRangeAll = await this.queryClientCore.TryGetOverlappingRangesAsync( | ||
collectionResourceId: containerProperties.ResourceId, | ||
range: new Documents.Routing.Range<string>("00", "FF", true, false), | ||
forceRefresh: false); | ||
|
||
Assert.IsNotNull(pkRangeAll); | ||
Assert.IsTrue(pkRangeAll.Count > 1); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters