Esempio n. 1
0
        public override void ProcessResponse(JObject response)
        {
            base.ProcessResponse(response);

            var variableProvider = new NodeEvaluationVariable(this._stackFrame, this._expression, response["body"]);

            this.Result = this._resultFactory.Create(variableProvider);
        }
Esempio n. 2
0
        public override void ProcessResponse(JObject response)
        {
            base.ProcessResponse(response);

            // Retrieve references
            var refs       = (JArray)response["refs"] ?? new JArray();
            var references = new Dictionary <int, JToken>(refs.Count);

            foreach (var reference in refs)
            {
                var id = (int)reference["handle"];
                references.Add(id, reference);
            }

            // Retrieve properties
            var body = response["body"];

            this.Results = new Dictionary <int, List <NodeEvaluationResult> >(this._handles.Length);

            foreach (var handle in this._handles)
            {
                var id   = handle.ToString(CultureInfo.InvariantCulture);
                var data = body[id];
                if (data == null)
                {
                    continue;
                }

                NodeEvaluationResult parent = null;
                if (this._parents != null)
                {
                    this._parents.TryGetValue(handle, out parent);
                }

                var properties = GetProperties(data, parent, references);
                if (properties.Count == 0)
                {
                    // Primitive javascript type
                    var variable = new NodeEvaluationVariable(null, id, data);
                    var property = this._resultFactory.Create(variable);
                    properties.Add(property);
                }

                this.Results.Add(handle, properties);
            }
        }
        public void CreateBacktraceVariableWithNullJson()
        {
            // Arrange
            var       stackFrame          = new NodeStackFrame(0);
            Exception exception           = null;
            NodeEvaluationVariable result = null;
            const string           name   = "name";

            // Act
            try {
                result = new NodeEvaluationVariable(stackFrame, name, null);
            } catch (Exception e) {
                exception = e;
            }

            // Assert
            Assert.IsNull(result);
            Assert.IsNotNull(exception);
            Assert.IsInstanceOfType(exception, typeof(ArgumentNullException));
        }
        public void CreateBacktraceVariableWithNullName()
        {
            // Arrange
            JObject   json                = SerializationTestData.GetBacktraceJsonObject();
            Exception exception           = null;
            NodeEvaluationVariable result = null;
            const string           name   = "name";

            // Act
            try {
                result = new NodeEvaluationVariable(null, name, json);
            } catch (Exception e) {
                exception = e;
            }

            // Assert
            Assert.IsNull(result);
            Assert.IsNotNull(exception);
            Assert.IsInstanceOfType(exception, typeof(ArgumentNullException));
        }
Esempio n. 5
0
        public void CreateEvaluationVariable()
        {
            // Arrange
            JObject      json       = SerializationTestData.GetEvaluationJsonObject();
            var          stackFrame = new NodeStackFrame(0);
            const string name       = "name";

            // Act
            var result = new NodeEvaluationVariable(stackFrame, name, json);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(NodePropertyAttributes.None, result.Attributes);
            Assert.IsNull(result.Class);
            Assert.AreEqual(16, result.Id);
            Assert.AreEqual(name, result.Name);
            Assert.IsNull(result.Parent);
            Assert.AreEqual(stackFrame, result.StackFrame);
            Assert.AreEqual("<tag>Value</tag>", result.Text);
            Assert.AreEqual(NodePropertyType.Normal, result.Type);
            Assert.AreEqual("string", result.TypeName);
            Assert.AreEqual("<tag>Value</tag>", result.Value);
        }