public async Task GivenThatICopySymbolsWithNoPrimaryVerifyWarning()
        {
            using (var workingDir = new TestFolder())
            {
                // Arrange
                var log    = new TestLogger();
                var nuspec = new TestNuspec()
                {
                    Id              = "a",
                    Version         = "1.0.0",
                    IsSymbolPackage = true
                };
                var nupkg = nuspec.CreateNupkg();
                nupkg.Files.Clear();
                nupkg.AddFile("lib/net45/a.dll");
                var path = nupkg.Save(workingDir);

                // Act
                var before   = GetNupkgFiles(path.FullName);
                var exitCode = await Program.MainCore(new[] { "files", "copysymbols", workingDir }, log);

                var after = GetNupkgFiles(path.FullName);

                var diff = new SortedSet <string>(after, StringComparer.OrdinalIgnoreCase);
                diff.ExceptWith(before);

                // Assert
                exitCode.Should().Be(0, log.GetMessages());

                log.GetMessages().Should().Be("Missing primary package for a.1.0.0");
            }
        }
Example #2
0
        public async Task GivenThatIAddAFrameworkAssemblyVerifyErrorIfNoFrameworkAndFrameworksAreGiven()
        {
            using (var workingDir = new TestFolder())
            {
                // Arrange
                var nuspec = new TestNuspec()
                {
                    Id      = "a",
                    Version = "1.0.0"
                };

                var nupkg = nuspec.CreateNupkg();
                var path  = nupkg.Save(workingDir).FullName;

                var log = new TestLogger();

                // Act
                var exitCode = await Program.MainCore(new[] { "nuspec", "frameworkassemblies", "add", path, "--assembly-name", "test", "--framework", "net46", "--no-frameworks" }, log);

                NuspecReader reader = null;
                using (var package = new PackageArchiveReader(path))
                {
                    reader = package.NuspecReader;
                }

                // Assert
                exitCode.Should().Be(1, "error expected");
                string.Join("|", log.Messages.Where(e => e.Level == LogLevel.Error).Select(e => e.Message)).Should().Contain("--framework, --no-frameworks may not be used together.");
            }
        }
        public async Task GivenThatIUpdateTheNameOfANupkgVerifyItIsCorrect()
        {
            using (var workingDir = new TestFolder())
            {
                // Arrange
                var nuspec = new TestNuspec()
                {
                    Id      = "a",
                    Version = "1.0.0"
                };

                var zipFile = nuspec.CreateNupkg().Save(workingDir);

                var log = new TestLogger();

                var altPath  = Path.Combine(zipFile.Directory.FullName, "test.nupkg");
                var origPath = zipFile.FullName;

                File.Move(origPath, altPath);

                // Act
                var exitCode = await Program.MainCore(new[] { "updatefilename", altPath }, log);

                // Assert
                Assert.Equal(0, exitCode);
                Assert.True(File.Exists(origPath), string.Join("|", log.Messages));
            }
        }
        public async Task GivenThatIUpdateASymbolPackageVerifyTheFileNameIsCorrect()
        {
            using (var workingDir = new TestFolder())
            {
                // Arrange
                var nuspec = new TestNuspec()
                {
                    Id              = "a",
                    Version         = "1.0.0",
                    IsSymbolPackage = true
                };

                var nupkg = nuspec.CreateNupkg().Save(workingDir);

                var log = new TestLogger();

                var altPath  = Path.Combine(nupkg.Directory.FullName, "a.1.0.symbols.nupkg");
                var origPath = nupkg.FullName;

                File.Move(origPath, altPath);

                // Act
                var exitCode = await Program.MainCore(new[] { "updatefilename", altPath }, log);

                // Assert
                exitCode.Should().Be(0, "no errors");
                File.Exists(origPath).Should().BeTrue("the original path was the correct name");
            }
        }
        public async Task GivenThatICopySymbolsVerifyFirstSymbolPackageUsed()
        {
            using (var workingDir = new TestFolder())
            {
                // Arrange
                var log    = new TestLogger();
                var nuspec = new TestNuspec()
                {
                    Id      = "a",
                    Version = "1.0.0"
                };
                var nupkg = nuspec.CreateNupkg();
                nupkg.Files.Clear();
                nupkg.AddFile("lib/net45/a.dll");
                var path = nupkg.Save(workingDir);

                var nuspecSymbols = new TestNuspec()
                {
                    Id              = "a",
                    Version         = "1.0.0",
                    IsSymbolPackage = true
                };
                var nupkgSymbols = nuspecSymbols.CreateNupkg();
                nupkgSymbols.Files.Clear();
                nupkgSymbols.AddFile("lib/net45/a.dll");
                nupkgSymbols.AddFile("lib/net45/a.pdb");
                nupkgSymbols.Save(workingDir);

                var nuspecSymbols2 = new TestNuspec()
                {
                    Id              = "a",
                    Version         = "1.0",
                    IsSymbolPackage = true
                };
                var nupkgSymbols2 = nuspecSymbols2.CreateNupkg();
                nupkgSymbols2.Files.Clear();
                nupkgSymbols2.AddFile("lib/net45/a.dll");
                nupkgSymbols2.Save(workingDir);

                // Act
                var before   = GetNupkgFiles(path.FullName);
                var exitCode = await Program.MainCore(new[] { "files", "copysymbols", workingDir }, log);

                var after = GetNupkgFiles(path.FullName);

                var diff = new SortedSet <string>(after, StringComparer.OrdinalIgnoreCase);
                diff.ExceptWith(before);

                // Assert
                exitCode.Should().Be(0, log.GetMessages());

                after.Should().Contain("lib/net45/a.dll");
                diff.ShouldBeEquivalentTo(new string[] { "lib/net45/a.pdb" });
            }
        }
