Ejemplo n.º 1
0
        public void TestBigXml()
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            ReadXml r = new ReadXml
            {
                StringPath = @"C:\Users\dor\source\repos\xmlTest\XmlParser\test2.xml"
            };

            XmlParser parser = new AdvancedXmlParser
            {
                Document = r.ReadFile(),

                ParserConfig = new Config
                {
                    Paths = new List <string>(new string[] { "rows/head", "rows", "rows/head/property", "bla", "rows/row" }),
                }
            };

            parser.ParseData(LoggerType.DEBUG);
            sw.Stop();
            using (parser.Log = LoggerFactory.GetLogger(LoggerType.DEBUG))
            {
                parser.Log.LogMessage("Time total: " + sw.Elapsed);
            }
            Assert.IsTrue(sw.Elapsed.TotalSeconds < 1, String.Format("Took more than a second {0} for 1000 line XML, not good enough", sw.Elapsed));
        }
Ejemplo n.º 2
0
        public void CheckIfFileExists()
        {
            ReadXml r = new ReadXml();

            r.StringPath = @"bla.xml";

            XDocument doc = r.ReadFile();
        }
Ejemplo n.º 3
0
        public void CheckForNullPath()
        {
            ReadXml r = new ReadXml();

            r.StringPath = null;

            r.ReadFile();
        }
Ejemplo n.º 4
0
        public void TryReadingXmlFile()
        {
            ReadXml r = new ReadXml();

            r.StringPath = @"C:\Users\dor\source\repos\xmlTest\XmlParser\test.xml";

            XmlParser parser = new SimpleXmlParser();

            parser.Document = r.ReadFile();
        }
Ejemplo n.º 5
0
        private static Dictionary <string, List <Tag> > init()
        {
            ReadXml r = new ReadXml
            {
                StringPath = @"C:\Users\dor\source\repos\xmlTest\XmlParser\test2.xml"
            };

            XmlParser parser = new AdvancedXmlParser();

            try
            {
                parser.Document     = r.ReadFile();
                parser.ParserConfig = new Config
                {
                    Paths = new List <string>(new string[] { "rows/head", "rows/row" }),
                };

                parser.ParseData(LoggerType.DEBUG);
                return(parser.ParsedData);
            } catch (FileNotFoundException fnfException)
            {
                Console.WriteLine(fnfException.Message + " " + fnfException.FileName);
                Console.WriteLine("Click any key to exit the program");
                Console.ReadKey();
                Environment.Exit(1);
            } catch (XmlException xmlException)
            {
                Console.WriteLine(xmlException.Message);
                Console.WriteLine("Click any key to exit the program");
                Console.ReadKey();
                Environment.Exit(1);
            } catch (ArgumentNullException anException)
            {
                Console.WriteLine(anException.Message);
                Console.WriteLine("Click any key to exit the program");
                Console.ReadKey();
                Environment.Exit(1);
            } catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Click any key to exit the program");
                Console.ReadKey();
                Environment.Exit(1);
            }
            return(null);
        }