コード例 #1
0
        public void GetFeedType_WithUnknownSource_ReturnsFileSystemUnknown()
        {
            // Arrange & Act
            var type = FeedTypeUtility.GetFeedType(new PackageSource("\\blah"));

            // Assert
            Assert.Equal(FeedType.FileSystemUnknown, type);
        }
コード例 #2
0
        public void FeedTypeUtility_VerifyBadSourceIsUnknown2()
        {
            // Arrange & Act
            var type = FeedTypeUtility.GetFeedType(new PackageSource("$|. \n\t"));

            // Assert
            Assert.Equal(FeedType.FileSystemUnknown, type);
        }
コード例 #3
0
        public void GetFeedType_WithIllegalPathCharacters_ReturnsFileSystemUnknown()
        {
            // Arrange & Act
            var type = FeedTypeUtility.GetFeedType(new PackageSource("$|. \n\t"));

            // Assert
            Assert.Equal(FeedType.FileSystemUnknown, type);
        }
コード例 #4
0
        public void GetFeedType_WithRelativePath_ReturnsFileSystemUnknown(string source)
        {
            // Arrange & Act
            var type = FeedTypeUtility.GetFeedType(new PackageSource(source));

            // Assert
            Assert.Equal(FeedType.FileSystemUnknown, type);
        }
コード例 #5
0
        public void FeedTypeUtility_VerifyRelativePathIsUnknown(string source)
        {
            // Arrange & Act
            var type = FeedTypeUtility.GetFeedType(new PackageSource(source));

            // Assert
            Assert.Equal(FeedType.FileSystemUnknown, type);
        }
コード例 #6
0
        public void GetFeedType_WithEmptyDirectory_ReturnsFileSystemUnknown()
        {
            using (var root = TestDirectory.Create())
            {
                // Arrange & Act
                var type = FeedTypeUtility.GetFeedType(new PackageSource(root));

                // Assert
                Assert.Equal(FeedType.FileSystemUnknown, type);
            }
        }
コード例 #7
0
        public void FeedTypeUtility_EmptyDirectoryIsUnknownType()
        {
            using (var root = TestFileSystemUtility.CreateRandomTestFolder())
            {
                // Arrange & Act
                var type = FeedTypeUtility.GetFeedType(new PackageSource(root));

                // Assert
                Assert.Equal(FeedType.FileSystemUnknown, type);
            }
        }
コード例 #8
0
        public void FeedTypeUtility_NupkgAtRootIsV2_FileUri()
        {
            using (var root = TestDirectory.Create())
            {
                // Arrange
                CreateFile(Path.Combine(root, "a.1.0.0.nupkg"));

                // Act
                var type = FeedTypeUtility.GetFeedType(new PackageSource(UriUtility.CreateSourceUri(root).AbsoluteUri));

                // Assert
                Assert.Equal(FeedType.FileSystemV2, type);
            }
        }
コード例 #9
0
        public void FeedTypeUtility_NupkgAtInvalidLocationIsUnknown()
        {
            using (var root = TestDirectory.Create())
            {
                // Arrange
                CreateFile(Path.Combine(root, "a", "b", "a.1.0.0.nupkg"));

                // Act
                var type = FeedTypeUtility.GetFeedType(new PackageSource(root));

                // Assert
                Assert.Equal(FeedType.FileSystemUnknown, type);
            }
        }
コード例 #10
0
            public override Task <Tuple <bool, INuGetResource> > TryCreate(SourceRepository source, CancellationToken token)
            {
                DownloadResource resource = null;

                if ((FeedTypeUtility.GetFeedType(source.PackageSource) & FeedType.HttpV2) != FeedType.None)
                {
                    var httpSource = HttpSource.Create(source);
                    var parser     = new V2FeedParser(httpSource, source.PackageSource);

                    resource = new DownloadResourceV2FeedPrivate(parser, httpSource);
                }

                return(Task.FromResult(new Tuple <bool, INuGetResource>(resource != null, resource)));
            }
コード例 #11
0
        public void FeedTypeUtility_NupkgOnlyInVersionFolderIsUnknown()
        {
            using (var root = TestFileSystemUtility.CreateRandomTestFolder())
            {
                // Arrange
                CreateFile(Path.Combine(root, "a", "1.0.0", "a.1.0.0.nupkg"));

                // Act
                var type = FeedTypeUtility.GetFeedType(new PackageSource(root));

                // Assert
                Assert.Equal(FeedType.FileSystemUnknown, type);
            }
        }
コード例 #12
0
        public void FeedTypeUtility_NupkgAtRootIsV2()
        {
            using (var root = TestFileSystemUtility.CreateRandomTestFolder())
            {
                // Arrange
                CreateFile(Path.Combine(root, "a.1.0.0.nupkg"));

                // Act
                var type = FeedTypeUtility.GetFeedType(new PackageSource(root));

                // Assert
                Assert.Equal(FeedType.FileSystemV2, type);
            }
        }
コード例 #13
0
        public void GetFeedType_WithNupkgOnlyInVersionFolder_ReturnsFileSystemUnknown()
        {
            using (var root = TestDirectory.Create())
            {
                // Arrange
                CreateFile(Path.Combine(root, "a", "1.0.0", "a.1.0.0.nupkg"));

                // Act
                var type = FeedTypeUtility.GetFeedType(new PackageSource(root));

                // Assert
                Assert.Equal(FeedType.FileSystemUnknown, type);
            }
        }
