Exemplo n.º 1
0
        public void QueryByWiql_WithoutWhereClause_ShouldBeRunInBatchesOfSpecifiedSize()
        {
            // Arrange
            var projectName        = _fixture.Create <string>();
            var workItemReferences = new[] { new WorkItemReference {
                                                 Id = 42
                                             }, new WorkItemReference {
                                                 Id = 96
                                             } };
            var processor = new QueryBatchProcessor(_client);

            MockQueryResultsByOne(workItemReferences);

            // Act
            var results = processor.QueryByWiql(projectName, batchSize: 1).ToImmutableList();

            // Assert
            results.ShouldBe(workItemReferences);
            _client
            .Received(workItemReferences.Length + 1)
            .PostAsync(
                Arg.Is <IVstsRequest <QueryByWiql, WorkItemQueryResult> >(r =>
                                                                          r.QueryParams.Any(p => p.Key == "$top" && 1.Equals(p.Value))),
                Arg.Any <QueryByWiql>());
            AssertQueriesReceivedContain(workItemReferences, "SELECT [System.Id]");
        }
        public async Task GivenNoPolicyPresent_WhenReconcile_PostIsUsed()
        {
            // Arrange
            CustomizeScope(_fixture, refName: "some/other/branch");
            SetupPoliciesResolver(_policiesResolver, _fixture);

            // Act
            var rule = new ReleaseBranchesProtectedByPolicies(_client, _policiesResolver) as IReconcile;
            await rule.ReconcileAsync("", RepositoryId);

            // Assert
            await _client
            .Received()
            .PostAsync(Arg.Any <IVstsRequest <Policy, Policy> >(), Arg.Any <MinimumNumberOfReviewersPolicy>());
        }
Exemplo n.º 3
0
        public async Task GivenPolicySettingsAreNotCorrect_WhenReconcile_ThenSettingsArePut()
        {
            //Arrange
            CustomizePolicySettings(_fixture, 10, false);
            SetupClient(_client, _fixture);

            //Act
            var rule = new PipelineHasRequiredRetentionPolicy(_client) as IReconcile;
            await rule.ReconcileAsync("", PipelineId);

            // Assert
            await _client
            .Received()
            .PutAsync(Arg.Any <IVstsRequest <ReleaseSettings> >(), Arg.Any <ReleaseSettings>());
        }