public async Task PointOperationRequestTimeoutDiagnostic(bool disableDiagnostics)
        {
            ItemRequestOptions requestOptions = new ItemRequestOptions();

            if (disableDiagnostics)
            {
                requestOptions.DiagnosticContextFactory = () => EmptyCosmosDiagnosticsContext.Singleton;
            }
            ;

            Guid      exceptionActivityId             = Guid.NewGuid();
            string    transportExceptionDescription   = "transportExceptionDescription" + Guid.NewGuid();
            Container containerWithTransportException = TransportClientHelper.GetContainerWithItemTransportException(
                this.database.Id,
                this.Container.Id,
                exceptionActivityId,
                transportExceptionDescription);

            //Checking point operation diagnostics on typed operations
            ToDoActivity testItem = ToDoActivity.CreateRandomToDoActivity();

            try
            {
                ItemResponse <ToDoActivity> createResponse = await containerWithTransportException.CreateItemAsync <ToDoActivity>(
                    item : testItem,
                    requestOptions : requestOptions);

                Assert.Fail("Should have thrown a request timeout exception");
            }
            catch (CosmosException ce) when(ce.StatusCode == System.Net.HttpStatusCode.RequestTimeout)
            {
                string exception = ce.ToString();

                Assert.IsNotNull(exception);
                Assert.IsTrue(exception.Contains(exceptionActivityId.ToString()));
                Assert.IsTrue(exception.Contains(transportExceptionDescription));

                string diagnosics = ce.Diagnostics.ToString();

                if (disableDiagnostics)
                {
                    Assert.IsTrue(string.IsNullOrEmpty(diagnosics));
                }
                else
                {
                    Assert.IsFalse(string.IsNullOrEmpty(diagnosics));
                    Assert.IsTrue(exception.Contains(diagnosics));
                    DiagnosticValidator.ValidatePointOperationDiagnostics(ce.DiagnosticsContext);
                }
            }
        }
        public static void VerifyPointDiagnostics(
            CosmosDiagnostics diagnostics,
            bool disableDiagnostics)
        {
            string info = diagnostics.ToString();

            if (disableDiagnostics)
            {
                Assert.AreEqual(string.Empty, info);
                return;
            }

            CosmosDiagnosticsContext diagnosticsContext = (diagnostics as CosmosDiagnosticsCore).Context;

            DiagnosticValidator.ValidatePointOperationDiagnostics(diagnosticsContext);
        }
        public async Task PointOperationThrottledDiagnostic(bool disableDiagnostics)
        {
            string errorMessage        = "Mock throttle exception" + Guid.NewGuid().ToString();
            Guid   exceptionActivityId = Guid.NewGuid();
            // Set a small retry count to reduce test time
            CosmosClient throttleClient = TestCommon.CreateCosmosClient(builder =>
                                                                        builder.WithThrottlingRetryOptions(TimeSpan.FromSeconds(5), 5)
                                                                        .WithTransportClientHandlerFactory(transportClient => new TransportClientWrapper(
                                                                                                               transportClient,
                                                                                                               (uri, resourceOperation, request) => TransportClientHelper.ReturnThrottledStoreResponseOnItemOperation(
                                                                                                                   uri,
                                                                                                                   resourceOperation,
                                                                                                                   request,
                                                                                                                   exceptionActivityId,
                                                                                                                   errorMessage)))
                                                                        );

            ItemRequestOptions requestOptions = new ItemRequestOptions();

            if (disableDiagnostics)
            {
                requestOptions.DiagnosticContextFactory = () => EmptyCosmosDiagnosticsContext.Singleton;
            }
            ;

            Container containerWithThrottleException = throttleClient.GetContainer(
                this.database.Id,
                this.Container.Id);

            //Checking point operation diagnostics on typed operations
            ToDoActivity testItem = ToDoActivity.CreateRandomToDoActivity();

            try
            {
                ItemResponse <ToDoActivity> createResponse = await containerWithThrottleException.CreateItemAsync <ToDoActivity>(
                    item : testItem,
                    requestOptions : requestOptions);

                Assert.Fail("Should have thrown a request timeout exception");
            }
            catch (CosmosException ce) when((int)ce.StatusCode == (int)Documents.StatusCodes.TooManyRequests)
            {
                string exception = ce.ToString();

                Assert.IsNotNull(exception);
                Assert.IsTrue(exception.Contains(exceptionActivityId.ToString()));
                Assert.IsTrue(exception.Contains(errorMessage));

                string diagnosics = ce.Diagnostics.ToString();

                if (disableDiagnostics)
                {
                    Assert.IsTrue(string.IsNullOrEmpty(diagnosics));
                }
                else
                {
                    Assert.IsFalse(string.IsNullOrEmpty(diagnosics));
                    Assert.IsTrue(exception.Contains(diagnosics));
                    DiagnosticValidator.ValidatePointOperationDiagnostics(ce.DiagnosticsContext);
                }
            }
        }