Esempio n. 1
0
        public void NamedPropertyForMultipleHitsShouldNotThrowWhenValueCachedIsNull()
        {
            var element = new XElement("element1",
                new XElement("property1"));

            var adapter = new NamedPropertyAdapterStub(element);
            adapter.SetInternalCacheOption(true);

            Assert.That(adapter.NamedPropertyNotRequired, Is.Null);
            Assert.That(adapter.NamedPropertyNotRequired, Is.Null);
        }
Esempio n. 2
0
        public void NamedPropertyShouldCacheResults()
        {
            var element = new XElement("element1",
                new XElement("property1", "value1"));

            var adapter = new NamedPropertyAdapterStub(element);

            adapter.SetInternalCacheOption(true);

            Assert.That(adapter.NamedPropertyNotRequired, Is.EqualTo("value1"));

            element.Element("property1").SetValue("value2");

            Assert.That(adapter.NamedPropertyNotRequired, Is.EqualTo("value1"));
        }
Esempio n. 3
0
        public void NamedPropertyShouldReturnNullWhenElementIsEmpty()
        {
            var element = new XElement("element1",
                new XElement("property1", ""));

            var adapter = new NamedPropertyAdapterStub(element);

            Assert.That(adapter.NamedPropertyNotRequired, Is.Null);

            element.Element("property1").SetValue("\t");

            Assert.That(adapter.NamedPropertyNotRequired, Is.Null);

            element.Element("property1").SetValue(" ");

            Assert.That(adapter.NamedPropertyNotRequired, Is.Null);
        }
Esempio n. 4
0
        public void NamedPropertyShouldReturnNullWhenElementIsMissingAndNotRequired()
        {
            var element = new XElement("element1");

            var adapter = new NamedPropertyAdapterStub(element);

            Assert.That(adapter.NamedPropertyNotRequired, Is.Null);
        }
Esempio n. 5
0
        public void NamePropertyShouldThrowWhenElementContainsChildren()
        {
            var element = new XElement("element1",
                new XElement("property1",
                    new XElement("property2")));

            var adapter = new NamedPropertyAdapterStub(element);

            Assert.Throws<ElementContainsChildrenException>(() =>
                                                            {
                                                                var a = adapter.NamedPropertyNotRequired;
                                                            });
        }
Esempio n. 6
0
        public void NamedPropertyShouldThrowWhenElementIsMissingAndRequired()
        {
            var element = new XElement("element1");

            var adapter = new NamedPropertyAdapterStub(element);

            Assert.Throws<ElementNotFoundException>(() =>
            {
                var a = adapter.NamedPropertyRequired;
            });
        }
Esempio n. 7
0
        public void NamedPropertyShouldReturnValue()
        {
            var element = new XElement("element1",
                new XElement("property1", "value1"));

            var adapter = new NamedPropertyAdapterStub(element);

            Assert.That(adapter.NamedPropertyNotRequired, Is.EqualTo("value1"));
        }