@@ -51,27 +51,57 @@ public async Task Cleanup()
51
51
}
52
52
53
53
[ TestMethod ]
54
- public async Task ReadManyTypedTest ( )
54
+ [ DataRow ( true , DisplayName = "Validates Read Many scenario with advanced replica selection enabled." ) ]
55
+ [ DataRow ( false , DisplayName = "Validates Read Many scenario with advanced replica selection disabled." ) ]
56
+ public async Task ReadManyTypedTestWithAdvancedReplicaSelection (
57
+ bool advancedReplicaSelectionEnabled )
55
58
{
56
- List < ( string , PartitionKey ) > itemList = new List < ( string , PartitionKey ) > ( ) ;
57
- for ( int i = 0 ; i < 10 ; i ++ )
59
+ CosmosClient cosmosClient = advancedReplicaSelectionEnabled
60
+ ? TestCommon . CreateCosmosClient (
61
+ customizeClientBuilder : ( CosmosClientBuilder builder ) => builder . WithAdvancedReplicaSelectionEnabledForTcp ( ) )
62
+ : TestCommon . CreateCosmosClient ( ) ;
63
+
64
+ Database database = null ;
65
+ try
58
66
{
59
- itemList . Add ( ( i . ToString ( ) , new PartitionKey ( "pk" + i . ToString ( ) ) ) ) ;
60
- }
67
+ database = await cosmosClient . CreateDatabaseAsync ( "ReadManyTypedTestScenarioDb" ) ;
68
+ Container containerCC1 = await database . CreateContainerAsync ( "ReadManyTypedTestContainer" , "/pk" ) ;
61
69
62
- FeedResponse < ToDoActivity > feedResponse = await this . Container . ReadManyItemsAsync < ToDoActivity > ( itemList ) ;
63
- Assert . IsNotNull ( feedResponse ) ;
64
- Assert . AreEqual ( feedResponse . Count , 10 ) ;
65
- Assert . IsTrue ( feedResponse . Headers . RequestCharge > 0 ) ;
66
- Assert . IsNotNull ( feedResponse . Diagnostics ) ;
70
+ // Create items with different pk values
71
+ for ( int i = 0 ; i < 500 ; i ++ )
72
+ {
73
+ ToDoActivity item = ToDoActivity . CreateRandomToDoActivity ( ) ;
74
+ item . pk = "pk" + i . ToString ( ) ;
75
+ item . id = i . ToString ( ) ;
76
+ ItemResponse < ToDoActivity > itemResponse = await containerCC1 . CreateItemAsync ( item ) ;
77
+ Assert . AreEqual ( HttpStatusCode . Created , itemResponse . StatusCode ) ;
78
+ }
79
+
80
+ List < ( string , PartitionKey ) > itemList = new List < ( string , PartitionKey ) > ( ) ;
81
+ for ( int i = 0 ; i < 20 ; i ++ )
82
+ {
83
+ itemList . Add ( ( i . ToString ( ) , new PartitionKey ( "pk" + i . ToString ( ) ) ) ) ;
84
+ }
85
+
86
+ FeedResponse < ToDoActivity > feedResponse = await containerCC1 . ReadManyItemsAsync < ToDoActivity > ( itemList ) ;
87
+ Assert . IsNotNull ( feedResponse ) ;
88
+ Assert . AreEqual ( 20 , feedResponse . Count ) ;
89
+ Assert . IsTrue ( feedResponse . Headers . RequestCharge > 0 ) ;
90
+ Assert . IsNotNull ( feedResponse . Diagnostics ) ;
67
91
68
- int count = 0 ;
69
- foreach ( ToDoActivity item in feedResponse )
92
+ int count = 0 ;
93
+ foreach ( ToDoActivity item in feedResponse )
94
+ {
95
+ count ++ ;
96
+ Assert . IsNotNull ( item ) ;
97
+ }
98
+ Assert . AreEqual ( 20 , count ) ;
99
+ }
100
+ finally
70
101
{
71
- count ++ ;
72
- Assert . IsNotNull ( item ) ;
102
+ await database . DeleteAsync ( ) ;
103
+ cosmosClient . Dispose ( ) ;
73
104
}
74
- Assert . AreEqual ( count , 10 ) ;
75
105
}
76
106
77
107
[ TestMethod ]
0 commit comments