public TestInfoCollection Parse(string[] args)
        {
            TestInfoCollection collection = new TestInfoCollection();

            // Command line parsing
            Arguments commandLine = new Arguments(args);

            // Check if default total test is requested...
            m_bIsDefault = false;
            if (commandLine["default"] != null)
            {
                m_bIsDefault = true;
            }

            // 1. Handle the "proj" option
            if (commandLine["proj"] != null)
            {
                return ParseProject(commandLine["proj"]);
            }

            // 2. Handle the display filter option
            XmlTestType testType = XmlTestType.None;
            if (commandLine["filter"] != null)
            {
                testType = ParseXmlTestType(commandLine["filter"]);
            }

            // 3. Handle the display of the exception messages option
            bool bDisplayException = true;
            if (commandLine["exception"] != null)
            {
                string strException = commandLine["exception"];
                strException        = strException.ToLower();

                bDisplayException   = (strException == "true");
            }

            // 4. Handle the verbose display option 
            bool bVerbose = true;
            if (commandLine["verbose"] != null)
            {
                string strVerbose = commandLine["verbose"];
                strVerbose        = strVerbose.ToLower();

                bVerbose   = (strVerbose == "true");
            }

            // 4. Handle the interactivity option 
            bool bInteractive = false;
            if (commandLine["interactive"] != null)
            {
                string strInteractive = commandLine["interactive"];
                strInteractive        = strInteractive.ToLower();

                bInteractive          = (strInteractive == "true");
                if (bInteractive)
                {
                    TestInfo info = new TestInfo(testType);
                    info.Verbose     = bVerbose;
                    info.Exception   = bDisplayException;
                    info.Interactive = bInteractive;

                    collection.Add(info);

                    return collection;
                }
            }

            // 5. Handle the files option, if any
            if (commandLine["files"] != null)
            {
                string strFiles = commandLine["files"];
                Console.WriteLine(strFiles);

                string[] strSplits = strFiles.Split(',');
    
                for (int i = 0; i < strSplits.Length; i++)
                {
                    TestInfo info    = new TestInfo(testType);
                    info.FileName    = strSplits[i].Trim();
                    info.Verbose     = bVerbose;
                    info.Exception   = bDisplayException;
                    info.Interactive = false;

                    collection.Add(info);
                }
            }

            // 6. Handle the dirs option, if any
            if (commandLine["dirs"] != null)
            {
                string strDirs = commandLine["dirs"];

                string[] strSplits = strDirs.Split(',');
    
                for (int i = 0; i < strSplits.Length; i++)
                {
                    TestInfo info    = new TestInfo(testType);
                    info.Directory   = strSplits[i].Trim();
                    info.Verbose     = bVerbose;
                    info.Exception   = bDisplayException;
                    info.Interactive = false;

                    collection.Add(info);
                }
            }

            return collection;
        }
        public TestInfoCollection ParseProject(string projectFile)
        {
            if (!File.Exists(projectFile))
            {
                throw new ArgumentException(projectFile, 
                    "The file does not exits or the 'projectFile' is not valid.");
            }

            try
            {
                TestInfoCollection collection = new TestInfoCollection();

                XmlDocument xmldoc = new XmlDocument();

                xmldoc.Load(projectFile);

                XmlElement root = xmldoc.DocumentElement; 

                // Now, handle the "case" nodes
                XmlNodeList elemList = xmldoc.GetElementsByTagName("test");
                for (int i = 0; i < elemList.Count; i++)
                {   
                    XmlNode element = elemList[i];
                    if (element != null)
                    {
                        XmlTestType filterType = XmlTestType.None;
                        bool bDisplayException = true;
                        bool bVerbose          = true;
                        bool bInteractive      = false;

                        XmlAttributeCollection attributes = element.Attributes;
                        if (attributes != null && attributes.Count > 0)
                        {
                            XmlAttribute attFilter = attributes["filter"];
                            if (attFilter != null)
                            {
                                filterType = ParseXmlTestType(attFilter.InnerText);
                            }

                            XmlAttribute attException = attributes["exception"];
                            if (attException != null)
                            {
                                bDisplayException = Boolean.Parse(attException.InnerText);
                            }

                            XmlAttribute attVerbose = attributes["verbose"];
                            if (attVerbose != null)
                            {
                                bVerbose = Boolean.Parse(attVerbose.InnerText);
                            }

                            XmlAttribute attInteractive = attributes["interactive"];
                            if (attInteractive != null)
                            {
                                bInteractive = Boolean.Parse(attInteractive.InnerText);
                            }   
                        }

                        XmlNodeList elemFiles = element.SelectNodes("files/file");
                        if (elemFiles != null)
                        {
                            for (int j = 0; j < elemFiles.Count; j++)
                            { 
                                XmlNode xmlFile = elemFiles[j];
                                if (xmlFile != null)
                                {
                                    TestInfo info    = new TestInfo(filterType);
                                    info.FileName    = xmlFile.InnerText;
                                    info.Verbose     = bVerbose;
                                    info.Exception   = bDisplayException;
                                    info.Interactive = bInteractive;

                                    collection.Add(info);
                                }
                            } 
                        }
 
                        XmlNodeList elemDirs = element.SelectNodes("dirs/dir");
                        if (elemDirs != null)
                        {
                            for (int k = 0; k < elemDirs.Count; k++)
                            { 
                                XmlNode xmlDir = elemDirs[k];
                                if (xmlDir != null)
                                {
                                    TestInfo info    = new TestInfo(filterType);
                                    info.Directory   = xmlDir.InnerText;
                                    info.Verbose     = bVerbose;
                                    info.Exception   = bDisplayException;
                                    info.Interactive = bInteractive;

                                    collection.Add(info);
                                }
                            } 
                        }
                    }
                }

                return collection;
            }
            catch (Exception ex)
            {
                XmlTestExceptionManager.Publish(ex);

                return null;
            }
        }