Example #6
0
        public async Task GivenThatIAddMultipleFrameworkAssembliesToAnEmptyNuspecVerifyItIsAdded()
        {
            using (var workingDir = new TestFolder())
            {
                // Arrange
                var nuspec = new TestNuspec()
                {
                    Id      = "a",
                    Version = "1.0.0"
                };

                var nupkg = nuspec.CreateNupkg();
                nupkg.Files.Clear();
                nupkg.AddFile("lib/net45/a.dll");
                nupkg.AddFile("lib/netstandard1.0/a.dll");

                var path = nupkg.Save(workingDir).FullName;

                var log = new TestLogger();

                // Act
                var exitCode = await Program.MainCore(new[] { "nuspec", "frameworkassemblies", "add", path, "--assembly-name", "testA", "--assembly-name", "testB", "--framework", "net60", "--framework", "net70" }, log);

                NuspecReader reader = null;

                using (var package = new PackageArchiveReader(path))
                {
                    reader = package.NuspecReader;
                }

                // Assert
                exitCode.Should().Be(0, "no errors");

                reader.GetFrameworkReferenceGroups().Count().Should().Be(2);
                reader.GetFrameworkReferenceGroups().Select(e => e.TargetFramework.GetShortFolderName()).ShouldBeEquivalentTo(new[] { "net60", "net70" });

                foreach (var group in reader.GetFrameworkReferenceGroups())
                {
                    group.Items.ShouldBeEquivalentTo(new[] { "testA", "testB" });
                }
            }
        }
Example #7
0
        public async Task GivenThatIAddAFrameworkAssemblyToAnEmptyNuspecVerifyItIsAdded()
        {
            using (var workingDir = new TestFolder())
            {
                // Arrange
                var nuspec = new TestNuspec()
                {
                    Id      = "a",
                    Version = "1.0.0"
                };

                var nupkg = nuspec.CreateNupkg();
                nupkg.Files.Clear();
                nupkg.AddFile("lib/net45/a.dll");
                nupkg.AddFile("lib/netstandard1.0/a.dll");

                var path = nupkg.Save(workingDir).FullName;

                var log = new TestLogger();

                // Act
                var exitCode = await Program.MainCore(new[] { "nuspec", "frameworkassemblies", "add", path, "--assembly-name", "test" }, log);

                NuspecReader reader = null;

                using (var package = new PackageArchiveReader(path))
                {
                    reader = package.NuspecReader;
                }

                // Assert
                exitCode.Should().Be(0, "no errors");

                reader.GetFrameworkReferenceGroups().Count().Should().Be(1, "packages based frameworks are ignored");
                reader.GetFrameworkReferenceGroups().Single().Items.Count().Should().Be(1);
                reader.GetFrameworkReferenceGroups().Single().Items.Single().Should().Be("test");
                reader.GetFrameworkReferenceGroups().Single().TargetFramework.ShouldBeEquivalentTo(NuGetFramework.Parse("net45"));
            }
        }
        public async Task GivenThatIUpdateAnAlreadyCorrectFileNameVerifyNoop()
        {
            using (var workingDir = new TestFolder())
            {
                // Arrange
                var nuspec = new TestNuspec()
                {
                    Id      = "a",
                    Version = "1.0.0"
                };

                var zipFile = nuspec.CreateNupkg().Save(workingDir);

                var log = new TestLogger();

                // Act
                var exitCode = await Program.MainCore(new[] { "updatefilename", zipFile.FullName }, log);

                // Assert
                Assert.Equal(0, exitCode);
                Assert.True(File.Exists(zipFile.FullName));
            }
        }