private static void AreEqual(MetricTrigger exp, MetricTrigger act)
 {
     if (exp != null)
     {
         Assert.Equal(exp.MetricName, act.MetricName);
         Assert.Equal(exp.MetricNamespace, act.MetricNamespace);
         Assert.Equal(exp.MetricResourceUri, act.MetricResourceUri);
         Assert.Equal(exp.Operator, act.Operator);
         Assert.Equal(exp.Statistic, act.Statistic);
         Assert.Equal(exp.Threshold, act.Threshold);
         Assert.Equal(exp.TimeAggregation, act.TimeAggregation);
         Assert.Equal(exp.TimeGrain, act.TimeGrain);
         Assert.Equal(exp.TimeWindow, act.TimeWindow);
     }
 }
        /// <summary>
        /// Create an Autoscale setting rule based on the properties of the object
        /// </summary>
        /// <returns>A ScaleRule created based on the properties of the object</returns>
        public ScaleRule CreateSettingRule()
        {
            if (this.TimeWindow != default(TimeSpan) && this.TimeWindow < MinimumTimeWindow)
            {
                throw new ArgumentOutOfRangeException("TimeWindow", this.TimeWindow, ResourcesForAutoscaleCmdlets.MinimumTimeWindow5min);
            }

            if (this.TimeGrain < MinimumTimeGrain)
            {
                throw new ArgumentOutOfRangeException("TimeGrain", this.TimeGrain, ResourcesForAutoscaleCmdlets.MinimumTimeGrain1min);
            }

            MetricTrigger trigger = new MetricTrigger()
            {
                MetricName = this.MetricName,
                MetricResourceUri = this.MetricResourceId,
                Operator = this.Operator,
                Statistic = this.MetricStatistic,
                Threshold = this.Threshold,
                TimeAggregation = this.TimeAggregationOperator,
                TimeGrain = this.TimeGrain,
                TimeWindow = this.TimeWindow == default(TimeSpan) ? MinimumTimeWindow : this.TimeWindow,
            };

            ScaleAction action = new ScaleAction()
            {
                Cooldown = this.ScaleActionCooldown,
                Direction = this.ScaleActionDirection,
                Type = this.ScaleActionScaleType,
                Value = this.ScaleActionValue,
            };

            return new ScaleRule()
            {
                MetricTrigger = trigger,
                ScaleAction = action,
            };
        }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the ScaleRule class.
 /// </summary>
 /// <param name="metricTrigger">the trigger that results in a scaling
 /// action.</param>
 /// <param name="scaleAction">the parameters for the scaling
 /// action.</param>
 public ScaleRule(MetricTrigger metricTrigger, ScaleAction scaleAction)
 {
     MetricTrigger = metricTrigger;
     ScaleAction   = scaleAction;
 }