public void CreateLookupVariableWithNullJsonReferences() { // Arrange var parent = new NodeEvaluationResult(0, null, null, null, null, null, NodeExpressionType.None, null); JObject json = SerializationTestData.GetLookupJsonPrototype(); Exception exception = null; NodePrototypeVariable result = null; // Act try { result = new NodePrototypeVariable(parent, json, null); } catch (Exception e) { exception = e; } // Assert Assert.IsNull(result); Assert.IsNotNull(exception); Assert.IsInstanceOfType(exception, typeof(ArgumentNullException)); }
public void CreateLookupVariableWithNullParent() { // Arrange JObject json = SerializationTestData.GetLookupJsonPrototype(); Dictionary <int, JToken> references = SerializationTestData.GetLookupJsonReferences(); // Act var result = new NodePrototypeVariable(null, 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.IsNull(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); }
private List <NodeEvaluationResult> GetProperties(JToken data, NodeEvaluationResult parent, Dictionary <int, JToken> references) { var properties = new List <NodeEvaluationResult>(); var props = (JArray)data["properties"]; if (props != null) { properties.AddRange(props.Select(property => new NodeLookupVariable(parent, property, references)) .Select(variableProvider => this._resultFactory.Create(variableProvider))); } // Try to get prototype var prototype = data["protoObject"]; if (prototype != null) { var variableProvider = new NodePrototypeVariable(parent, prototype, references); var result = this._resultFactory.Create(variableProvider); properties.Add(result); } return(properties); }