public void OnExecuteWhereMultipleInputFromRecordSetWithOutputToScalarExpectOutputResultOfLastCommandinScalar() { //------------Setup for test-------------------------- var activity = new DsfExecuteCommandLineActivity(); var toolPath = TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; if (!File.Exists(toolPath)) { toolPath = Environment.CurrentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; } var command1 = "\"" + toolPath + "\" output"; var command2 = "\"" + toolPath + "\" differentoutput"; activity.CommandFileName = "[[recset1(*).rec1]]"; activity.CommandResult = "[[OutVar1]]"; var testData = "<root><recset1><rec1>" + command1 + "</rec1></recset1><recset1><rec1>" + command2 + "</rec1></recset1></root>"; SetUpForExecution(activity, testData, "<ADL><recset1><rec1></rec1></recset1><OutVar1/></ADL>"); const string Expected = "This is a different output from the user"; string error; string actual; //------------Execute Test--------------------------- var result = ExecuteProcess(); //------------Assert Results------------------------- GetScalarValueFromEnvironment(result.Environment, "OutVar1", out actual, out error); StringAssert.Contains(actual, Expected); }
public void OnExecuteWhereConsoleErrorsExpectErrorInDatalist() { // ------------Setup for test-------------------------- var activity = new DsfExecuteCommandLineActivity(); var toolPath = TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; if (!File.Exists(toolPath)) { toolPath = Environment.CurrentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; } var randomString = "\"" + toolPath + "\" error"; activity.CommandFileName = randomString; activity.CommandResult = "[[OutVar1]]"; TestStartNode = new FlowStep { Action = activity }; string actual; string error; TestData = "<root><OutVar1 /></root>"; //------------Execute Test--------------------------- var result = ExecuteProcess(); //------------Assert Results------------------------- Assert.IsTrue(result.Environment.HasErrors()); GetScalarValueFromEnvironment(result.Environment, "OutVar1", out actual, out error); Assert.IsNull(actual); var fetchErrors = DataObject.Environment.FetchErrors(); // remove test datalist ;) StringAssert.Contains(fetchErrors, "The console errored"); }
public void OnExecuteWhereConsoleDoesNothingExpectNothingForResult() { //------------Setup for test-------------------------- var activity = new DsfExecuteCommandLineActivity(); var randomString = "\"" + TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe\""; activity.CommandFileName = randomString; activity.CommandResult = "[[OutVar1]]"; TestStartNode = new FlowStep { Action = activity }; string actual; string error; TestData = "<root><OutVar1 /></root>"; //------------Execute Test--------------------------- var result = ExecuteProcess(); //------------Assert Results------------------------- GetScalarValueFromEnvironment(result.Environment, "OutVar1", out actual, out error); // remove test datalist ;) Assert.IsNull(actual); }
public void OnExecuteWhereConsolePathHasSpacesIsNotWrappedInQuotesExpectError() { //------------Setup for test-------------------------- const string ExeName = "ConsoleAppToTestExecuteCommandLineActivity.exe"; var destDir = Path.Combine(TestContext.DeploymentDirectory, Guid.NewGuid() + " Temp"); var sourceFile = Path.Combine(TestContext.DeploymentDirectory, ExeName); if (!File.Exists(sourceFile)) { sourceFile = Path.Combine(Environment.CurrentDirectory, ExeName); } var destFile = Path.Combine(destDir, ExeName); Directory.CreateDirectory(destDir); File.Copy(sourceFile, destFile, true); var activity = new DsfExecuteCommandLineActivity { CommandFileName = destFile, CommandResult = "[[OutVar1]]" }; TestStartNode = new FlowStep { Action = activity }; TestData = "<root><OutVar1 /></root>"; //------------Execute Test--------------------------- var result = ExecuteProcess(); var res = result.Environment.HasErrors(); // remove test datalist ;) //------------Assert Results------------------------- Assert.IsTrue(res); }
public void OnExecuteWhereConsolePathHasNoSpacesIsNotWrappedInQuotesExpectSuccess() { //------------Setup for test-------------------------- var activity = new DsfExecuteCommandLineActivity(); var toolPath = TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; if (!File.Exists(toolPath)) { toolPath = Environment.CurrentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; } var randomString = "\"" + toolPath + "\" \"output\""; activity.CommandFileName = randomString; activity.CommandResult = "[[OutVar1]]"; TestStartNode = new FlowStep { Action = activity }; TestData = "<root><OutVar1 /></root>"; //------------Execute Test--------------------------- var result = ExecuteProcess(); //------------Assert Results------------------------- var fetchErrors = DataObject.Environment.FetchErrors(); if (fetchErrors != string.Empty) { Assert.Fail(fetchErrors); } GetScalarValueFromEnvironment(result.Environment, "OutVar1", out string actual, out string error); // remove test datalist ;) StringAssert.Contains(actual, ""); }
public void OnExecuteWhereOutputToRecordWithSpecificIndexWithConsoleOutputsExpectOutputForResultInsertsToRecordsets() { //------------Setup for test-------------------------- var activity = new DsfExecuteCommandLineActivity(); var toolPath = TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; if (!File.Exists(toolPath)) { toolPath = Environment.CurrentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; } var randomString = "\"" + toolPath + "\" output"; activity.CommandFileName = randomString; activity.CommandResult = "[[recset1(1).field1]]"; SetUpForExecution(activity, "<root></root>", "<ADL><recset1><field1/></recset1></ADL>"); var expected = new List <string> { "This is output from the user" }; string error; //------------Execute Test--------------------------- var result = ExecuteProcess(); //------------Assert Results------------------------- List <string> actual = RetrieveAllRecordSetFieldValues(result.Environment, "recset1", "field1", out error); // remove test datalist ;) var actualArray = actual.ToArray(); actual.Clear(); actual.AddRange(actualArray.Select(s => s.Trim())); CollectionAssert.AreEqual(expected, actual, new ActivityUnitTests.Utils.StringComparer()); }
protected override void BuildDataList() { scenarioContext.TryGetValue("variableList", out List <Tuple <string, string> > variableList); if (variableList == null) { variableList = new List <Tuple <string, string> >(); scenarioContext.Add("variableList", variableList); } var resultVariable = ResultVariable; if (scenarioContext.TryGetValue("resVar", out string resVar)) { resultVariable = resVar; } variableList.Add(new Tuple <string, string>(resultVariable, "")); BuildShapeAndTestData(); scenarioContext.TryGetValue("commandToExecute", out string commandToExecute); var commandLine = new DsfExecuteCommandLineActivity { CommandFileName = commandToExecute, CommandResult = resultVariable, }; TestStartNode = new FlowStep { Action = commandLine }; scenarioContext.Add("activity", commandLine); }
public void OnExecuteWhereMultipleInputFromRecordSetWithOutputToRecordSetExpectOutputResultsToMultipleRowsInRecordSet() { //------------Setup for test-------------------------- var activity = new DsfExecuteCommandLineActivity(); var toolPath = TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; if (!File.Exists(toolPath)) { toolPath = Environment.CurrentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; } var command1 = "\"" + toolPath + "\" output"; var command2 = "\"" + toolPath + "\" differentoutput"; activity.CommandFileName = "[[recset1(*).rec1]]"; activity.CommandResult = "[[recset2().field1]]"; var testData = "<root><recset1><rec1>" + command1 + "</rec1></recset1><recset1><rec1>" + command2 + "</rec1></recset1></root>"; SetUpForExecution(activity, testData, "<ADL><recset1><rec1></rec1></recset1><recset2><field1></field1></recset2></ADL>"); var expected = new List <string> { "This is output from the user", "This is a different output from the user" }; string error; //------------Execute Test--------------------------- var result = ExecuteProcess(); //------------Assert Results------------------------- List <string> actual = RetrieveAllRecordSetFieldValues(result.Environment, "recset2", "field1", out error); var actualArray = actual.ToArray(); actual.Clear(); actual.AddRange(actualArray.Select(s => s.Trim())); CollectionAssert.AreEqual(expected, actual, new ActivityUnitTests.Utils.StringComparer()); }
protected override void BuildDataList() { List<Tuple<string, string>> variableList; ScenarioContext.Current.TryGetValue("variableList", out variableList); if(variableList == null) { variableList = new List<Tuple<string, string>>(); ScenarioContext.Current.Add("variableList", variableList); } variableList.Add(new Tuple<string, string>(ResultVariable, "")); BuildShapeAndTestData(); string commandToExecute; ScenarioContext.Current.TryGetValue("commandToExecute", out commandToExecute); var commandLine = new DsfExecuteCommandLineActivity { CommandFileName = commandToExecute, CommandResult = ResultVariable, }; TestStartNode = new FlowStep { Action = commandLine }; ScenarioContext.Current.Add("activity", commandLine); }
void SetUpForExecution(DsfExecuteCommandLineActivity activity, string testData, string currentDl) { TestStartNode = new FlowStep { Action = activity }; TestData = testData; CurrentDl = currentDl; }
public void ExecuteCommandLineShouldHaveCommandResultProperty() { //------------Setup for test-------------------------- var activity = new DsfExecuteCommandLineActivity(); var randomString = GetRandomString(); //------------Execute Test--------------------------- activity.CommandResult = randomString; //------------Assert Results------------------------- Assert.AreEqual(randomString, activity.CommandResult); }
public void DsfExecuteCommandLineActivity_Priority_Initialization_Normal() { //------------Setup for test-------------------------- var activity = new DsfExecuteCommandLineActivity(); //------------Execute Test--------------------------- ProcessPriorityClass priority = activity.CommandPriority; //------------Assert Results------------------------- Assert.AreEqual(ProcessPriorityClass.Normal, priority); }
public void DsfExecuteCommandLineActivity_UpdateForEachOutputs_NullUpdates_DoesNothing() { //------------Setup for test-------------------------- var command1 = "\"" + TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe\" output"; const string result = "[[OutVar1]]"; var act = new DsfExecuteCommandLineActivity { CommandFileName = command1, CommandResult = result }; act.UpdateForEachOutputs(null, null); //------------Assert Results------------------------- Assert.AreEqual(result, act.CommandResult); }
public void DsfExecuteCommandLineActivity_GetOutputs_Called_ShouldReturnListWithResultValueInIt() { //------------Setup for test-------------------------- var act = new DsfExecuteCommandLineActivity { CommandResult = "[[Bob]]" }; //------------Execute Test--------------------------- var outputs = act.GetOutputs(); //------------Assert Results------------------------- Assert.AreEqual(1, outputs.Count); Assert.AreEqual("[[Bob]]", outputs[0]); }
public void DsExecuteCommandLineActivity_GetState_ReturnsStateVariable() { //---------------Set up test pack------------------- //------------Setup for test-------------------------- var act = new DsfExecuteCommandLineActivity { CommandFileName = "cm bob", CommandResult = "[[res]]" }; //------------Execute Test--------------------------- var stateItems = act.GetState(); Assert.AreEqual(3, stateItems.Count()); var expectedResults = new[] { new StateVariable { Name = "Command", Type = StateVariable.StateType.Input, Value = "cm bob" }, new StateVariable { Name = "CommandPriority", Type = StateVariable.StateType.Input, Value = ProcessPriorityClass.Normal.ToString() }, new StateVariable { Name = "CommandResult", Type = StateVariable.StateType.Output, Value = "[[res]]" } }; var iter = act.GetState().Select( (item, index) => new { value = item, expectValue = expectedResults[index] } ); //------------Assert Results------------------------- foreach (var entry in iter) { Assert.AreEqual(entry.expectValue.Name, entry.value.Name); Assert.AreEqual(entry.expectValue.Type, entry.value.Type); Assert.AreEqual(entry.expectValue.Value, entry.value.Value); } }
public void DsfExecuteCommandLineActivity_UpdateForEachInputs_NullUpdates_DoesNothing() { //------------Setup for test-------------------------- var command1 = "\"" + TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe\" output"; var act = new DsfExecuteCommandLineActivity { CommandFileName = command1, CommandResult = "[[OutVar1]]", CommandPriority = ProcessPriorityClass.RealTime }; //------------Execute Test--------------------------- act.UpdateForEachInputs(null, null); //------------Assert Results------------------------- Assert.AreEqual(command1, act.CommandFileName); Assert.AreEqual(ProcessPriorityClass.RealTime, act.CommandPriority); }
public void GetActivityFieldsOffDsfExecuteCommandLineActivityExpectedAllFindMissingFieldsToBeReturned() { DsfExecuteCommandLineActivity activity = new DsfExecuteCommandLineActivity(); activity.CommandFileName = "[[CommandFileName]]"; activity.CommandResult = "[[CommandResult]]"; Dev2FindMissingStrategyFactory fac = new Dev2FindMissingStrategyFactory(); IFindMissingStrategy strategy = fac.CreateFindMissingStrategy(enFindMissingType.StaticActivity); List <string> actual = strategy.GetActivityFields(activity); List <string> expected = new List <string> { "[[CommandFileName]]", "[[CommandResult]]" }; CollectionAssert.AreEqual(expected, actual); }
public void Dev2FindMissingStrategyFactory_GetActivityFieldsOff_DsfExecuteCommandLine_Activity_ExpectAllFindMissingFieldsToBeReturned() { var activity = new DsfExecuteCommandLineActivity { CommandFileName = "[[CommandFileName]]", CommandResult = "[[CommandResult]]" }; var fac = new Dev2FindMissingStrategyFactory(); var strategy = fac.CreateFindMissingStrategy(enFindMissingType.StaticActivity); var actual = strategy.GetActivityFields(activity); var expected = new List <string> { "[[CommandFileName]]", "[[CommandResult]]" }; CollectionAssert.AreEqual(expected, actual); }
public void DsfExecuteCommandLineActivity_GetForEachOutputs_WhenHasResult_ReturnsOutputList() { //------------Setup for test-------------------------- var command1 = "\"" + TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe\" output"; const string result = "[[OutVar1]]"; DsfExecuteCommandLineActivity act = new DsfExecuteCommandLineActivity { CommandFileName = command1, CommandResult = result }; //------------Execute Test--------------------------- var dsfForEachItems = act.GetForEachOutputs(); //------------Assert Results------------------------- Assert.AreEqual(1, dsfForEachItems.Count); Assert.AreEqual(result, dsfForEachItems[0].Name); Assert.AreEqual(result, dsfForEachItems[0].Value); }
public void OnExecuteWhereConsolePathHasSpacesIsNotWrappedInQuotesExpectError() { //------------Setup for test-------------------------- const string ExeName = "ConsoleAppToTestExecuteCommandLineActivity.exe"; string destFile; if (!TestContext.DeploymentDirectory.Contains(" ")) { var destDir = Path.Combine(TestContext.DeploymentDirectory, Guid.NewGuid() + " Temp"); var sourceFile = Path.Combine(TestContext.DeploymentDirectory, ExeName); if (!File.Exists(sourceFile)) { sourceFile = Path.Combine(Environment.CurrentDirectory, ExeName); } destFile = Path.Combine(destDir, ExeName); Directory.CreateDirectory(destDir); File.Copy(sourceFile, destFile, true); } else { destFile = TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; } var activity = new DsfExecuteCommandLineActivity { CommandFileName = destFile, CommandResult = "[[OutVar1]]" }; TestStartNode = new FlowStep { Action = activity }; TestData = "<root><OutVar1 /></root>"; //------------Execute Test--------------------------- var result = ExecuteProcess(); var hasErrors = result.Environment.HasErrors(); var res = result.Environment.Errors.FirstOrDefault(); // remove test datalist ;) //------------Assert Results------------------------- Assert.IsTrue(hasErrors); Assert.IsTrue(res.StartsWith("'" + TestContext.DeploymentDirectory.Substring(0, TestContext.DeploymentDirectory.IndexOf(" ")) + "' is not recognized as an internal or external command,")); Assert.IsTrue(res.Contains("operable program or batch file.")); }
public void DsfExecuteCommandLineActivity_UpdateForEachOutputs_1Updates_UpdateCommandResult() { //------------Setup for test-------------------------- var command1 = "\"" + TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe\" output"; const string result = "[[OutVar1]]"; var act = new DsfExecuteCommandLineActivity { CommandFileName = command1, CommandResult = result }; var tuple1 = new Tuple <string, string>("[[OutVar1]]", "Test"); //------------Execute Test--------------------------- act.UpdateForEachOutputs(new List <Tuple <string, string> > { tuple1 }, null); //------------Assert Results------------------------- Assert.AreEqual("Test", act.CommandResult); }
public void DsfExecuteCommandLineActivity_UpdateForEachInputs_UpdatesNotMatching_DoesNotUpdateRecordsetName() { //------------Setup for test-------------------------- var command1 = "\"" + TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe\" output"; var act = new DsfExecuteCommandLineActivity { CommandFileName = command1, CommandResult = "[[OutVar1]]", CommandPriority = ProcessPriorityClass.RealTime }; var tuple1 = new Tuple <string, string>("Test", "Test"); //------------Execute Test--------------------------- act.UpdateForEachInputs(new List <Tuple <string, string> > { tuple1 }, null); //------------Assert Results------------------------- Assert.AreEqual(command1, act.CommandFileName); Assert.AreEqual(ProcessPriorityClass.RealTime, act.CommandPriority); }
public void DsfExecuteCommandLineActivity_GetForEachInputs_WhenHasExpression_ReturnsInputList() { //------------Setup for test-------------------------- const ProcessPriorityClass commandPriority = ProcessPriorityClass.RealTime; var command1 = "\"" + TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe\" output"; var act = new DsfExecuteCommandLineActivity { CommandFileName = command1, CommandResult = "[[OutVar1]]", CommandPriority = commandPriority }; //------------Execute Test--------------------------- var dsfForEachItems = act.GetForEachInputs(); //------------Assert Results------------------------- Assert.AreEqual(2, dsfForEachItems.Count); Assert.AreEqual(command1, dsfForEachItems[0].Name); Assert.AreEqual(command1, dsfForEachItems[0].Value); Assert.AreEqual(commandPriority.ToString(), dsfForEachItems[1].Name); Assert.AreEqual(commandPriority.ToString(), dsfForEachItems[1].Value); }
public void OnExecuteWhereConsoleDoesNothingExpectNothingForResult() { //------------Setup for test-------------------------- var activity = new DsfExecuteCommandLineActivity(); activity.CommandFileName = "\"" + TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe\" output"; activity.CommandResult = "[[Result]]"; TestStartNode = new FlowStep { Action = activity }; TestData = "<root><Result /></root>"; //------------Execute Test--------------------------- var result = ExecuteProcess(); //------------Assert Results------------------------- GetScalarValueFromEnvironment(result.Environment, "Result", out string actual, out string error); Assert.AreEqual("This is output from the user", actual, "Executing an exe with execute commandline activity did not return the expected output."); }
public void DsfExecuteCommandLineActivity_UpdateForEachInputs_MoreThan1Updates_DoesNothing() { //------------Setup for test-------------------------- var command1 = "\"" + TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe\" output"; var act = new DsfExecuteCommandLineActivity { CommandFileName = command1, CommandResult = "[[OutVar1]]", CommandPriority = ProcessPriorityClass.RealTime }; var tuple1 = new Tuple <string, string>("Test", "Test"); var tuple2 = new Tuple <string, string>(command1, "Test2"); var tuple3 = new Tuple <string, string>(ProcessPriorityClass.RealTime.ToString(), ProcessPriorityClass.High.ToString()); //------------Execute Test--------------------------- act.UpdateForEachInputs(new List <Tuple <string, string> > { tuple1, tuple2, tuple3 }, null); //------------Assert Results------------------------- Assert.AreEqual("Test2", act.CommandFileName); Assert.AreEqual(ProcessPriorityClass.High, act.CommandPriority); }
public void Equals_Given_EmptyActivityTools_AreEqual() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var activity = new DsfExecuteCommandLineActivity() { UniqueID = uniqueId }; var activity1 = new DsfExecuteCommandLineActivity() { UniqueID = uniqueId }; //---------------Assert Precondition---------------- Assert.IsNotNull(activity); //---------------Execute Test ---------------------- var @equals = activity.Equals(activity1); //---------------Test Result ----------------------- Assert.IsTrue(@equals); }
public void Equals_Given_Different_CommandPriority_Is_Not_Equal() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var activity1 = new DsfExecuteCommandLineActivity() { UniqueID = uniqueId, CommandPriority = ProcessPriorityClass.High }; var activity = new DsfExecuteCommandLineActivity() { UniqueID = uniqueId, CommandPriority = ProcessPriorityClass.Normal }; //---------------Assert Precondition---------------- Assert.IsNotNull(activity1); //---------------Execute Test ---------------------- var @equals = activity1.Equals(activity); //---------------Test Result ----------------------- Assert.IsFalse(@equals); }
public void Equals_Given_Different_DisplayName_Is_Not_Equal() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var activity1 = new DsfExecuteCommandLineActivity() { UniqueID = uniqueId, DisplayName = "A" }; var activity = new DsfExecuteCommandLineActivity() { UniqueID = uniqueId, DisplayName = "ass" }; //---------------Assert Precondition---------------- Assert.IsNotNull(activity1); //---------------Execute Test ---------------------- var @equals = activity1.Equals(activity); //---------------Test Result ----------------------- Assert.IsFalse(@equals); }
public void Equals_Given_Same_CommandFileName_CommandResult_Casing_IsNotEqual() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var activity1 = new DsfExecuteCommandLineActivity() { UniqueID = uniqueId, CommandResult = "A" }; var activity = new DsfExecuteCommandLineActivity() { UniqueID = uniqueId, CommandResult = "a" }; //---------------Assert Precondition---------------- Assert.IsNotNull(activity1); //---------------Execute Test ---------------------- var @equals = activity1.Equals(activity); //---------------Test Result ----------------------- Assert.IsFalse(@equals); }
public void OnExecuteWhereConsoleOutputsExpectOutputForResult() { //------------Setup for test-------------------------- var activity = new DsfExecuteCommandLineActivity(); var toolPath = TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; if (!File.Exists(toolPath)) { toolPath = Environment.CurrentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; } var randomString = "\"" + toolPath + "\" output"; activity.CommandFileName = randomString; activity.CommandResult = "[[OutVar1]]"; TestStartNode = new FlowStep { Action = activity }; string actual; string error; TestData = "<root><OutVar1 /></root>"; //------------Execute Test--------------------------- var result = ExecuteProcess(); //------------Assert Results------------------------- var fetchErrors = Compiler.FetchErrors(result.DataListID); if (fetchErrors != string.Empty) { Assert.Fail(fetchErrors); } GetScalarValueFromDataList(result.DataListID, "OutVar1", out actual, out error); // remove test datalist ;) DataListRemoval(result.DataListID); StringAssert.Contains(actual, "This is output from the user"); }
public void OnExecuteWhereConsoleOutputsExpectOutputForResultExplorer() { //------------Setup for test-------------------------- var activity = new DsfExecuteCommandLineActivity(); const string RandomString = @"C:\Windows\explorer.exe"; activity.CommandFileName = RandomString; activity.CommandResult = "[[OutVar1]]"; TestStartNode = new FlowStep { Action = activity }; TestData = "<root><OutVar1 /></root>"; //------------Execute Test--------------------------- var result = ExecuteProcess(); //------------Assert Results------------------------- Assert.IsTrue(result.Environment.HasErrors()); var fetchErrors = DataObject.Environment.FetchErrors(); // remove test datalist ;) StringAssert.Contains(fetchErrors, "Cannot execute explorer from tool."); }
public void OnExecuteWhereMultipleInputFromRecordSetWithOutputToRecordSetExpectOutputResultsToMultipleRowsInRecordSet() { //------------Setup for test-------------------------- var activity = new DsfExecuteCommandLineActivity(); var toolPath = TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; if(!File.Exists(toolPath)) { toolPath = Environment.CurrentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; } var command1 = "\"" + toolPath + "\" output"; var command2 = "\"" + toolPath + "\" differentoutput"; activity.CommandFileName = "[[recset1(*).rec1]]"; activity.CommandResult = "[[recset2().field1]]"; var testData = "<root><recset1><rec1>" + command1 + "</rec1></recset1><recset1><rec1>" + command2 + "</rec1></recset1></root>"; SetUpForExecution(activity, testData, "<ADL><recset1><rec1></rec1></recset1><recset2><field1></field1></recset2></ADL>"); var expected = new List<string> { "This is output from the user", "This is a different output from the user" }; string error; //------------Execute Test--------------------------- var result = ExecuteProcess(); //------------Assert Results------------------------- List<string> actual = RetrieveAllRecordSetFieldValues(result.Environment, "recset2", "field1", out error); var actualArray = actual.ToArray(); actual.Clear(); actual.AddRange(actualArray.Select(s => s.Trim())); CollectionAssert.AreEqual(expected, actual, new ActivityUnitTests.Utils.StringComparer()); }
public void OnExecuteWhereMultipleInputFromRecordSetWithOutputToScalarExpectOutputResultOfLastCommandinScalar() { //------------Setup for test-------------------------- var activity = new DsfExecuteCommandLineActivity(); var toolPath = TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; if(!File.Exists(toolPath)) { toolPath = Environment.CurrentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; } var command1 = "\"" + toolPath + "\" output"; var command2 = "\"" + toolPath + "\" differentoutput"; activity.CommandFileName = "[[recset1(*).rec1]]"; activity.CommandResult = "[[OutVar1]]"; var testData = "<root><recset1><rec1>" + command1 + "</rec1></recset1><recset1><rec1>" + command2 + "</rec1></recset1></root>"; SetUpForExecution(activity, testData, "<ADL><recset1><rec1></rec1></recset1><OutVar1/></ADL>"); const string Expected = "This is a different output from the user"; string error; string actual; //------------Execute Test--------------------------- var result = ExecuteProcess(); //------------Assert Results------------------------- GetScalarValueFromEnvironment(result.Environment, "OutVar1", out actual, out error); StringAssert.Contains(actual, Expected); }
public void DsfExecuteCommandLineActivity_UpdateForEachInputs_NullUpdates_DoesNothing() { //------------Setup for test-------------------------- var command1 = "\"" + TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe\" output"; var act = new DsfExecuteCommandLineActivity { CommandFileName = command1, CommandResult = "[[OutVar1]]", CommandPriority = ProcessPriorityClass.RealTime }; //------------Execute Test--------------------------- act.UpdateForEachInputs(null); //------------Assert Results------------------------- Assert.AreEqual(command1, act.CommandFileName); Assert.AreEqual(ProcessPriorityClass.RealTime, act.CommandPriority); }
public void DsfExecuteCommandLineActivity_UpdateForEachInputs_MoreThan1Updates_DoesNothing() { //------------Setup for test-------------------------- var command1 = "\"" + TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe\" output"; var act = new DsfExecuteCommandLineActivity { CommandFileName = command1, CommandResult = "[[OutVar1]]", CommandPriority = ProcessPriorityClass.RealTime }; var tuple1 = new Tuple<string, string>("Test", "Test"); var tuple2 = new Tuple<string, string>(command1, "Test2"); var tuple3 = new Tuple<string, string>(ProcessPriorityClass.RealTime.ToString(), ProcessPriorityClass.High.ToString()); //------------Execute Test--------------------------- act.UpdateForEachInputs(new List<Tuple<string, string>> { tuple1, tuple2, tuple3 }); //------------Assert Results------------------------- Assert.AreEqual("Test2", act.CommandFileName); Assert.AreEqual(ProcessPriorityClass.High, act.CommandPriority); }
public void OnExecute_WhereConsolePathStartsWithCmd_ShouldError() { //------------Setup for test-------------------------- var activity = new DsfExecuteCommandLineActivity { CommandFileName = "cmd C:\\", CommandResult = "[[OutVar1]]" }; TestStartNode = new FlowStep { Action = activity }; TestData = "<root><OutVar1 /></root>"; //------------Execute Test--------------------------- var result = ExecuteProcess(); //------------Assert Results------------------------- var fetchErrors = result.Environment.FetchErrors(); if(fetchErrors == string.Empty) { Assert.Fail("no error"); } StringAssert.Contains(fetchErrors, "Cannot execute CMD from tool."); }
public void DsfExecuteCommandLineActivity_UpdateForEachOutputs_1Updates_UpdateCommandResult() { //------------Setup for test-------------------------- var command1 = "\"" + TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe\" output"; const string result = "[[OutVar1]]"; var act = new DsfExecuteCommandLineActivity { CommandFileName = command1, CommandResult = result }; var tuple1 = new Tuple<string, string>("[[OutVar1]]", "Test"); //------------Execute Test--------------------------- act.UpdateForEachOutputs(new List<Tuple<string, string>> { tuple1 }); //------------Assert Results------------------------- Assert.AreEqual("Test", act.CommandResult); }
public void OnExecuteWhereOutputToRecordWithSpecificIndexWithConsoleOutputsExpectOutputForResultInsertsToRecordsets() { //------------Setup for test-------------------------- var activity = new DsfExecuteCommandLineActivity(); var toolPath = TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; if(!File.Exists(toolPath)) { toolPath = Environment.CurrentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; } var randomString = "\"" + toolPath + "\" output"; activity.CommandFileName = randomString; activity.CommandResult = "[[recset1(1).field1]]"; SetUpForExecution(activity, "<root></root>", "<ADL><recset1><field1/></recset1></ADL>"); var expected = new List<string> { "This is output from the user" }; string error; //------------Execute Test--------------------------- var result = ExecuteProcess(); //------------Assert Results------------------------- List<string> actual = RetrieveAllRecordSetFieldValues(result.Environment, "recset1", "field1", out error); // remove test datalist ;) var actualArray = actual.ToArray(); actual.Clear(); actual.AddRange(actualArray.Select(s => s.Trim())); CollectionAssert.AreEqual(expected, actual, new ActivityUnitTests.Utils.StringComparer()); }
public void OnExecuteWhereConsoleErrorsExpectErrorInDatalist() { // ------------Setup for test-------------------------- var activity = new DsfExecuteCommandLineActivity(); var toolPath = TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; if(!File.Exists(toolPath)) { toolPath = Environment.CurrentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; } var randomString = "\"" + toolPath + "\" error"; activity.CommandFileName = randomString; activity.CommandResult = "[[OutVar1]]"; TestStartNode = new FlowStep { Action = activity }; string actual; string error; TestData = "<root><OutVar1 /></root>"; //------------Execute Test--------------------------- var result = ExecuteProcess(); //------------Assert Results------------------------- Assert.IsTrue(result.Environment.HasErrors()); GetScalarValueFromEnvironment(result.Environment, "OutVar1", out actual, out error); Assert.IsNull(actual); var fetchErrors = DataObject.Environment.FetchErrors(); // remove test datalist ;) StringAssert.Contains(fetchErrors, "The console errored"); }
public void DsfExecuteCommandLineActivity_UpdateForEachOutputs_NullUpdates_DoesNothing() { //------------Setup for test-------------------------- var command1 = "\"" + TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe\" output"; const string result = "[[OutVar1]]"; var act = new DsfExecuteCommandLineActivity { CommandFileName = command1, CommandResult = result }; act.UpdateForEachOutputs(null); //------------Assert Results------------------------- Assert.AreEqual(result, act.CommandResult); }
public void OnExecuteWhereConsoleOutputsExpectOutputForResult() { //------------Setup for test-------------------------- var activity = new DsfExecuteCommandLineActivity(); var toolPath = TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; if(!File.Exists(toolPath)) { toolPath = Environment.CurrentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe"; } var randomString = "\"" + toolPath + "\" output"; activity.CommandFileName = randomString; activity.CommandResult = "[[OutVar1]]"; TestStartNode = new FlowStep { Action = activity }; string actual; string error; TestData = "<root><OutVar1 /></root>"; //------------Execute Test--------------------------- var result = ExecuteProcess(); //------------Assert Results------------------------- var fetchErrors = DataObject.Environment.FetchErrors(); if(fetchErrors != string.Empty) { Assert.Fail(fetchErrors); } GetScalarValueFromEnvironment(result.Environment, "OutVar1", out actual, out error); // remove test datalist ;) StringAssert.Contains(actual, "This is output from the user"); }
public void DsfExecuteCommandLineActivity_UpdateForEachInputs_UpdatesNotMatching_DoesNotUpdateRecordsetName() { //------------Setup for test-------------------------- var command1 = "\"" + TestContext.DeploymentDirectory + "\\ConsoleAppToTestExecuteCommandLineActivity.exe\" output"; var act = new DsfExecuteCommandLineActivity { CommandFileName = command1, CommandResult = "[[OutVar1]]", CommandPriority = ProcessPriorityClass.RealTime }; var tuple1 = new Tuple<string, string>("Test", "Test"); //------------Execute Test--------------------------- act.UpdateForEachInputs(new List<Tuple<string, string>> { tuple1 }); //------------Assert Results------------------------- Assert.AreEqual(command1, act.CommandFileName); Assert.AreEqual(ProcessPriorityClass.RealTime, act.CommandPriority); }
public void GetActivityFieldsOffDsfExecuteCommandLineActivityExpectedAllFindMissingFieldsToBeReturned() { DsfExecuteCommandLineActivity activity = new DsfExecuteCommandLineActivity(); activity.CommandFileName = "[[CommandFileName]]"; activity.CommandResult = "[[CommandResult]]"; Dev2FindMissingStrategyFactory fac = new Dev2FindMissingStrategyFactory(); IFindMissingStrategy strategy = fac.CreateFindMissingStrategy(enFindMissingType.StaticActivity); List<string> actual = strategy.GetActivityFields(activity); List<string> expected = new List<string> { "[[CommandFileName]]", "[[CommandResult]]" }; CollectionAssert.AreEqual(expected, actual); }
public void OnExecuteWhereConsolePathHasSpacesIsNotWrappedInQuotesExpectError() { //------------Setup for test-------------------------- const string ExeName = "ConsoleAppToTestExecuteCommandLineActivity.exe"; var destDir = Path.Combine(TestContext.DeploymentDirectory, Guid.NewGuid() + " Temp"); var sourceFile = Path.Combine(TestContext.DeploymentDirectory, ExeName); if(!File.Exists(sourceFile)) { sourceFile = Path.Combine(Environment.CurrentDirectory, ExeName); } var destFile = Path.Combine(destDir, ExeName); Directory.CreateDirectory(destDir); File.Copy(sourceFile, destFile, true); var activity = new DsfExecuteCommandLineActivity { CommandFileName = destFile, CommandResult = "[[OutVar1]]" }; TestStartNode = new FlowStep { Action = activity }; TestData = "<root><OutVar1 /></root>"; //------------Execute Test--------------------------- var result = ExecuteProcess(); var res = result.Environment.HasErrors(); // remove test datalist ;) //------------Assert Results------------------------- Assert.IsTrue(res); }