Exemple #1
0
        public void TestBooleanParsing()
        {
            var xAttributeTrue  = new XAttribute(XName.Get("fixed", ""), "true");
            var xAttributeFalse = new XAttribute(XName.Get("fixed", ""), "false");

            var trueResult  = XTypedServices.ParseValue <bool>(xAttributeTrue, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Boolean).Datatype);
            var falseResult = XTypedServices.ParseValue <bool>(xAttributeFalse, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Boolean).Datatype);

            Assert.IsTrue(trueResult);
            Assert.IsFalse(falseResult);
        }
Exemple #2
0
        public void TestAnyAtomicTypeConversionToTWhereTIsString()
        {
            var xAttribute = new XAttribute(XName.Get("value"), "abcdef");

            Assert.DoesNotThrow(() => {
                var d = XTypedServices.ParseValue <string>(xAttribute, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.AnyAtomicType).Datatype);

                Assert.IsTrue(d.GetTypeCode() == TypeCode.String);
                Assert.IsTrue(d == "abcdef");
            });
        }