ForEachAttribute() public method

public ForEachAttribute ( string>.Action action ) : void
action string>.Action
return void
Example #1
0
        public void for_each_attribute()
        {
            var cache = new Cache<string, string>
            {
                OnMissing = key =>
                {
                    Assert.Fail(key + " does not exist");
                    return null;
                }
            };

            var node = new JsonNode("Test");
            node.InnerText = "something";

            node["a"] = "1";
            node["b"] = "2";
            node["c"] = "3";

            node.ForEachAttribute((key, value) => cache[key] = value);

            cache.Count.ShouldEqual(3);
            cache["a"].ShouldEqual("1");
            cache["b"].ShouldEqual("2");
            cache["c"].ShouldEqual("3");
        }