Exemplo n.º 1
0
        public void Items_will_remove_item_by_name_when_element_is_removed()
        {
            var doc   = new DomDocument();
            var index = doc.CreateAttributeIndex("id");
            var a     = doc.AppendElement("root").AppendElement("a").Attribute("id", "a");

            Assume.NotEmpty(index);

            a.RemoveSelf();
            Assert.Empty(index);
        }
Exemplo n.º 2
0
        public void Items_will_contain_items_by_name_when_index_is_created_after_the_fact()
        {
            var doc = new DomDocument();
            var a   = doc.AppendElement("root").AppendElement("a");

            a.Id = "id";

            var index = doc.CreateAttributeIndex("id");

            Assert.SetEqual(new [] { a }, index["id"]);
        }
Exemplo n.º 3
0
        public void Items_will_contain_item_by_name_when_an_attribute_is_added()
        {
            var doc   = new DomDocument();
            var index = doc.CreateAttributeIndex("id");
            var a     = doc.AppendElement("root").AppendElement("a");

            a.Id = "id";

            Assert.True(index.IsConnected);
            Assert.SetEqual(new [] { a }, index["id"]);
        }
Exemplo n.º 4
0
        public void Items_will_not_update_after_disconnected()
        {
            var doc   = new DomDocument();
            var index = doc.CreateAttributeIndex("id");
            var a     = doc.AppendElement("root").AppendElement("a");

            index.Disconnect();
            a.Id = "id";

            Assert.False(index.IsConnected);
            Assert.DoesNotContainKey("a", index);
        }
Exemplo n.º 5
0
        public void Items_will_contain_item_by_name_when_an_element_is_added()
        {
            var doc = new DomDocument();
            var e   = doc.CreateElement("hello").Attribute("id", "id");

            var index = doc.CreateAttributeIndex("id");

            Assume.Empty(index);

            var a = doc.AppendElement("root").Append(e);

            Assert.SetEqual(new [] { e }, index["id"]);
        }
Exemplo n.º 6
0
        public void Items_will_throw_if_disposed()
        {
            var doc   = new DomDocument();
            var index = doc.CreateAttributeIndex("id");

            index.Dispose();

            Assert.Throws <ObjectDisposedException>(
                () => index.Count
                );
            Assert.Throws <ObjectDisposedException>(
                () => index["anything"]
                );
        }