public async Task AdditionalTimelines_IgnoreOldest()
        {
            // Test input
            DateTimeOffset timeDatum        = DateTimeOffset.Parse("2021-01-01T01:00:00Z");
            string         azdoProjectName  = "public";
            string         targetBranchName = "theTargetBranch";

            BuildAndTimeline build = BuildAndTimelineBuilder.NewPullRequestBuild(1, azdoProjectName, targetBranchName)
                                     .AddTimeline(TimelineBuilder.EmptyTimeline("1", timeDatum)
                                                  .AddRecord()
                                                  .AddRecord("2")) // Represents a retry
                                     .AddTimeline(TimelineBuilder.EmptyTimeline("2", timeDatum.AddHours(-1))
                                                  .AddRecord()
                                                  .AddRecord())
                                     .Build();

            // Test setup
            await using TestData testData = await TestData.Default
                                            .WithRepository(azdoProjectName, timeDatum.AddHours(-1))
                                            .WithStaticClock(timeDatum)
                                            .WithBuild(build)
                                            .BuildAsync();

            /// Test execution
            await testData.Controller.RunProject(azdoProjectName, 1000, CancellationToken.None);

            // Test results
            IEnumerable <TimelineRecord> expectedRecords = build.Timelines
                                                           .Where(timeline => timeline.LastChangedOn > timeDatum.AddHours(-1))
                                                           .SelectMany(b => b.Records);

            testData.Repository.TimelineRecords
            .Select(r => r.Raw)
            .Should().BeEquivalentTo(expectedRecords);
        }
        public async Task PullRequestWithNoParameters()
        {
            DateTimeOffset timeDatum        = DateTimeOffset.Parse("2021-01-01T01:00:00Z");
            string         azdoProjectName  = "public";
            string         targetBranchName = null;

            BuildAndTimeline build = BuildAndTimelineBuilder.NewPullRequestBuild(1, azdoProjectName, targetBranchName)
                                     .AddTimeline(TimelineBuilder.EmptyTimeline("1", timeDatum)
                                                  .AddRecord()
                                                  .AddRecord()
                                                  ).Build();

            // Test setup
            await using TestData testData = await TestData.Default
                                            .WithStaticClock(timeDatum)
                                            .WithBuild(build)
                                            .BuildAsync();

            /// Test execution
            await testData.Controller.RunProject(azdoProjectName, 1000, CancellationToken.None);

            // Test results
            testData.Repository.TimelineBuilds.Should().SatisfyRespectively(
                first =>
            {
                first.Build.Should().BeSameAs(build.Build);
                first.TargetBranch.Should().Be(string.Empty);
            });
        }
        public async Task GetAdditionalTimelines()
        {
            DateTimeOffset timeDatum        = DateTimeOffset.Parse("2021-01-01T01:00:00Z");
            string         azdoProjectName  = "public";
            string         targetBranchName = "theTargetBranch";

            // Test input
            BuildAndTimeline build = BuildAndTimelineBuilder.NewPullRequestBuild(1, azdoProjectName, targetBranchName)
                                     .AddTimeline(TimelineBuilder.EmptyTimeline("1", timeDatum)
                                                  .AddRecord()
                                                  .AddRecord("2")) // Represents a retry
                                     .AddTimeline(TimelineBuilder.EmptyTimeline("2", timeDatum.AddHours(-1))
                                                  .AddRecord()
                                                  .AddRecord())
                                     .Build();

            // Test setup
            using TestData testData = await TestData.Default
                                      .WithStaticClock(timeDatum)
                                      .WithBuild(build)
                                      .BuildAsync();

            /// Test execution
            await testData.Controller.RunProject("public", 1000, CancellationToken.None);

            // Test results
            testData.Repository.TimelineRecords
            .Select(r => r.Raw)
            .Should()
            .BeEquivalentTo(build.Timelines
                            .SelectMany(timeline => timeline.Records));

            testData.Repository.TimelineValidationMessages.Should().BeEmpty();
        }
        public async Task VanillaTest()
        {
            DateTimeOffset timeDatum        = DateTimeOffset.Parse("2021-01-01T01:00:00Z");
            string         azdoProjectName  = "public";
            string         targetBranchName = "theTargetBranch";

            BuildAndTimeline build = BuildAndTimelineBuilder.NewPullRequestBuild(1, azdoProjectName, targetBranchName)
                                     .AddTimeline(TimelineBuilder.EmptyTimeline("1", timeDatum)
                                                  .AddRecord()
                                                  .AddRecord()
                                                  ).Build();

            // Test setup
            await using TestData testData = await TestData.Default
                                            .WithStaticClock(timeDatum)
                                            .WithBuild(build)
                                            .BuildAsync();

            /// Test execution
            await testData.Controller.RunProject(azdoProjectName, 1000, CancellationToken.None);

            // Test results
            testData.Repository.TimelineBuilds.Should().SatisfyRespectively(
                first =>
            {
                first.Build.Should().BeSameAs(build.Build);
                first.TargetBranch.Should().Be(targetBranchName);
            });

            testData.Repository.TimelineIssues.Should().BeEmpty();

            testData.Repository.TimelineRecords.Should().HaveCount(2);
            testData.Repository.TimelineRecords
            .Select(r => r.Raw)
            .Should().Contain(build.Timelines
                              .SelectMany(timeline => timeline.Records));

            testData.Repository.TimelineValidationMessages.Should().BeEmpty();
        }