public void WriteCdataTest()
        {
            var root = new SavannahTagNode
            {
                TagName    = "root",
                ChildNodes = new []
                {
                    new SavannahTagNode
                    {
                        TagName    = "tag",
                        InnerText  = "",
                        ChildNodes = new[]
                        {
                            new SavannahCdataNode
                            {
                                InnerText = "  <?xml version=\"1.0\"?>\n  <document>\n      doc.\n  </document>",
                            }
                        }
                    }
                }
            };

            var ms     = new MemoryStream();
            var writer = new SavannahXmlWriter();

            writer.Write(ms, root);
            ms.Position = 0;
            var xml = new StreamReader(ms).ReadToEnd();
            var exp = File.ReadAllText(CommonXmlReaderTest.GetTestPath("Cdata.xml")).UnifiedBreakLine();

            Assert.AreEqual(exp, xml);
        }
        public void GetAttributesClearTest()
        {
            XmlNodeList firstNodes  = null;
            XmlNodeList secondNodes = null;
            Dictionary <XmlNode, AbstractSavannahXmlNode> firstDict  = null;
            Dictionary <XmlNode, AbstractSavannahXmlNode> secondDict = null;

            var reader = new CachesSavannahXmlReaderForTest(CommonXmlReaderTest.GetTestPath())
            {
                SelectNodesAssertAction = (nodes) => firstNodes = nodes,
                CreateTableAssertAction = (dict) => firstDict = dict
            };
            var names = reader.GetAttributes("name", "/ServerSettings/property");

            reader.SelectNodesAssertAction = (nodes) => secondNodes = nodes;
            reader.CreateTableAssertAction = (dict) => secondDict = dict;
            reader.ClearCache();
            var names2 = reader.GetAttributes("name", "/ServerSettings/property");

            if (firstNodes == null && secondNodes == null)
            {
                Assert.Fail("firstNodes and secondNodes is null");
            }
            if (firstDict == null && secondDict == null)
            {
                Assert.Fail("firstNodes and secondNodes is null");
            }

            Assert.AreNotSame(firstNodes, secondNodes);
            Assert.AreNotSame(firstDict, secondDict);
        }
        public void WriteTest()
        {
            var root = new SavannahTagNode
            {
                TagName    = "ServerSettings",
                ChildNodes = new[]
                {
                    new SavannahTagNode
                    {
                        TagName    = "property",
                        Attributes = new AttributeInfo[]
                        {
                            new AttributeInfo
                            {
                                Name  = "name",
                                Value = "ServerName"
                            },
                            new AttributeInfo
                            {
                                Name  = "value",
                                Value = "My Game Host"
                            }
                        },
                        ChildNodes = new []
                        {
                            new SavannahTextNode
                            {
                                InnerText = "サーバー名を設定します。サーバーリストにはこの名前で表示されます。"
                            }
                        }
                    },
                    new SavannahTagNode
                    {
                        TagName    = "property",
                        Attributes = new AttributeInfo[]
                        {
                            new AttributeInfo
                            {
                                Name  = "name",
                                Value = "ServerName2"
                            },
                            new AttributeInfo
                            {
                                Name  = "value",
                                Value = "My Game Host"
                            }
                        },
                        ChildNodes = new []
                        {
                            new SavannahTextNode
                            {
                                InnerText = "サーバー名を設定します。サーバーリストにはこの名前で表示されます。\n    test"
                            }
                        }
                    },
                    new SavannahTagNode
                    {
                        TagName    = "property",
                        Attributes = new AttributeInfo[]
                        {
                            new AttributeInfo
                            {
                                Name  = "name",
                                Value = "ServerDescription"
                            },
                            new AttributeInfo
                            {
                                Name  = "value",
                                Value = "A 7 Days to Die server"
                            }
                        },
                        ChildNodes = new []
                        {
                            new SavannahTextNode
                            {
                                InnerText = "サーバーの説明を設定します。"
                            }
                        }
                    },
                    new SavannahTagNode
                    {
                        TagName    = "property",
                        Attributes = new AttributeInfo[]
                        {
                            new AttributeInfo
                            {
                                Name  = "name",
                                Value = "ServerWebsiteURL"
                            },
                            new AttributeInfo
                            {
                                Name  = "value",
                                Value = ""
                            }
                        },
                        ChildNodes = new []
                        {
                            new SavannahTextNode
                            {
                                InnerText = "サーバーのウェブサイトを設定します。"
                            }
                        }
                    },
                    new SavannahTagNode
                    {
                        TagName    = "property",
                        Attributes = new AttributeInfo[]
                        {
                            new AttributeInfo
                            {
                                Name  = "name",
                                Value = "Nested"
                            }
                        },
                        ChildNodes = new[]
                        {
                            new SavannahTagNode
                            {
                                TagName    = "property",
                                Attributes = new AttributeInfo[]
                                {
                                    new AttributeInfo
                                    {
                                        Name  = "name",
                                        Value = "NestedElem"
                                    }
                                },
                                ChildNodes = new []
                                {
                                    new SavannahTextNode
                                    {
                                        InnerText = "Value"
                                    }
                                }
                            }
                        }
                    }
                }
            };

            var exp = File.ReadAllText(CommonXmlReaderTest.GetTestPath()).UnifiedBreakLine();

            var writer = new SavannahXmlWriter("version=\"1.0\" encoding=\"UTF-8\"");

            using var ms = new MemoryStream();
            writer.Write(ms, root);
            ms.Seek(0, SeekOrigin.Begin);

            using var sr = new StreamReader(ms);
            var xml = sr.ReadToEnd().UnifiedBreakLine();

            Assert.AreEqual(exp, xml);
        }