Exemplo n.º 1
0
        public void ExcludeFilesDoesNotUseDefaultExcludesIfDisabled()
        {
            // Arrange
            var files = GetPackageFiles(
                @"p:\some-file\test.txt",
                @"p:\some-file\should-not-be-removed\ext\sample.nupkg",
                @"p:\some-file\manifest.nuspec",
                @"p:\some-file\should-not-be-removed\.hgignore",
                @"p:\some-file\should-be-removed\file.ext"
                );

            // Act
            var packCommand = new PackCommand {
                BasePath = @"p:\some-file", NoDefaultExcludes = true
            };

            packCommand.Exclude.Add(@"**\*.ext");
            packCommand.ExcludeFiles(files);

            // Assert
            Assert.AreEqual(3, files.Count);
            Assert.AreEqual(files[0].Path, @"p:\some-file\test.txt");
            Assert.AreEqual(files[1].Path, @"p:\some-file\should-not-be-removed\ext\sample.nupkg");
            Assert.AreEqual(files[2].Path, @"p:\some-file\should-not-be-removed\.hgignore");
        }
Exemplo n.º 2
0
        public void PackCommandDefaultFiltersRemovesManifestAndPackageFiles()
        {
            // Arrange
            var files = GetPackageFiles(
                @"x:\packagefiles\some-file\1.txt",
                @"x:\packagefiles\folder\test.nupkg",
                @"x:\packagefiles\folder\should-not-exclude\test.nupkg.html",
                @"x:\packagefiles\test.nuspec",
                @"x:\packagefiles\test.nuspec.bkp",
                @"x:\packagefiles\subdir\foo.nuspec"
                );

            // Act
            var packCommand = new PackCommand {
                BasePath = @"x:\packagefiles\", NoDefaultExcludes = false
            };

            packCommand.ExcludeFiles(files);

            // Assert
            Assert.AreEqual(3, files.Count);
            Assert.AreEqual(files[0].Path, @"x:\packagefiles\some-file\1.txt");
            Assert.AreEqual(files[1].Path, @"x:\packagefiles\folder\should-not-exclude\test.nupkg.html");
            Assert.AreEqual(files[2].Path, @"x:\packagefiles\test.nuspec.bkp");
        }
Exemplo n.º 3
0
        public void PackCommandDefaultFiltersRemovesNugetFiles()
        {
            // Arrange
            var files = GetPackageFiles(
                @"x:\packagefiles\some-file\1.txt",
                @"x:\packagefiles\foo\bar.nupkg",
                @"x:\packagefiles\bar\test.nuspec"
                );

            // Act
            var packCommand = new PackCommand {
                BasePath = @"x:\packagefiles", NoDefaultExcludes = false
            };

            packCommand.ExcludeFiles(files);

            // Assert
            Assert.AreEqual(1, files.Count);
            Assert.AreEqual(files[0].Path, @"x:\packagefiles\some-file\1.txt");
        }
Exemplo n.º 4
0
        public void ExcludeFilesUsesPathIfFileIsNotPhysicalPackageFile()
        {
            // Arrange
            var mockFile = new Mock <IPackageFile>();

            mockFile.Setup(c => c.Path).Returns(@"content\foo.txt");
            var files = GetPackageFiles(@"p:\some-file\test.txt").Concat(new[] { mockFile.Object }).ToList();

            // Act
            var packCommand = new PackCommand {
                BasePath = @"p:\some-file", NoDefaultExcludes = true
            };

            packCommand.Exclude.Add(@"content\f*");
            packCommand.ExcludeFiles(files);

            // Assert
            Assert.AreEqual(1, files.Count);
            Assert.AreEqual(files[0].Path, @"p:\some-file\test.txt");
        }
