Esempio n. 1
0
        public void ImportQC(TestScript ts)
        {
            TreeManager treeM = TdOLE.TreeManager;
            SubjectNode node  = treeM.get_NodeByPath("Subject") as SubjectNode;

            SubjectNode TargetNode = (SubjectNode)GetTargetNode(node, ts.QcFolderPath);

            TestFactory TstFac = TargetNode.TestFactory;

            List existingTests = TstFac.NewList("");

            bool exists  = false;
            Test tarTest = null;

            foreach (Test tst in existingTests)
            {
                if (tst.Name == ts.TestCaseName)
                {
                    exists  = true;
                    tarTest = tst;
                    continue;
                }
            }



            if (exists) // checkout and update
            {
                VCS vcs = tarTest.VCS;
                if (vcs.IsLocked)
                {
                    vcs.UndoCheckout(true);
                    vcs.CheckOut("-1", "Test Update " + DateTime.Now.ToString(), true);
                }
                else
                {
                    vcs.CheckOut("-1", "Test Update " + DateTime.Now.ToString(), true);
                }



                AssignValue2Test(tarTest, ts);
                vcs.CheckIn("", "");
                tarTest.Post();
            }
            else   // new creation
            {
                tarTest = TstFac.AddItem(DBNull.Value);
                AssignValue2Test(tarTest, ts);
                tarTest.Post();
            }
        }
