Пример #1
0
        public async Task ShouldStartAllVms()
        {
            var step1 = new BotTestCase()
            {
                Action        = "start all vms",
                ExpectedReply = "You are trying to start the following virtual machines",
            };

            var step2 = new BotTestCase()
            {
                Action        = "Yes",
                ExpectedReply = "Starting the following virtual machines",
            };

            var completionTestCase = new BotTestCase()
            {
                ExpectedReply = "virtual machine was started successfully",
            };

            var steps = new List <BotTestCase> {
                step1, step2
            };

            await TestRunner.RunTestCases(steps, completionTestCase, 3);
        }
Пример #2
0
        public async Task ShouldStartAllVmsFromSpecifiedResourceGroup()
        {
            var resourceGroup = this.TestContext.GetResourceGroup();

            var step1 = new BotTestCase()
            {
                Action        = $"start all vms from {resourceGroup} resource group",
                ExpectedReply = "You are trying to start the following virtual machines",
            };

            var step2 = new BotTestCase()
            {
                Action        = "Yes",
                ExpectedReply = "Starting the following virtual machines",
            };

            var completionTestCase = new BotTestCase()
            {
                ExpectedReply = "virtual machine was started successfully",
            };

            var steps = new List <BotTestCase> {
                step1, step2
            };

            await TestRunner.RunTestCases(steps, completionTestCase, 2);
        }
Пример #3
0
        public static void CleanUp()
        {
            if (testContext.DeallocateResourcesOnCleanup())
            {
                var step1 = new BotTestCase()
                {
                    Action        = "stop all vms",
                    ExpectedReply = "You are trying to stop the following virtual machines",
                };

                var step2 = new BotTestCase()
                {
                    Action        = "Yes",
                    ExpectedReply = "Stopping the following virtual machines",
                };

                var completionTestCase = new BotTestCase()
                {
                    ExpectedReply = $"virtual machine was stopped successfully.",
                };

                var steps = new List <BotTestCase> {
                    step1, step2
                };

                TestRunner.RunTestCases(steps, completionTestCase, 2).Wait();
            }

            if (botHelper != null)
            {
                botHelper.Dispose();
            }
        }
Пример #4
0
        public async Task ShouldStartSpecifiedVm()
        {
            var virtualMachine = this.TestContext.GetVirtualMachine();

            var step1 = new BotTestCase()
            {
                Action        = $"start vm {virtualMachine}",
                ExpectedReply = $"Would you like to start virtual machine '{virtualMachine}",
            };

            var step2 = new BotTestCase()
            {
                Action        = "Yes",
                ExpectedReply = $"Starting the '{virtualMachine}' virtual machine...",
            };

            var completionTestCase = new BotTestCase()
            {
                ExpectedReply = $"The '{virtualMachine}' virtual machine was started successfully.",
            };

            var steps = new List <BotTestCase> {
                step1, step2
            };

            await TestRunner.RunTestCases(steps, completionTestCase);
        }
Пример #5
0
        public async Task ShouldStartVm()
        {
            var step1 = new BotTestCase()
            {
                Action        = "start vm",
                ExpectedReply = "Please select the virtual machine you want to start",
            };

            var step2 = new BotTestCase()
            {
                Action        = "1",
                ExpectedReply = "Would you like to start virtual machine",
            };

            var step3 = new BotTestCase()
            {
                Action        = "Yes",
                ExpectedReply = "Starting the",
            };

            var completionTestCase = new BotTestCase()
            {
                ExpectedReply = "virtual machine was started successfully",
            };

            var steps = new List <BotTestCase> {
                step1, step2, step3
            };

            await TestRunner.RunTestCases(steps, completionTestCase);
        }
Пример #6
0
        public static void SetUp(TestContext context)
        {
            testContext = context;
            string directLineToken = context.Properties["DirectLineToken"].ToString();
            string microsoftAppId  = context.Properties["MicrosoftAppId"].ToString();
            string fromUser        = context.Properties["FromUser"].ToString();
            string botId           = context.Properties["BotId"].ToString();

            botHelper = new BotHelper(directLineToken, microsoftAppId, fromUser, botId);

            var subscription = context.GetSubscription();

            var testCase = new BotTestCase()
            {
                Action        = $"select subscription {subscription}",
                ExpectedReply = $"Setting {subscription} as the current subscription. What would you like to do next?",
            };

            TestRunner.RunTestCase(testCase).Wait();

            try
            {
                TestRunner.EnsureAllVmsStopped().Wait();
            }
            catch
            {
                Console.WriteLine("CleanUp called from SetUp failed");
            }
        }
Пример #7
0
        public async Task ShutdownVmShouldNotifyWhenNoVmsAreAvailableToStart()
        {
            var testCase = new BotTestCase()
            {
                Action        = "shutdown vm",
                ExpectedReply = "No virtual machines that can be shut down were found in the current subscription.",
            };

            await TestRunner.RunTestCase(testCase);
        }
