@@ -121,6 +121,98 @@ public async Task CreateItemsTest()
121121 {
122122 ItemResponse < TestObject > response = await this . container . CreateItemAsync ( item , new PartitionKey ( item . Pk ) ) ;
123123 Assert . AreEqual ( HttpStatusCode . Created , response . StatusCode ) ;
124+ string diagnostics = response . Diagnostics . ToString ( ) ;
125+ Assert . IsTrue ( diagnostics . Contains ( "ThinClientStoreModel" ) , "Diagnostics should contain 'ThinClientStoreModel'" ) ;
126+ }
127+ }
128+
129+ [ TestMethod ]
130+ [ TestCategory ( "ThinClient" ) ]
131+ public async Task CreateItemsTestWithThinClientFlagEnabledAndAccountDisabled ( )
132+ {
133+ Environment . SetEnvironmentVariable ( ConfigurationManager . ThinClientModeEnabled , "True" ) ;
134+ this . connectionString = Environment . GetEnvironmentVariable ( "COSMOSDB_ACCOUNT_CONNECTION_STRING" ) ;
135+
136+ if ( string . IsNullOrEmpty ( this . connectionString ) )
137+ {
138+ Assert . Fail ( "Set environment variable COSMOSDB_ACCOUNT_CONNECTION_STRING to run the tests" ) ;
139+ }
140+
141+ JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions
142+ {
143+ PropertyNamingPolicy = null ,
144+ PropertyNameCaseInsensitive = true ,
145+ DefaultIgnoreCondition = JsonIgnoreCondition . WhenWritingNull
146+ } ;
147+ this . cosmosSystemTextJsonSerializer = new MultiRegionSetupHelpers . CosmosSystemTextJsonSerializer ( jsonSerializerOptions ) ;
148+
149+ this . client = new CosmosClient (
150+ this . connectionString ,
151+ new CosmosClientOptions ( )
152+ {
153+ ConnectionMode = ConnectionMode . Gateway ,
154+ Serializer = this . cosmosSystemTextJsonSerializer ,
155+ } ) ;
156+
157+ string uniqueDbName = "TestDb2_" + Guid . NewGuid ( ) . ToString ( ) ;
158+ this . database = await this . client . CreateDatabaseIfNotExistsAsync ( uniqueDbName ) ;
159+ string uniqueContainerName = "TestContainer2_" + Guid . NewGuid ( ) . ToString ( ) ;
160+ this . container = await this . database . CreateContainerIfNotExistsAsync ( uniqueContainerName , "/pk" ) ;
161+
162+ string pk = "pk_create" ;
163+ IEnumerable < TestObject > items = this . GenerateItems ( pk ) ;
164+
165+ foreach ( TestObject item in items )
166+ {
167+ ItemResponse < TestObject > response = await this . container . CreateItemAsync ( item , new PartitionKey ( item . Pk ) ) ;
168+ Assert . AreEqual ( HttpStatusCode . Created , response . StatusCode ) ;
169+ string diagnostics = response . Diagnostics . ToString ( ) ;
170+ Assert . IsTrue ( diagnostics . Contains ( "GatewayStoreModel" ) , "Diagnostics should contain 'GatewayStoreModel'" ) ;
171+ }
172+ }
173+
174+ [ TestMethod ]
175+ [ TestCategory ( "ThinClient" ) ]
176+ public async Task CreateItemsTestWithThinClientFlagDisabledAccountEnabled ( )
177+ {
178+ Environment . SetEnvironmentVariable ( ConfigurationManager . ThinClientModeEnabled , "False" ) ;
179+ this . connectionString = Environment . GetEnvironmentVariable ( "COSMOSDB_THINCLIENT" ) ;
180+
181+ if ( string . IsNullOrEmpty ( this . connectionString ) )
182+ {
183+ Assert . Fail ( "Set environment variable COSMOSDB_THINCLIENT to run the tests" ) ;
184+ }
185+
186+ JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions
187+ {
188+ PropertyNamingPolicy = null ,
189+ PropertyNameCaseInsensitive = true ,
190+ DefaultIgnoreCondition = JsonIgnoreCondition . WhenWritingNull
191+ } ;
192+ this . cosmosSystemTextJsonSerializer = new MultiRegionSetupHelpers . CosmosSystemTextJsonSerializer ( jsonSerializerOptions ) ;
193+
194+ this . client = new CosmosClient (
195+ this . connectionString ,
196+ new CosmosClientOptions ( )
197+ {
198+ ConnectionMode = ConnectionMode . Gateway ,
199+ Serializer = this . cosmosSystemTextJsonSerializer ,
200+ } ) ;
201+
202+ string uniqueDbName = "TestDbTCDisabled_" + Guid . NewGuid ( ) . ToString ( ) ;
203+ this . database = await this . client . CreateDatabaseIfNotExistsAsync ( uniqueDbName ) ;
204+ string uniqueContainerName = "TestContainerTCDisabled_" + Guid . NewGuid ( ) . ToString ( ) ;
205+ this . container = await this . database . CreateContainerIfNotExistsAsync ( uniqueContainerName , "/pk" ) ;
206+
207+ string pk = "pk_create" ;
208+ IEnumerable < TestObject > items = this . GenerateItems ( pk ) ;
209+
210+ foreach ( TestObject item in items )
211+ {
212+ ItemResponse < TestObject > response = await this . container . CreateItemAsync ( item , new PartitionKey ( item . Pk ) ) ;
213+ Assert . AreEqual ( HttpStatusCode . Created , response . StatusCode ) ;
214+ string diagnostics = response . Diagnostics . ToString ( ) ;
215+ Assert . IsTrue ( diagnostics . Contains ( "GatewayStoreModel" ) , "Diagnostics should contain 'GatewayStoreModel'" ) ;
124216 }
125217 }
126218
0 commit comments