public void CustomXmlElementTests() { Type baseType = typeof(CustomXmlElement); Assert.True(baseType.GetTypeInfo().IsAbstract); // CustomXmlRuby CustomXmlRuby cxRuby = new CustomXmlRuby(); ValidateCustomXmlElement(cxRuby); // CustomXmlBlock CustomXmlBlock cxBlock = new CustomXmlBlock(); ValidateCustomXmlElement(cxBlock); // CustomXmlRow CustomXmlRow cxRow = new CustomXmlRow(); ValidateCustomXmlElement(cxRow); // CustomXmlRun CustomXmlRun cxRun = new CustomXmlRun(); ValidateCustomXmlElement(cxRun); // CustomXmlCell CustomXmlCell cxCell = new CustomXmlCell(); ValidateCustomXmlElement(cxCell); // Test loading and modification on DOM tree using (var stream = GetStream(TestFiles.simpleSdt)) using (var doc = WordprocessingDocument.Open(stream, false)) { // find customXml var customXml = doc.MainDocumentPart.Document.Descendants <CustomXmlRun>().First(); Assert.Equal("firstName", customXml.Element.Value); Assert.Null(customXml.Uri); Assert.Equal(typeof(Run), customXml.FirstChild.GetType()); customXml.Uri = "urn:sampleUri"; customXml.Append(new Hyperlink()); Assert.Equal(2, customXml.ChildElements.Count); } }
public void CustomXmlElementTests() { Type baseType = typeof(CustomXmlElement); Assert.True(baseType.IsAbstract); // CustomXmlRuby CustomXmlRuby cxRuby = new CustomXmlRuby(); ValidateCustomXmlElement(cxRuby); // CustomXmlBlock CustomXmlBlock cxBlock = new CustomXmlBlock(); ValidateCustomXmlElement(cxBlock); // CustomXmlRow CustomXmlRow cxRow = new CustomXmlRow(); ValidateCustomXmlElement(cxRow); // CustomXmlRun CustomXmlRun cxRun = new CustomXmlRun(); ValidateCustomXmlElement(cxRun); // CustomXmlCell CustomXmlCell cxCell = new CustomXmlCell(); ValidateCustomXmlElement(cxCell); // Test loading and modification on DOM tree using (var doc = WordprocessingDocument.Open(new MemoryStream(TestFileStreams.simpleSdt), false)) { // find customXml var customXml = doc.MainDocumentPart.Document.Descendants<CustomXmlRun>().First(); Assert.Equal("firstName", customXml.Element.Value); Assert.Null(customXml.Uri); Assert.Equal(typeof(Run), customXml.FirstChild.GetType()); customXml.Uri = "urn:sampleUri"; customXml.Append(new Hyperlink()); Assert.Equal(2, customXml.ChildElements.Count); } }