Exemple #1
0
        private static void Save(TextWriter tw, TestResultNode result, int padding)
        {
            int newPadding = padding;

            if (!string.IsNullOrEmpty(result.Name))
            {
                if (padding > 0)
                {
                    tw.Write(new string(' ', padding));
                }
                tw.Write(result.Name);
                if (!string.IsNullOrEmpty(result.Result))
                {
                    tw.Write(" [");
                    tw.Write(result.Result);
                    tw.Write(']');
                }
                newPadding += 2;
                tw.WriteLine();
                if (!string.IsNullOrEmpty(result.Message))
                {
                    WriteMessage(tw, result.Message, newPadding);
                }
            }
            foreach (TestResultNode node in result)
            {
                Save(tw, node, newPadding);
            }
        }
Exemple #2
0
        private static void Compress(TestResultNode parent)
        {
            int index = 0;

            while (index < parent.Count)
            {
                TestResultNode node = parent[index];
                if (node.SuiteType == TestSuiteType.Namespace)
                {
                    bool repeat = true;
                    while (repeat && (node.Count == 1))
                    {
                        TestResultNode child = node[0];
                        repeat = (child.SuiteType == TestSuiteType.Namespace);
                        if (repeat)
                        {
                            string         combinedName = (node.Name + "." + child.Name);
                            TestResultNode combined     = new TestResultNode(combinedName, child);
                            parent[index] = combined;
                            node          = combined;
                        }
                    }
                }
                Compress(node);
                index++;
            }
        }
Exemple #3
0
 private static void Save(TestResultNode result, string fileName)
 {
     using (StreamWriter sw = new StreamWriter(fileName, false, Encoding.UTF8))
     {
         Save(sw, result, 0);
     }
 }
Exemple #4
0
        static int Main(string[] args)
        {
            try
            {
                if (args.Length > 2)
                {
                    DisplayHelp(Console.Error, false);
                    return((int)ApplicationResult.InvalidCommandLine);
                }
                XmlDocument document = LoadXmlDocument(args);
                if (ReferenceEquals(document, null))
                {
                    return((int)ApplicationResult.InvalidCommandLine);
                }
                TestResultNode result = new TestResultNode();
                result.Load(document.DocumentElement);
                Compress(result);
                if (args.Length == 2)
                {
                    Save(result, args[1]);
                }
                else
                {
                    Save(Console.Out, result, 0);
                }
                return((int)ApplicationResult.OK);
            }
#pragma warning disable S2221 // Do not let fall exception to system
            catch (Exception ex)
#pragma warning restore S2221 // "Exception" should not be caught when not required by called methods
            {
                Console.Error.WriteLine(ex.GetType());
                Console.Error.WriteLine(ex.Message);
                return((int)ApplicationResult.Exception);
            }
        }