/// <summary> /// Sets a new value for variable in this stack frame. /// </summary> /// <param name="name">Variable name.</param> /// <param name="value">New value.</param> /// <param name="cancellationToken">Cancellation token.</param> public async Task <NodeEvaluationResult> SetVariableValueAsync(string name, string value, CancellationToken cancellationToken = new CancellationToken()) { Utilities.CheckNotNull(Process); NodeEvaluationResult result = await Process.SetVariableValueAsync(this, name, value, cancellationToken).ConfigureAwait(false); if (result == null) { return(null); } // Update variable in locals for (int i = 0; i < Locals.Count; i++) { NodeEvaluationResult evaluationResult = Locals[i]; if (evaluationResult.Expression == name) { Locals[i] = result; } } // Update variable in parameters for (int i = 0; i < Parameters.Count; i++) { NodeEvaluationResult evaluationResult = Parameters[i]; if (evaluationResult.Expression == name) { Parameters[i] = result; } } return(result); }
public void CreateLookupVariableWithNullJsonValue() { // Arrange var parent = new NodeEvaluationResult(0, null, null, null, null, null, NodeExpressionType.None, null); Exception exception = null; Dictionary<int, JToken> references = SerializationTestData.GetLookupJsonReferences(); NodeLookupVariable result = null; // Act try { result = new NodeLookupVariable(parent, null, references); } catch (Exception e) { exception = e; } // Assert Assert.IsNull(result); Assert.IsNotNull(exception); Assert.IsInstanceOfType(exception, typeof (ArgumentNullException)); }
public void CreateLookupVariable() { // Arrange var parent = new NodeEvaluationResult(0, null, null, null, null, null, NodeExpressionType.None, null); JObject json = SerializationTestData.GetLookupJsonProperty(); Dictionary<int, JToken> references = SerializationTestData.GetLookupJsonReferences(); // Act var result = new NodeLookupVariable(parent, json, references); // Assert Assert.IsNotNull(result); Assert.AreEqual(NodePropertyAttributes.None, result.Attributes); Assert.IsNull(result.Class); Assert.AreEqual(54, result.Id); Assert.AreEqual("first", result.Name); Assert.AreEqual(parent, result.Parent); Assert.IsNull(result.StackFrame); Assert.AreEqual("1", result.Text); Assert.AreEqual(NodePropertyType.Field, result.Type); Assert.AreEqual("number", result.TypeName); Assert.AreEqual("1", result.Value); }
public void CreatePrototypeVariable() { // Arrange var parent = new NodeEvaluationResult(0, null, null, null, null, null, NodeExpressionType.None, null); JObject json = SerializationTestData.GetLookupJsonPrototype(); Dictionary<int, JToken> references = SerializationTestData.GetLookupJsonReferences(); // Act var result = new NodePrototypeVariable(parent, json, references); // Assert Assert.IsNotNull(result); Assert.AreEqual(NodePropertyAttributes.DontEnum, result.Attributes); Assert.AreEqual(NodeVariableType.Object, result.Class); Assert.AreEqual(4, result.Id); Assert.AreEqual(NodeVariableType.Prototype, result.Name); Assert.AreEqual(parent, result.Parent); Assert.IsNull(result.StackFrame); Assert.AreEqual("#<Object>", result.Text); Assert.AreEqual(NodePropertyType.Normal, result.Type); Assert.AreEqual("object", result.TypeName); Assert.IsNull(result.Value); }
internal async Task<List<NodeEvaluationResult>> EnumChildrenAsync(NodeEvaluationResult nodeEvaluationResult, CancellationToken cancellationToken = new CancellationToken()) { DebugWriteCommand("Enum Children"); var lookupCommand = new LookupCommand(CommandId, _resultFactory, new List<NodeEvaluationResult> { nodeEvaluationResult }); if (!await TrySendRequestAsync(lookupCommand, cancellationToken).ConfigureAwait(false)) { return null; } return lookupCommand.Results[nodeEvaluationResult.Handle]; }
private bool ChildrenMatch(ChildInfo curChild, NodeEvaluationResult curReceived) { return curReceived.StringValue == curChild.ChildText && (curReceived.StringValue == curChild.Repr || curChild.Repr == null); }