Esempio n. 1
0
        public void NodeGroupSerializationAfterReadingFromJson()
        {
            NodeGroup ngRoot = new NodeGroup();

            ngRoot.AddJsonEncodedNodeGroup((JsonObject.Parse(jsonContent)).GetNamedObject("sNodeGroup"));

            JsonObject serialized = ngRoot.ToJson();

            NodeGroup ngAlternate = new NodeGroup();

            ngAlternate.AddJsonEncodedNodeGroup(serialized);

            Assert.AreEqual(ngRoot.GetNodeCount(), ngAlternate.GetNodeCount());

            foreach (Node nd in ngRoot.GetNodeList())
            {
                int propCount = nd.GetPropertyItems().Count;
                int nodeCount = nd.GetNodeItemList().Count;

                List <Node> compareNodes = ngAlternate.GetNodeByURI(nd.GetFullUriName());

                Boolean foundIt = false;

                Debug.WriteLine("checking node: " + nd.GetFullUriName() + " with nodeItemCount: " + nodeCount + " , and propertyCount :" + propCount);

                foreach (Node comNode in compareNodes)
                {
                    int compPropCount = comNode.GetPropertyItems().Count;
                    int compNodeCount = comNode.GetNodeItemList().Count;

                    if (propCount == compPropCount && nodeCount == compNodeCount)
                    {
                        foundIt = true;
                    }
                }

                if (!foundIt)
                {
                    Assert.Fail();
                }
            }
        }