Ejemplo n.º 1
0
        public void AddCustomXmlPartTestTwoParts()
        {
            InteropExcel.Application excelApp = new InteropExcel.Application();

            try
            {
                InteropExcel.Workbook workbook = excelApp.Workbooks.Add();
                string content     = "<Product xmlns:ns=\"" + Common.Constants.XmlNamespace + "\">" + "<ProductName>WWT Excel Add-In</ProductName>" + "</Product>";
                string moreContent = "<Product xmlns:ns=\"" + Common.Constants.XmlNamespace + "\">" + "<Publisher>Microsoft Corporation</Publisher>" + "</Product>";
                workbook.AddCustomXmlPart(content, Common.Constants.XmlNamespace);
                workbook.AddCustomXmlPart(moreContent, Common.Constants.XmlNamespace);
                string existingContent = workbook.GetCustomXmlPart(Common.Constants.XmlNamespace);
                Assert.AreEqual(moreContent, existingContent);
            }
            finally
            {
                excelApp.Close();
            }
        }
Ejemplo n.º 2
0
        public void AddCustomXmlPartTestOnePartInvalidXML()
        {
            string content = "<Product xmlns:ns=\"" + Common.Constants.XmlNamespace + "\"></Product>" + "<ProductName>WWT Excel Add-In</ProductName>";

            InteropExcel.Application excelApp = new InteropExcel.Application();

            try
            {
                excelApp.Workbooks.Add();
                InteropExcel.Workbook workbook = excelApp.Workbooks.Add();
                workbook.AddCustomXmlPart(content, Common.Constants.XmlNamespace);
                Assert.Fail("Invalid XML is inserted in to custom XML part!");
            }
            finally
            {
                excelApp.Close();
            }
        }
Ejemplo n.º 3
0
        public void AddCustomXmlPartTestEmptyString()
        {
            InteropExcel.Application excelApp = new InteropExcel.Application();

            try
            {
                excelApp.Workbooks.Add();
                InteropExcel.Workbook workbook = excelApp.Workbooks.Add();

                string content  = string.Empty;
                int    expected = workbook.CustomXMLParts.Count;
                workbook.AddCustomXmlPart(content, Common.Constants.XmlNamespace);
                Assert.AreEqual(workbook.CustomXMLParts.Count, expected);
                string existingContent = workbook.GetCustomXmlPart(Common.Constants.XmlNamespace);
                Assert.AreEqual(content, existingContent);
            }
            finally
            {
                excelApp.Close();
            }
        }