コード例 #1
0
        public void ScriptsOutsideToolsFolder()
        {
            // Arrange
            var package = PackageUtility.CreatePackage(
                "A",
                content: new[] { "install.ps1" },
                assemblyReferences: new[] { "init.ps1" }
                );
            var rule = new MisplacedScriptFileRule();

            // Act
            IList <PackageIssue> issues = rule.Validate(package).ToList();

            // Assert
            Assert.Equal(2, issues.Count);

            PackageIssueTestHelper.AssertPackageIssue(
                issues[0],
                "PowerShell file outside tools folder.",
                "The script file 'content\\install.ps1' is outside the 'tools' folder and hence will not be executed during installation of this package.",
                "Move it into the 'tools' folder.");

            PackageIssueTestHelper.AssertPackageIssue(
                issues[1],
                "PowerShell file outside tools folder.",
                "The script file 'init.ps1' is outside the 'tools' folder and hence will not be executed during installation of this package.",
                "Move it into the 'tools' folder.");
        }
コード例 #2
0
        public void UnrecognizedScriptsInsideToolsFolder()
        {
            // Arrange
            var package = PackageUtility.CreatePackage(
                "A",
                tools: new[] { "hello.ps1", "install.ps1", "abc.ps1" }
                );
            var rule = new MisplacedScriptFileRule();

            // Act
            IList <PackageIssue> issues = rule.Validate(package).ToList();

            // Assert
            Assert.Equal(2, issues.Count);

            PackageIssueTestHelper.AssertPackageIssue(
                issues[0],
                "Unrecognized PowerShell file.",
                "The script file 'tools\\hello.ps1' is not recognized by NuGet and hence will not be executed during installation of this package.",
                "Rename it to install.ps1, uninstall.ps1 or init.ps1 and place it directly under 'tools'.");

            PackageIssueTestHelper.AssertPackageIssue(
                issues[1],
                "Unrecognized PowerShell file.",
                "The script file 'tools\\abc.ps1' is not recognized by NuGet and hence will not be executed during installation of this package.",
                "Rename it to install.ps1, uninstall.ps1 or init.ps1 and place it directly under 'tools'.");
        }
コード例 #3
0
        public void TwoAssembliesPlacedUnderLibHasTwoIssues()
        {
            // Arrange
            var package = PackageUtility.CreatePackage("A", assemblyReferences: new[] { "lib\\abc.dll", "lib\\def.winmd" });
            var rule    = new MisplacedAssemblyRule();

            // Act
            IList <PackageIssue> issues = rule.Validate(package).ToList();

            // Assert
            Assert.Equal(2, issues.Count);
            PackageIssueTestHelper.AssertPackageIssue(
                issues[0],
                "Assembly not inside a framework folder.",
                "The assembly 'lib\\abc.dll' is placed directly under 'lib' folder. It is recommended that assemblies be placed inside a framework-specific folder.",
                "Move it into a framework-specific folder. If this assembly is targeted for multiple frameworks, ignore this warning."
                );

            PackageIssueTestHelper.AssertPackageIssue(
                issues[1],
                "Assembly not inside a framework folder.",
                "The assembly 'lib\\def.winmd' is placed directly under 'lib' folder. It is recommended that assemblies be placed inside a framework-specific folder.",
                "Move it into a framework-specific folder. If this assembly is targeted for multiple frameworks, ignore this warning."
                );
        }
コード例 #4
0
        public void TransformFileOutsideContentFolderHasIssue()
        {
            // Arrange
            var package = PackageUtility.CreatePackage(
                "A",
                content: new[] { "say.cs.pp", "app.config.transform" },
                tools: new[] { "web.config.transform" },
                assemblyReferences: new[] { "one.cs.pp" });
            var rule = new MisplacedTransformFileRule();

            // Act
            IList <PackageIssue> issues = rule.Validate(package).ToList();

            // Assert
            Assert.Equal(2, issues.Count);

            PackageIssueTestHelper.AssertPackageIssue(
                issues[0],
                "Transform file outside content folder.",
                "The transform file 'tools\\web.config.transform' is outside the 'content' folder and hence will not be transformed during installation of this package.",
                "Move it into the 'content' folder.");

            PackageIssueTestHelper.AssertPackageIssue(
                issues[1],
                "Transform file outside content folder.",
                "The transform file 'one.cs.pp' is outside the 'content' folder and hence will not be transformed during installation of this package.",
                "Move it into the 'content' folder.");
        }
