Exemplo n.º 1
0
        public void CanParseSchemaAndGenerateCode(ParserTestFile xmlSchemaTestFile)
        {
            var generatedCode   = SchemaCorrectorHelper.GetSchemaCorrectorCode(xmlSchemaTestFile);
            var didGenerateCode = !string.IsNullOrWhiteSpace(generatedCode);

            Assert.True(didGenerateCode);
        }
Exemplo n.º 2
0
        public void CanCallCorrectCodeOnXml(ParserTestFile xmlSchemaTestFile)
        {
            var sourceDoc      = GetExampleDocument();
            var actualDoc      = SchemaCorrectorHelper.CorrectXmlInstanceForSchema(xmlSchemaTestFile, sourceDoc);
            var expectedDoc    = GetExampleDocument();
            var xDocComparator = new XDocumentComparator(expectedDoc, actualDoc);

            xDocComparator.AssertXDocumentsAreEqual();
        }
Exemplo n.º 3
0
        public void CorrectsNumber(string sourceValue, string expectedValue)
        {
            var schemaFile     = ParserTestFile.GAEB_XML_3_1_Schema;
            var invalidXDoc    = XDocument.Parse(GetXmlStringWithValue(sourceValue));
            var correctedXDoc  = SchemaCorrectorHelper.CorrectXmlInstanceForSchema(schemaFile, invalidXDoc);
            var expectedXDoc   = XDocument.Parse(GetXmlStringWithValue(expectedValue));
            var xDocComparator = new XDocumentComparator(expectedXDoc, correctedXDoc);

            xDocComparator.AssertXDocumentsAreEqual();
        }
Exemplo n.º 4
0
 public void WriteCodeGenToDisk()
 {
     const string outputFilePath = @"C:\Users\Georg\Downloads\CodeGenOutput\Generated.cs";
     {
         var generatedCode = SchemaCorrectorHelper.GetSchemaCorrectorCode(ParserTestFile.GAEB_XML_3_1_Schema);
         using (var fs = File.CreateText(outputFilePath))
         {
             fs.Write(generatedCode);
         }
     }
 }
Exemplo n.º 5
0
        public void RemovesElementWithoutContent_WithEmptyValue()
        {
            // There have been cases where GAEB files had empty or self-closing elements
            // where decimals were expected, this resulted in the Xml parser reading their
            // values as empty strings and failing to return a meaningful numerical value

            var input = @"<?xml version=""1.0"" encoding=""UTF-8""?>
<GAEB xmlns=""http://www.gaeb.de/GAEB_DA_XML/200407"">
	<GAEBInfo>
		<Version>3.1</Version>
		<VersDate>2009-12</VersDate>
	</GAEBInfo>
	<Award>
		<DP>83</DP>
		<BoQ>
			<BoQBody>
				<BoQCtgy RNoPart=""1"">
                    <Totals>
                      <Total></Total>
                    </Totals>
				</BoQCtgy>
			</BoQBody>
		</BoQ>
	</Award>
</GAEB>";

            var expected = @"<?xml version=""1.0"" encoding=""UTF-8""?>
<GAEB xmlns=""http://www.gaeb.de/GAEB_DA_XML/200407"">
	<GAEBInfo>
		<Version>3.1</Version>
		<VersDate>2009-12</VersDate>
	</GAEBInfo>
	<Award>
		<DP>83</DP>
		<BoQ>
			<BoQBody>
				<BoQCtgy RNoPart=""1"">
                    <Totals>
                    </Totals>
				</BoQCtgy>
			</BoQBody>
		</BoQ>
	</Award>
</GAEB>";

            var schemaFile     = ParserTestFile.GAEB_XML_3_1_Schema;
            var invalidXDoc    = XDocument.Parse(input);
            var correctedXDoc  = SchemaCorrectorHelper.CorrectXmlInstanceForSchema(schemaFile, invalidXDoc);
            var expectedXDoc   = XDocument.Parse(expected);
            var xDocComparator = new XDocumentComparator(expectedXDoc, correctedXDoc);

            xDocComparator.AssertXDocumentsAreEqual();
        }
Exemplo n.º 6
0
        public void RemovesDecimalElementWithInvalidContent(string invalidDecimalContent)
        {
            var expected = @"<?xml version=""1.0"" encoding=""UTF-8""?>
<GAEB xmlns=""http://www.gaeb.de/GAEB_DA_XML/200407"">
	<GAEBInfo>
		<Version>3.1</Version>
		<VersDate>2009-12</VersDate>
	</GAEBInfo>
	<Award>
		<DP>83</DP>
		<BoQ>
			<BoQBody>
				<BoQCtgy RNoPart=""1"">
					<BoQBody>
						<Itemlist>
							<Item RNoPart=""2"">
								<Qty>59</Qty>
								<QU>stck</QU>
								<UP>170,45</UP>
							</Item>
						</Itemlist>
					</BoQBody>
				</BoQCtgy>
			</BoQBody>
		</BoQ>
	</Award>
</GAEB>";

            var schemaFile     = ParserTestFile.GAEB_XML_3_1_Schema;
            var invalidXDoc    = XDocument.Parse(GetXmlStringWithValue(invalidDecimalContent));
            var correctedXDoc  = SchemaCorrectorHelper.CorrectXmlInstanceForSchema(schemaFile, invalidXDoc);
            var expectedXDoc   = XDocument.Parse(expected);
            var xDocComparator = new XDocumentComparator(expectedXDoc, correctedXDoc);

            xDocComparator.AssertXDocumentsAreEqual();
        }