예제 #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);
            }
        }
예제 #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);
                }
            }
        }
예제 #3
0
        void Remove(TreeNode node)
        {
            TreeNode current  = node;
            TreeNode fileNode = null;

            while (current.Parent != null)
            {
                fileNode = current;
                current  = current.Parent;
            }

            current.Nodes.Remove(fileNode);
            // remove from AppState

            string fileName = _fileNodes[fileNode];

            Context.TreeState state = Context.AppContext.Instance.TreeState;

            switch (current.Name)
            {
            case PARAMETERSROOT:
                state.ParametersFiles.Remove(fileName);
                _parametersNodes.Remove(fileNode);
                break;

            case TESTSROOT:
                state.TestFiles.Remove(fileName);
                state.DutTestFiles.Remove(fileName);
                TestSuite ts = fileNode.Tag as TestSuite;
                if (ts != null)
                {
                    if (TestSuiteRemoved != null)
                    {
                        TestSuiteRemoved(ts);
                    }
                    foreach (Test test in ts.Tests)
                    {
                        foreach (TestCase tc in test.TestCases)
                        {
                            TreeNode tcNode = _tcNodes[tc.TestCaseID];
                            _tcNodes.Remove(tc.TestCaseID);
                            _testCaseNodes.Remove(tcNode);
                        }
                    }
                }
                else
                {
                    DutTest dt = fileNode.Tag as DutTest;
                    if (DutTestSuiteRemoved != null)
                    {
                        DutTestSuiteRemoved(dt);
                    }

                    foreach (DutTestCase tc in dt.Tests)
                    {
                        TreeNode tcNode = _tcNodes[tc.TestCaseID];
                        _tcNodes.Remove(tc.TestCaseID);
                        _dutTestCaseNodes.Remove(tcNode);
                    }
                }
                break;

            case FEATUREDEFINITIONROOT:
                state.FeatureDefinitionFiles.Remove(fileName);

                FeatureDefinition def = (FeatureDefinition)fileNode.Tag;

                foreach (TestCase tc in def.TestCases)
                {
                    TreeNode tcNode = _tcNodes[tc.TestCaseID];
                    _tcNodes.Remove(tc.TestCaseID);
                    _featureDefinitionNodes.Remove(tcNode);
                }
                break;
            }
            _fileNodes.Remove(fileNode);
        }
예제 #4
0
        internal Task GetTask()
        {
            Task task = new Task();

            foreach (TreeNode node in _testCaseNodes.Keys)
            {
                if (node.Checked)
                {
                    TreeNode testNode = node.Parent;
                    TestCase tc       = _testCaseNodes[node];
                    Test     test     = (Test)testNode.Tag;

                    TestCaseSettings settings = new TestCaseSettings();

                    if (string.IsNullOrEmpty(tc.FileName))
                    {
                        settings.FileName = test.DefaultFileName;
                    }
                    else
                    {
                        settings.FileName = tc.FileName;
                    }
                    settings.TestCaseID = tc.TestCaseID;

                    settings.Category = test.Category;
                    settings.TestID   = test.TestID;

                    task.Tests.Add(settings);
                }
            }
            foreach (TreeNode node in _dutTestCaseNodes.Keys)
            {
                if (node.Checked)
                {
                    DutTestCase tc       = _dutTestCaseNodes[node];
                    TreeNode    testNode = node.Parent;
                    DutTest     test     = (DutTest)testNode.Tag;

                    TestCaseSettings settings = new TestCaseSettings();

                    settings.FileName   = test.FileName;
                    settings.Category   = test.Category;
                    settings.TestID     = test.TestID;
                    settings.TestCaseID = tc.TestCaseID;

                    task.Tests.Add(settings);
                }
            }
            foreach (TreeNode node in _featureDefinitionNodes.Keys)
            {
                if (node.Checked)
                {
                    FeatureDefinition def      = (FeatureDefinition)(node.Parent.Tag);
                    TestCase          tc       = _featureDefinitionNodes[node];
                    TestCaseSettings  settings = new TestCaseSettings();
                    settings.TestCaseID = tc.TestCaseID;

                    if (string.IsNullOrEmpty(tc.FileName))
                    {
                        settings.FileName = def.DefaultFileName;
                    }
                    else
                    {
                        settings.FileName = tc.FileName;
                    }

                    if (task.FeatureDefnitionSettings != null)
                    {
                        throw new ApplicationException("More that one node of type 'FeatureDefinition' selected");
                    }
                    else
                    {
                        task.FeatureDefnitionSettings = settings;
                    }
                }
            }

            foreach (TreeNode node in _parametersNodes.Keys)
            {
                if (node.Checked)
                {
                    if (task.Parameters != null)
                    {
                        throw new ApplicationException("More that one node of type 'Parameters' selected");
                    }
                    else
                    {
                        task.Parameters = _parametersNodes[node];
                    }
                }
            }

            if (task.Parameters == null)
            {
                throw new ApplicationException("No node of type 'Parameters' selected");
            }

            return(task);
        }
예제 #5
0
 void testsTree_DutTestSuiteRemoved(DutTest dt)
 {
     _testController.DutTests.Remove(dt);
 }