public async Task CRUDTest()
        {
            CosmosTriggerSettings settings = new CosmosTriggerSettings
            {
                Id               = Guid.NewGuid().ToString(),
                Body             = TriggersTests.GetTriggerFunction(".05"),
                TriggerOperation = TriggerOperation.Create,
                TriggerType      = Cosmos.TriggerType.Pre
            };

            CosmosTriggerResponse triggerResponse =
                await this.container.Triggers.CreateTriggerAsync(settings);

            double reqeustCharge = triggerResponse.RequestCharge;

            Assert.IsTrue(reqeustCharge > 0);
            Assert.AreEqual(HttpStatusCode.Created, triggerResponse.StatusCode);
            TriggersTests.ValidateTriggerSettings(settings, triggerResponse);

            triggerResponse = await triggerResponse.Trigger.ReadAsync();

            reqeustCharge = triggerResponse.RequestCharge;
            Assert.IsTrue(reqeustCharge > 0);
            Assert.AreEqual(HttpStatusCode.OK, triggerResponse.StatusCode);
            TriggersTests.ValidateTriggerSettings(settings, triggerResponse);

            CosmosTriggerSettings updatedSettings = triggerResponse.Resource;

            updatedSettings.Body = TriggersTests.GetTriggerFunction(".42");

            CosmosTriggerResponse replaceResponse = await triggerResponse.Trigger.ReplaceAsync(updatedSettings);

            TriggersTests.ValidateTriggerSettings(updatedSettings, replaceResponse);
            reqeustCharge = replaceResponse.RequestCharge;
            Assert.IsTrue(reqeustCharge > 0);
            Assert.AreEqual(HttpStatusCode.OK, replaceResponse.StatusCode);

            replaceResponse = await replaceResponse.Trigger.DeleteAsync();

            reqeustCharge = replaceResponse.RequestCharge;
            Assert.IsTrue(reqeustCharge > 0);
            Assert.AreEqual(HttpStatusCode.NoContent, replaceResponse.StatusCode);
        }
        private async Task <CosmosTriggerResponse> CreateRandomTrigger()
        {
            string id       = Guid.NewGuid().ToString();
            string function = GetTriggerFunction(".05");

            CosmosTriggerSettings settings = new CosmosTriggerSettings
            {
                Id               = id,
                Body             = function,
                TriggerOperation = TriggerOperation.Create,
                TriggerType      = Cosmos.TriggerType.Pre
            };

            //Create a user defined function
            CosmosTriggerResponse createResponse = await this.container.Triggers.CreateTriggerAsync(
                triggerSettings : settings,
                cancellationToken : this.cancellationToken);

            ValidateTriggerSettings(settings, createResponse);

            return(createResponse);
        }
        private static void ValidateTriggerSettings(CosmosTriggerSettings triggerSettings, CosmosTriggerResponse cosmosResponse)
        {
            CosmosTriggerSettings settings = cosmosResponse.Resource;

            Assert.AreEqual(triggerSettings.Body, settings.Body,
                            "Trigger function do not match");
            Assert.AreEqual(triggerSettings.Id, settings.Id,
                            "Trigger id do not match");
            Assert.IsTrue(cosmosResponse.RequestCharge > 0);
            Assert.IsNotNull(cosmosResponse.MaxResourceQuota);
            Assert.IsNotNull(cosmosResponse.CurrentResourceQuotaUsage);
        }