Example #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]");
        }
Example #2
0
        public void QueryByWiql_WithWhereClause_ShouldBeRunInBatchesOfSpecifiedSize()
        {
            // Arrange
            const string whereClause = "[System.ChangedDate] < @startOfDay";

            var projectName        = _fixture.Create <string>();
            var workItemReferences = _fixture.CreateMany <WorkItemReference>().ToImmutableList();
            var processor          = new QueryBatchProcessor(_client);

            MockQueryResultsByOne(workItemReferences);

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

            // Assert
            results.ShouldBe(workItemReferences);
            AssertQueriesReceivedContain(workItemReferences, whereClause);
        }