Example #1
0
        public async Task GetLatestVersionFromSources_WithMoreSourcesThanProcessorCount()
        {
            using (var testDirectory = TestDirectory.Create())
            {
                // Arrange
                var processors = Environment.ProcessorCount * 2;
                var sources    = new PackageSource[processors];
                var packages   = new SimpleTestPackageContext[processors];
                for (var i = 0; i < processors; i++)
                {
                    var sourcePath = Path.Combine(testDirectory.Path, "Source" + i.ToString());
                    var packageX   = new SimpleTestPackageContext("packageX", "1.0." + i.ToString());
                    await SimpleTestPackageUtility.CreateFolderFeedV3Async(sourcePath, packageX);

                    sources[i]  = new PackageSource(sourcePath);
                    packages[i] = packageX;
                }

                // Act
                var logger = NullLogger.Instance;
                var result = await AddPackageCommandUtility.GetLatestVersionFromSourcesAsync(sources, logger, packages.Last().Id, false);

                // Assert
                Assert.Equal(packages.Last().Identity.Version, result);
            }
        }