Example #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);
        }
Example #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"));
        }
Example #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);
        }
Example #4
0
        public void NamedPropertyShouldReturnNullWhenElementIsMissingAndNotRequired()
        {
            var element = new XElement("element1");

            var adapter = new NamedPropertyAdapterStub(element);

            Assert.That(adapter.NamedPropertyNotRequired, Is.Null);
        }
Example #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;
                                                            });
        }
Example #6
0
        public void NamedPropertyShouldThrowWhenElementIsMissingAndRequired()
        {
            var element = new XElement("element1");

            var adapter = new NamedPropertyAdapterStub(element);

            Assert.Throws<ElementNotFoundException>(() =>
            {
                var a = adapter.NamedPropertyRequired;
            });
        }
Example #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"));
        }