示例#3
0
        public TestInfoCollection Parse(string[] args)
        {
            TestInfoCollection collection = new TestInfoCollection();

            // Command line parsing
            Arguments commandLine = new Arguments(args);

            // Check if default total test is requested...
            m_bIsDefault = false;
            if (commandLine["default"] != null)
            {
                m_bIsDefault = true;
            }

            // 1. Handle the "proj" option
            if (commandLine["proj"] != null)
            {
                return(ParseProject(commandLine["proj"]));
            }

            // 2. Handle the display filter option
            XmlTestType testType = XmlTestType.None;

            if (commandLine["filter"] != null)
            {
                testType = ParseXmlTestType(commandLine["filter"]);
            }

            // 3. Handle the display of the exception messages option
            bool bDisplayException = true;

            if (commandLine["exception"] != null)
            {
                string strException = commandLine["exception"];
                strException = strException.ToLower();

                bDisplayException = (strException == "true");
            }

            // 4. Handle the verbose display option
            bool bVerbose = true;

            if (commandLine["verbose"] != null)
            {
                string strVerbose = commandLine["verbose"];
                strVerbose = strVerbose.ToLower();

                bVerbose = (strVerbose == "true");
            }

            // 4. Handle the interactivity option
            bool bInteractive = false;

            if (commandLine["interactive"] != null)
            {
                string strInteractive = commandLine["interactive"];
                strInteractive = strInteractive.ToLower();

                bInteractive = (strInteractive == "true");
                if (bInteractive)
                {
                    TestInfo info = new TestInfo(testType);
                    info.Verbose     = bVerbose;
                    info.Exception   = bDisplayException;
                    info.Interactive = bInteractive;

                    collection.Add(info);

                    return(collection);
                }
            }

            // 5. Handle the files option, if any
            if (commandLine["files"] != null)
            {
                string strFiles = commandLine["files"];
                Console.WriteLine(strFiles);

                string[] strSplits = strFiles.Split(',');

                for (int i = 0; i < strSplits.Length; i++)
                {
                    TestInfo info = new TestInfo(testType);
                    info.FileName    = strSplits[i].Trim();
                    info.Verbose     = bVerbose;
                    info.Exception   = bDisplayException;
                    info.Interactive = false;

                    collection.Add(info);
                }
            }

            // 6. Handle the dirs option, if any
            if (commandLine["dirs"] != null)
            {
                string strDirs = commandLine["dirs"];

                string[] strSplits = strDirs.Split(',');

                for (int i = 0; i < strSplits.Length; i++)
                {
                    TestInfo info = new TestInfo(testType);
                    info.Directory   = strSplits[i].Trim();
                    info.Verbose     = bVerbose;
                    info.Exception   = bDisplayException;
                    info.Interactive = false;

                    collection.Add(info);
                }
            }

            return(collection);
        }
