示例#1
0
        public void Can_run_notepad_via_a_script_a_running_VM()
        {
            // arrange
            var target = new VirtualPC {
                Action = VirtualPCAction.RunScript
            };

            Dictionary <string, object> args = new Dictionary <string, object>
            {
                { "VMName", this.VMName },
                { "Script", new ScriptItem[]
                  {
                      new ScriptItem(ScriptAction.TypeKeySequence, "Key_LeftWindows"),
                      new ScriptItem(ScriptAction.TypeKeySequence, "Key_Up"),
                      new ScriptItem(ScriptAction.TypeKeySequence, "Key_Up"),
                      new ScriptItem(ScriptAction.TypeKeySequence, "Key_Up"),
                      new ScriptItem(ScriptAction.TypeKeySequence, "Key_Enter"),
                      new ScriptItem(ScriptAction.TypeAsciiText, "notepad"),
                      new ScriptItem(ScriptAction.TypeKeySequence, "Key_Enter"),
                      new ScriptItem(ScriptAction.TypeAsciiText, "Here is some text")
                  } }
            };
            WorkflowInvoker invoker = new WorkflowInvoker(target);

            // act
            var results = invoker.Invoke(args);

            // assert
            Assert.AreEqual(true, results["Success"]);
        }
示例#2
0
        public void Can_merge_a_change_disk_on_a_VM_and_will_wait_for_completion()
        {
            // arrange
            var target = new VirtualPC {
                Action = VirtualPCAction.MergeUndoDisks, WaitForCompletion = -1
            };

            Dictionary <string, object> args = new Dictionary <string, object>
            {
                { "VMName", this.VMName }
            };
            WorkflowInvoker invoker = new WorkflowInvoker(target);

            // act
            var results = invoker.Invoke(args);

            // assert
            Assert.AreEqual(true, results["Success"]);
        }
示例#3
0
        public void Can_discard_undo_disk_from_a_stopped_VM()
        {
            // arrange
            var target = new VirtualPC {
                Action = VirtualPCAction.DiscardUndoDisks
            };

            Dictionary <string, object> args = new Dictionary <string, object>
            {
                { "VMName", this.VMName }
            };
            WorkflowInvoker invoker = new WorkflowInvoker(target);

            // act
            var results = invoker.Invoke(args);

            // assert
            Assert.AreEqual(true, results["Success"]);
        }
        public void Can_restart_a_VM_that_is_not_off()
        {
            // arrange
            var target = new VirtualPC {
                Action = VirtualPCAction.Restart
            };

            Dictionary <string, object> args = new Dictionary <string, object>
            {
                { "VMName", this.VMName }
            };
            WorkflowInvoker invoker = new WorkflowInvoker(target);

            // act
            var results = invoker.Invoke(args);

            // assert
            Assert.AreEqual(true, results["Success"]);
        }
        public void Can_turnoff_from_a_running_VM()
        {
            // arrange
            var target = new VirtualPC {
                Action = VirtualPCAction.Turnoff
            };

            Dictionary <string, object> args = new Dictionary <string, object>
            {
                { "VMName", this.VMName }
            };
            WorkflowInvoker invoker = new WorkflowInvoker(target);

            // act
            var results = invoker.Invoke(args);

            // assert
            Assert.AreEqual(true, results["Success"]);
        }
        public void Can_list_the_vms_on_host()
        {
            // arrange
            var target = new VirtualPC {
                Action = VirtualPCAction.List
            };

            Dictionary <string, object> args = new Dictionary <string, object>
            {
            };
            WorkflowInvoker invoker = new WorkflowInvoker(target);

            // act
            var results = invoker.Invoke(args);

            // assert
            Assert.AreEqual(1, results["VirtualMachineCount"]);
            Assert.AreEqual(this.VMName, ((string[])results["VirtualMachines"])[0]);
        }
示例#7
0
        public void Can_remove_a_disk_from_a_stopped_VM()
        {
            // arrange
            var target = new VirtualPC {
                Action = VirtualPCAction.RemoveHardDiskConnection
            };

            Dictionary <string, object> args = new Dictionary <string, object>
            {
                { "VMName", this.VMName },
                { "FileName", @"C:\VPC Images\ScratchXP\ExtraDrive.vhd" },
            };
            WorkflowInvoker invoker = new WorkflowInvoker(target);

            // act
            var results = invoker.Invoke(args);

            // assert
            Assert.AreEqual(true, results["Success"]);
        }
示例#8
0
        public void Can_click_the_mouse_on_a_running_VM()
        {
            // arrange
            var target = new VirtualPC {
                Action = VirtualPCAction.RunScript
            };

            Dictionary <string, object> args = new Dictionary <string, object>
            {
                { "VMName", this.VMName },
                { "Script", new ScriptItem[] { new ScriptItem(ScriptAction.ClickLeft, string.Empty) } }
            };
            WorkflowInvoker invoker = new WorkflowInvoker(target);

            // act
            var results = invoker.Invoke(args);

            // assert
            Assert.AreEqual(true, results["Success"]);
        }
        public void Can_check_if_vm_is_screenlocked()
        {
            // arrange
            var target = new VirtualPC {
                Action = VirtualPCAction.IsScreenLocked
            };

            Dictionary <string, object> args = new Dictionary <string, object>
            {
                { "VMName", this.VMName }
            };
            WorkflowInvoker invoker = new WorkflowInvoker(target);

            // act
            var results = invoker.Invoke(args);

            // assert
            Assert.AreEqual(true, results["Success"]);
            Assert.AreEqual(true, results["Result"], "Is not locked");
        }
        public void Wait_until_a_running_VM_is_under_a_given_load()
        {
            // arrange
            var target = new VirtualPC {
                Action = VirtualPCAction.WaitForLowCpuUtilization
            };

            Dictionary <string, object> args = new Dictionary <string, object>
            {
                { "VMName", this.VMName },
                { "MaxCpuUsage", 50 },
                { "MaxCpuThreshold", 7 }
            };
            WorkflowInvoker invoker = new WorkflowInvoker(target);

            // act
            var results = invoker.Invoke(args);

            // assert
            Assert.AreEqual(true, results["Success"]);
        }
示例#11
0
        public void Can_take_a_screen_shot()
        {
            // arrange
            var target = new VirtualPC {
                Action = VirtualPCAction.TakeScreenshot
            };
            var imageFile = "image.bmp";

            Dictionary <string, object> args = new Dictionary <string, object>
            {
                { "VMName", this.VMName },
                { "FileName", imageFile }
            };
            WorkflowInvoker invoker = new WorkflowInvoker(target);

            // act
            var results = invoker.Invoke(args);

            // assert
            Assert.AreEqual(true, results["Success"]);
            Assert.IsTrue(File.Exists(imageFile));
        }