示例#1
0
        public void AddAzureRmWebtestAlertRuleCommandParametersProcessing()
        {
            // Test null actions
            cmdlet.Name                = Utilities.Name;
            cmdlet.Location            = "East US";
            cmdlet.ResourceGroup       = Utilities.ResourceGroup;
            cmdlet.FailedLocationCount = 10;
            cmdlet.Actions             = null;
            cmdlet.WindowSize          = TimeSpan.FromMinutes(15);

            cmdlet.ExecuteCmdlet();

            this.AssertResults(
                location: "East US",
                tagsKey: "hidden-link:",
                isEnabled: true,
                actionsNull: true,
                actionsCount: 0,
                failedLocationCount: 10,
                totalMinutes: 15);

            // Test null actions and disabled
            cmdlet.DisableRule = true;

            cmdlet.ExecuteCmdlet();

            this.AssertResults(
                location: "East US",
                tagsKey: "hidden-link:",
                isEnabled: false,
                actionsNull: true,
                actionsCount: 0,
                failedLocationCount: 10,
                totalMinutes: 15);

            // Test empty actions
            cmdlet.DisableRule = false;
            cmdlet.Actions     = new List <RuleAction>();

            cmdlet.ExecuteCmdlet();

            this.AssertResults(
                location: "East US",
                tagsKey: "hidden-link:",
                isEnabled: true,
                actionsNull: false,
                actionsCount: 0,
                failedLocationCount: 10,
                totalMinutes: 15);

            // Test non-empty actions (one action)
            List <string> eMails = new List <string>();

            eMails.Add("*****@*****.**");
            RuleAction ruleAction = new RuleEmailAction
            {
                SendToServiceOwners = true,
                CustomEmails        = eMails
            };

            cmdlet.Actions.Add(ruleAction);

            cmdlet.ExecuteCmdlet();

            this.AssertResults(
                location: "East US",
                tagsKey: "hidden-link:",
                isEnabled: true,
                actionsNull: false,
                actionsCount: 1,
                failedLocationCount: 10,
                totalMinutes: 15);

            // Test non-empty actions (two actions)
            var properties = new Dictionary <string, string>();

            properties.Add("hello", "goodbye");
            ruleAction = new RuleWebhookAction
            {
                ServiceUri = "http://bueno.net",
                Properties = properties
            };

            cmdlet.Actions.Add(ruleAction);

            cmdlet.ExecuteCmdlet();

            this.AssertResults(
                location: "East US",
                tagsKey: "hidden-link:",
                isEnabled: true,
                actionsNull: false,
                actionsCount: 2,
                failedLocationCount: 10,
                totalMinutes: 15);

            // Test non-empty actions (two actions) and non-default window size
            cmdlet.WindowSize = TimeSpan.FromMinutes(300);

            cmdlet.ExecuteCmdlet();

            this.AssertResults(
                location: "East US",
                tagsKey: "hidden-link:",
                isEnabled: true,
                actionsNull: false,
                actionsCount: 2,
                failedLocationCount: 10,
                totalMinutes: 300);
        }