示例#1
0
文件: Class1.cs 项目: uvbs/Holodeck
        private void getContents(string origFileName, string genFileName)
        {
            //compare the two files
            xmlFileRdr = new XmlTextReader(origFileName);
            origContentsQ = new Queue();

            int testNo = 0;

            //get the contents of the orignal file
            while (xmlFileRdr.Read())
            {
                switch (xmlFileRdr.NodeType)
                {
                    case XmlNodeType.Element:
                    {
                        switch (xmlFileRdr.Name)
                        {
                            case "Inject":
                            {
                                testNo++;
                                //information about fault, limit, or test
                                type = Convert.ToInt16(xmlFileRdr.GetAttribute("Type").ToString());
                                name = xmlFileRdr.GetAttribute("Name").ToString();
                                enabled = Convert.ToInt16(xmlFileRdr.GetAttribute("Enabled").ToString());

                                //create a new test case
                                TestCase newCase = new TestCase("", enabled, name, type, testNo);
                                origContentsQ.Enqueue(newCase);
                                break;
                            }

                            case "TestFile":
                            {
                                //start of the test file
                                Console.Out.WriteLine();
                                Console.Out.WriteLine("Purpose of this test is to [" + xmlFileRdr.GetAttribute("Purpose") + "]");
                                Console.Out.WriteLine("-----------------------------------------------------------------------");
                                Console.Out.WriteLine();
                                break;
                            }

                        }
                        break;
                    }
                }
            }

            xmlFileRdr.Close();
            origContentsQ.TrimToSize();

            //get the contents of the generated file
            xmlFileRdr = new XmlTextReader(genFileName);
            genContentsQ = new Queue();

            while (xmlFileRdr.Read())
            {
                switch (xmlFileRdr.NodeType)
                {
                    case XmlNodeType.Element:
                    {
                        switch (xmlFileRdr.Name)
                        {
                            case "Inject":
                            {
                                testNo++;
                                //information about fault, limit, or test
                                type = Convert.ToInt16(xmlFileRdr.GetAttribute("Type").ToString());
                                name = xmlFileRdr.GetAttribute("Name").ToString();
                                enabled = Convert.ToInt16(xmlFileRdr.GetAttribute("Enabled").ToString());

                                //create a new test case
                                TestCase newCase = new TestCase("", enabled, name, type, testNo);
                                genContentsQ.Enqueue(newCase);
                                break;
                            }
                        }
                        break;
                    }
                }
            }

            //close the file and make sure the queue is as small as it can be
            xmlFileRdr.Close();
            genContentsQ.TrimToSize();

            //compare the two contents of the file
            compare();
        }
示例#2
0
        private bool beginTestCaseFile()
        {
            try
            {
                testCaseReader = new XmlTextReader(fileName);

                while (testCaseReader.Read())
                {
                    switch (testCaseReader.NodeType)
                    {
                        case XmlNodeType.Element:
                        {
                            switch (testCaseReader.Name)
                            {
                                case "TestFile":
                                {
                                    mainForm.thisTime.updateTime();

                                    //start of the test file
                                    testPurpose = testCaseReader.GetAttribute("Purpose");
                                    mainForm.infoTextBox.AppendText(mainForm.thisTime.getTime() + "Purpose of this test file is to test [" + testPurpose + "]\n");
                                    break;
                                }

                                case "Recorded_Session":
                                {
                                    //start of a test case
                                    testCaseQ = new Queue();
                                    testNo++;
                                    break;
                                }

                                case "Record":
                                {
                                    //start of some recorded feature
                                    featureNo++;
                                    break;
                                }

                                case "Log":
                                {
                                    //information about the feature
                                    break;
                                }

                                case "Inject":
                                {
                                    //information about fault, limit, or test
                                    type = Convert.ToInt16(testCaseReader.GetAttribute("Type").ToString());
                                    name = testCaseReader.GetAttribute("Name").ToString();
                                    enabled = Convert.ToInt16(testCaseReader.GetAttribute("Enabled").ToString());

                                    //create a new test case
                                    TestCase newCase = new TestCase(fileName, enabled, name, type, testNo);
                                    testCaseQ.Enqueue(newCase);
                                    break;
                                }
                            }

                            break;
                        }

                        case XmlNodeType.EndElement:
                        {
                            switch (testCaseReader.Name)
                            {
                                case "TestFile":
                                {
                                    //we have reached the end of this test case file
                                    mainForm.thisTime.updateTime();

                                    //now show the results for this test file
                                    mainForm.infoTextBox.AppendText(mainForm.thisTime.getTime() + "Finished!  Test Cases [" + testNo + "] Features Tested [" + featureNo + "]\n");

                                    //close holodeck
                                    //holodeckEE.closeHolodeck();

                                    endTestCaseFile();
                                    break;
                                }

                                case "Recorded_Session":
                                {
                                    //we have a complete recorded session now so now run the test cases from this session
                                    startTest();
                                    break;
                                }

                                case "Record":
                                {
                                    //end the test of a feature
                                    break;
                                }
                            }
                            break;
                        }
                    }
                }

                //close the test reader our work here is done
                testCaseReader.Close();
            }

            catch (FileNotFoundException)
            {
                //could not find the file
                mainForm.thisTime.updateTime();
                mainForm.infoTextBox.AppendText("\n" + mainForm.thisTime.getTime() + "File [" + fileName + "] not Found!! Skipping..\n");
                endTestCaseFile();
            }

            return true;
        }