public CurrentExecutionViewModel(TestsExecutionViewModel testsExecutionViewModel)
 {
     TestsExecutionViewModel  = testsExecutionViewModel;
     AlreadyCreatedWorkspaces = new List <string>();
     MessagesToBeDisplayed    = new ConcurrentQueue <string>();
     CommandsToBeExecuted     = new List <string>();
     CurrentSelectedMachine   = TestsExecutionViewModel.GetCurrentlySelectedExecutionMachine();
     CurrentAgentMachineExecutionIpSettings  = new IpAddressSettings(CurrentSelectedMachine.Ip, "8888");
     CurrentAgentMachineMsBuildLogIpSettings = new IpAddressSettings(CurrentSelectedMachine.Ip, "8889");
     GenerateMessagesToBeSentToAgent();
 }
 public CurrentExecutionViewModel(TestsExecutionViewModel testsExecutionViewModel)
 {
     
     TestsExecutionViewModel = testsExecutionViewModel;
     AlreadyCreatedWorkspaces = new List<string>();
     MessagesToBeDisplayed = new ConcurrentQueue<string>();
     CommandsToBeExecuted = new List<string>();
     CurrentSelectedMachine = TestsExecutionViewModel.GetCurrentlySelectedExecutionMachine();
     CurrentAgentMachineExecutionIpSettings = new IpAddressSettings(CurrentSelectedMachine.Ip, "8888");
     CurrentAgentMachineMsBuildLogIpSettings = new IpAddressSettings(CurrentSelectedMachine.Ip, "8889");
     GenerateMessagesToBeSentToAgent();
 }
        public AgentMachineViewModel GetCurrentlySelectedExecutionMachine()
        {
            AgentMachineViewModel machine = null;

            foreach (var cT in Teams)
            {
                foreach (var cM in cT.ObservableAgentMachines)
                {
                    if (cM.IsSelected)
                    {
                        machine = cM;
                        break;
                    }
                }
            }
            return(machine);
        }
        private string GenerateTestExecutionCommand(AgentMachineViewModel currentSelectedMachine, string msTestProj, List<string> selectedProjectsLocalPaths, List<string> selectedProjectsAgentPaths)
        {
            List<string> selectedTestsMethodIds = new List<string>();
            GetSelectedTestsMethodIds(selectedTestsMethodIds);

            List<string> assembliesPaths = ATACore.Project.ProjectInfoCollector.GetAssemblyPathsByProjectPaths(selectedProjectsLocalPaths);
            List<TestLink> testLinks = ATACore.TestExecution.TestListGenerator.GetProjectTestLinksMultipleAssemblies(assembliesPaths, selectedProjectsAgentPaths);
            MethodInfo[] methodInfos = ATACore.Project.ProjectInfoCollector.GetProjectTestMethodsMultipleAssemblies(assembliesPaths);
            testLinks = ATACore.TestExecution.TestListGenerator.RemoveTestLinksNotSpecifiedIds(selectedTestsMethodIds, testLinks);
            string listName = Guid.NewGuid().ToString();
            string testListContent = ATACore.TestExecution.TestListGenerator.GenerateListOfSpecifiedTests(testLinks, listName);

            string uniqueTestResultName = ATACore.Utilities.TimeStampGenerator.GenerateTrxFilePath(currentSelectedMachine.WorkingDirPath);
        
            string messageToBeSend = ATACore.CommandExecutor.GenerateMsTestMessage(msTestProj, testListContent, uniqueTestResultName, listName, CurrentAgentMachineMsBuildLogIpSettings, currentSelectedMachine.WorkingDirPath);
            CommandsToBeExecuted.Add(messageToBeSend);

            return uniqueTestResultName;
        }
        private string GenerateTestExecutionCommand(AgentMachineViewModel currentSelectedMachine, string msTestProj, List <string> selectedProjectsLocalPaths, List <string> selectedProjectsAgentPaths)
        {
            List <string> selectedTestsMethodIds = new List <string>();

            GetSelectedTestsMethodIds(selectedTestsMethodIds);

            List <string>   assembliesPaths = ATACore.Project.ProjectInfoCollector.GetAssemblyPathsByProjectPaths(selectedProjectsLocalPaths);
            List <TestLink> testLinks       = ATACore.TestExecution.TestListGenerator.GetProjectTestLinksMultipleAssemblies(assembliesPaths, selectedProjectsAgentPaths);

            MethodInfo[] methodInfos = ATACore.Project.ProjectInfoCollector.GetProjectTestMethodsMultipleAssemblies(assembliesPaths);
            testLinks = ATACore.TestExecution.TestListGenerator.RemoveTestLinksNotSpecifiedIds(selectedTestsMethodIds, testLinks);
            string listName        = Guid.NewGuid().ToString();
            string testListContent = ATACore.TestExecution.TestListGenerator.GenerateListOfSpecifiedTests(testLinks, listName);

            string uniqueTestResultName = ATACore.Utilities.TimeStampGenerator.GenerateTrxFilePath(currentSelectedMachine.WorkingDirPath);

            string messageToBeSend = ATACore.CommandExecutor.GenerateMsTestMessage(msTestProj, testListContent, uniqueTestResultName, listName, CurrentAgentMachineMsBuildLogIpSettings, currentSelectedMachine.WorkingDirPath);

            CommandsToBeExecuted.Add(messageToBeSend);

            return(uniqueTestResultName);
        }
        private void PrepareAllCurrentProjectAddiotionalPaths(string currentUserName, string currentTfsUserName, ProjectViewModel cProject, AgentMachineViewModel currentSelectedMachine, string msTestProjPath, string tfsProj)
        {
            foreach (var cAdditionalPath in cProject.ObservableAdditionalPaths)
            {
                string localPath     = ATACore.Project.ProjectInfoCollector.MapWorkingDirTfsPath(currentSelectedMachine.WorkingDirPath, cProject.TfsPath);
                string workspaceName = ATACore.RegistryManager.GetWorkspaceName(currentUserName, localPath);
                string tfsUrl        = cAdditionalPath.TfsUrl;
                string tfsPath       = cAdditionalPath.TfsPath;

                GenerateProjectWorkspaceDeletionMessages(currentTfsUserName, tfsProj, tfsUrl, cAdditionalPath.WorkspacesForDelete);
                GenerateProjectWorkspaceCreationMessages(tfsProj, tfsUrl, tfsPath, localPath, workspaceName);
                CommandsToBeExecuted.Add(ATACore.CommandExecutor.GenerateTfsGetLatestMessage(tfsProj, localPath, currentTfsUserName, CurrentAgentMachineMsBuildLogIpSettings));
            }
        }
        private void PrepareAllCurrentProjectAddiotionalPaths(string currentUserName, string currentTfsUserName, ProjectViewModel cProject, AgentMachineViewModel currentSelectedMachine, string msTestProjPath, string tfsProj)
        {
            foreach (var cAdditionalPath in cProject.ObservableAdditionalPaths)
            {
                string localPath = ATACore.Project.ProjectInfoCollector.MapWorkingDirTfsPath(currentSelectedMachine.WorkingDirPath, cProject.TfsPath);
                string workspaceName = ATACore.RegistryManager.GetWorkspaceName(currentUserName, localPath);
                string tfsUrl = cAdditionalPath.TfsUrl;
                string tfsPath = cAdditionalPath.TfsPath;

                GenerateProjectWorkspaceDeletionMessages(currentTfsUserName, tfsProj, tfsUrl, cAdditionalPath.WorkspacesForDelete);
                GenerateProjectWorkspaceCreationMessages(tfsProj, tfsUrl, tfsPath, localPath, workspaceName);
                CommandsToBeExecuted.Add(ATACore.CommandExecutor.GenerateTfsGetLatestMessage(tfsProj, localPath, currentTfsUserName, CurrentAgentMachineMsBuildLogIpSettings));
            }
        }