示例#1
0
        public void GivenIHaveAnApprovalForRelease(KeyValuePair <string, string> teamProject, int releaseDefinitionId)
        {
            var service   = new VstsService();
            var approvals = service.GetApprovals(Config.Account, teamProject.Value, Config.Profile).Result;

            Config.Approval = approvals.FirstOrDefault(a => a.ReleaseDefinitionReference.Id.Equals(releaseDefinitionId));
        }
示例#2
0
        public void GivenNoApprovalsAreWaitingIn(KeyValuePair <string, string> teamProject)
        {
            var service   = new VstsService();
            var approvals = service.GetApprovals(Config.Account, teamProject.Value, Config.Profile).Result;

            foreach (var approval in approvals)
            {
                service.ChangeApprovalStatus(Config.Account, teamProject.Value, Config.Profile, approval.Id, ApprovalStatus.Rejected, string.Empty).Wait();
            }
        }
示例#3
0
        public async Task GetApprovalsTest()
        {
            var accountName = "MyAccount";
            var projectName = "MyProject";
            var profile     = new VstsProfile
            {
                Id           = Guid.NewGuid(),
                Token        = this.token,
                EmailAddress = "*****@*****.**"
            };
            var service = new VstsService();

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await service.GetApprovals(null, projectName, profile));

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await service.GetApprovals(accountName, null, profile));

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await service.GetApprovals(accountName, projectName, null));

            using (ShimsContext.Create())
            {
                var expected = new List <ReleaseApproval>
                {
                    new ReleaseApproval
                    {
                        Id           = 1234,
                        ApprovalType = ApprovalType.Undefined
                    }
                };

                InitializeConnectionShim(new VssHttpClientBase[]
                {
                    GetAccountHttpClient(new List <Account>
                    {
                        new Account(Guid.Empty)
                        {
                            AccountName = "myaccount",
                            AccountUri  = new Uri("https://myaccount.visualstudio.com")
                        }
                    }),
                    GetProfileHttpClient(new Profile()),
                    new ShimReleaseHttpClient2
                    {
                        GetApprovalsAsync2StringStringNullableOfApprovalStatusIEnumerableOfInt32NullableOfApprovalTypeNullableOfInt32NullableOfInt32NullableOfReleaseQueryOrderNullableOfBooleanObjectCancellationToken
                            = (project, assignedToFilter, statusFilter, releaseIdsFilter, typeFilter, top, continuationToken, queryOrder, includeMyGroupApprovals, userState, cancellationToken) =>
                              Task.Run(
                                  () => (IPagedCollection <ReleaseApproval>) new StubIPagedCollection <ReleaseApproval>
                        {
                            CountGet     = () => expected.Count,
                            ItemGetInt32 = i => expected[i]
                        },
                                  cancellationToken)
                    }.Instance
                });

                IList <ReleaseApproval> actual = await service.GetApprovals(accountName, projectName, profile);

                Assert.AreEqual(expected.Count, actual.Count);

                for (var i = 0; i < actual.Count; i++)
                {
                    Assert.AreEqual(expected[i], actual[i]);
                }
            }
        }