Exemplo n.º 1
0
        public async Task GivenAnUnreachableSource_DoesNotThrow()
        {
            var source   = new PackageSource("http://nuget.org/a/");
            var context  = new Mock <SourceCacheContext>();
            var provider = new Mock <IRemoteDependencyProvider>();

            provider.Setup(e => e.GetAllVersionsAsync(It.IsAny <string>(), It.IsAny <SourceCacheContext>(), It.IsAny <ILogger>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(() => null);         // unreachable sources would return null
            provider.SetupGet(e => e.Source).Returns(source);

            var info = await UnresolvedMessages.GetSourceInfoForIdAsync(provider.Object, "a", context.Object, NullLogger.Instance, CancellationToken.None);

            info.Value.Should().BeEmpty();
            info.Key.Source.Should().Be(source.Source);
        }
Exemplo n.º 2
0
        public async Task GivenAnEmptySourceVerifySourceInfoContainsAllVersions()
        {
            var versions = new[]
            {
                NuGetVersion.Parse("1.0.0"),
                NuGetVersion.Parse("2.0.0"),
                NuGetVersion.Parse("3.0.0-beta"),
            };

            var source   = new PackageSource("http://nuget.org/a/");
            var context  = new Mock <SourceCacheContext>();
            var provider = new Mock <IRemoteDependencyProvider>();

            provider.Setup(e => e.GetAllVersionsAsync(It.IsAny <string>(), It.IsAny <SourceCacheContext>(), It.IsAny <ILogger>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(() => versions);
            provider.SetupGet(e => e.Source).Returns(source);

            var info = await UnresolvedMessages.GetSourceInfoForIdAsync(provider.Object, "a", context.Object, NullLogger.Instance, CancellationToken.None);

            info.Value.Should().BeEquivalentTo(versions);
            info.Key.Source.Should().Be(source.Source);
        }