public void AllTestCasesInAThreadAreExecuted(string strCallerId) { if (_resourcesAllocatedByCallerId.ContainsKey(strCallerId)) { foreach (var resource in _resourcesAllocatedByCallerId[strCallerId]) { this.Agent.LogUtil.LogMessage($"Shared resource deallocated to Thread {strCallerId}: {resource.ID}"); SharedResourcesUtil.ResourceUsageCompleted(resource); } } }
public string[] GetExecutableAlongWithCommandLineParametersOfAGivenProperty(ConfigProperty configProperty, string strConfigExecutionLocation, IObjectFactory Agent, out List <ResourceSection> lstResourcesAllocated) { lstResourcesAllocated = new List <ResourceSection>(); string strConfigPropertyValue = this[configProperty.ToString()].ToString(); if (string.IsNullOrEmpty(strConfigPropertyValue)) { return(null); } var arr = strConfigPropertyValue.Split(new string[] { CONSTANTS.SeparatorBetweenExecutableFilePathAndItsCommandLineParameter }, StringSplitOptions.None) .Select(x => x.Trim()) .Where(y => !string.IsNullOrEmpty(y)).ToArray(); arr[0] = arr[0].GetFullPath(Agent.InputOutputUtil); if (!File.Exists(arr[0])) { arr[0] = Path.Combine(strConfigExecutionLocation, arr[0]); } if (!File.Exists(arr[0])) { throw new InvalidConfigurationException(GetInvalidPathExceptionMessageForGivenConfigProperty(arr[0], configProperty)); } string strPathSwitch = "/Path:"; string strSharedResourcesSwitch = "/SharedResources:"; for (int i = 1; i < arr.Length; i++) { string strParameter = arr[i]; if (strParameter.ToLower().StartsWith(strPathSwitch.ToLower())) { strParameter = strParameter.Substring(strPathSwitch.Length); if (File.Exists(Path.Combine(strConfigExecutionLocation, strParameter))) { strParameter = Path.Combine(strConfigExecutionLocation, strParameter); } else { var testingProjectLocation = this[ConfigProperty.TestingProjectLocation.ToString()]; string strTempPath = strParameter.GetFullPath(Agent.InputOutputUtil, testingProjectLocation == null ? null : testingProjectLocation.ToString()); if (File.Exists(strTempPath)) { strParameter = strTempPath; } } if (!File.Exists(strParameter)) { throw new InvalidConfigurationException(GetInvalidPathExceptionMessageForGivenConfigProperty(strParameter, configProperty)); } } else if (strParameter.ToLower().StartsWith(strSharedResourcesSwitch.ToLower())) { strParameter = strParameter.Substring(strSharedResourcesSwitch.Length); var IDs = strParameter.Split(';').Select(x => x.Trim()).Where(x => !string.IsNullOrEmpty(x)).Shuffle(); if (!SharedResourcesUtil.SharedResources.Select(x => x.ID).ContainsAll(IDs)) { throw new InvalidConfigurationException(GetInvalidSharedResourceExceptionMessage(strSharedResourcesSwitch + strParameter, configProperty)); } var resource = SharedResourcesUtil.GetLeastUsedResource(IDs); lstResourcesAllocated.Add(resource); strParameter = resource.SemicolonSeparatedResources; } arr[i] = strParameter; } return(arr); }