Esempio n. 1
0
        public void ReadHandlesNull()
        {
            var member    = TestClass.Fetch();
            var attribute = new ReflectorPropertyAttribute("test");

            attribute.Required = false;
            var serialiser = new PrivateStringSerialiser(member, attribute);
            var result     = serialiser.Read(null, null);

            Assert.IsNull(result);
        }
Esempio n. 2
0
        public void ReadFailsNullOnRequired()
        {
            var member    = TestClass.Fetch();
            var attribute = new ReflectorPropertyAttribute("test");

            attribute.Required = true;
            var serialiser = new PrivateStringSerialiser(member, attribute);

            Assert.Throws <NetReflectorItemRequiredException>(() =>
            {
                serialiser.Read(null, null);
            }, "test is required");
        }
Esempio n. 3
0
        public void ReadLoadsAttribute()
        {
            var member     = TestClass.Fetch();
            var attribute  = new ReflectorPropertyAttribute("test");
            var serialiser = new PrivateStringSerialiser(member, attribute);
            var document   = new XmlDocument();
            var element    = document.CreateAttribute("test");

            element.Value = "value of the attribute";
            var result = serialiser.Read(element, null);

            Assert.IsInstanceOf <PrivateString>(result);
            Assert.AreEqual("value of the attribute", (result as PrivateString).PrivateValue);
        }