예제 #1
0
        private void GlobalConfig_Modify_Button_Click(object sender, RoutedEventArgs e)
        {
            if (dgGlobalCfg.Items.Count < 1)
                return;
            if (dgGlobalCfg.SelectedIndex < 0)
                return;

            TestConfiguration tc = TestConfiguraionGlobalOc[dgGlobalCfg.SelectedIndex];

            if (tc.ConfigKey == "Project Name" || tc.ConfigKey == "Sub Project Name")
            {
                if (DatabaseConnected == false)
                {
                    MessageBox.Show("Database is disconnected.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                else
                {
                    if (tc.ConfigKey == "Project Name")
                    {
                        if (ProjectOc == null || ProjectOc.Count < 1)
                        {
                            MessageBox.Show("Please create the project in the database first.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                            return;
                        }

                        Tuple<string, string> ti = null;
                        foreach (Tuple<string, string> t in ProjectOc)
                        {
                            if (t.Item2 == tc.ConfigValue)
                            {
                                ti = t;
                                break;
                            }
                        }

                        OneLineSelector ols = new OneLineSelector("Select Project", "Project Name", ProjectOc, (string.IsNullOrWhiteSpace(tc.ConfigValue)) ? null : tc.ConfigValue);
                        bool? b = ols.ShowDialog();
                        if (b != true)
                            return;
                        tc.ConfigValue = ols.UserSelectContent;
                        _curProject = tc.ConfigValue;
                        ti = null;
                        foreach (Tuple<string, string> t in ProjectOc)
                        {
                            if (t.Item2 == tc.ConfigValue)
                            {
                                ti = t;
                                break;
                            }
                        }
                        _curPorjectDB = ti.Item1;

                        foreach (TestConfiguration tci in TestConfiguraionGlobalOc)
                        {
                            if (tci.ConfigKey == "Sub Project Name")
                            {
                                tci.ConfigValue = "";
                            }
                        }
                        _curSubProject = "";
                        _curSubProjectDB = "";
                    }
                    else
                    {
                        if (ProjectOc == null || ProjectOc.Count < 1)
                        {
                            MessageBox.Show("Please create the project in the database first.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                            return;
                        }

                        if (string.IsNullOrWhiteSpace(_curProject))
                        {
                            MessageBox.Show("Please select the project first.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                            return;
                        }

                        Tuple<string, string> ti = null;
                        foreach (Tuple<string, string> t in ProjectOc)
                        {
                            if (t.Item2 == _curProject)
                            {
                                ti = t;
                                break;
                            }
                        }

                        Tuple<string, ObservableCollection<Tuple<string, string>>> tii = null;
                        foreach (Tuple<string, ObservableCollection<Tuple<string, string>>> t in SubProjectOc)
                        {
                            if (t.Item1 == ti.Item1)
                            {
                                tii = t;
                                break;
                            }
                        }

                        if (tii == null || tii.Item2.Count < 1)
                        {
                            MessageBox.Show("Please create the sub project for the Project \"" + _curProject + "\"in the database first.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                            return;
                        }

                        OneLineSelector ols = new OneLineSelector("Select Sub Project", "Sub Project Name", tii.Item2, (string.IsNullOrWhiteSpace(tc.ConfigValue)) ? null : tc.ConfigValue);
                        bool? b = ols.ShowDialog();
                        if (b != true)
                            return;
                        tc.ConfigValue = ols.UserSelectContent;
                        _curSubProject = tc.ConfigValue;
                        ti = null;
                        foreach (Tuple<string, string> t in tii.Item2)
                        {
                            if (t.Item2 == _curSubProject)
                            {
                                ti = t;
                                break;
                            }
                        }
                        _curSubProjectDB = ti.Item1;
                    }
                }
            }
            else
            {
                List<string> ls = new List<string>();
                foreach (TestConfiguration tci in TestConfiguraionGlobalOc)
                {
                    ls.Add(tci.ConfigKey);
                }

                OneLineEditor ole = new OneLineEditor("Modify " + tc.ConfigKey, tc.ConfigKey, tc.ConfigValue);
                bool? bv = ole.ShowDialog();
                if (bv != true)
                    return;
                string s = ole.UserContent.Trim();
                tc.ConfigValue = s;
            }

            SaveConfig();
        }
예제 #2
0
        private void GlobalConfig_Add_Button_Click(object sender, RoutedEventArgs e)
        {
            ObservableCollection<string> ls = new ObservableCollection<string>();
            foreach (TestConfiguration tc in TestConfiguraionGlobalOc)
            {
                ls.Add(tc.ConfigKey);
            }

            OneLineEditor ole = new OneLineEditor("New Configuration Entry", "Key", userCompareList: ls);
            bool? bv = ole.ShowDialog();
            if (bv != true)
                return;
            string s = ole.UserContent.Trim();
            TestConfiguraionGlobalOc.Add(new TestConfiguration()
            {
                ConfigKey = s,
                ConfigValue = ""
            });

            SaveConfig();
        }
예제 #3
0
        private void DestroyDatabase_Button_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Are you sure to destroy the whole database?", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
                return;

            OneLineEditor ole = new OneLineEditor("Input Password", "Password");
            if (ole.ShowDialog() != true)
                return;

            if (ole.UserContent != "itester")
            {
                MessageBox.Show("Wrong password!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            InDatabaseTalking = true;
            spbTimer.IsIndeterminate = true;
            DBMsgOc.Clear();
            ReadyString = "Start destroying the database.";

            Thread th = new Thread(new ThreadStart(DestroyDatabaseThread));
            th.Start();
        }
예제 #4
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            OneLineEditor ole = new OneLineEditor("New Group", "Group Name");
            if (ole.ShowDialog() != true)
                return;

            int index = 0;
            string sc = "";
            while (true)
            {
                bool bFound = false;
                foreach (TestGroupCase tgct in TestColInstance.TestGroupCaseOc)
                {
                    sc = ole.UserContent + ((index == 0) ? "" : " (" + index.ToString() + ")");
                    if (string.Compare(sc, tgct.GroupCaseName) == 0)
                    {
                        bFound = true;
                        break;
                    }
                }
                if (bFound == true)
                    index++;
                else
                    break;
            }
            if (string.IsNullOrWhiteSpace(sc))
                sc = ole.UserContent;

            TestGroupCase tgc = new TestGroupCase(TestColInstance, null, sc, false, null, null);

            CurrentDirtyFlag = true;

            UpdateTotalTestCases();
        }
예제 #5
0
        private void ProjectNew_Button_Click(object sender, RoutedEventArgs e)
        {
            OneLineEditor ole = new OneLineEditor("New Project", "Project Name :", userCompareListTuple: ProjectOc, maxLength: 32);
            if (ole.ShowDialog() != true)
                return;

            InDatabaseTalking = true;
            spbTimer.IsIndeterminate = true;
            ReadyString = "Start creating the new project : " + ole.UserContent;

            Thread th = new Thread(new ParameterizedThreadStart(ProjectNewThread));
            th.Start(new Tuple<string, string>(ole.UserContentDB, ole.UserContent));
        }