public void TestActualGenerationDoubleItemIfWithItemText()
        {
            MemoryStream output;

            using (var input = AssemblyResourceHelper.GetResourceStream(this, "corruptedDoc.docx"))
            {
                output = new MemoryStream();
                var       generator = new DocxGenerator();
                XDocument data;
                using (var dataStream = AssemblyResourceHelper.GetResourceStream(this, "DemoData2.xml"))
                {
                    data = XDocument.Load(dataStream);
                }
                generator.GenerateDocx(
                    input,
                    output,
                    data,
                    new DocxGeneratorSettings()
                {
                    MissingDataMode = MissingDataMode.ThrowException
                });
            }

            var package = new DocxPackage(output);

            package.Load();

            var documentPart = package.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;

            Console.WriteLine(documentPart.ToString());
            Assert.IsFalse(documentPart.Descendants(WordMl.SdtName).Any());
        }
        public void TestSave()
        {
            using (var docxStream = AssemblyResourceHelper.GetResourceStream(this, "DocxPackageTest.docx"))
            {
                var memoryStream = new MemoryStream();
                memoryStream.Seek(0, SeekOrigin.Begin);
                docxStream.Seek(0, SeekOrigin.Begin);
                docxStream.CopyTo(memoryStream);
                var testPackage = new DocxPackage(memoryStream);

                testPackage.Load();

                var      documentPart = testPackage.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;
                XElement sdt          = documentPart.Descendants(WordMl.SdtName).First();
                sdt.Remove();

                testPackage.Save();

                var expectedDocumentStream = AssemblyResourceHelper.GetResourceStream(this, "DocxPackageTest_save.docx");

                DocxPackage expectedPackagePart = new DocxPackage(expectedDocumentStream).Load();
                DocxPackage actualPackagePart   = new DocxPackage(memoryStream).Load();
                Assert.AreEqual(expectedPackagePart.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml.Root.ToString().Trim(),
                                actualPackagePart.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml.Root.ToString().Trim());
            }
        }
        public void TestActualGeneration()
        {
            var input = AssemblyResourceHelper.GetResourceStream(this, "DocxPackageTest.docx");
            using (input)
            {
                var output = new MemoryStream();
                var generator = new DocxGenerator();
                const string DynamicText = "My anaconda don't";
                generator.GenerateDocx(
                    input,
                    output,
                    new SomeEntityWrapper
                    {
                        Test = new SomeEntity
                        {
                            Text = DynamicText
                        }
                    });
                var package = new DocxPackage(output);
                package.Load();

                XDocument documentPartXml = package.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;
                Assert.IsFalse(documentPartXml.Descendants(WordMl.SdtName).Any());
                Assert.IsNotNull(documentPartXml.Descendants(WordMl.TextRunName).Single(e => e.Value == DynamicText));
            }
          
        }       
        public void TestSave()
        {
            using (var docxStream = AssemblyResourceHelper.GetResourceStream(this, "DocxPackageHeaderFooterTest.docx"))
            {
                var memoryStream = new MemoryStream();
                memoryStream.Seek(0, SeekOrigin.Begin);
                docxStream.Seek(0, SeekOrigin.Begin);
                docxStream.CopyTo(memoryStream);
                var package = new DocxPackage(memoryStream);

                package.Load();
                foreach (var part in package.Parts)
                {
                    XElement sdt = part.PartXml.Descendants(WordMl.SdtName).First();
                    sdt.Remove();
                }
                package.Save();

                var expectedDocumentStream = AssemblyResourceHelper.GetResourceStream(this, "DocxPackageHeaderFooterTest_saved.docx");

                DocxPackage expectedPackagePart = new DocxPackage(expectedDocumentStream).Load();
                DocxPackage actualPackagePart = new DocxPackage(memoryStream).Load();

                foreach (var expected in expectedPackagePart.Parts)
                {
                    var actual = actualPackagePart.Parts.Single(x => x.PartUri == expected.PartUri);
                    Assert.AreEqual(expected.PartXml.Root.ToString().Trim(), actual.PartXml.Root.ToString().Trim());
                }
            }
        }
        public void TestActualGenerationStaticTextAfterTag()
        {
            var input = AssemblyResourceHelper.GetResourceStream(this, "corruptedDocxx.docx");

            using (input)
            {
                var       output    = new MemoryStream();
                var       generator = new DocxGenerator();
                XDocument data;
                using (var dataStream = AssemblyResourceHelper.GetResourceStream(this, "DemoData2.xml"))
                {
                    data = XDocument.Load(dataStream);
                }
                generator.GenerateDocx(
                    input,
                    output,
                    data);

                var package = new DocxPackage(output);
                package.Load();
                var documentPart = package.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;
                Assert.IsFalse(documentPart.Descendants(WordMl.SdtName).Any());
                Console.WriteLine(documentPart);
                Assert.IsTrue(documentPart.Root.Descendants(WordMl.TableCellName).All(element => element.Elements().All(el => el.Name != WordMl.TextRunName)));
            }
        }
        public void TestSave()
        {
            using (var docxStream = AssemblyResourceHelper.GetResourceStream(this, "DocxPackageHeaderFooterTest.docx"))
            {
                var memoryStream = new MemoryStream();
                memoryStream.Seek(0, SeekOrigin.Begin);
                docxStream.Seek(0, SeekOrigin.Begin);
                docxStream.CopyTo(memoryStream);
                var package = new DocxPackage(memoryStream);

                package.Load();
                foreach (var part in package.Parts)
                {
                    XElement sdt = part.PartXml.Descendants(WordMl.SdtName).First();
                    sdt.Remove();
                }
                package.Save();

                var expectedDocumentStream = AssemblyResourceHelper.GetResourceStream(this, "DocxPackageHeaderFooterTest_saved.docx");

                DocxPackage expectedPackagePart = new DocxPackage(expectedDocumentStream).Load();
                DocxPackage actualPackagePart   = new DocxPackage(memoryStream).Load();

                foreach (var expected in expectedPackagePart.Parts)
                {
                    var actual = actualPackagePart.Parts.Single(x => x.PartUri == expected.PartUri);
                    Assert.AreEqual(expected.PartXml.Root.ToString().Trim(), actual.PartXml.Root.ToString().Trim());
                }
            }
        }
        public void TestSave()
        {
            using (var docxStream = AssemblyResourceHelper.GetResourceStream(this, "DocxPackageTest.docx"))
            {
                var memoryStream = new MemoryStream();
                memoryStream.Seek(0, SeekOrigin.Begin);
                docxStream.Seek(0, SeekOrigin.Begin);
                docxStream.CopyTo(memoryStream);
                var testPackage = new DocxPackage(memoryStream);

                testPackage.Load();

                var documentPart = testPackage.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;
                XElement sdt = documentPart.Descendants(WordMl.SdtName).First();
                sdt.Remove();

                testPackage.Save();

                var expectedDocumentStream = AssemblyResourceHelper.GetResourceStream(this, "DocxPackageTest_save.docx");

                DocxPackage expectedPackagePart = new DocxPackage(expectedDocumentStream).Load();
                DocxPackage actualPackagePart = new DocxPackage(memoryStream).Load();
                Assert.AreEqual(expectedPackagePart.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml.Root.ToString().Trim(),
                                actualPackagePart.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml.Root.ToString().Trim());
            }
        }                
        public void TestActualGenerationTextInTable()
        {
            MemoryStream output;

            using (var input = AssemblyResourceHelper.GetResourceStream(this, "textintable.docx"))
            {
                output = new MemoryStream();
                var       generator = new DocxGenerator();
                XDocument data;
                using (var dataStream = AssemblyResourceHelper.GetResourceStream(this, "data.xml"))
                {
                    data = XDocument.Load(dataStream);
                }
                generator.GenerateDocx(
                    input,
                    output,
                    data);
            }

            var package = new DocxPackage(output);

            package.Load();

            var documentPart = package.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;

            Assert.IsFalse(documentPart.Descendants(WordMl.SdtName).Any());
            // documentPart.Descendants(WordMl.ParagraphName).Remove();
            Console.WriteLine(documentPart.Descendants(WordMl.TableName).First());
            Assert.IsTrue(documentPart.Descendants(WordMl.TableRowName).All(element => element.Elements().All(el => el.Name != WordMl.ParagraphName)));
        }
        public void TestActualGenerationIfWithTableWithParagraphs()
        {
            MemoryStream output;

            using (var input = AssemblyResourceHelper.GetResourceStream(this, "ifTtable1.docx"))
            {
                output = new MemoryStream();
                var       generator = new DocxGenerator();
                XDocument data;
                using (var dataStream = AssemblyResourceHelper.GetResourceStream(this, "data.xml"))
                {
                    data = XDocument.Load(dataStream);
                }
                generator.GenerateDocx(
                    input,
                    output,
                    data);
            }

            var package = new DocxPackage(output);

            package.Load();

            var documentPart = package.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;

            Assert.IsFalse(documentPart.Descendants(WordMl.SdtName).Any());
        }
        public void TestActualGenerationItemRepeaterElementsInParagraphs2()
        {
            MemoryStream output;

            using (var input = AssemblyResourceHelper.GetResourceStream(this, "badplan.docx"))
            {
                output = new MemoryStream();
                var       generator = new DocxGenerator();
                XDocument data;
                using (var dataStream = AssemblyResourceHelper.GetResourceStream(this, "PlanDocx.xml"))
                {
                    data = XDocument.Load(dataStream);
                }
                generator.GenerateDocx(
                    input,
                    output,
                    data, new DocxGeneratorSettings()
                {
                    MissingDataMode = MissingDataMode.ThrowException
                });
            }

            var package = new DocxPackage(output);

            package.Load();

            var documentPart = package.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;

            Console.WriteLine(documentPart.Descendants(WordMl.TableRowName).First(tr => tr.Descendants().Any(el => el.Value == "тестовое ЭА мероприятие")));
            Assert.IsFalse(documentPart.Descendants(WordMl.SdtName).Any());
            Assert.IsFalse(documentPart.Descendants(WordMl.ParagraphName).Descendants().Any(el => el.Name == WordMl.ParagraphName));
        }
        public void TestActualGenerationItemIfInRepeater()
        {
            MemoryStream output;

            using (var input = AssemblyResourceHelper.GetResourceStream(this, "FaultItemIf.docx"))
            {
                output = new MemoryStream();
                var       generator = new DocxGenerator();
                XDocument data;
                using (var dataStream = AssemblyResourceHelper.GetResourceStream(this, "FaultItemIfData.xml"))
                {
                    data = XDocument.Load(dataStream);
                }
                generator.GenerateDocx(
                    input,
                    output,
                    data, new DocxGeneratorSettings()
                {
                    MissingDataMode = MissingDataMode.ThrowException
                });
            }

            var package = new DocxPackage(output);

            package.Load();

            var documentPart = package.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;

            Console.WriteLine(documentPart);
            //Console.WriteLine(documentPart);
            Assert.IsFalse(documentPart.Descendants(WordMl.SdtName).Any());
            Assert.IsFalse(documentPart.Descendants(WordMl.ParagraphName).Descendants().Any(el => el.Name == WordMl.ParagraphName));
        }
        public void TestActualGenerationItemRepeaterNestedDemoIRInParagraph()
        {
            MemoryStream output;

            using (var input = AssemblyResourceHelper.GetResourceStream(this, "ItemRepeaterNestedDemoIRParagraph.docx"))
            {
                output = new MemoryStream();
                var       generator = new DocxGenerator();
                XDocument data;
                using (var dataStream = AssemblyResourceHelper.GetResourceStream(this, "ItemRepeaterNested2IRDemoData.xml"))
                {
                    data = XDocument.Load(dataStream);
                }
                generator.GenerateDocx(
                    input,
                    output,
                    data, new DocxGeneratorSettings()
                {
                    MissingDataMode = MissingDataMode.ThrowException
                });
            }

            var package = new DocxPackage(output);

            package.Load();

            var documentPart = package.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;

            Console.WriteLine(documentPart.Descendants(WordMl.TableRowName).First(tr => tr.Descendants().Any(el => el.Value == "Certificate 1")));
            //Console.WriteLine(documentPart);
            Assert.IsFalse(documentPart.Descendants(WordMl.SdtName).Any());
            Assert.IsFalse(documentPart.Descendants(WordMl.ParagraphName).Descendants().Any(el => el.Name == WordMl.ParagraphName));
            Assert.IsFalse(documentPart.Descendants(WordMl.TableCellName).Elements(WordMl.ParagraphName).Any(el => el.Name.Equals(WordMl.TextRunName)));
        }
        public void TestActualGeneration()
        {
            var input = AssemblyResourceHelper.GetResourceStream(this, "DocxPackageTest.docx");

            using (input)
            {
                var          output      = new MemoryStream();
                var          generator   = new DocxGenerator();
                const string DynamicText = "My anaconda don't";
                generator.GenerateDocx(
                    input,
                    output,
                    new SomeEntityWrapper
                {
                    Test = new SomeEntity
                    {
                        Text = DynamicText
                    }
                });
                var package = new DocxPackage(output);
                package.Load();

                XDocument documentPartXml = package.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;
                Assert.IsFalse(documentPartXml.Descendants(WordMl.SdtName).Any());
                Assert.IsNotNull(documentPartXml.Descendants(WordMl.TextRunName).Single(e => e.Value == DynamicText));
            }
        }
        public void TestActualGenerationItemHtmlContentInTable()
        {
            var input = AssemblyResourceHelper.GetResourceStream(this, "ItemHtmlContentInTable.docx");

            using (input)
            {
                var       output    = new MemoryStream();
                var       generator = new DocxGenerator();
                XDocument data;
                using (var dataStream = AssemblyResourceHelper.GetResourceStream(this, "data.xml"))
                {
                    data = XDocument.Load(dataStream);
                }
                generator.GenerateDocx(
                    input,
                    output,
                    data, new DocxGeneratorSettings()
                {
                    MissingDataMode = MissingDataMode.Ignore
                });
                var package = new DocxPackage(output);
                package.Load();

                var documentPart = package.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;
                Assert.IsFalse(documentPart.Descendants(WordMl.SdtName).Any());
                Assert.IsFalse(documentPart.Descendants(WordMl.ParagraphName).Descendants().Any(el => el.Name == WordMl.ParagraphName));
            }
        }
        public void TestLoad()
        {
            using(var docxStream = AssemblyResourceHelper.GetResourceStream(this, "DocxPackageTest.docx"))
            {
                var testPackage = new DocxPackage(docxStream);

                testPackage.Load();

                Stream expectedDocStream = AssemblyResourceHelper.GetResourceStream(this, "DocxPackageTest_document.xml");
                var expectedDocument = XDocument.Load(expectedDocStream);

                var documentPart = testPackage.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;

                Assert.AreEqual(expectedDocument.ToString().Trim(), documentPart.Root.ToString().Trim());
            }
        }
        public void TestLoad()
        {
            using (var docxStream = AssemblyResourceHelper.GetResourceStream(this, "DocxPackageTest.docx"))
            {
                var testPackage = new DocxPackage(docxStream);

                testPackage.Load();

                Stream expectedDocStream = AssemblyResourceHelper.GetResourceStream(this, "DocxPackageTest_document.xml");
                var    expectedDocument  = XDocument.Load(expectedDocStream);

                var documentPart = testPackage.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;

                Assert.AreEqual(expectedDocument.ToString().Trim(), documentPart.Root.ToString().Trim());
            }
        }
        public void TestActualXDocumentGenerationHTMLLat1Content()
        {
            const string htmlContentText = @"
                <html>
		        <head />
		        <body>
		        <p> Text is  «gfdgfdg </p>
		        </body>
		        </html>
            ";
            var          input           = AssemblyResourceHelper.GetResourceStream(this, "HTMLLat1Content.docx");

            using (input)
            {
                var output    = new MemoryStream();
                var generator = new DocxGenerator();

                var data = new XDocument();
                data.Add(
                    new XElement("test", new XElement(
                                     "hypertext", htmlContentText
                                     )
                                 )
                    );

                generator.GenerateDocx(
                    input,
                    output,
                    data, new DocxGeneratorSettings()
                {
                    MissingDataMode = MissingDataMode.ThrowException
                });
                var package = new DocxPackage(output);
                package.Load();

                using (var fileStream = File.Create("C:\\xdochtmlcontent.docx"))
                {
                    output.Seek(0, SeekOrigin.Begin);
                    output.CopyTo(fileStream);
                }

                var documentPart = package.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;
                Console.WriteLine(documentPart);
                Assert.IsFalse(documentPart.Descendants(WordMl.SdtName).Any());
                Assert.IsFalse(documentPart.Descendants(WordMl.ParagraphName).Descendants().Any(el => el.Name == WordMl.ParagraphName));
            }
        }
        public void TestActualGenerationRepeaterInIf()
        {
            var input = AssemblyResourceHelper.GetResourceStream(this, "RepeaterInIf.docx");

            using (input)
            {
                var       output    = new MemoryStream();
                var       generator = new DocxGenerator();
                XDocument data;
                using (var dataStream = AssemblyResourceHelper.GetResourceStream(this, "dataRepeaterInIf.xml"))
                {
                    data = XDocument.Load(dataStream);
                }
                generator.GenerateDocx(
                    input,
                    output,
                    data);
                var package = new DocxPackage(output);
                package.Load();

                Assert.IsFalse(package.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml.Descendants(WordMl.SdtName).Any());
            }
        }
        public void TestActualGenerationStaticTextAfterTag()
        {
            var input = AssemblyResourceHelper.GetResourceStream(this, "corruptedDocxx.docx");
            using (input)
            {
                var output = new MemoryStream();
                var generator = new DocxGenerator();
                XDocument data;
                using (var dataStream = AssemblyResourceHelper.GetResourceStream(this, "DemoData2.xml"))
                {
                    data = XDocument.Load(dataStream);
                }
                generator.GenerateDocx(
                    input,
                    output,
                    data);

                var package = new DocxPackage(output);
                package.Load();
                var documentPart = package.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;
                Assert.IsFalse(documentPart.Descendants(WordMl.SdtName).Any());
                Console.WriteLine(documentPart);
                Assert.IsTrue(documentPart.Root.Descendants(WordMl.TableCellName).All(element => element.Elements().All(el => el.Name != WordMl.TextRunName)));
            
            }
        }
        public void TestActualGenerationItemHtmlContentInTable()
        {
            var input = AssemblyResourceHelper.GetResourceStream(this, "ItemHtmlContentInTable.docx");
            using (input)
            {
                var output = new MemoryStream();
                var generator = new DocxGenerator();
                XDocument data;
                using (var dataStream = AssemblyResourceHelper.GetResourceStream(this, "data.xml"))
                {
                    data = XDocument.Load(dataStream);
                }
                generator.GenerateDocx(
                    input,
                    output,
                    data, new DocxGeneratorSettings() { MissingDataMode = MissingDataMode.Ignore });
                var package = new DocxPackage(output);
                package.Load();

                var documentPart = package.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;
                Assert.IsFalse(documentPart.Descendants(WordMl.SdtName).Any());
                Assert.IsFalse(documentPart.Descendants(WordMl.ParagraphName).Descendants().Any(el => el.Name == WordMl.ParagraphName));
            }
        }
        public void TestActualGenerationItemRepeaterNestedInOneParagraph()
        {
            MemoryStream output;
            using (var input = AssemblyResourceHelper.GetResourceStream(this, "ItemRepeaterNestedInOneParagraph.docx"))
            {
                output = new MemoryStream();
                var generator = new DocxGenerator();
                XDocument data;
                using (var dataStream = AssemblyResourceHelper.GetResourceStream(this, "ItemRepeaterNested2IRDemoData.xml"))
                {
                    data = XDocument.Load(dataStream);
                }
                generator.GenerateDocx(
                    input,
                    output,
                    data, new DocxGeneratorSettings() { MissingDataMode = MissingDataMode.ThrowException });
            }

            var package = new DocxPackage(output);
            package.Load();

            var documentPart = package.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;
            var firstRow =
                documentPart.Descendants(WordMl.TableRowName)
                       .First(tr => tr.Descendants().Any(el => el.Value == "Certificate 1"));
            Console.WriteLine(firstRow);            
            Assert.IsFalse(documentPart.Descendants(WordMl.ParagraphName).Descendants().Any(el => el.Name == WordMl.ParagraphName));
            Assert.IsFalse(documentPart.Descendants(WordMl.SdtName).Any());            
            Assert.IsFalse(firstRow.Elements().Last(el => el.Name.Equals(WordMl.TableCellName)).Elements().Any(el => el.Name.Equals(WordMl.TextRunName)));
        }     
        public void TestActualXDocumentGenerationHTMLLat1Content()
        {
            const string htmlContentText = @"
                <html>
		        <head />
		        <body>
		        <p> Text is  «gfdgfdg </p>
		        </body>
		        </html>
            ";
            var input = AssemblyResourceHelper.GetResourceStream(this, "HTMLLat1Content.docx");
            using (input)
            {
                var output = new MemoryStream();
                var generator = new DocxGenerator();

                var data = new XDocument();
                data.Add(
                        new XElement("test", new XElement(
                            "hypertext", htmlContentText
                            )
                        )
                );

                generator.GenerateDocx(
                    input,
                    output,
                    data, new DocxGeneratorSettings() { MissingDataMode = MissingDataMode.ThrowException });
                var package = new DocxPackage(output);
                package.Load();

                using (var fileStream = File.Create("C:\\xdochtmlcontent.docx"))
                {
                    output.Seek(0, SeekOrigin.Begin);
                    output.CopyTo(fileStream);
                }

                var documentPart = package.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;
                Console.WriteLine(documentPart);
                Assert.IsFalse(documentPart.Descendants(WordMl.SdtName).Any());
                Assert.IsFalse(documentPart.Descendants(WordMl.ParagraphName).Descendants().Any(el => el.Name == WordMl.ParagraphName));
            }

        }
        public void TestActualGenerationItemIfInRepeater()
        {
            MemoryStream output;
            using (var input = AssemblyResourceHelper.GetResourceStream(this, "FaultItemIf.docx"))
            {
                output = new MemoryStream();
                var generator = new DocxGenerator();
                XDocument data;
                using (var dataStream = AssemblyResourceHelper.GetResourceStream(this, "FaultItemIfData.xml"))
                {
                    data = XDocument.Load(dataStream);
                }
                generator.GenerateDocx(
                    input,
                    output,
                    data, new DocxGeneratorSettings() { MissingDataMode = MissingDataMode.ThrowException });
            }

            var package = new DocxPackage(output);
            package.Load();

            var documentPart = package.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;
            Console.WriteLine(documentPart);
            //Console.WriteLine(documentPart);
            Assert.IsFalse(documentPart.Descendants(WordMl.SdtName).Any());
            Assert.IsFalse(documentPart.Descendants(WordMl.ParagraphName).Descendants().Any(el => el.Name == WordMl.ParagraphName));
        }
        public void TestActualGenerationItemRepeaterElementsInParagraphs2()
        {
            MemoryStream output;
            using (var input = AssemblyResourceHelper.GetResourceStream(this, "badplan.docx"))
            {
                output = new MemoryStream();
                var generator = new DocxGenerator();
                XDocument data;
                using (var dataStream = AssemblyResourceHelper.GetResourceStream(this, "PlanDocx.xml"))
                {
                    data = XDocument.Load(dataStream);
                }
                generator.GenerateDocx(
                    input,
                    output,
                    data, new DocxGeneratorSettings() { MissingDataMode = MissingDataMode.ThrowException });
            }

            var package = new DocxPackage(output);
            package.Load();

            var documentPart = package.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;
            Console.WriteLine(documentPart.Descendants(WordMl.TableRowName).First(tr => tr.Descendants().Any(el => el.Value == "тестовое ЭА мероприятие")));
            Assert.IsFalse(documentPart.Descendants(WordMl.SdtName).Any());
            Assert.IsFalse(documentPart.Descendants(WordMl.ParagraphName).Descendants().Any(el => el.Name == WordMl.ParagraphName));
        }
        public void TestActualGenerationDoubleRepeater()
        {
            MemoryStream output;
            using (var input = AssemblyResourceHelper.GetResourceStream(this, "DoubleRepeater.docx"))
            {
                output = new MemoryStream();
                var generator = new DocxGenerator();
                XDocument data;
                using (var dataStream = AssemblyResourceHelper.GetResourceStream(this, "data.xml"))
                {
                    data = XDocument.Load(dataStream);
                }
                generator.GenerateDocx(
                    input,
                    output,
                    data);
            }

            var package = new DocxPackage(output);
            package.Load();

            var documentPart = package.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;
            Assert.IsFalse(documentPart.Descendants(WordMl.SdtName).Any());
        }
        public void TestActualGenerationTextInTable()
        {
            MemoryStream output;
            using (var input = AssemblyResourceHelper.GetResourceStream(this, "textintable.docx"))
            {
                output = new MemoryStream();
                var generator = new DocxGenerator();
                XDocument data;
                using (var dataStream = AssemblyResourceHelper.GetResourceStream(this, "data.xml"))
                {
                    data = XDocument.Load(dataStream);
                }
                generator.GenerateDocx(
                    input,
                    output,
                    data);
            }

            var package = new DocxPackage(output);
            package.Load();

            var documentPart = package.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;
            Assert.IsFalse(documentPart.Descendants(WordMl.SdtName).Any());
           // documentPart.Descendants(WordMl.ParagraphName).Remove();
            Console.WriteLine(documentPart.Descendants(WordMl.TableName).First());
            Assert.IsTrue(documentPart.Descendants(WordMl.TableRowName).All(element => element.Elements().All(el => el.Name != WordMl.ParagraphName)));

        }
        public void TestActualGenerationDoubleItemIfWithItemText()
        {
            MemoryStream output;
            using (var input = AssemblyResourceHelper.GetResourceStream(this, "corruptedDoc.docx"))
            {
                output = new MemoryStream();
                var generator = new DocxGenerator();
                XDocument data;
                using (var dataStream = AssemblyResourceHelper.GetResourceStream(this, "DemoData2.xml"))
                {
                    data = XDocument.Load(dataStream);
                }
                generator.GenerateDocx(
                    input,
                    output,
                    data, 
                    new DocxGeneratorSettings() { MissingDataMode = MissingDataMode.ThrowException });
            }

            var package = new DocxPackage(output);
            package.Load();

            var documentPart = package.Parts.Single(p => p.PartUri.OriginalString.Contains("document.xml")).PartXml;
            Console.WriteLine(documentPart.ToString());
            Assert.IsFalse(documentPart.Descendants(WordMl.SdtName).Any());                        
        }