private async Task ItemOperations(CosmosContainer container, bool containerNotExist)
        {
            if (containerNotExist)
            {
                dynamic randomItem = new { id = "test", pk = "doesnotexist" };
                Stream  create     = jsonSerializer.ToStream <dynamic>(randomItem);
                this.VerifyNotFoundResponse(await container.CreateItemStreamAsync(new PartitionKey(randomItem.pk), create));

                var queryIterator = container.CreateItemQueryStream("select * from t where true", maxConcurrency: 2);
                this.VerifyQueryNotFoundResponse(await queryIterator.FetchNextSetAsync());

                var feedIterator = container.GetItemsStreamIterator();
                this.VerifyNotFoundResponse(await feedIterator.FetchNextSetAsync());

                dynamic randomUpsertItem = new { id = DoesNotExist, pk = DoesNotExist, status = 42 };
                Stream  upsert           = jsonSerializer.ToStream <dynamic>(randomUpsertItem);
                this.VerifyNotFoundResponse(await container.UpsertItemStreamAsync(
                                                partitionKey: new Cosmos.PartitionKey(randomUpsertItem.pk),
                                                streamPayload: upsert));
            }

            this.VerifyNotFoundResponse(await container.ReadItemStreamAsync(partitionKey: new Cosmos.PartitionKey(DoesNotExist), id: DoesNotExist));
            this.VerifyNotFoundResponse(await container.DeleteItemStreamAsync(partitionKey: new Cosmos.PartitionKey(DoesNotExist), id: DoesNotExist));

            dynamic randomReplaceItem = new { id = "test", pk = "doesnotexist", status = 42 };
            Stream  replace           = jsonSerializer.ToStream <dynamic>(randomReplaceItem);

            this.VerifyNotFoundResponse(await container.ReplaceItemStreamAsync(
                                            partitionKey: new Cosmos.PartitionKey(randomReplaceItem.pk),
                                            id: randomReplaceItem.id,
                                            streamPayload: replace));
        }
        public async Task ExecutionLogsAsStreamTests()
        {
            const string testLogsText    = "this is a test";
            const string testPartitionId = "1";
            string       sprocId         = Guid.NewGuid().ToString();
            string       sprocBody       = @"function(name) { var context = getContext(); console.log('" + testLogsText + "'); var response = context.getResponse(); response.setBody('hello there ' + name); }";

            StoredProcedureResponse storedProcedureResponse =
                await this.scripts.CreateStoredProcedureAsync(new CosmosStoredProcedureProperties(sprocId, sprocBody));

            double requestCharge = storedProcedureResponse.RequestCharge;

            Assert.IsTrue(requestCharge > 0);
            Assert.AreEqual(HttpStatusCode.Created, storedProcedureResponse.StatusCode);
            StoredProcedureTests.ValidateStoredProcedureSettings(sprocId, sprocBody, storedProcedureResponse);



            CosmosStoredProcedureProperties storedProcedure = storedProcedureResponse;
            CosmosResponseMessage           sprocResponse   = await this.scripts.ExecuteStoredProcedureStreamAsync(
                new Cosmos.PartitionKey(testPartitionId),
                sprocId,
                cosmosJsonSerializer.ToStream(new string[] { Guid.NewGuid().ToString() }),
                new StoredProcedureRequestOptions()
            {
                EnableScriptLogging = true
            });

            Assert.AreEqual(HttpStatusCode.OK, sprocResponse.StatusCode);
            Assert.AreEqual(testLogsText, Uri.UnescapeDataString(sprocResponse.Headers["x-ms-documentdb-script-log-results"]));
        }