public void ThenTheDecisionResultShouldBe(string expectedRes) { var modelData = scenarioContext.Get <string>("modelData"); var result = scenarioContext.Get <IDSFDataObject>("result"); if (result.DataListID == Guid.Empty) { result.DataListID = Guid.NewGuid(); } try { Dev2DataListDecisionHandler.Instance.RemoveEnvironment(result.DataListID); Dev2DataListDecisionHandler.Instance.AddEnvironment(result.DataListID, result.Environment); } catch { //Possible exception as the scenerio could already have hit this } bool actual = new Dev2DataListDecisionHandler().ExecuteDecisionStack(modelData, new List <string> { result.DataListID.ToString() }, 0); bool expected = Boolean.Parse(expectedRes); Assert.AreEqual(expected, actual); }
public void DecisionWithQuotesInDataExpectedNoUnhandledExceptions() { Dev2DecisionStack dds = new Dev2DecisionStack { TheStack = new List <Dev2Decision>(), Mode = Dev2DecisionMode.AND }; IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); dds.AddModelItem(new Dev2Decision { Col1 = "[[var]]", Col2 = "[[var]]", EvaluationFn = enDecisionType.IsEqual }); string modelData = dds.ToVBPersistableModel(); CurrentDl = "<ADL><var/></ADL>"; TestData = "<root><var>\"something \"data\" \"</var></root>"; ErrorResultTO errors; Guid exeID = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), new StringBuilder(TestData), new StringBuilder(CurrentDl), out errors); IList <string> getDatalistID = new List <string> { exeID.ToString() }; var res = new Dev2DataListDecisionHandler().ExecuteDecisionStack(modelData, getDatalistID); // remove test datalist ;) DataListRemoval(exeID); Assert.IsTrue(res); }
public void ThenTheDecisionResultShouldBe(string expectedRes) { var modelData = ScenarioContext.Current.Get <string>("modelData"); var result = ScenarioContext.Current.Get <IDSFDataObject>("result"); bool actual = new Dev2DataListDecisionHandler().ExecuteDecisionStack(modelData, new List <string> { result.DataListID.ToString() }); bool expected = Boolean.Parse(expectedRes); Assert.AreEqual(expected, actual); }
public void Dev2DataListDecisionHandler_ExecuteDecisionStack_SlashInVariable_CanDeserialize() { CurrentDl = "<ADL><down/><resul><t/></resul></ADL>"; TestData = @"<root><down>1\n2\n3\n4\n</down><resul><t>1234</t></resul><resul><t>1234</t></resul><resul><t>1/2\3/4\</t></resul><resul><t>1\n2\n3\n4\n</t></resul><resul><t>1 2 3 4 5 </t></resul></root>"; ErrorResultTO errors; IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); Guid exeID = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), new StringBuilder(TestData), new StringBuilder(CurrentDl), out errors); IList <string> getDatalistID = new List <string> { exeID.ToString() }; var dev2DataListDecisionHandler = new Dev2DataListDecisionHandler(); //------------Execute Test--------------------------- var res = dev2DataListDecisionHandler.ExecuteDecisionStack(@"{""TheStack"":[{""Col1"":""[[resul(1).t]]"",""Col2"":""1234"",""Col3"":"""",""PopulatedColumnCount"":2,""EvaluationFn"":""IsEqual""},{""Col1"":""[[resul(2).t]]"",""Col2"":""1234"",""Col3"":"""",""PopulatedColumnCount"":2,""EvaluationFn"":""IsEqual""},{""Col1"":""[[resul(3).t]]"",""Col2"":""1/2\\3/4\\"",""Col3"":"""",""PopulatedColumnCount"":2,""EvaluationFn"":""IsEqual""},{""Col1"":""[[resul(4).t]]"",""Col2"":""[[down]]"",""Col3"":"""",""PopulatedColumnCount"":2,""EvaluationFn"":""IsEqual""},{""Col1"":""[[resul(5).t]]"",""Col2"":""1 2 3 4 5 "",""Col3"":"""",""PopulatedColumnCount"":2,""EvaluationFn"":""IsEqual""}],""TotalDecisions"":5,""ModelName"":""Dev2DecisionStack"",""Mode"":""AND"",""TrueArmText"":""True"",""FalseArmText"":""False"",""DisplayText"":""Decision""}", getDatalistID); // Assert Can Deserialize Assert.IsTrue(res); }