示例#4
0
        public TestInfoCollection ParseProject(string projectFile)
        {
            if (!File.Exists(projectFile))
            {
                throw new ArgumentException(projectFile,
                                            "The file does not exits or the 'projectFile' is not valid.");
            }

            try
            {
                TestInfoCollection collection = new TestInfoCollection();

                XmlDocument xmldoc = new XmlDocument();

                xmldoc.Load(projectFile);

                XmlElement root = xmldoc.DocumentElement;

                // Now, handle the "case" nodes
                XmlNodeList elemList = xmldoc.GetElementsByTagName("test");
                for (int i = 0; i < elemList.Count; i++)
                {
                    XmlNode element = elemList[i];
                    if (element != null)
                    {
                        XmlTestType filterType        = XmlTestType.None;
                        bool        bDisplayException = true;
                        bool        bVerbose          = true;
                        bool        bInteractive      = false;

                        XmlAttributeCollection attributes = element.Attributes;
                        if (attributes != null && attributes.Count > 0)
                        {
                            XmlAttribute attFilter = attributes["filter"];
                            if (attFilter != null)
                            {
                                filterType = ParseXmlTestType(attFilter.InnerText);
                            }

                            XmlAttribute attException = attributes["exception"];
                            if (attException != null)
                            {
                                bDisplayException = Boolean.Parse(attException.InnerText);
                            }

                            XmlAttribute attVerbose = attributes["verbose"];
                            if (attVerbose != null)
                            {
                                bVerbose = Boolean.Parse(attVerbose.InnerText);
                            }

                            XmlAttribute attInteractive = attributes["interactive"];
                            if (attInteractive != null)
                            {
                                bInteractive = Boolean.Parse(attInteractive.InnerText);
                            }
                        }

                        XmlNodeList elemFiles = element.SelectNodes("files/file");
                        if (elemFiles != null)
                        {
                            for (int j = 0; j < elemFiles.Count; j++)
                            {
                                XmlNode xmlFile = elemFiles[j];
                                if (xmlFile != null)
                                {
                                    TestInfo info = new TestInfo(filterType);
                                    info.FileName    = xmlFile.InnerText;
                                    info.Verbose     = bVerbose;
                                    info.Exception   = bDisplayException;
                                    info.Interactive = bInteractive;

                                    collection.Add(info);
                                }
                            }
                        }

                        XmlNodeList elemDirs = element.SelectNodes("dirs/dir");
                        if (elemDirs != null)
                        {
                            for (int k = 0; k < elemDirs.Count; k++)
                            {
                                XmlNode xmlDir = elemDirs[k];
                                if (xmlDir != null)
                                {
                                    TestInfo info = new TestInfo(filterType);
                                    info.Directory   = xmlDir.InnerText;
                                    info.Verbose     = bVerbose;
                                    info.Exception   = bDisplayException;
                                    info.Interactive = bInteractive;

                                    collection.Add(info);
                                }
                            }
                        }
                    }
                }

                return(collection);
            }
            catch (Exception ex)
            {
                XmlTestExceptionManager.Publish(ex);

                return(null);
            }
        }
 public void Remove(TestInfo value)  
 {
     List.Remove(value);
 }
 public bool Contains(TestInfo value)  
 {
     // If value is not of type TestInfo, this will return false.
     return (List.Contains(value));
 }
 public int IndexOf(TestInfo value)  
 {
     return (List.IndexOf(value));
 }
示例#8
0
 public int IndexOf(TestInfo value)
 {
     return(List.IndexOf(value));
 }
