public AlertTestFixture()
    {
        Channel = CreateChannel();
        string filter = @"metric.label.state=""blocked"" AND 
            metric.type=""agent.googleapis.com/processes/count_by_state""  
            AND resource.type=""gce_instance""";

        Alert = AlertPolicyClient.CreateAlertPolicy(
            new ProjectName(ProjectId), new AlertPolicy()
        {
            DisplayName = "AlertTest.cs",
            Enabled     = false,
            Combiner    = ConditionCombinerType.Or,
            Conditions  =
            {
                new AlertPolicy.Types.Condition()
                {
                    ConditionThreshold = new MetricThreshold()
                    {
                        Filter       = filter,
                        Aggregations =
                        {
                            new Aggregation()
                            {
                                AlignmentPeriod = Duration.FromTimeSpan(
                                    TimeSpan.FromSeconds(60)),
                                PerSeriesAligner   = Aligner.AlignMean,
                                CrossSeriesReducer = Reducer.ReduceMean,
                                GroupByFields      =
                                {
                                    "project",
                                    "resource.label.instance_id",
                                    "resource.label.zone"
                                }
                            }
                        },
                        DenominatorFilter       = "",
                        DenominatorAggregations ={                  },
                        Comparison     = ComparisonType.ComparisonGt,
                        ThresholdValue = 100.0,
                        Duration       = Duration.FromTimeSpan(
                            TimeSpan.FromSeconds(900)),
                        Trigger = new Trigger()
                        {
                            Count   = 1,
                            Percent = 0.0,
                        }
                    },
                    DisplayName = "AlertTest.cs",
                }
            },
        });
    }
        public AlertTestFixture()
        {
            var channel = new NotificationChannel()
            {
                Type        = "email",
                DisplayName = "Email joe.",
                Description = "AlertTest.cs",
                Labels      = { { "email_address", "*****@*****.**" } },
                UserLabels  =
                {
                    { "role",     "operations"               },
                    { "level",    "5"                        },
                    { "office",   "california_westcoast_usa" },
                    { "division", "fulfillment"              }
                }
            };

            Channel = NotificationChannelClient.CreateNotificationChannel(
                new ProjectName(ProjectId), channel);

            Alert = AlertPolicyClient.CreateAlertPolicy(
                new ProjectName(ProjectId), new AlertPolicy()
            {
                DisplayName = "AlertTest.cs",
                Enabled     = false,
                Combiner    = ConditionCombinerType.Or,
                Conditions  =
                {
                    new AlertPolicy.Types.Condition()
                    {
                        ConditionThreshold = new MetricThreshold()
                        {
                            Filter       = "metric.label.state=\"blocked\" AND metric.type=\"agent.googleapis.com/processes/count_by_state\"  AND resource.type=\"gce_instance\"",
                            Aggregations =
                            {
                                new Aggregation()
                                {
                                    AlignmentPeriod = Duration.FromTimeSpan(
                                        TimeSpan.FromSeconds(60)),
                                    PerSeriesAligner   = Aligner.AlignMean,
                                    CrossSeriesReducer = Reducer.ReduceMean,
                                    GroupByFields      =
                                    {
                                        "project",
                                        "resource.label.instance_id",
                                        "resource.label.zone"
                                    }
                                }
                            },
                            DenominatorFilter       = "",
                            DenominatorAggregations ={                  },
                            Comparison     = ComparisonType.ComparisonGt,
                            ThresholdValue = 100.0,
                            Duration       = Duration.FromTimeSpan(
                                TimeSpan.FromSeconds(900)),
                            Trigger = new Trigger()
                            {
                                Count   = 1,
                                Percent = 0.0,
                            }
                        },
                        DisplayName = "AlertTest.cs",
                    }
                },
            });
        }