示例#1
0
        public void FromDictionary_Null()
        {
            // Arrange
            Dictionary <string, int> dictionary = null;

            // Act
            JsonObjectNode.FromDictionary(dictionary);
        }
示例#2
0
        public void FromDictionary_Empty()
        {
            // Arrange
            var dictionary = new Dictionary <string, int>();

            // Act
            var objectNode = JsonObjectNode.FromDictionary(dictionary);

            // Assert
            Assert.IsNotNull(objectNode);
            Assert.AreEqual(0, objectNode.Count);
        }
示例#3
0
        public void FromDictionary_Properties()
        {
            // Arrange
            var dictionary = new Dictionary <string, int>();

            dictionary["A"] = 1;
            dictionary["B"] = 2;
            dictionary["C"] = 4;

            // Act
            var objectNode = JsonObjectNode.FromDictionary(dictionary);

            // Assert
            Assert.IsNotNull(objectNode);
            Assert.AreEqual(3, objectNode.Count);

            var nodeA = objectNode["A"] as JsonIntegerNode;
            var nodeB = objectNode["B"] as JsonIntegerNode;
            var nodeC = objectNode["C"] as JsonIntegerNode;

            Assert.AreEqual(1, (int)nodeA.Value);
            Assert.AreEqual(2, (int)nodeB.Value);
            Assert.AreEqual(4, (int)nodeC.Value);
        }