Exemple #1
0
        public void GetXMLActionTest()
        {
            RunPowershellScriptAction target = new RunPowershellScriptAction();

            target.FullPath           = @"C:\Windows\System32\Config.ps1";
            target.Parameters         = @"\u AC76BA86-7AD7-1036-7B44-AB0000000001 \qn \norestart";
            target.KillProcess        = true;
            target.DelayBeforeKilling = 5;
            target.StoreToVariable    = true;

            string expected = "<Action>\r\n<ElementType>CustomActions.RunPowershellScriptAction</ElementType>\r\n<FullPath>" + target.FullPath +
                              "</FullPath>\r\n<Parameters>" + target.Parameters +
                              "</Parameters>\r\n<KillProcess>" + "true" +
                              "</KillProcess>\r\n<DelayBeforeKilling>" + target.DelayBeforeKilling.ToString() + "</DelayBeforeKilling>\r\n<StoreToVariable>true</StoreToVariable>\r\n</Action>";
            string actual;

            actual = target.GetXMLAction();
            Assert.AreEqual(expected, actual, true, "The 'GetXMLAction' method doesn't return the good string");

            target.FullPath = @"  C:\Windows\System32\Config.ps1   ";
            expected        = "<Action>\r\n<ElementType>CustomActions.RunPowershellScriptAction</ElementType>\r\n<FullPath>" + target.FullPath +
                              "</FullPath>\r\n<Parameters>" + target.Parameters +
                              "</Parameters>\r\n<KillProcess>" + "true" +
                              "</KillProcess>\r\n<DelayBeforeKilling>" + target.DelayBeforeKilling.ToString() + "</DelayBeforeKilling>\r\n<StoreToVariable>true</StoreToVariable>\r\n</Action>";
            actual = target.GetXMLAction();
            Assert.AreEqual(expected, actual, true, "The 'GetXMLAction' method doesn't return the good string");
        }
Exemple #2
0
        public void DelayBeforeKillingTest()
        {
            RunPowershellScriptAction target = new RunPowershellScriptAction();

            Assert.AreEqual(target.DelayBeforeKilling, 10, "The property 'DelayBeforeKilling' is not properly initialized.");

            int expected = 1;
            int actual;

            target.DelayBeforeKilling = expected;
            actual = target.DelayBeforeKilling;
            Assert.AreEqual(expected, actual, "The property 'DelayBeforeKilling' is not properly set.");
            Assert.IsTrue(target.GetXMLAction().Contains("<DelayBeforeKilling>" + expected.ToString() + "</DelayBeforeKilling>"), "The property 'DelayBeoreKilling' is not correctly encoded in the XmlAction string.");

            expected = 120;
            target.DelayBeforeKilling = expected;
            actual = target.DelayBeforeKilling;
            Assert.AreEqual(expected, actual, "The property 'DelayBeforeKilling' is not properly set.");
            Assert.IsTrue(target.GetXMLAction().Contains("<DelayBeforeKilling>" + expected.ToString() + "</DelayBeforeKilling>"), "The property 'DelayBeoreKilling' is not correctly encoded in the XmlAction string.");

            expected = 120;
            target.DelayBeforeKilling = 121;
            actual = target.DelayBeforeKilling;
            Assert.AreEqual(expected, actual, "The property 'DelayBeforeKilling' doesn't respect maximum.");

            expected = 120;
            target.DelayBeforeKilling = 0;
            actual = target.DelayBeforeKilling;
            Assert.AreEqual(expected, actual, "The property 'DelayBeforeKilling' doesn't respect minimum.");
        }
Exemple #3
0
        public void StoreToVariableTest()
        {
            RunPowershellScriptAction target = new RunPowershellScriptAction();

            bool expected = false;
            bool actual;

            target.StoreToVariable = expected;
            actual = target.StoreToVariable;
            Assert.AreEqual(expected, actual, "The property 'StoreToVariable' is not properly initialized.");
            Assert.IsTrue(target.GetXMLAction().Contains("<StoreToVariable>" + expected.ToString() + "</StoreToVariable>"), "The property 'StoreToVariable' is not correctly encoded in the XmlAction string.");

            expected = true;
            target.StoreToVariable = expected;
            actual = target.StoreToVariable;
            Assert.AreEqual(expected, actual, "The property 'StoreToVariable' is not properly set.");
            Assert.IsTrue(target.GetXMLAction().Contains("<StoreToVariable>" + expected.ToString() + "</StoreToVariable>"), "The property 'StoreToVariable' is not correctly encoded in the XmlAction string.");
        }
Exemple #4
0
        public void KillProcessTest()
        {
            RunPowershellScriptAction target = new RunPowershellScriptAction();

            Assert.IsFalse(target.KillProcess, "The property is not properly initialized.");

            bool expected = true;
            bool actual;

            target.KillProcess = expected;
            actual             = target.KillProcess;
            Assert.AreEqual(expected, actual, "The property is not properly set.");
            Assert.IsTrue(target.GetXMLAction().Contains("<KillProcess>" + expected.ToString() + "</KillProcess>"), "The property 'KillProcess' is not correctly encoded in the XmlAction string.");
        }