Exemplo n.º 1
0
        private void AddTest()
        {
            RootNode node = GetSelectedNode();
            if (node.CanAddTest())
            {

                OpenFileDialog dialog = new OpenFileDialog();
                dialog.Filter = "xml files (*.xml)|*.xml";
                dialog.InitialDirectory = lastLoadDir;
                dialog.Title = "Select a test file";
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    string testName = System.IO.Path.GetFileNameWithoutExtension(dialog.FileName);
                    TestNode testNode = new TestNode(testName, dialog.FileName);
                    node.Nodes.Add(testNode);
                    node.Expand();
                }
                lastLoadDir = System.IO.Directory.GetCurrentDirectory();
            }
        }
Exemplo n.º 2
0
        public bool RunTest(TestNode testNode, Dictionary<string, string> argDic, System.IO.StringWriter strWr)
        {
            XmlDocument testDoc = new XmlDocument();
            XmlDocument resultDoc = new XmlDocument();
            testDoc.Load(testNode.testFile);
            argDic["testfile"] = testNode.testFile;

            SeeFlawRunner.TestFinishedDelegate callBack = new SeeFlawRunner.TestFinishedDelegate(this.TestFinished);

            System.AppDomain SeeFlawRunnerDomain = System.AppDomain.CreateDomain("SeeFlawRunnerDomain");
            System.Runtime.Remoting.ObjectHandle handle = SeeFlawRunnerDomain.CreateInstance("SeeFlawRunner", "SeeFlawRunner.SeeFlaw");
            seeFlaw = (SeeFlawRunner.SeeFlaw) handle.Unwrap();
            seeFlaw.AddDetails(testDoc, null, resultDoc, argDic, callBack, bgRunner);

            Thread testThread = new Thread(new ThreadStart(seeFlaw.RunTestCase));
            testThread.Start();
            while (!isFinished)
            {
                testThread.Join(200);
                if (AddLog(testNode, strWr))
                {
                    bgRunner.ReportProgress(ProgressEvent.LogUpdated, testNode);
                }
            }
            System.AppDomain.Unload(SeeFlawRunnerDomain);
            if (!testSuccessful && error != "")
            {
                XmlElement htmlElement = resultDoc.CreateElement("html");
                XmlElement bodyElement = resultDoc.CreateElement("body");
                string[] errorLines = error.Split(new char[] { '\n' });
                for (int line = 0; line < errorLines.Length; line++)
                {
                    bodyElement.AppendChild(resultDoc.CreateTextNode(errorLines[line]));
                    bodyElement.AppendChild(resultDoc.CreateElement("br"));
                }
                htmlElement.AppendChild(bodyElement);
                resultDoc.AppendChild(htmlElement);
            }
            testNode.htmlOutput = resultDoc.OuterXml;
            AddLog(testNode, strWr);
            return testSuccessful;
        }
Exemplo n.º 3
0
 private static RootNode AddSubDirs(string dirPath, bool includeSubDirs)
 {
     bool hasTests = false;
     string dirName = System.IO.Path.GetFileNameWithoutExtension(dirPath);
     RootNode dirNode = new GroupNode(dirName);
     if (includeSubDirs)
     {
         string[] subDirs = System.IO.Directory.GetDirectories(dirPath);
         if (subDirs.Count() > 0)
         {
             foreach (string subDir in subDirs)
             {
                 RootNode subDirNode = AddSubDirs(subDir, includeSubDirs);
                 if (subDirNode != null)
                 {
                     dirNode.Nodes.Add(subDirNode);
                     hasTests = true;
                 }
             }
         }
     }
     string[] files = System.IO.Directory.GetFiles(dirPath, "*.xml");
     if (files.Count() > 0)
     {
         foreach (string file in files)
         {
             string testName = System.IO.Path.GetFileNameWithoutExtension(file);
             TestNode testNode = new TestNode(testName, file);
             dirNode.Nodes.Add(testNode);
         }
         hasTests = true;
     }
     if (hasTests)
     {
         return dirNode;
     }
     return null;
 }
Exemplo n.º 4
0
 public bool AddLog(TestNode testNode, System.IO.StringWriter strWr)
 {
     string log = strWr.GetStringBuilder().ToString();
     if (log.Length > 0)
     {
         testNode.log += log;
         strWr.GetStringBuilder().Remove(0, log.Length);
         return true;
     }
     return false;
 }