Ejemplo n.º 1
0
        public async Task QueueBuildAsyncTest()
        {
            var accountName     = "myaccount";
            var teamProjectName = "myproject";
            var service         = new VstsService();
            var id = 1;

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

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

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

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

            using (ShimsContext.Create())
            {
                var client = new ShimBuildHttpClientBase(new ShimBuildHttpClient());

                InitializeConnectionShim(client.Instance);

                client.QueueBuildAsyncBuildStringNullableOfBooleanStringObjectCancellationToken =
                    (build, teamProject, arg3, arg4, arg5, cancellationToken) =>
                    Task.Run(
                        () =>
                {
                    build.Definition.Id.Should().Be(id);
                    teamProject.Should().Be(teamProjectName);

                    return(new Build());
                },
                        cancellationToken);

                await service.QueueBuildAsync(accountName, teamProjectName, id, this.token);
            }
        }