Beispiel #1
0
        public void DependencyAnalyzerBuildAnalyzerContextTest()
        {
            log.Info("-----------------------------DependencyAnalyzer BuildAnalyzerContext-----------------------------");

            // Test setup.
            var tapPackage = new PackageDef()
            {
                Name = "Tap", Version = PluginManager.GetOpenTapAssembly().SemanticVersion
            };
            var packages = new List <PackageDef>();

            packages.Add(tapPackage);

            // Correct packages.
            using (var xmlText = File.OpenRead(Path.Combine(Directory.GetCurrentDirectory(), "TapPackages/MyPlugin1.xml")))
            {
                packages.AddRange(PackageDef.ManyFromXml(xmlText));

                // Multiple identical packages.
                xmlText.Seek(0, 0);
                packages.AddRange(PackageDef.ManyFromXml(xmlText));
            }

            // Reset test.
            packages.Clear();

            // No packages.
            var dependencyAnalyzer = DependencyAnalyzer.BuildAnalyzerContext(packages);

            Assert.IsTrue(dependencyAnalyzer.BrokenPackages.Count == 0, "No packages");
            log.Info("Multiple identical items - SUCCESS");
        }
Beispiel #2
0
        public void DependencyAnalyzerGetIssuesTest()
        {
            log.Info("-----------------------------DependencyAnalyzer GetIssues-----------------------------");

            // Test setup.
            var tapPackage = new PackageDef()
            {
                Name = "Tap", Version = SemanticVersion.Parse("7.0.700")
            };
            var packages = new List <PackageDef>();

            packages.Add(tapPackage);

            // Dependencies without any issues.
            using (var xmlText = File.OpenRead(Path.Combine(Directory.GetCurrentDirectory(), "TapPackages/MyPlugin1.xml")))
                packages.AddRange(PackageDef.ManyFromXml(xmlText));
            var dependencyAnalyzer = DependencyAnalyzer.BuildAnalyzerContext(packages);
            var issues             = dependencyAnalyzer.GetIssues(packages.Last());

            if (issues.Any())
            {
                Assert.Fail("Unexpected Dependency Issue: {1} {0} ", issues.First().IssueType, issues.First().PackageName);
            }
            log.Info("Dependencies without any issues - SUCCESS");

            // Reset test.
            packages = packages.Take(1).ToList();

            // Dependencies with issues (Tap newer than plugin).
            using (var xmlText = File.OpenRead(Path.Combine(Directory.GetCurrentDirectory(), "TapPackages/MyPlugin2.xml")))
            {
                var pkgs = PackageDef.ManyFromXml(xmlText);
                packages.AddRange(pkgs);
                Assert.IsTrue(pkgs.First().Version.Major == 1);
                Assert.IsTrue(pkgs.First().Version.Minor == 2);
                Assert.IsTrue(pkgs.First().Version.Patch == 3);
            }
            dependencyAnalyzer = DependencyAnalyzer.BuildAnalyzerContext(packages);
            issues             = dependencyAnalyzer.GetIssues(packages.Last());
            Assert.IsTrue(issues.Count == 1, "Dependencies with issues (Tap newer than plugin)");
            log.Info("Dependencies with issues (Tap newer than plugin) - SUCCESS");

            // Reset test.
            packages = packages.Take(1).ToList();

            // No dependencies.
            dependencyAnalyzer = DependencyAnalyzer.BuildAnalyzerContext(packages);
            issues             = dependencyAnalyzer.GetIssues(new PackageDef());
            Assert.IsTrue(issues.Count == 0, "No dependencies");
            log.Info("No dependencies - SUCCESS");
        }
Beispiel #3
0
        public void DependencyAnalyzerFilterRelatedTest()
        {
            log.Info("-----------------------------DependencyAnalyzer FilterRelated-----------------------------");

            // Test setup.
            var tapPackage = new PackageDef()
            {
                Name = "Tap", Version = SemanticVersion.Parse("9.0")
            };                                                                                         // TapVersion.GetTapEngineVersion().ToString() };
            var packages = new List <PackageDef>();

            packages.Add(tapPackage);
            using (var xmlText = File.OpenRead(Path.Combine(Directory.GetCurrentDirectory(), "TapPackages/MyPlugin3.xml")))
                packages.AddRange(PackageDef.ManyFromXml(xmlText));
            using (var xmlText = File.OpenRead(Path.Combine(Directory.GetCurrentDirectory(), "TapPackages/MyPlugin2.xml")))
                packages.AddRange(PackageDef.ManyFromXml(xmlText));
            using (var xmlText = File.OpenRead(Path.Combine(Directory.GetCurrentDirectory(), "TapPackages/MyPlugin1.xml")))
                packages.AddRange(PackageDef.ManyFromXml(xmlText));

            // No dependencies
            var dependencyAnalyzer = DependencyAnalyzer.BuildAnalyzerContext(packages.Take(2).ToList());
            var issues             = dependencyAnalyzer.FilterRelated(packages.Take(2).ToList());

            Assert.IsTrue(issues.BrokenPackages.Count == 0, "No dependencies");
            log.Info("No dependencies - SUCCESS");

            // Tap dependency
            dependencyAnalyzer = DependencyAnalyzer.BuildAnalyzerContext(packages.Take(3).ToList());
            issues             = dependencyAnalyzer.FilterRelated(packages.Take(3).ToList());
            Assert.IsTrue(issues.BrokenPackages.Count == 1, "Tap dependency");
            log.Info("Tap dependency - SUCCESS");

            // Several Tap dependencies
            dependencyAnalyzer = DependencyAnalyzer.BuildAnalyzerContext(packages.ToList());
            issues             = dependencyAnalyzer.FilterRelated(packages.ToList());
            Assert.IsTrue(issues.BrokenPackages.Count == 2, "Several Tap dependencies");
            log.Info("Several Tap dependencies - SUCCESS");
        }