Exemple #1
0
        public async Task <List <AzureDevOpsPRCommit> > GetAzureDevOpsPullRequestCommits(string patToken, TableStorageConfiguration tableStorageConfig, string organization, string project, string repository, string pullRequestId, bool useCache)
        {
            Newtonsoft.Json.Linq.JArray list;
            if (useCache == true)
            {
                //Get the commits from Azure storage
                AzureTableStorageDA daTableStorage = new AzureTableStorageDA();
                list = daTableStorage.GetTableStorageItemsFromStorage(tableStorageConfig, tableStorageConfig.TableAzureDevOpsPRCommits, PartitionKeys.CreateAzureDevOpsPRCommitPartitionKey(organization, project, pullRequestId));
            }
            else
            {
                //Get the commits from the Azure DevOps API
                AzureDevOpsAPIAccess api = new AzureDevOpsAPIAccess();
                list = await api.GetAzureDevOpsPullRequestCommitsJArray(patToken, organization, project, repository, pullRequestId);
            }

            List <AzureDevOpsPRCommit> commits = JsonConvert.DeserializeObject <List <AzureDevOpsPRCommit> >(list.ToString());

            return(commits);
        }
Exemple #2
0
        public void AzGetPRCommitsDAIntegrationTest()
        {
            //Arrange
            TableStorageConfiguration tableStorageConfig = Common.GenerateTableAuthorization(base.Configuration);
            string organization = "samsmithnz";
            string project      = "SamLearnsAzure";

            //Act
            AzureTableStorageDA da = new();
            JArray prList          = da.GetTableStorageItemsFromStorage(tableStorageConfig, tableStorageConfig.TableAzureDevOpsPRs, PartitionKeys.CreateAzureDevOpsPRPartitionKey(organization, project));
            int    itemsAdded      = 0;

            foreach (JToken item in prList)
            {
                AzureDevOpsPR pullRequest   = JsonConvert.DeserializeObject <AzureDevOpsPR>(item.ToString());
                string        pullRequestId = pullRequest.PullRequestId;
                JArray        list          = da.GetTableStorageItemsFromStorage(tableStorageConfig, tableStorageConfig.TableAzureDevOpsPRCommits, PartitionKeys.CreateAzureDevOpsPRCommitPartitionKey(organization, project, pullRequestId));
                if (list.Count > 0)
                {
                    itemsAdded = list.Count;
                    break;
                }
            }

            //Assert
            Assert.IsTrue(itemsAdded >= 0);
        }