public void DelayBeforeKillingTest() { ExecutableAction target = new ExecutableAction(); 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."); }
public void StoreToVariableTest() { ExecutableAction target = new ExecutableAction(); 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."); }
public void ParametersTest() { ExecutableAction target = new ExecutableAction(); Assert.IsTrue(target.Parameters == string.Empty, "The property 'Parameters' is not properly initialized."); string expected = "-k"; string actual; target.Parameters = expected; actual = target.Parameters; Assert.AreEqual(expected, actual, "The property 'Parameters' is not properly set."); Assert.IsTrue(target.GetXMLAction().Contains("<Parameters>" + expected + "</Parameters>"), "The property 'Parameters' is not correctly encoded in the XmlAction string."); }
public void KillProcessTest() { ExecutableAction target = new ExecutableAction(); 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."); }
public void GetXMLActionTest() { ExecutableAction target = new ExecutableAction(); target.PathToTheFile = @"C:\Windows\System32\MsiExec.exe"; 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.ExecutableAction</ElementType>\r\n<PathToTheFile>" + target.PathToTheFile + "</PathToTheFile>\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, "GetXmlAction doesn't returns the good string."); }