Пример #8
0
        public async Task StopAllVmsShouldNotifyWhenNoVmsAreAvailableToStop()
        {
            var testCase = new BotTestCase()
            {
                Action        = "stop all vms",
                ExpectedReply = "No virtual machines that can be stopped were found in the current subscription.",
            };

            await TestRunner.RunTestCase(testCase);
        }
Пример #9
0
        public async Task ShowJobOutputShouldNotifyWhenJobIsNotSpecified()
        {
            var testCase = new BotTestCase()
            {
                Action        = $"show output",
                ExpectedReply = "No runbook job id was specified. Try 'show <jobId> output'.",
            };

            await TestRunner.RunTestCase(testCase);
        }
Пример #10
0
        public async Task ShowRunbookDescriptionShouldNotifyWhenRunbookIsNotSpecified()
        {
            var testCase = new BotTestCase()
            {
                Action        = $"show runbook description",
                ExpectedReply = "No runbook was specified. Please try again specifying a runbook name.",
            };

            await TestRunner.RunTestCase(testCase);
        }
Пример #11
0
        public async Task ShouldShowHelp()
        {
            var testCase = new BotTestCase()
            {
                Action        = "help",
                ExpectedReply = "I can help you",
            };

            await TestRunner.RunTestCase(testCase);
        }
Пример #12
0
        public async Task ShouldShowStatusOfJobs()
        {
            var testCase = new BotTestCase()
            {
                Action        = $"show status of my jobs",
                ExpectedReply = "|job",
            };

            await TestRunner.RunTestCase(testCase);
        }
Пример #13
0
        public async Task ShoudListRunbooks()
        {
            var testCase = new BotTestCase()
            {
                Action        = "list my runbooks",
                ExpectedReply = "Available runbooks are",
            };

            await TestRunner.RunTestCase(testCase);
        }
Пример #14
0
        public async Task ShoudListAutomationAccounts()
        {
            var testCase = new BotTestCase()
            {
                Action        = "list automation accounts",
                ExpectedReply = "Available automations accounts are",
            };

            await TestRunner.RunTestCase(testCase);
        }
Пример #15
0
        public async Task ShouldShowCurrentSubscription()
        {
            var testCase = new BotTestCase()
            {
                Action        = "What's my current subscription?",
                ExpectedReply = "Your current subscription is",
            };

            await TestRunner.RunTestCase(testCase);
        }
Пример #16
0
        public async Task ShoudListSubscriptions()
        {
            var testCase = new BotTestCase()
            {
                Action        = "list subscriptions",
                ExpectedReply = "Your subscriptions are",
            };

            await TestRunner.RunTestCase(testCase);
        }
Пример #17
0
        public async Task ShouldShowHelp()
        {
            var testCase = new BotTestCase()
            {
                Action        = "help",
                ExpectedReply = "Hello! You can use the Azure Bot to",
            };

            await TestRunner.RunTestCase(testCase);
        }
Пример #18
0
        public async Task ShouldShowJobOutput()
        {
            var runbook = this.TestContext.GetRunbookWithDescription();

            var step1 = new BotTestCase()
            {
                Action        = $"run runbook {runbook}",
                ExpectedReply = $"Would you like to run runbook '{runbook}' of automation acccount",
            };

            var step2 = new BotTestCase()
            {
                Action        = $"Yes",
                ExpectedReply = $"Created Job",
            };

            var steps = new List <BotTestCase>()
            {
                step1, step2
            };

            var completionStep1 = new BotTestCase()
            {
                ExpectedReply = $"is currently in 'Running' status",
            };

            string jobId = null;

            var completionStep2 = new BotTestCase()
            {
                ExpectedReply = $"Runbook '{runbook}' is currently in 'Completed' status. Type **show job",
                Verified      = (reply) =>
                {
                    var jobIndex = reply.LastIndexOf("job");
                    jobId = reply.Substring(jobIndex, reply.Substring(jobIndex).IndexOf(" "));
                }
            };

            var completionSteps = new List <BotTestCase>()
            {
                completionStep1, completionStep2
            };

            await TestRunner.RunTestCases(steps, completionSteps, completionSteps.Count);

            var jobOutput = this.TestContext.GetJobOutput();

            var showOutputTestCase = new BotTestCase()
            {
                Action        = $"show {jobId} output",
                ExpectedReply = jobOutput,
            };

            await TestRunner.RunTestCase(showOutputTestCase);
        }
Пример #19
0
        public async Task ShouldNotifyIfActionIsNotUnderstood()
        {
            var message  = "I love AzureBot";
            var testCase = new BotTestCase()
            {
                Action        = message,
                ExpectedReply = $"Sorry, I did not understand '{message}'. Type 'help' if you need assistance.",
            };

            await TestRunner.RunTestCase(testCase);
        }