コード例 #5
0
 private void AssertPackageIssueWithPath(PackageIssue issue, string target)
 {
     PackageIssueTestHelper.AssertPackageIssue(
         issue,
         "Incompatible files in lib folder.",
         "The file '" + target + "' is not a valid assembly. If it is an XML documentation file or a .pdb file, there is no matching assembly specified in the same folder.",
         "Either remove this file from 'lib' folder or add a matching .dll for it.");
 }
        public void PackageWithLongDescriptionYieldOneIssue()
        {
            // Arrange
            var package = PackageUtility.CreatePackage("A", description: new string('a', 301));
            var rule    = new MissingSummaryRule();

            // Act
            IList <PackageIssue> issues = rule.Validate(package).ToList();

            // Assert
            Assert.Equal(1, issues.Count);
            PackageIssueTestHelper.AssertPackageIssue(
                issues[0],
                "Consider providing Summary text.",
                "The Description text is long but the Summary text is empty. This means the Description text will be truncated in the 'Manage NuGet Packages' dialog.",
                "Provide a brief summary of the package in the Summary field.");
        }
コード例 #7
0
        public void WinRTGenerateAnIssueForWinRTUnderContent()
        {
            // Arrange
            var package = PackageUtility.CreatePackage("A", "1.0", new[] { "winRT\\one.txt" });

            var rule = new WinRTNameIsObsoleteRule();

            // Act
            var results = rule.Validate(package).ToList();

            // Assert
            Assert.Equal(1, results.Count);
            PackageIssueTestHelper.AssertPackageIssue(
                results[0],
                "The framework name 'WinRT' is obsolete.",
                "The file at 'content\\winRT\\one.txt' uses the obsolete 'WinRT' as the framework folder.",
                "Replace 'WinRT' or 'WinRT45' with 'NetCore45'.");
        }
コード例 #8
0
        public void TwoAssembliesPlacedOutsideLibHasOneIssues()
        {
            // Arrange
            var package = PackageUtility.CreatePackage("A", assemblyReferences: new[] { "content\\abc.exe", "tools\\def.winmd" });
            var rule    = new MisplacedAssemblyRule();

            // Act
            IList <PackageIssue> issues = rule.Validate(package).ToList();

            // Assert
            Assert.Equal(1, issues.Count);

            PackageIssueTestHelper.AssertPackageIssue(
                issues[0],
                "Assembly outside lib folder.",
                "The assembly 'tools\\def.winmd' is not inside the 'lib' folder and hence it won't be added as reference when the package is installed into a project.",
                "Move it into the 'lib' folder if it should be referenced."
                );
        }
コード例 #9
0
        public void PackageWithValidCultureFolderButDoesNotSetLanguageAttributeHasOneIssue(string culture)
        {
            // Arrange
            var package = PackageUtility.CreatePackage(
                "A",
                content: new[] { "one", "two" },
                assemblyReferences: new[] { "lib\\" + culture + "\\abc.dll" });
            var rule = new InvalidFrameworkFolderRule();

            // Act
            IList <PackageIssue> issues = rule.Validate(package).ToList();

            // Assert
            Assert.Equal(1, issues.Count);
            PackageIssueTestHelper.AssertPackageIssue(
                issues[0],
                "Invalid framework folder.",
                "The folder '" + culture + "' under 'lib' is not recognized as a valid framework name or a supported culture identifier.",
                "Rename it to a valid framework name.");
        }