Exemplo n.º 5
0
        public void ExcludeFilesUsesWildCardExtension()
        {
            // Arrange
            var files = GetPackageFiles(
                @"p:\some-file\should-be-removed\test.ext",
                @"p:\some-file\should-not-be-removed\ext\sample.txt",
                @"p:\some-file\should-not-be-removed\test.ext\sample3.jpg"
                );

            // Act
            var packCommand = new PackCommand {
                BasePath = @"p:\some-file", NoDefaultExcludes = false
            };

            packCommand.Exclude.Add(@"**\*.ext");
            packCommand.ExcludeFiles(files);

            // Assert
            Assert.AreEqual(2, files.Count);
            Assert.AreEqual(files[0].Path, @"p:\some-file\should-not-be-removed\ext\sample.txt");
            Assert.AreEqual(files[1].Path, @"p:\some-file\should-not-be-removed\test.ext\sample3.jpg");
        }
Exemplo n.º 6
0
        public void ExcludeFilesPerformsCaseInsensitiveSearch()
        {
            // Arrange
            var files = GetPackageFiles(
                @"p:\some-file\should-be-removed\test.ext",
                @"p:\some-file\should-not-be-removed\ext\sample.txt",
                @"p:\some-file\should-not-be-removed\.ext\sample2.txt",
                @"p:\some-file\should-not-be-removed\test.ext\sample3.jpg"
                );

            // Act
            var packCommand = new PackCommand {
                BasePath = @"p:\some-file", NoDefaultExcludes = false
            };

            packCommand.Exclude.Add(@"**\*.EXt");
            packCommand.ExcludeFiles(files);

            // Assert
            Assert.Equal(2, files.Count);
            Assert.Equal(files[0].Path, @"p:\some-file\should-not-be-removed\ext\sample.txt");
            Assert.Equal(files[1].Path, @"p:\some-file\should-not-be-removed\test.ext\sample3.jpg");
        }
Exemplo n.º 7
0
        public void PackCommandDefaultFiltersRemovesRepoFiles()
        {
            // Arrange
            var files = GetPackageFiles(
                @"x:\packagefiles\some-file\1.txt",
                @"x:\packagefiles\folder\.hg",
                @"x:\packagefiles\folder\should-not-exclude\hg",
                @"x:\packagefiles\repo\.git\HEAD",
                @"x:\packagefiles\svnrepo\.svn\all-wcrops",
                @"x:\packagefiles\.git\should-not-exist"
                );

            // Act
            var packCommand = new PackCommand {
                BasePath = @"x:\packagefiles\", NoDefaultExcludes = false
            };

            packCommand.ExcludeFiles(files);

            // Assert
            Assert.AreEqual(2, files.Count);
            Assert.AreEqual(files[0].Path, @"x:\packagefiles\some-file\1.txt");
            Assert.AreEqual(files[1].Path, @"x:\packagefiles\folder\should-not-exclude\hg");
        }
Exemplo n.º 8
0
        public void ExcludeFilesDoesNotExcludeDefaultFilesIfExcludeSpecialPathsIsDisabled()
        {
            // Arrange
            var files = GetPackageFiles(
                @"p:\some-file\should-be-removed\test.ext",
                @"p:\some-file\should-not-be-removed\ext\sample.txt",
                @"p:\some-file\should-not-be-removed\.ext\sample2.txt",
                @"p:\some-file\should-not-be-removed\test.ext\sample3.jpg"
                );

            // Act
            var packCommand = new PackCommand {
                BasePath = @"p:\some-file", NoDefaultExcludes = true
            };

            packCommand.Exclude.Add(@"**\*.ext");
            packCommand.ExcludeFiles(files);

            // Assert
            Assert.AreEqual(3, files.Count);
            Assert.AreEqual(files[0].Path, @"p:\some-file\should-not-be-removed\ext\sample.txt");
            Assert.AreEqual(files[1].Path, @"p:\some-file\should-not-be-removed\.ext\sample2.txt");
            Assert.AreEqual(files[2].Path, @"p:\some-file\should-not-be-removed\test.ext\sample3.jpg");
        }