diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosItemTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosItemTests.cs index bdb8e751e8..1050f3987f 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosItemTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosItemTests.cs @@ -3392,20 +3392,14 @@ public async Task VerifySessionNotFoundStatistics() string invalidSessionToken = this.GetDifferentLSNToken(responseAstype.Headers.Session, 2000); - try - { - ItemResponse readResponse = await container.ReadItemAsync(temp.id, new Cosmos.PartitionKey(temp.pk), new ItemRequestOptions() { SessionToken = invalidSessionToken }); - Assert.Fail("Should had thrown ReadSessionNotAvailable"); - } - catch (CosmosException cosmosException) - { - Assert.AreEqual(StatusCodes.NotFound, cosmosException.StatusCode); - Assert.AreEqual(SubStatusCodes.ReadSessionNotAvailable, cosmosException.SubStatusCode); - - Assert.IsTrue(cosmosException.Message.Contains("The read/write session is not available"), cosmosException.Message); - string exception = cosmosException.ToString(); - Assert.IsTrue(exception.Contains("Point Operation Statistics"), exception); - } + // With exception-less behavior enabled by default, typed APIs return responses instead of throwing exceptions + ItemResponse readResponse = await container.ReadItemAsync(temp.id, new Cosmos.PartitionKey(temp.pk), new ItemRequestOptions() { SessionToken = invalidSessionToken }); + + Assert.AreEqual(HttpStatusCode.NotFound, readResponse.StatusCode); + Assert.AreEqual(SubStatusCodes.ReadSessionNotAvailable, readResponse.Headers.SubStatusCode); + + string diagnostics = readResponse.Diagnostics.ToString(); + Assert.IsTrue(diagnostics.Contains("Point Operation Statistics"), diagnostics); } finally {