Example #1
0
        public void ThenIsRejectedWithComment(KeyValuePair <string, string> teamProject)
        {
            var service  = new VstsService();
            var approval = service.GetApproval(Config.Account, teamProject.Value, Config.Approval.Id, Config.Profile.Token).Result;

            approval.Status.Should().Be(ApprovalStatus.Rejected);
        }
        public async Task GetApprovalTest()
        {
            var accountName = "myaccount";
            var projectName = "myproject";
            var service     = new VstsService();
            int id          = 1;

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await service.GetApproval(null, projectName, id, this.token));

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await service.GetApproval(accountName, null, id, this.token));

            await Assert.ThrowsExceptionAsync <ArgumentOutOfRangeException>(async() => await service.GetApproval(accountName, projectName, 0, this.token));

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

            using (ShimsContext.Create())
            {
                var expected = 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 ShimReleaseHttpClientBase(new ShimReleaseHttpClient2())
                    {
                        GetApprovalAsyncStringInt32NullableOfBooleanObjectCancellationToken
                            = (project, approvalId, includeHistory, objectState, cancellationToken) => Task.Run(
                                  () =>
                        {
                            expected.Id = approvalId;
                            return(expected);
                        },
                                  cancellationToken)
                    }.Instance
                });

                ReleaseApproval actual = await service.GetApproval(accountName, projectName, id, this.token);

                Assert.IsNotNull(actual);
                Assert.AreEqual(expected, actual);
                Assert.AreEqual(id, actual.Id);
            }
        }