public void AssignStrict(string exp, string value, bool throwsifnotexists, int update) { if (string.IsNullOrEmpty(exp)) { return; } try { var envTemp = PublicFunctions.EvalAssignWithFrameStrict(new AssignValue(exp, value), update, _env); _env = envTemp; CommitAssign(); } catch (Exception err) { var msg = err.Message; if (throwsifnotexists && err.Message.Contains("parse error")) { throw new WarewolfExecutionEnvironmentException(msg + ": " + "{ " + DataListUtilBase.StripLeadingAndTrailingBracketsFromValue(exp) + " }"); } if (throwsifnotexists && err.Message.Contains("invalid variable assigned to")) { throw new WarewolfExecutionEnvironmentException(msg); } //NOTE:This have a possibility to duplicate error add if caller is also catching exceptions and adding error, use with caution Errors.Add(msg + ": " + "{ " + DataListUtilBase.StripLeadingAndTrailingBracketsFromValue(exp) + " }"); } }
public void Assign_Given_Value_StartsWithOpeningLanguageBracktes_Should_Assign_Value_Correclty_Scalar() { //------------Setup for test-------------------------- var emptyenv = CreateEmptyEnvironment(); var value = "[[nathi"; var exp = "[[myValue]]"; //------------Execute Test--------------------------- var envTemp = PublicFunctions.EvalAssignWithFrameStrict(new AssignValue(exp, value), 1, emptyenv); //------------Assert Results------------------------- Assert.IsNotNull(envTemp.Scalar); Assert.AreEqual(1, envTemp.Scalar.Count); Assert.AreEqual(value, envTemp.Scalar["myValue"].ToString()); }
public void Assign_Given_Value_ContainsOpeningLanguageBracktes_Should_Assign_Value_Correclty_JsonObjects() { //------------Setup for test-------------------------- var emptyenv = CreateEmptyEnvironment(); var value = "na[[thi"; var exp = "[[@myValue().name]]"; //------------Execute Test--------------------------- var envTemp = PublicFunctions.EvalAssignWithFrameStrict(new AssignValue(exp, value), 1, emptyenv); //------------Assert Results------------------------- Assert.IsNotNull(envTemp.RecordSets); Assert.AreEqual(1, envTemp.RecordSets.Count); var a = PublicFunctions.EvalEnvExpression(exp, 0, false, envTemp); var valueFromEnv = ExecutionEnvironment.WarewolfEvalResultToString(a); Assert.AreEqual(value, valueFromEnv); }
public void AssignStrict(string exp, string value, int update) { if (string.IsNullOrEmpty(exp)) { return; } try { var envTemp = PublicFunctions.EvalAssignWithFrameStrict(new AssignValue(exp, value), update, _env); _env = envTemp; CommitAssign(); } catch (Exception err) { Errors.Add(err.Message); } }