示例#1
0
        private void removedLinkButton_Click(object sender, EventArgs e)
        {
            if (testListDropdown.SelectedIndex > -1)
            {
                string currentlySelectedTest = testListDropdown.GetItemText(testListDropdown.SelectedItem);

                if (testNameAndBuildableDictionary.ContainsKey(currentlySelectedTest))
                {
                    DialogResult result = MessageBox.Show("Are you sure, you would like to detach"
                                                          + Environment.NewLine + $"'{currentlySelectedTest}' from" + Environment.NewLine
                                                          + $"'{testNameAndBuildableDictionary[ currentlySelectedTest ]}'?", "Remove linked buildable", MessageBoxButtons.YesNo);

                    if (result == DialogResult.Yes)
                    {
                        string buildablePathToRemove = testNameAndBuildableDictionary[currentlySelectedTest];
                        testNameAndBuildableDictionary.Remove(currentlySelectedTest);
                        LinkTestListBuildable serializationLinkBuildables = new LinkTestListBuildable(testNameAndBuildableDictionary);
                        serializationLinkBuildables.SerializeTestDictionary( );
                        testBuildableSuccessfulLinkedMessage.Text = $"Successfully removed" + Environment.NewLine + $"'{buildablePathToRemove}'"
                                                                    + Environment.NewLine + $"from '{currentlySelectedTest}' test";
                    }
                }
                else
                {
                    MessageBox.Show("You cannot remove link to a buildable, because that test doesn't contains one");
                }
            }
            else
            {
                MessageBox.Show("Please select a test first");
            }
        }
示例#2
0
        private void saveBuildableLinkedButton_Click(object sender, EventArgs e)
        {
            string currentSelectedBuildablePath = pathToBuildableTextBox.Text;

            if (testListDropdown.SelectedIndex > -1 && !string.IsNullOrEmpty(currentSelectedBuildablePath))
            {
                string currentSelectedTestName = testListDropdown.GetItemText(testListDropdown.SelectedItem);

                DialogResult linkTestWithBuildable =
                    MessageBox.Show($"Are You sure, you want to link: '{currentSelectedTestName}'" +
                                    Environment.NewLine + $"with this test buildable: '{currentSelectedBuildablePath}'?",
                                    "Link Test with Buildable", MessageBoxButtons.OKCancel);

                if (linkTestWithBuildable == DialogResult.OK)
                {
                    DictionaryManipulators handleDictionary = new DictionaryManipulators( );

                    bool successfullyAddedToDictionary = handleDictionary.AddLinkedTestWithBuildableDictionary(
                        currentSelectedTestName, currentSelectedBuildablePath, testNameAndBuildableDictionary);

                    string message;

                    if (successfullyAddedToDictionary)
                    {
                        LinkTestListBuildable serializationLinkBuildables = new LinkTestListBuildable(testNameAndBuildableDictionary);

                        serializationLinkBuildables.SerializeTestDictionary( );

                        message = $"You are successfully linked '{currentSelectedTestName}' test with"
                                  + Environment.NewLine + currentSelectedBuildablePath + Environment.NewLine + "buildable.";
                    }
                    else
                    {
                        message = $"Something went wrong, when tried to link '{currentSelectedTestName}' test with"
                                  + Environment.NewLine + currentSelectedBuildablePath + Environment.NewLine +
                                  "buildable. Please try again, and if the issue still exist, contact TestSharp team.";
                    }

                    testBuildableSuccessfulLinkedMessage.Text = message;
                }

                testListDropdown.SelectedIndex = -1;
                pathToBuildableTextBox.Clear( );
            }
        }