Exemplo n.º 1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                _testController = new AutomatedTesting.GUI.Controllers.TestController(this);
                _testController.Initialize();

                Controllers.StateController ctrl = new AutomatedTesting.GUI.Controllers.StateController();
                ctrl.LoadState();

                foreach (string fileName in Context.AppContext.Instance.TreeState.ParametersFiles)
                {
                    TestParameters tp = TestParameters.Load(fileName);
                    if (tp != null)
                    {
                        testsTree.AddParametersSet(fileName, tp);
                    }
                }
                foreach (string fileName in Context.AppContext.Instance.TreeState.FeatureDefinitionFiles)
                {
                    FeatureDefinition def = FeatureDefinition.Load(fileName);
                    if (def != null)
                    {
                        testsTree.AddFeatureDefinitionNode(fileName, def);
                    }
                }
                foreach (string fileName in Context.AppContext.Instance.TreeState.TestFiles)
                {
                    TestSuite ts = TestSuite.Load(fileName);
                    if (ts != null)
                    {
                        testsTree.AddTestSuite(fileName, ts);
                        _testController.TestSuites.Add(ts);
                    }
                }
                foreach (string fileName in Context.AppContext.Instance.TreeState.DutTestFiles)
                {
                    DutTest ts = DutTest.Load(fileName);
                    if (ts != null)
                    {
                        testsTree.AddTestSuite(fileName, ts);
                        _testController.DutTests.Add(ts);
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
Exemplo n.º 2
0
        private void tsbLoadTests_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    string fileName = ofd.FileName;

                    XmlDocument doc = new XmlDocument();
                    doc.Load(fileName);

                    switch (doc.DocumentElement.LocalName)
                    {
                    case FeatureDefinition.ROOT:
                        FeatureDefinition def = FeatureDefinition.Load(fileName);
                        testsTree.AddFeatureDefinitionNode(fileName, def);
                        Context.AppContext.Instance.TreeState.FeatureDefinitionFiles.Add(fileName);
                        break;

                    case TestSuite.ROOT:
                        TestSuite ts = TestSuite.Load(fileName);
                        testsTree.AddTestSuite(fileName, ts);
                        Context.AppContext.Instance.TreeState.TestFiles.Add(fileName);
                        break;

                    case TestParameters.ROOT:
                        TestParameters parameters = TestParameters.Load(fileName);
                        testsTree.AddParametersSet(fileName, parameters);
                        Context.AppContext.Instance.TreeState.ParametersFiles.Add(fileName);
                        break;

                    case DutTest.ROOT:
                        DutTest test = DutTest.Load(fileName);
                        testsTree.AddTestSuite(fileName, test);
                        Context.AppContext.Instance.TreeState.DutTestFiles.Add(fileName);
                        break;
                    }
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message);
                }
            }
        }