示例#9
0
        private bool RunTestFile(TestInfo info, XmlTestController controller)
        {
            if (info != null)
            {
                XmlTestCollection listTests = null;
                try
                {
                    listTests = controller.Load(info.FileName);
                }
                catch (Exception ex)
                {
                    XmlTestExceptionManager.Publish(ex);
                }

                SimpleTestReset(info.Filter, info.Verbose);

                if (listTests != null && listTests.Count > 0)
                {
                    listTests.TestEvent += new XmlTextEventHandler(OnSimpleTest);
                    listTests.TestEvent += new XmlTextEventHandler(OnTest);

                    if (info.Exception)
                    {
                        XmlTestExceptionManager.ErrorEvent +=
                            new XmlTestErrorEventHandler(this.OnErrorEvent);
                    }

                    try
                    {
                        Console.WriteLine("Running...{0}", listTests.Name);

                        XmlTestTimer timer = new XmlTestTimer();

                        timer.Start();

                        listTests.RunTests();

                        timer.Stop();

                        PrintSimpleTestResult(listTests.Count);

                        Console.WriteLine("Duration in milliseconds: {0}", timer.Duration * 1000);

                        elapsedTime += (timer.Duration * 1000);

                        m_nTotalCount += listTests.Count;

                        listTests.TestEvent -= new XmlTextEventHandler(OnSimpleTest);
                        listTests.TestEvent -= new XmlTextEventHandler(OnTest);

                        if (info.Exception)
                        {
                            XmlTestExceptionManager.ErrorEvent -=
                                new XmlTestErrorEventHandler(this.OnErrorEvent);
                        }
                    }
                    catch (Exception ex)
                    {
                        XmlTestExceptionManager.Publish(ex);
                    }
                }

                return(true);
            }

            return(false);
        }
 public int Add(TestInfo value)  
 {
     return (List.Add(value));
 }
示例#11
0
 public bool Contains(TestInfo value)
 {
     // If value is not of type TestInfo, this will return false.
     return(List.Contains(value));
 }
示例#12
0
 public void Remove(TestInfo value)
 {
     List.Remove(value);
 }
示例#13
0
 public void Insert(int index, TestInfo value)
 {
     List.Insert(index, value);
 }
示例#14
0
        private bool RunTestFile(TestInfo info, XmlTestController controller)
        {
            if (info != null)
            {
                XmlTestCollection listTests = null;
                try
                {
                    listTests = controller.Load(info.FileName);
                }
                catch (Exception ex)
                {
                    XmlTestExceptionManager.Publish(ex);
                } 

                SimpleTestReset(info.Filter, info.Verbose);

                if (listTests != null && listTests.Count > 0)
                {
                    listTests.TestEvent += new XmlTextEventHandler(OnSimpleTest);
                    listTests.TestEvent += new XmlTextEventHandler(OnTest);

                    if (info.Exception)
                    {
                        XmlTestExceptionManager.ErrorEvent += 
                            new XmlTestErrorEventHandler(this.OnErrorEvent);
                    }

                    try
                    {
                        Console.WriteLine("Running...{0}", listTests.Name);

                        XmlTestTimer timer = new XmlTestTimer();

                        timer.Start();

                        listTests.RunTests();

                        timer.Stop();

                        PrintSimpleTestResult(listTests.Count);

                        Console.WriteLine("Duration in milliseconds: {0}", timer.Duration * 1000);

                        elapsedTime += (timer.Duration * 1000);

                        m_nTotalCount += listTests.Count;

                        listTests.TestEvent -= new XmlTextEventHandler(OnSimpleTest);
                        listTests.TestEvent -= new XmlTextEventHandler(OnTest);

                        if (info.Exception)
                        {
                            XmlTestExceptionManager.ErrorEvent -= 
                                new XmlTestErrorEventHandler(this.OnErrorEvent);
                        }
                    }
                    catch (Exception ex)
                    {
                        XmlTestExceptionManager.Publish(ex);
                    }
                }

                return true;
            }

            return false;
        }
 public void Insert(int index, TestInfo value)  
 {
     List.Insert(index, value);
 }
示例#16
0
 private bool RunTestDirectory(TestInfo info, XmlTestController controller)
 {
     if (info != null && info.Directory != null)
     {
         try
         {
             string currentDir = Environment.CurrentDirectory;
             string[] files = Directory.GetFiles(info.Directory, "*.xml");
             foreach (string file in files) 
             {
                 info.FileName = file;
                 RunTestFile(info, controller);
             }               
             return true;
         }
         catch (Exception ex)
         {
             XmlTestExceptionManager.Publish(ex);
         }
         return true;
     }
     return false;
 }
示例#17
0
 public int Add(TestInfo value)
 {
     return(List.Add(value));
 }