예제 #1
0
        private static void SetNugetPackageDependencyExpectations(ITeamCityApi api, PackageBuildMappingCache cache, BuildTemplate template, IExternalIssueResolver issueResolver)
        {
            var initial = template.StartBuildPackages.Select(p => new TeamCityApi.PackageDetails {
                Id = p.Key, Version = p.Value
            }).ToList();
            var final = template.FinishBuildPackages.Select(p => new TeamCityApi.PackageDetails {
                Id = p.Key, Version = p.Value
            }).ToList();

            if (initial.Any())
            {
                A.CallTo(() => api.GetNuGetDependenciesByBuildTypeAndBuildId(template.BuildId, template.StartBuildNumber.ToString()))
                .Returns(initial);
            }

            if (initial.Any())
            {
                A.CallTo(() => api.GetNuGetDependenciesByBuildTypeAndBuildId(template.BuildId, template.FinishBuildNumber.ToString()))
                .Returns(final);
            }

            if (template.CreateNuGetPackageChangeManifests && initial.Any() && final.Any())
            {
                var packageDiffs = new PackageChangeComparator().GetPackageChanges(initial, final);
                foreach (var diff in packageDiffs.Where(d => d.Type == NuGetPackageChangeType.Modified))
                {
                    if (!cache.PackageBuildMappings.Any(c => c.PackageId.Equals(diff.PackageId) && c.BuildConfigurationId.Equals(diff.PackageId)))
                    {
                        cache.PackageBuildMappings.Add(new PackageBuildMapping
                        {
                            BuildConfigurationId   = diff.PackageId,
                            BuildConfigurationName = diff.PackageId,
                            PackageId = diff.PackageId,
                            Project   = diff.PackageId,
                            ServerUrl = api.TeamCityServer
                        });
                    }

                    SetExpectations(new BuildTemplate
                    {
                        BuildId            = diff.PackageId,
                        BuildCount         = 15,
                        BuildName          = diff.PackageId,
                        BuildNumberPattern = "1.{0}",
                        CreateNuGetPackageChangeManifests = false,
                        StartBuildNumber  = Convert.ToInt16(diff.OldVersion.Split('.')[1]),
                        FinishBuildNumber = Convert.ToInt16(diff.NewVersion.Split('.')[1]),
                        IssueCount        = 1,
                        NestedIssueChance = 100,
                        NestedIssueDepth  = 1,
                    },
                                    api,
                                    issueResolver,
                                    cache);
                }
            }
        }
예제 #2
0
        public int DetectsAddedRemovedPackages(int initialCount, int finalCount, NuGetPackageChangeType changeType)
        {
            var initial = Enumerable.Range(1, initialCount).Select(i => Tuple.Create("Package" + i.ToString(CultureInfo.InvariantCulture), "1.0")).ToList();
            var final   = Enumerable.Range(1, finalCount).Select(i => Tuple.Create("Package" + i.ToString(CultureInfo.InvariantCulture), "1.0")).ToList();

            var compararator = new PackageChangeComparator();
            var results      = compararator.GetPackageChanges(CreateNuGetPackegList(initial), CreateNuGetPackegList(final));

            return(results.Count(r => r.Type == changeType));
        }
예제 #3
0
        public int DetectsModifiedPackages(string package1Final, string package2Final)
        {
            var initial = new[] { Tuple.Create("Package1", "1.0"), Tuple.Create("Package2", "1.0") };
            var final   = new[] { Tuple.Create("Package1", package1Final), Tuple.Create("Package2", package2Final) };

            var compararator = new PackageChangeComparator();
            var results      = compararator.GetPackageChanges(CreateNuGetPackegList(initial), CreateNuGetPackegList(final));

            return(results.Count(r => r.Type == NuGetPackageChangeType.Modified));
        }