Example #1
0
        public void ShouldReturnCalculateCorrectPRDescriptionWhenUpdatingExistingPR()
        {
            PullRequestDescriptionBuilder pullRequestDescriptionBuilder = new PullRequestDescriptionBuilder(new NullLoggerFactory(), "");
            UpdateAssetsParameters        update1 = CreateUpdateAssetsParameters(false, "11111111-1111-1111-1111-111111111111");
            UpdateAssetsParameters        update2 = CreateUpdateAssetsParameters(false, "22222222-2222-2222-2222-222222222222");
            UpdateAssetsParameters        update3 = CreateUpdateAssetsParameters(false, "33333333-3333-3333-3333-333333333333");
            List <DependencyUpdate>       deps1   = CreateDependencyUpdates('a');
            List <DependencyUpdate>       deps2   = CreateDependencyUpdates('b');
            List <DependencyUpdate>       deps3   = CreateDependencyUpdates('c');
            Build build = GivenANewBuild(true);

            pullRequestDescriptionBuilder.AppendBuildDescription(update1, deps1, null, build);
            pullRequestDescriptionBuilder.AppendBuildDescription(update2, deps2, null, build);
            pullRequestDescriptionBuilder.AppendBuildDescription(update3, deps3, null, build);

            String description = pullRequestDescriptionBuilder.ToString();

            description.Should().Contain(BuildCorrectPRDescriptionWhenCoherencyUpdate(deps1, 1));
            description.Should().Contain(BuildCorrectPRDescriptionWhenCoherencyUpdate(deps2, 3));
            description.Should().Contain(BuildCorrectPRDescriptionWhenCoherencyUpdate(deps3, 5));

            List <DependencyUpdate> deps22 = CreateDependencyUpdates('d');

            pullRequestDescriptionBuilder.AppendBuildDescription(update2, deps22, null, build);

            description = pullRequestDescriptionBuilder.ToString();

            description.Should().Contain(BuildCorrectPRDescriptionWhenCoherencyUpdate(deps1, 1));
            description.Should().Contain(BuildCorrectPRDescriptionWhenCoherencyUpdate(deps3, 5));
            description.Should().NotContain(BuildCorrectPRDescriptionWhenCoherencyUpdate(deps2, 3));
            description.Should().Contain(BuildCorrectPRDescriptionWhenCoherencyUpdate(deps22, 7));
        }
Example #2
0
        public void ShouldReturnCalculateCorrectPRDescriptionWhenNonCoherencyUpdate()
        {
            PullRequestDescriptionBuilder pullRequestDescriptionBuilder = new PullRequestDescriptionBuilder(new NullLoggerFactory(), "");
            UpdateAssetsParameters        update = CreateUpdateAssetsParameters(true, "11111111-1111-1111-1111-111111111111");
            List <DependencyUpdate>       deps   = CreateDependencyUpdates('a');

            pullRequestDescriptionBuilder.AppendBuildDescription(update, deps, null, null);

            pullRequestDescriptionBuilder.ToString().Should().Contain(BuildCorrectPRDescriptionWhenNonCoherencyUpdate(deps));
        }
Example #3
0
        private string BuildCorrectPRDescriptionWhenCoherencyUpdate(List <DependencyUpdate> deps, int startingId)
        {
            StringBuilder builder = new StringBuilder();
            List <string> urls    = new List <string>();

            for (int i = 0; i < deps.Count; i++)
            {
                urls.Add(PullRequestDescriptionBuilder.GetChangesURI(deps[i].To.RepoUri, deps[i].From.Commit, deps[i].To.Commit));
                builder.AppendLine($"  - **{deps[i].To.Name}**: [from {deps[i].From.Version} to {deps[i].To.Version}][{startingId + i}]");
            }
            builder.AppendLine();
            for (int i = 0; i < urls.Count; i++)
            {
                builder.AppendLine($"[{i + startingId}]: {urls[i]}");
            }
            return(builder.ToString());
        }
Example #4
0
        public void ShouldReturnCorrectMaximumIndex(string str, int expectedResult)
        {
            PullRequestDescriptionBuilder pullRequestDescriptionBuilder = new PullRequestDescriptionBuilder(new NullLoggerFactory(), str);

            pullRequestDescriptionBuilder.GetStartingReferenceId().Should().Be(expectedResult);
        }