Пример #20
0
        public async Task SwitchSubscriptionShouldNotifyWhenTheSpecifiedSubscriptionDoesNotExist()
        {
            var subscription = "notfound";

            var testCase = new BotTestCase()
            {
                Action        = $"switch subscription {subscription}",
                ExpectedReply = $"The '{subscription}' subscription was not found.",
            };

            await TestRunner.RunTestCase(testCase);
        }
Пример #21
0
        public async Task ShouldShowRunbookDescription()
        {
            var runbook = this.TestContext.GetRunbookWithDescription();

            var testCase = new BotTestCase()
            {
                Action        = $"show runbook {runbook} description",
                ExpectedReply = this.TestContext.GetRunbookDescription(),
            };

            await TestRunner.RunTestCase(testCase);
        }
Пример #22
0
        public async Task ShouldSwitchToSpecifiedSubscription()
        {
            var subscription = this.TestContext.GetSubscription();

            var testCase = new BotTestCase()
            {
                Action        = $"switch subscription {subscription}",
                ExpectedReply = $"Setting {subscription} as the current subscription. What would you like to do next?",
            };

            await TestRunner.RunTestCase(testCase);
        }
Пример #23
0
        public async Task RunRunbookShouldNotifyWhenTheSpecifiedRunbookIsNotPublished()
        {
            var runbook = this.TestContext.GetRunbookNotPublished();

            var testCase = new BotTestCase()
            {
                Action        = $"run runbook {runbook}",
                ExpectedReply = $"The '{runbook}' runbook that you are trying to run is not Published. Please go the Azure Portal and publish the runbook.",
            };

            await TestRunner.RunTestCase(testCase);
        }
Пример #24
0
        public async Task RunRunbookShouldNotifyWhenTheSpecifiedRunbookDoesNotExist()
        {
            var runbook = "notfoundRunbook";

            var testCase = new BotTestCase()
            {
                Action        = $"run runbook {runbook}",
                ExpectedReply = $"The '{runbook}' runbook was not found in any of your automation accounts.",
            };

            await TestRunner.RunTestCase(testCase);
        }
Пример #25
0
        public async Task StopVmShouldNotifyWhenTheSpecifiedVmDoesNotExist()
        {
            var virtualMachine = "notfound-stop";

            var testCase = new BotTestCase()
            {
                Action        = $"stop vm {virtualMachine}",
                ExpectedReply = $"The '{virtualMachine}' virtual machine was not found in the current subscription.",
            };

            await TestRunner.RunTestCase(testCase);
        }
Пример #26
0
        public async Task ShowJobOutputShouldNotifyWhenTheSpecifiedJobDoesNotExist()
        {
            var jobId = "job0";

            var testCase = new BotTestCase()
            {
                Action        = $"show {jobId} output",
                ExpectedReply = $"The job with id '{jobId}' was not found.",
            };

            await TestRunner.RunTestCase(testCase);
        }
Пример #27
0
        public async Task StartAllVmsFromSpecifiedResourceGroupShouldNotifyWhenNoVmsInTheResourceGroupAreAvailableToStart()
        {
            var resourceGroup = this.TestContext.GetResourceGroup();

            var testCase = new BotTestCase()
            {
                Action        = $"start all vms from {resourceGroup} resource group",
                ExpectedReply = $"No virtual machines that can be started were found in the {resourceGroup} resource group of the current subscription.",
            };

            await TestRunner.RunTestCase(testCase);
        }
Пример #28
0
        public async Task ShowRunbookDescriptionShouldNotifyWhenTheSpecifiedRunbookDoesntHaveDescription()
        {
            var runbook = this.TestContext.GetRunbookWithoutDescription();

            var testCase = new BotTestCase()
            {
                Action        = $"show runbook {runbook} description",
                ExpectedReply = "No description",
            };

            await TestRunner.RunTestCase(testCase);
        }
Пример #29
0
        public async Task ShouldShowRunbookDescriptionsWhenSpecifiedRunbookExistsInMultipleAutomationAccounts()
        {
            var runbook = this.TestContext.GetRunbookInMultipleAutomationAccounts();

            var testCase = new BotTestCase()
            {
                Action        = $"show runbook {runbook} description",
                ExpectedReply = $"I found the runbook '{runbook}' in multiple automation accounts. Showing the description of all of them:",
            };

            await TestRunner.RunTestCase(testCase);
        }
Пример #30
0
        public async Task StartAllVmsFromSpecifiedResourceGroupShouldNotifyWhenTheSpecifiedResourceGroupDoesNotExist()
        {
            var resourceGroup = "NOTFOUND";

            var testCase = new BotTestCase()
            {
                Action        = $"start all vms from {resourceGroup} resource group",
                ExpectedReply = $"The {resourceGroup} resource group doesn't contain VMs or doesn't exist in the current subscription.",
            };

            await TestRunner.RunTestCase(testCase);
        }