Ejemplo n.º 1
0
        public void Invalid_root_element_throws_an_exception(string xml)
        {
            var schemas   = CreateSchemas();
            var schema    = schemas.GetSchemaByNamespace(NS1);
            var parser    = new Impl.Parser.XmlElementParser();
            var exception = Assert.Throws <ParseException>(() => parser.Parse(new StringReader(xml), schema, new ProjectFile("file.xml")));

            exception.Message.Should().Contain("Invalid root XML element");
        }
Ejemplo n.º 2
0
        public void Parse_root_element()
        {
            var schemas = CreateSchemas();
            var schema  = schemas.GetSchemaByNamespace(NS1);
            var parser  = new Impl.Parser.XmlElementParser();
            var xml     = $@"
                <root xmlns='{NS1}' a='va' />
            ";

            var root = parser.Parse(new StringReader(xml), schema, new ProjectFile("file.xml"));

            root.Should().NotBeNull();
            root.Definition.Name.Should().BeEquivalentTo(NS1 + "root");

            var attributes = root.Attributes.Select(x => (x.Definition.Name, x.Value));

            attributes.Should().BeEquivalentTo(new[] { (NS1 + "a", "va") });