private string GetExpectedXMLContent(DumpValueItem[] Items)
        {
            StringBuilder builder = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
                                                      "<ValueDumper>\r\n");
            foreach (DumpValueItem item in Items)
            {
                builder.Append("  <ValueDumperItem>\r\n");
                builder.Append("    <Name>" + item.Name + "</Name>\r\n");
                if (item.ValueInCDATA)
                    builder.Append("    <Value><![CDATA[" + item.Value + "]]></Value>\r\n");
                else
                    builder.Append("    <Value>" + item.Value.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;") + "</Value>\r\n");
                builder.Append("  </ValueDumperItem>\r\n");
            }
            builder.Append("</ValueDumper>");

            return builder.ToString();
        }
示例#2
0
 public ValueDumperItem(DumpValueItem Item)
 {
     Name         = Item.Name;
     value        = Item.Value;
     valueInCDATA = Item.ValueInCDATA;
 }
        private void BaseTest(DumpValueItem[] NameValues)
        {
            DumpValueTask task = new DumpValueTask();
            task.XmlFileName = dumpFilePath;
            task.Items = NameValues;
            task.Run(GetResult());
            Assert.IsTrue(File.Exists(dumpFilePath), "Dump file not generated");

            StreamReader reader = File.OpenText(dumpFilePath);
            string dumpContent;
            try
            {
                dumpContent = reader.ReadToEnd();
            }
            finally
            {
                reader.Close();
            }

            Assert.AreEqual(GetExpectedXMLContent(task.Items), dumpContent);
        }