public void IsNotDictionaryElement()
        {
            NotADictionaryElement notADict = new NotADictionaryElement();

            DictionaryElement elem = new DictionaryElement("some_element", notADict);
            Assert.IsNull(elem);
        }
        public void IsDictionaryElement()
        {
            Dictionary<object, string> dict = new Dictionary<object,string>();

            DictionaryElement elem = new DictionaryElement("some_name", dict);
            Assert.IsNotNull(elem);
        }
        public void ChildsCount()
        {
            Dictionary<string, object> dict = new Dictionary<string, object>();
            dict.Add("asd", "fgh");
            dict.Add("123", 123);

            DictionaryElement elem = new DictionaryElement("some_name", dict);

            Assert.AreEqual(2, elem.GetChilds().Count());
        }
        public void VisitDictionaryElement(DictionaryElement element)
        {
            DictionaryElementsCount += 1;
            IEnumerable<ITreeElement> childrens = element.GetChilds();

            foreach (var child in childrens)
            {
                child.Visit(this);
            }
        }
        public void VisitDictionaryElement(DictionaryElement element)
        {
            if (!IsNeedProcessElement(element.ValueObject))
            {
                return;
            }

            _builder.WriteStartDictionary(element.Name);

            VisitChildrens(element);

            _builder.WriteEndDictionary(element.Name);
        }
        public void ChildsElements()
        {
            Dictionary<object, object> dict = new Dictionary<object, object>();
            dict.Add("ads", 123);
            dict.Add("fgh", 456);
            dict.Add("jkl", 789);
            dict.Add(10, "11");
            dict.Add(1, 1);

            DictionaryElement elem = new DictionaryElement("dict", dict);

            IEnumerable<ITreeElement> childs = elem.GetChilds();

            Assert.AreEqual("ads", childs.ElementAt(0).Name);
            Assert.AreEqual("1", childs.Last().Name);
            Assert.AreEqual("jkl", childs.ElementAt(2).Name);
        }
        public void VisitDictionaryElement(DictionaryElement element)
        {
            if (_visited.ContainsKey(element.ValueObject))
            {
                return;
            }

            _visited.Add(element.ValueObject, true);

            depth++;
            IEnumerable<ITreeElement> childrens = element.GetChilds();

            for (int i = 0; i < depth; ++i)
            {
                _writer.Write("  ");
            }
            _writer.WriteLine("Name: {0}", element.Name);

            foreach (var child in childrens)
            {
                child.Visit(this);
            }
            depth--;
        }