コード例 #14
0
        public void GetFeedType_WithFileSystemV2LayoutAndFileUri_ReturnsFileSystemV2()
        {
            using (var root = TestDirectory.Create())
            {
                // Arrange
                CreateFile(Path.Combine(root, "a.1.0.0.nupkg"));

                // Act
                var type = FeedTypeUtility.GetFeedType(new PackageSource(UriUtility.CreateSourceUri(root).AbsoluteUri));

                // Assert
                Assert.Equal(FeedType.FileSystemV2, type);
            }
        }
コード例 #15
0
        public void GetFeedType_WithRandomFilesInRoot_ReturnsFileSystemUnknown()
        {
            using (var root = TestDirectory.Create())
            {
                // Arrange
                CreateFile(Path.Combine(root, "a.txt"));
                CreateFile(Path.Combine(root, "a", "a.txt"));
                CreateFile(Path.Combine(root, "a", "b", "a.txt"));

                // Act
                var type = FeedTypeUtility.GetFeedType(new PackageSource(root));

                // Assert
                Assert.Equal(FeedType.FileSystemUnknown, type);
            }
        }
コード例 #16
0
        public void FeedTypeUtility_RandomFilesInRootIsUnknownType()
        {
            using (var root = TestFileSystemUtility.CreateRandomTestFolder())
            {
                // Arrange
                CreateFile(Path.Combine(root, "a.txt"));
                CreateFile(Path.Combine(root, "a", "a.txt"));
                CreateFile(Path.Combine(root, "a", "b", "a.txt"));

                // Act
                var type = FeedTypeUtility.GetFeedType(new PackageSource(root));

                // Assert
                Assert.Equal(FeedType.FileSystemUnknown, type);
            }
        }
        public override async Task <Tuple <bool, INuGetResource> > TryCreate(SourceRepository source, CancellationToken token)
        {
            DependencyInfoResource DependencyInfoResourceV2 = null;

            if (FeedTypeUtility.GetFeedType(source.PackageSource) == FeedType.FileSystem)
            {
                var v2repo = await GetRepository(source, token);

                if (v2repo != null)
                {
                    DependencyInfoResourceV2 = new DependencyInfoResourceV2(v2repo, source);
                }
            }

            return(Tuple.Create <bool, INuGetResource>(DependencyInfoResourceV2 != null, DependencyInfoResourceV2));
        }
コード例 #18
0
        public override async Task <Tuple <bool, INuGetResource> > TryCreate(SourceRepository source, CancellationToken token)
        {
            MetadataResource resource = null;

            if (FeedTypeUtility.GetFeedType(source.PackageSource) == FeedType.FileSystem)
            {
                var v2repo = await GetRepository(source, token);

                if (v2repo != null)
                {
                    resource = new MetadataResourceV2(v2repo);
                }
            }

            return(new Tuple <bool, INuGetResource>(resource != null, resource));
        }
コード例 #19
0
        public void FeedTypeUtility_NupkgInVersionFolderIsV3_FileUri()
        {
            using (var root = TestDirectory.Create())
            {
                // Arrange
                CreateFile(Path.Combine(root, "a", "1.0.0", "a.1.0.0.nupkg.sha512"));
                CreateFile(Path.Combine(root, "a", "1.0.0", "a.nuspec"));
                CreateFile(Path.Combine(root, "a", "1.0.0", "a.1.0.0.nupkg"));

                // Act
                var type = FeedTypeUtility.GetFeedType(new PackageSource(UriUtility.CreateSourceUri(root).AbsoluteUri));

                // Assert
                Assert.Equal(FeedType.FileSystemV3, type);
            }
        }
コード例 #20
0
        public void GetFeedType_WithBothFileSystemV2AndV3Layouts_ReturnsFileSystemV2()
        {
            using (var root = TestDirectory.Create())
            {
                // Arrange
                CreateFile(Path.Combine(root, "a.1.0.0.nupkg"));
                CreateFile(Path.Combine(root, "a", "a.1.0.0.nupkg"));
                CreateFile(Path.Combine(root, "a", "1.0.0", "a.1.0.0.nupkg"));

                // Act
                var type = FeedTypeUtility.GetFeedType(new PackageSource(root));

                // Assert
                Assert.Equal(FeedType.FileSystemV2, type);
            }
        }
コード例 #21
0
        public void GetFeedType_WithFileSystemV3LayoutAndFeedTypePackageSource_ReturnsFeedTypePackageSourceFeedType()
        {
            using (var root = TestDirectory.Create())
            {
                CreateFile(Path.Combine(root, "a", "1.0.0", "a.1.0.0.nupkg.sha512"));
                CreateFile(Path.Combine(root, "a", "1.0.0", "a.nuspec"));
                CreateFile(Path.Combine(root, "a", "1.0.0", "a.1.0.0.nupkg"));

                var feedTypes = new[] { FeedType.FileSystemV2, FeedType.FileSystemV3, FeedType.FileSystemUnknown };

                foreach (var expectedFeedType in feedTypes)
                {
                    var packageSource = new FeedTypePackageSource(root, expectedFeedType);

                    var actualFeedType = FeedTypeUtility.GetFeedType(packageSource);

                    Assert.Equal(expectedFeedType, actualFeedType);
                }
            }
        }
コード例 #22
0
 public void GetFeedType_WithV3HttpSources_ReturnsHttpV3(string source)
 {
     Assert.Equal(FeedType.HttpV3, FeedTypeUtility.GetFeedType(new PackageSource(source)));
 }
コード例 #23
0
 public void FeedTypeUtility_HttpSourcesV3(string source)
 {
     Assert.Equal(FeedType.HttpV3, FeedTypeUtility.GetFeedType(new PackageSource(source)));
 }