Пример #1
0
        public void PropertyShouldThrowWhenElementContainsChildren()
        {
            var element = new XElement("element1", new XElement("element2"));

            var adapter = new IsPropertyAdapterStub(element);

            Assert.Throws<ElementContainsChildrenException>(() =>
            {
                var a = adapter.Value;
            });
        }
Пример #2
0
        public void PropertyShouldReturnNullWhenEmpty()
        {
            var element = new XElement("element1", "");

            var adapter = new IsPropertyAdapterStub(element);

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

            element.SetValue("\t");

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

            element.SetValue(" ");

            Assert.That(adapter.Value, Is.Null);
        }
Пример #3
0
        public void PropertyShouldReturnValue()
        {
            var element = new XElement("element1", "value1");

            var adapter = new IsPropertyAdapterStub(element);

            Assert.That(adapter.Value, Is.EqualTo("value1"));
        }
Пример #4
0
        public void PropertyShouldCacheResults()
        {
            var element = new XElement("element1", "value1");

            var adapter = new IsPropertyAdapterStub(element);

            adapter.SetInternalCacheOption(true);

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

            element.SetValue("value2");

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