From df50d7daf96430b70065747dceac5a43fd65fd1d Mon Sep 17 00:00:00 2001
From: Anton Bagliy <taccessviolation@gmail.com>
Date: Thu, 29 Aug 2019 19:13:10 +0300
Subject: [PATCH] FIX: reading old NUnit xml reports #55

---
 NunitReportParser/Program.cs | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/NunitReportParser/Program.cs b/NunitReportParser/Program.cs
index b8aecd6..5e77b65 100644
--- a/NunitReportParser/Program.cs
+++ b/NunitReportParser/Program.cs
@@ -25,6 +25,10 @@ namespace NunitReport
                 {
                     cases.Add(child);
                 }
+                else
+                {
+                    ParseTestSuite(child);   
+                }
             }
         }
 
@@ -43,8 +47,18 @@ namespace NunitReport
             var countedGrades = new Dictionary<string, double>();
             foreach (XmlNode testcase in cases)
             {
-                string caseClass = testcase.Attributes["classname"].Value.Split('.')[0];
-                string caseName = testcase.Attributes["name"].Value;
+                string caseClass;
+                string caseName;
+                try
+                {
+                    caseClass = testcase.Attributes["classname"].Value.Split('.')[0];
+                    caseName = testcase.Attributes["name"].Value;
+                } catch(Exception e)
+                {
+                    string[] fullName = testcase.Attributes["name"].Value.Split('.');
+                    caseClass = fullName[0];
+                    caseName = fullName[fullName.Length - 1];
+                }
 
                 foreach (JObject task in tasks)
                 {
@@ -93,12 +107,12 @@ namespace NunitReport
             }
             doc.Load(filePath);
             string[] XmlText = File.ReadAllLines(filePath);
-            System.Console.WriteLine("+++++++++++++++++++++++++");
-            foreach (string line in XmlText)
-            {
-                System.Console.WriteLine(line);
-            }
-            System.Console.WriteLine("+++++++++++++++++++++++++");
+//            System.Console.WriteLine("+++++++++++++++++++++++++");
+//            foreach (string line in XmlText)
+//            {
+//                System.Console.WriteLine(line);
+//            }
+//            System.Console.WriteLine("+++++++++++++++++++++++++");
 
             // XmlNodeList nodes = doc.DocumentElement.SelectNodes("test-run/test-suite"); 
             XmlNodeList nodes = doc.DocumentElement.ChildNodes;
-- 
GitLab