Esempio n. 2
0
        static void AppendIgnore(VCS vcs)
        {
            string file     = "";
            string patterns = "";

            switch (vcs)
            {
            case VCS.Git:
                file     = Path.Combine(Environment.CurrentDirectory, ".gitignore");
                patterns = GitIgnore;
                break;

            case VCS.TFVC:
                file     = Path.Combine(Environment.CurrentDirectory, ".tfignore");
                patterns = TfIgnore;
                break;
            }

            File.AppendAllText(file, patterns);
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
#if DEBUG
            //Set this for testing
            Environment.CurrentDirectory = @"C:\Users\charl\Google Drive\Documents\Clients\WebApplication1\WebApplication1";
#endif

            string input = "";

            string openingMsg = @"
Welcome to DeftConfig Initializer!

This utility attempts to set up the existing project using the 'base.config' method. You'll
be prompted whether to create a folder in your user profile to store your version
of the debug and/or release (or other!) configurations.

You can exit the utility at any time using CTRL-C. If you're being prompted for input, you can
also enter 'exit'.
";
            Show(openingMsg);

            ConfigType = GetConfigType();

            var projectFiles = GetProjectFiles();
            if (projectFiles.Count() > 1)
            {
                SelectProjectFile(projectFiles);
            }
            if (projectFiles.Count() == 0)
            {
                Show("There are no project files in this folder.", ErrorColor);
                Exit();
            }
            Show();
            ProjectFile = projectFiles[0];

            input = Read("Change DeftConfigInitializer BuildAction to None? (RECOMMENDED). (y)es, or <enter> to continue", PromptColor);
            if (input == "y" | input == "yes")
            {
                SetInitializerBuildActionToNone();
            }


            ProjectGuid = GetProjectGuid();
            if (ProjectGuid.Length == 0)
            {
                Show("Couldn't find the ProjectGuid in the project file", ErrorColor);
                Exit();
            }
            UserProfileFolder = Path.Combine(Environment.ExpandEnvironmentVariables(UserProfileBaseFolder), ProjectGuid);
            bool useUserProfile = false;
            if (!Directory.Exists(UserProfileFolder))
            {
                Show("Your user profile folder would be at");
                Show(UserProfileFolder);
                Show();
                input          = Read("Would you like to create it? Answer (y)es, otherwise it's not created:", PromptColor).ToLower();
                useUserProfile = (input == "y" | input == "yes");
                if (useUserProfile)
                {
                    if (!Directory.Exists(UserProfileFolder))
                    {
                        try
                        {
                            Directory.CreateDirectory(UserProfileFolder);
                            Show("Folder created");
                        }
                        catch (Exception ex)
                        {
                            Show($"Folder not created. {ex.Message}", ErrorColor);
                            useUserProfile = false;
                        }
                    }
                }
            }
            else
            {
                useUserProfile = true;
                Show("Your user profile folder already exists! The folder is:");
                Show(UserProfileFolder);
                Show();
                Read("Press a key to continue the initialization");
            }


            string   configFile       = Path.Combine(Environment.CurrentDirectory, $"{ConfigType}.config");
            string   configBase       = Path.Combine(Environment.CurrentDirectory, $"{ConfigType}.{BaseName}.config");
            string   configSample     = Path.Combine(Environment.CurrentDirectory, $"{ConfigType}.{BaseName}.Sample.config");
            string[] otherConfigFiles = Directory.GetFiles(Environment.CurrentDirectory, $"{ConfigType}.*.config");
            otherConfigFiles = otherConfigFiles.Where(a => !a.Contains(BaseName)).ToArray();

            string configFileName      = Path.GetFileName(configFile);
            string configBaseName      = Path.GetFileName(configBase);
            string configSampleName    = Path.GetFileName(configSample);
            string otherConfigFilesMsg = otherConfigFiles.Count() == 0 ? "no files found" : String.Join("\r\n    ", otherConfigFiles.Select(a => Path.GetFileName(a)));
            string convertFilesMsg     = $@"
The next step will attempt to migrate your files to use the .base.config method.

1. Copy {configFileName} to {configBaseName}.
2. Copy {ConfigType}.Debug.config, if it exists, to {configSampleName}. Otherwise, write a default sample.
3. Rename other configs into {ConfigType}.{BaseName}.[BuildDefinition].config files. Those other files are:
    {otherConfigFilesMsg}
4. If you created a profile folder, you can optionally copy the build-specific config files into there.
5. Modify your project file to:
    1. Remove the build definition file entries
    2. Remove <SubType> elements from the {ConfigType}.config entry.
    3. Add entries for {configBaseName} and {configSampleName} with BuildAction = None.

At the end, your Solution Explorer will show:

{configBaseName}
{configSampleName}
{configFileName}

Your folder may have more config files that are now not part of the project. 
If you want to re-include them, show all files in Solution Explorer, right-click
the file and choose 'Include in Project.'
";
            Show(convertFilesMsg);
            Show();
            input = Read("Do you want to proceed? Answer (y)es, otherwise nothing will change.", PromptColor);
            bool modifyFiles   = (input == "y" | input == "yes");
            bool copyToProfile = false;
            if (modifyFiles & useUserProfile)
            {
                input         = Read("Do you want to copy files to your user profile? Answer (y)es, otherwise files are copied locally.", PromptColor);
                copyToProfile = (input == "y" | input == "yes");
            }
            Show();
            Show("Results:");
            Show();
            if (modifyFiles)
            {
                //list of config files is used in both steps
                CopyConfigFiles(copyToProfile, configFile, configBase, configSample, otherConfigFiles);
                Show();
                ModifyProjectFile(configFile, configBase, configSample, otherConfigFiles);
            }

            Show();

            bool   hasVcs     = UsingGit() | UsingTfvc();
            bool   hasIgnore  = HasGitIgnore() | HasTfIgnore();
            VCS    vcs        = UsingGit() ? VCS.Git : VCS.TFVC;
            string vcsName    = vcs.ToString();
            string ignoreFile = UsingGit() ? ".gitignore" : (UsingTfvc() ? ".tfignore" : "");

            if (hasVcs)
            {
                if (hasIgnore)
                {
                    string hasIgnoreMsg = $@"
It looks like you're using {vcsName}, and you already have a {ignoreFile} file. 
Do you want to append the DeftConfig ignore patterns? Answer (y)es to append, or <enter> to leave alone.";
                    input = Read(hasIgnoreMsg, PromptColor);
                    bool appendIgnore = (input == "y" | input == "yes");
                    if (appendIgnore)
                    {
                        AppendIgnore(vcs);
                    }
                }
                else
                {
                    string hasIgnoreMsg = $@"
It looks like you're using {vcsName}. Do you want to create a {ignoreFile} file with the DeftConfig ignore patterns?
Answer (y)es to create, or <enter> to do nothing.";
                    input = Read(hasIgnoreMsg, PromptColor);
                    bool appendIgnore = (input == "y" | input == "yes");
                    if (appendIgnore)
                    {
                        AppendIgnore(vcs);
                    }
                }
            }

            Show();

            string finalMsg = $@"
The recommended final steps for you are:
1. Delete the project file backup.
2. Commit changes to your version control (if any)
3. Test the changes.
";

            Show(finalMsg);
            Exit();
        }