예제 #1
0
        public void CodedUITestMethod1()
        {
            TestSetList testSetList = new TestSetList();

            if (ConfigurationSettings.AppSettings["SingleFileSet"] == "true")
            {
                testSetList.testSetFilePaths = new List <string>();
                testSetList.testSetFilePaths.Add(ConfigurationSettings.AppSettings["TestSetFilePath"]);
            }
            else
            {
                testSetList = testSetList.DeSerializeData(ConfigurationSettings.AppSettings["TestSetListFilePath"]);
            }
            LogFile logFile = new LogFile();

            foreach (string filePath in testSetList.testSetFilePaths)
            {
                TestSet testSet = new TestSet();
                testSet = testSet.DeSerializeData(filePath);

                if (ConfigurationSettings.AppSettings["SingleFileSet"] == "true")
                {
                    testSetList.reportPrefix = testSet.reportPrefix;
                }
                string stepName = "";
                foreach (Test test in testSet.testList)
                {
                    try
                    {
                        LogTest logTest = new LogTest(test);

                        stepName = "LaunchONVIFClientTestTool";
                        this.LaunchTool.LaunchONVIFClientTestTool();

                        Configuration configuration = new Configuration(test);

                        stepName = "AddpcapngFiles";
                        configuration.AddpcapngFiles();

                        stepName = "StartParsing";
                        configuration.StartParsing();

                        stepName = "AddFeatureFiles";
                        configuration.AddFeatureFiles();

                        Event events = new Event();

                        stepName = "SelectEvents";
                        events.ClickSupportedEvents();
                        foreach (SupportedEvent supportedEvent in test.eventList)
                        {
                            events.CheckEvents(supportedEvent);
                        }

                        events.ClickParsingResults();


                        Diagnostics diagnostics = new Diagnostics(test, filePath);

                        stepName = "RunConformanceTest";
                        diagnostics.RunConformanceTest();

                        Thread.Sleep(5000);

                        stepName = "CheckExpectedResult";
                        diagnostics.CheckExpectedResult();

                        stepName = "CheckFeaturesExpectedResult";
                        diagnostics.CheckFeaturesExpectedResult();

                        Conformance conformance = new Conformance(test, filePath);

                        stepName = "CheckProfiles";
                        conformance.CheckProfiles();

                        stepName = "CloseONVIFClientTestTool";
                        this.LaunchTool.CloseONVIFClientTestTool();

                        foreach (LogData logData in diagnostics.logData)
                        {
                            logTest.check.Add(logData);
                        }

                        foreach (LogData logDataFeatures in diagnostics.logDataFeatures)
                        {
                            logTest.checkFeatures.Add(logDataFeatures);
                        }

                        foreach (LogData logDataProfiles in conformance.logDataProfiles)
                        {
                            logTest.checkProfiles.Add(logDataProfiles);
                        }

                        logFile.test.Add(logTest);
                    }
                    catch (Exception e)
                    {
                        throw new Exception(String.Format("Test ID: {0}, Step Name {1}. Message: {2}", test.id, stepName, e.Message), e);
                    }
                }
            }
            string logFile_failed = "";

            foreach (var test in logFile.test)
            {
                if (test.check.FindAll(C => C.result == "FAILED").Count != 0)
                {
                    logFile_failed = "_FAILED";
                }
            }

            string reportDate = DateTime.Now.ToString("yyyyMMdd_HH_mm_ss");

            logFile.SerializeData(logFile, ConfigurationSettings.AppSettings["LogFileFolderPath"] + testSetList.reportPrefix + reportDate + logFile_failed + ".xml");
            // Чтобы создать код для этого теста, выберите в контекстном меню команду "Сформировать код для кодированного теста ИП", а затем выберите один из пунктов меню.
            // Дополнительные сведения по сформированному коду см. по ссылке http://go.microsoft.com/fwlink/?LinkId=179463
        }