public void WarewolfListIterator_FetchNextValue_NoValuesToIterateOn_ReturnsException() { //------------Setup for test-------------------------- var env = new ExecutionEnvironment(); var warewolfListIterator = new WarewolfListIterator(); var warewolfIterator = new WarewolfIterator(env.Eval("[[rec().a]]", 0)); //------------Execute Test--------------------------- var value = warewolfListIterator.FetchNextValue(warewolfIterator); //------------Assert Results------------------------- Assert.IsNull(value); }
public void WarewolfEnvironment_ErrorsAreUnique() { ExecutionEnvironment env = new ExecutionEnvironment(); env.AddError("bob"); Assert.AreEqual(env.Errors.Count,1); env.AddError("bob"); Assert.AreEqual(env.Errors.Count, 1); env.AddError("dave"); Assert.AreEqual(env.Errors.Count, 2); env.AddError("dave"); Assert.AreEqual(env.Errors.Count, 2); }
public void WarewolfListIterator_FetchNextValue_HasValues_ShouldReturnValue() { //------------Setup for test-------------------------- var env = new ExecutionEnvironment(); env.Assign("[[rec().a]]", "Test", 0); env.Assign("[[rec().a]]", "Test2", 0); env.Assign("[[rec().a]]", "Test4", 0); env.Assign("[[rec().a]]", "Test5", 0); env.CommitAssign(); var warewolfListIterator = new WarewolfListIterator(); var warewolfIterator = new WarewolfIterator(env.Eval("[[rec().a]]", 0)); warewolfListIterator.AddVariableToIterateOn(warewolfIterator); //------------Execute Test--------------------------- var value = warewolfListIterator.FetchNextValue(warewolfIterator); //------------Assert Results------------------------- Assert.AreEqual("Test5", value); }
public void WarewolfListIterator_FetchNextValue_WithIndex_HasMoreData_ShouldReturnTrue_WhenCounterSmallerThanLargestIndex() { //------------Setup for test-------------------------- var env = new ExecutionEnvironment(); env.Assign("[[rec().a]]", "Test", 0); env.Assign("[[rec().a]]", "Test2", 0); env.Assign("[[rec().a]]", "Test4", 0); env.Assign("[[rec().a]]", "Test5", 0); env.CommitAssign(); var warewolfListIterator = new WarewolfListIterator(); var warewolfIterator = new WarewolfIterator(env.Eval("[[rec().a]]", 0)); warewolfListIterator.AddVariableToIterateOn(warewolfIterator); //------------Execute Test--------------------------- var hasMoreData = warewolfListIterator.HasMoreData(); //------------Assert Results------------------------- Assert.IsTrue(hasMoreData); }
public void SharepointUtils_BuildCamlQuery_ValidFilter_In_RecSetResultCommaSeperated() { //------------Setup for test-------------------------- var sharepointUtils = new SharepointUtils(); var executionEnvironment = new ExecutionEnvironment(); executionEnvironment.Assign("[[names().name]]", "bob,dora", 0); //------------Execute Test--------------------------- var camlQuery = sharepointUtils.BuildCamlQuery(executionEnvironment, new List<SharepointSearchTo> { new SharepointSearchTo("Title", "In", "[[names(*).name]]", 1) { InternalName = "Title" } }, new List<ISharepointFieldTo> { new SharepointFieldTo { InternalName = "Title", Type = SharepointFieldType.Text } }, 0); //------------Assert Results------------------------- Assert.AreEqual("<View><Query><Where><In><FieldRef Name=\"Title\"></FieldRef><Values><Value Type=\"Text\">bob</Value><Value Type=\"Text\">dora</Value></Values></In>" + Environment.NewLine + "</Where></Query></View>", camlQuery.ViewXml); }
public void WarewolfParse_Eval_Delete_Mid() { ExecutionEnvironment env = new ExecutionEnvironment(); env.AssignWithFrame(new AssignValue("[[rec().a]]", "25")); env.AssignWithFrame(new AssignValue("[[rec().a]]", "26")); env.AssignWithFrame(new AssignValue("[[rec().a]]", "25")); env.AssignWithFrame(new AssignValue("[[rec().a]]", "28")); env.EvalDelete("[[rec(3)]]"); var items = env.EvalAsListOfStrings("[[rec(*).a]]"); Assert.AreEqual(items[0], "25"); Assert.AreEqual(items[1], "26"); Assert.AreEqual(items[2], "28"); }
public void WarewolfParse_Eval_Delete_WithNoIndexAndMultipleColumns_Multipleresults() { ExecutionEnvironment env = new ExecutionEnvironment(); env.AssignWithFrame(new AssignValue("[[rec().a]]", "25")); env.AssignWithFrame(new AssignValue("[[rec().a]]", "26")); env.AssignWithFrame(new AssignValue("[[rec().a]]", "25")); env.AssignWithFrame(new AssignValue("[[rec().a]]", "28")); env.EvalDelete("[[rec(1)]]"); var items = env.EvalAsListOfStrings("[[rec(*).a]]"); Assert.AreEqual(items[0], "26"); Assert.AreEqual(items[1], "25"); Assert.AreEqual(items[2], "28"); }
public void WarewolfParse_Eval_where_WithNoIndexAndMultipleColumns_Multipleresults() { var assigns = new List<IAssignValue> { new AssignValue("[[rec().a]]", "25"), new AssignValue("[[rec().b]]", "33"), new AssignValue("[[rec().b]]", "25"), new AssignValue("[[rec().a]]", "27"), }; var testEnv = WarewolfTestData.CreateTestEnvEmpty(""); // ReSharper disable UnusedVariable var testEnv2 = PublicFunctions.EvalMultiAssign(assigns, testEnv); // ReSharper restore UnusedVariable ExecutionEnvironment env = new ExecutionEnvironment(); env.AssignWithFrame(new AssignValue("[[rec().a]]", "25")); env.AssignWithFrame(new AssignValue("[[rec().a]]", "26")); env.AssignWithFrame(new AssignValue("[[rec().a]]", "25")); env.AssignWithFrame(new AssignValue("[[rec().a]]", "28")); var items = env.EnvalWhere("[[rec(*).a]]", (a => PublicFunctions.AtomtoString(a) == "25")); IEnumerable<int> enumerable = items as int[] ?? items.ToArray(); Assert.AreEqual(enumerable.ToArray()[0], 1); Assert.AreEqual(enumerable.ToArray()[1], 3); }
public void WarewolfParse_Eval_Delete_Unordered_CheckForAttributes_Mixed() { ExecutionEnvironment env = new ExecutionEnvironment(); env.AssignWithFrame(new AssignValue("[[rec().a]]", "25")); env.AssignWithFrame(new AssignValue("[[rec().a]]", "26")); env.AssignWithFrame(new AssignValue("[[rec(5).a]]", "25")); env.AssignWithFrame(new AssignValue("[[rec(7).a]]", "28")); env.EvalDelete("[[rec(2)]]"); var items = env.EvalAsListOfStrings("[[rec(*).a]]"); Assert.AreEqual(items[0], "25"); Assert.AreEqual(items[1], "25"); Assert.AreEqual(items[2], "28"); PrivateObject p = new PrivateObject(env); var inner = p.GetField("_env") as DataASTMutable.WarewolfEnvironment; var recset = inner.RecordSets["rec"]; Assert.AreEqual(recset.Optimisations, DataASTMutable.WarewolfAttribute.Sorted); Assert.AreEqual(recset.LastIndex, 7); }
public void WarewolfParse_Eval_Delete_Unordered_CheckForAttributes_Multiple_Delete_Star() { ExecutionEnvironment env = new ExecutionEnvironment(); env.AssignWithFrame(new AssignValue("[[rec().a]]", "25")); env.AssignWithFrame(new AssignValue("[[rec().b]]", "26")); env.AssignWithFrame(new AssignValue("[[rec().b]]", "25")); env.AssignWithFrame(new AssignValue("[[rec().a]]", "28")); env.AssignWithFrame(new AssignValue("[[rec().b]]", "22")); env.AssignWithFrame(new AssignValue("[[rec().a]]", "24")); env.AssignWithFrame(new AssignValue("[[rec().b]]", "27")); env.AssignWithFrame(new AssignValue("[[rec().a]]", "1")); env.EvalDelete("[[rec(2)]]"); env.AssignWithFrame(new AssignValue("[[rec(1).b]]", "xxx")); env.AssignWithFrame(new AssignValue("[[rec(1).a]]", "yyy")); env.AssignWithFrame(new AssignValue("[[rec(17).b]]", "uuu")); env.AssignWithFrame(new AssignValue("[[rec().a]]", "aaa")); env.AssignWithFrame(new AssignValue("[[rec(7).b]]", "444")); env.AssignWithFrame(new AssignValue("[[rec(7).a]]", "222")); env.EvalDelete("[[rec(7)]]"); env.EvalDelete("[[rec(*)]]"); var items = env.EvalAsListOfStrings("[[rec(*).a]]"); Assert.AreEqual(items.Count, 0); PrivateObject p = new PrivateObject(env); var inner = p.GetField("_env") as DataASTMutable.WarewolfEnvironment; var recset = inner.RecordSets["rec"]; Assert.AreEqual(recset.Optimisations, DataASTMutable.WarewolfAttribute.Fragmented); Assert.AreEqual(recset.LastIndex, 0); Assert.AreEqual(recset.Count, 0); }
public DsfDataObject(string xmldata, Guid dataListId, string rawPayload = "") { Environment = new ExecutionEnvironment(); _environments = new Stack<IExecutionEnvironment>(); ThreadsToDispose = new Dictionary<int, List<Guid>>(); if (xmldata != null) { XElement xe = null; try { xe = XElement.Parse(xmldata); } // ReSharper disable EmptyGeneralCatchClause catch (Exception) // ReSharper restore EmptyGeneralCatchClause { // we only trying to parse ;) } if (xe != null) { bool isDebug; string debugString = ExtractValue(xe, "IsDebug"); if (!string.IsNullOrEmpty(debugString)) { bool.TryParse(debugString, out isDebug); } else { debugString = ExtractValue(xe, "BDSDebugMode"); bool.TryParse(debugString, out isDebug); } IsDebug = isDebug; Guid debugSessionId; Guid.TryParse(ExtractValue(xe, "DebugSessionID"), out debugSessionId); DebugSessionID = debugSessionId; Guid environmentId; if (Guid.TryParse(ExtractValue(xe, "EnvironmentID"), out environmentId)) { EnvironmentID = environmentId; } bool isOnDemandSimulation = false; string onDemandSimulationString = ExtractValue(xe, "IsOnDemandSimulation"); if (!string.IsNullOrEmpty(onDemandSimulationString)) { bool.TryParse(onDemandSimulationString, out isOnDemandSimulation); } IsOnDemandSimulation = isOnDemandSimulation; _parentServiceName = ExtractValue(xe, "ParentServiceName"); _parentWorkflowInstanceId = ExtractValue(xe, "ParentWorkflowInstanceId"); Guid executionCallbackId; Guid.TryParse(ExtractValue(xe, "ExecutionCallbackID"), out executionCallbackId); ExecutionCallbackID = executionCallbackId; Guid bookmarkExecutionCallbackId; Guid.TryParse(ExtractValue(xe, "BookmarkExecutionCallbackID"), out bookmarkExecutionCallbackId); BookmarkExecutionCallbackID = bookmarkExecutionCallbackId; if (BookmarkExecutionCallbackID == Guid.Empty && ExecutionCallbackID != Guid.Empty) { BookmarkExecutionCallbackID = ExecutionCallbackID; } Guid parentInstanceId; Guid.TryParse(ExtractValue(xe, "BookmarkExecutionCallbackID"), out parentInstanceId); ParentInstanceID = ExtractValue(xe, "ParentInstanceID"); int numberOfSteps; Int32.TryParse(ExtractValue(xe, "NumberOfSteps"), out numberOfSteps); NumberOfSteps = numberOfSteps; CurrentBookmarkName = ExtractValue(xe, "CurrentBookmarkName"); Guid instId; if (Guid.TryParse(ExtractValue(xe, "WorkflowInstanceId"), out instId)) { WorkflowInstanceId = instId; } // // Extract merge data form request // ExtractInMergeDataFromRequest(xe); ExtractOutMergeDataFromRequest(xe); // set the ID ;) DataListID = dataListId; // set the IsDataListScoped flag ;) bool isScoped; bool.TryParse(ExtractValue(xe, "IsDataListScoped"), out isScoped); IsDataListScoped = isScoped; // Set incoming service name ;) ServiceName = ExtractValue(xe, "Service"); // finally set raw payload RawPayload = new StringBuilder(xmldata); } } else { // ReSharper disable ConditionIsAlwaysTrueOrFalse if (xmldata == null) // ReSharper restore ConditionIsAlwaysTrueOrFalse { xmldata = "NULL"; } Errors.AddError("Failed to parse XML INPUT [ " + xmldata + " ]"); } if (!IsDebug && !string.IsNullOrEmpty(rawPayload)) { RawPayload = new StringBuilder(rawPayload); } }
private DsfDataObject() { Environment = new ExecutionEnvironment(); _environments = new Stack<IExecutionEnvironment>(); }
public void WarewolfParse_Eval_Delete_Star_WithUpdate_ShouldDeleteUpdateIndex() { ExecutionEnvironment env = new ExecutionEnvironment(); env.AssignWithFrame(new AssignValue("[[rec().a]]", "25"), 0); env.AssignWithFrame(new AssignValue("[[rec().a]]", "28"), 0); env.AssignWithFrame(new AssignValue("[[rec().a]]", "24"), 0); env.AssignWithFrame(new AssignValue("[[rec().a]]", "1"), 0); env.EvalDelete("[[rec(*)]]", 2); var items = env.EvalAsListOfStrings("[[rec(*).a]]", 0); Assert.AreEqual(items[0], "25"); Assert.AreEqual(items[1], "24"); Assert.AreEqual(items[2], "1"); PrivateObject p = new PrivateObject(env); var inner = p.GetField("_env") as DataASTMutable.WarewolfEnvironment; var recset = inner.RecordSets["rec"]; Assert.AreEqual(recset.LastIndex, 4); Assert.AreEqual(recset.Count, 3); }