public void AssignEvaluation_assignGivenAValue_ArrayJson_InvalidIndex() { var env = CreateTestEnvWithData(); AssignEvaluation.evalJsonAssign(new AssignValue("[[Person(abc).Name]]", "a"), 0, env); Assert.Fail("Failed"); }
public void AssignEvaluation_assignGivenAValue_ArrayJson_index() { var env = CreateTestEnvWithData(); var env2 = AssignEvaluation.evalJsonAssign(new AssignValue("[[Person(1).Name]]", "a"), 0, env); Assert.IsTrue(env2.JsonObjects.ContainsKey("Person")); Assert.AreEqual(env2.JsonObjects["Person"].ToString(), "[\r\n {\r\n \"Name\": \"a\"\r\n }\r\n]"); }
public void AssignEvaluation_assignObject_ArrayJson_Last_TwoObjects() { var env = CreateTestEnvWithData(); var env2 = AssignEvaluation.evalJsonAssign(new AssignValue("[[Person()]]", "{\"Name\":\"a\"}"), 0, env); var env3 = AssignEvaluation.evalJsonAssign(new AssignValue("[[Person()]]", "{\"Name\":\"h\"}"), 0, env2); Assert.IsTrue(env2.JsonObjects.ContainsKey("Person")); var nameValue = PublicFunctions.EvalEnvExpression("[[@Person().Name]]", 0, false, env3); Assert.IsNotNull(nameValue); var warewolfAtomResult = nameValue as CommonFunctions.WarewolfEvalResult.WarewolfAtomResult; Assert.IsNotNull(warewolfAtomResult); Assert.AreEqual("h", warewolfAtomResult.Item.ToString()); }
public void AssignJson(IAssignValue value, int update) { try { if (string.IsNullOrEmpty(value.Name)) { return; } var envTemp = AssignEvaluation.evalJsonAssign(value, update, _env, ShouldTypeCast.Yes); _env = envTemp; } catch (Exception err) { Errors.Add(err.Message); throw; } }
public void AssignJson(IAssignValue value, int update) { try { if (string.IsNullOrEmpty(value.Name)) { return; } var envTemp = AssignEvaluation.evalJsonAssign(value, update, _env, ShouldTypeCast.Yes); _env = envTemp; } catch (Exception err) { var res = err.Message + ": " + "{ " + DataListUtilBase.StripLeadingAndTrailingBracketsFromValue(value.Name) + " }"; Errors.Add(res); throw new WarewolfExecutionEnvironmentException(res); } }