Question

i m making some tests on my project and using Fixture to populate big objects. Those objects make part of an XML that has an schema.

//silly objects 
Fixture fixture = new Fixture();

boleto = fixture.Create<Boleto>();
agencia = fixture.Create<Agencia>();
pasajero = fixture.Create<Pasajero>();
aerolinea = fixture.Create<Aerolinea>();

//xml build
XmlMySuite objXmlMySuite = new XmlMySuite();

string strXML = objXmlMySuite.buildXML(aerolinea, pasajero, agencia);


//xml validation
XmlSchemaSet xmlSchema = new XmlSchemaSet();
xmlSchema .Add("schema.xsd");

bool errors = false;

Console.WriteLine("Attempting to validate");
XDocument custOrdDoc = XDocument.Load(new XmlTextReader(new System.IO.StringReader(strXML)));
custOrdDoc.Validate(xmlSchema , (o, e) =>
{
    Console.WriteLine("{0}", e.Message);
    errors = true;
});
Console.WriteLine("custOrdDoc {0}", errors ? "did not validate" : "validated");
Console.WriteLine();

Assert.IsFalse(errors);

Is there any way to fill/populate the objects with Fixture validating that schema?

For example, one of the elements tag of the XML Schema is:

<xs:element name="Type">
    <xs:simpleType>
        <xs:restriction base="xs:token">
            <xs:enumeration value="CCC"/>
            <xs:enumeration value="AAA"/>
            <xs:enumeration value="BBB"/>
            <xs:enumeration value="QQQQ"/>
        </xs:restriction>
    </xs:simpleType>
</xs:element>

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top