Example #1
0
        [Test] public void UpdateNonExistent()
        {
            PackageManager packageManager = new PackageManager(this.workEnv, this.setup);

            // Prepare the test by setting up remote repository and pre-installed local packages
            MockPackageSpec        dualityPluginA = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginA");
            MockPackageSpec        dualityPluginB = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginB");
            List <MockPackageSpec> repository     = new List <MockPackageSpec>();

            repository.Add(dualityPluginA);
            repository.Add(dualityPluginB);
            this.SetupReporistoryForTest(repository);

            // Install a regular, existing package
            packageManager.InstallPackage(dualityPluginA.Name);
            this.AssertLocalSetup(packageManager.LocalSetup, new [] { dualityPluginA });
            Assert.IsFalse(packageManager.IsPackageSyncRequired, "Package setup out of sync.");

            // Update the existing package
            packageManager.UpdatePackage(dualityPluginA.Name);

            // Update a package that does not exist at all
            Assert.Throws <InvalidOperationException>(() =>
            {
                packageManager.UpdatePackage(new PackageName("Unknown.Doesnt.Exist"));
            });

            // Update a package that is not installed
            Assert.Throws <InvalidOperationException>(() =>
            {
                packageManager.UpdatePackage(dualityPluginB.Name);
            });
        }
Example #2
0
        [Test] public void InstallNonExistent()
        {
            PackageManager packageManager = new PackageManager(this.workEnv, this.setup);

            // Prepare the test by setting up remote repository and pre-installed local packages
            MockPackageSpec        dualityPluginA = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginA");
            List <MockPackageSpec> repository     = new List <MockPackageSpec>();

            repository.Add(dualityPluginA);
            this.SetupReporistoryForTest(repository);

            // Install a non-existent package, invariant version
            Assert.Throws <InvalidOperationException>(() =>
            {
                packageManager.InstallPackage(new PackageName("Unknown.Doesnt.Exist"));
            });

            // Install a non-existent package, specific version
            Assert.Throws <InvalidOperationException>(() =>
            {
                packageManager.InstallPackage(new PackageName("Unknown.Doesnt.Exist", new Version(1, 0, 0, 0)));
            });

            // Install an existing package in a non-existent version
            Assert.Throws <InvalidOperationException>(() =>
            {
                packageManager.InstallPackage(new PackageName(dualityPluginA.Name.Id, new Version(9, 8, 7, 6)));
            });

            // Install a regular, existing package
            packageManager.InstallPackage(dualityPluginA.Name);
            this.AssertLocalSetup(packageManager.LocalSetup, new [] { dualityPluginA });
            Assert.IsFalse(packageManager.IsPackageSyncRequired, "Package setup out of sync.");
        }
Example #3
0
        [Test] public void GetLatestDualityPackages()
        {
            MockPackageSpec packageSpecNonDuality   = new MockPackageSpec("Some.Other.Package");
            MockPackageSpec packageSpecPlugin       = new MockPackageSpec("AdamsLair.Duality.TestPlugin", new Version(1, 0, 0, 0));
            MockPackageSpec packageSpecPluginLatest = new MockPackageSpec("AdamsLair.Duality.TestPlugin", new Version(1, 1, 0, 0));
            MockPackageSpec packageSpecSample       = new MockPackageSpec("AdamsLair.Duality.TestSample");

            packageSpecPlugin.Tags.Add(PackageManager.DualityTag);
            packageSpecPlugin.Tags.Add(PackageManager.PluginTag);
            packageSpecPluginLatest.Tags.Add(PackageManager.DualityTag);
            packageSpecPluginLatest.Tags.Add(PackageManager.PluginTag);
            packageSpecSample.Tags.Add(PackageManager.DualityTag);
            packageSpecSample.Tags.Add(PackageManager.SampleTag);

            packageSpecNonDuality.CreatePackage(TestPackageBuildPath, TestRepositoryPath);
            packageSpecPlugin.CreatePackage(TestPackageBuildPath, TestRepositoryPath);
            packageSpecPluginLatest.CreatePackage(TestPackageBuildPath, TestRepositoryPath);
            packageSpecSample.CreatePackage(TestPackageBuildPath, TestRepositoryPath);

            PackageManager     packageManager = new PackageManager(this.workEnv, this.setup);
            List <PackageInfo> packages       = packageManager.GetLatestDualityPackages().ToList();

            // We expect that only Duality packages are reported, and only the latest version of each.
            Assert.IsNotNull(packages);
            Assert.AreEqual(2, packages.Count);

            PackageInfo packagePluginInfo = packages.FirstOrDefault(item => item.Id == packageSpecPlugin.Name.Id);
            PackageInfo packageSampleInfo = packages.FirstOrDefault(item => item.Id == packageSpecSample.Name.Id);

            Assert.IsNotNull(packagePluginInfo);
            Assert.IsNotNull(packageSampleInfo);
            Assert.AreEqual(packageSpecPluginLatest.Name.Version, packagePluginInfo.Version);
        }
Example #4
0
        [Test] public void DuplicatePackage()
        {
            // Let's try to trick the package manager into having a duplicate version installed!
            PackageManager packageManager = new PackageManager(this.workEnv, this.setup);

            MockPackageSpec dualityPluginA_Old = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginA", new Version(0, 9, 0, 0));
            MockPackageSpec dualityPluginA_New = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginA", new Version(1, 0, 0, 0));
            MockPackageSpec dualityPluginB     = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginB", new Version(1, 0, 0, 0));
            MockPackageSpec dualityPluginC     = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginC", new Version(1, 0, 0, 0));

            dualityPluginB.Dependencies.Add(dualityPluginA_New.Name);
            dualityPluginC.Dependencies.Add(dualityPluginA_Old.Name);

            List <MockPackageSpec> repository = new List <MockPackageSpec>();

            repository.Add(dualityPluginA_Old);
            repository.Add(dualityPluginA_New);
            repository.Add(dualityPluginB);
            repository.Add(dualityPluginC);

            // Prepare the test by setting up remote repository and pre-installed local packages
            this.SetupReporistoryForTest(repository);

            // Install the old version first. Nothing special happens.
            packageManager.InstallPackage(dualityPluginA_Old.Name);
            this.AssertLocalSetup(packageManager.LocalSetup, new [] { dualityPluginA_Old });
            Assert.IsFalse(packageManager.IsPackageSyncRequired, "Package setup out of sync.");

            // Install a newer version without uninstalling the old one.
            // Expect the newer version to replace the old.
            packageManager.InstallPackage(dualityPluginA_New.Name);
            this.AssertLocalSetup(packageManager.LocalSetup, new [] { dualityPluginA_New });
            Assert.IsFalse(packageManager.IsPackageSyncRequired, "Package setup out of sync.");

            // Install an older version without uninstalling the newer one.
            // Expect the newer version to persist with no old version being installed.
            packageManager.InstallPackage(dualityPluginA_Old.Name);
            this.AssertLocalSetup(packageManager.LocalSetup, new [] { dualityPluginA_New });
            Assert.IsFalse(packageManager.IsPackageSyncRequired, "Package setup out of sync.");

            // Downgrade from new to old explicitly
            packageManager.UninstallPackage(dualityPluginA_New.Name);
            packageManager.InstallPackage(dualityPluginA_Old.Name);
            this.AssertLocalSetup(packageManager.LocalSetup, new [] { dualityPluginA_Old });
            Assert.IsFalse(packageManager.IsPackageSyncRequired, "Package setup out of sync.");

            // Install a package that depends on the newer version of the package.
            // Expect an update, but not a duplicate.
            packageManager.InstallPackage(dualityPluginB.Name);
            this.AssertLocalSetup(packageManager.LocalSetup, new [] { dualityPluginA_New, dualityPluginB });
            Assert.IsFalse(packageManager.IsPackageSyncRequired, "Package setup out of sync.");

            // Install a package that depends on the older version of the package.
            // Expect the newer version to be used because it was already there.
            packageManager.InstallPackage(dualityPluginC.Name);
            this.AssertLocalSetup(packageManager.LocalSetup, new [] { dualityPluginA_New, dualityPluginB, dualityPluginC });
            Assert.IsFalse(packageManager.IsPackageSyncRequired, "Package setup out of sync.");
        }
Example #5
0
        /// <summary>
        /// Creates a package spec with a mock Assembly file that is not tagged as a Duality-related package.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="version"></param>
        /// <returns></returns>
        public static MockPackageSpec CreateLibrary(string id, Version version = null)
        {
            MockPackageSpec package = new MockPackageSpec(id, version ?? new Version(1, 0, 0, 0));

            package.Files.Add(
                string.Format("{0}.dll", id),
                "lib");
            package.LocalMapping.Add(
                string.Format("lib\\{0}.dll", id),
                string.Format("{0}.dll", id));
            return(package);
        }
Example #6
0
        /// <summary>
        /// Creates a package spec with a mock Assembly file, tagged as a Duality core part or non-plugin package.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="version"></param>
        /// <returns></returns>
        public static MockPackageSpec CreateDualityCorePart(string id, Version version = null)
        {
            MockPackageSpec package = new MockPackageSpec(id, version ?? new Version(1, 0, 0, 0));

            package.Tags.Add(PackageManager.DualityTag);
            package.Files.Add(
                string.Format("{0}.dll", id),
                "lib");
            package.LocalMapping.Add(
                string.Format("lib\\{0}.dll", id),
                string.Format("{0}.dll", id));
            return(package);
        }
Example #7
0
        [Test] public void GetPackage()
        {
            MockPackageSpec packageSpec = new MockPackageSpec("AdamsLair.Duality.Test", new Version(1, 2, 3, 4));

            packageSpec.CreatePackage(TestPackageBuildPath, TestRepositoryPath);

            PackageManager packageManager = new PackageManager(this.workEnv, this.setup);
            PackageInfo    info           = packageManager.GetPackage(packageSpec.Name);

            Assert.IsNotNull(info);
            Assert.AreEqual(packageSpec.Name.Id, info.Id);
            Assert.AreEqual(packageSpec.Name.Version, info.Version);
            Assert.AreEqual(packageSpec.Name, info.Name);
        }
Example #8
0
        /// <summary>
        /// Creates a package spec with a mock Assembly file that is not tagged as a Duality-related package.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="version"></param>
        /// <param name="targetFramework"></param>
        /// <returns></returns>
        public static MockPackageSpec CreateLibrary(string id, Version version = null, string targetFramework = null)
        {
            MockPackageSpec package = new MockPackageSpec(id, version ?? new Version(1, 0, 0, 0));

            package.AddFile(
                string.Format("{0}.dll", id),
                targetFramework != null ?
                string.Format("lib\\{0}", targetFramework) :
                "lib");
            package.LocalMapping.Add(
                targetFramework != null ?
                string.Format("lib\\{0}\\{1}.dll", targetFramework, id) :
                string.Format("lib\\{0}.dll", id),
                string.Format("{0}.dll", id));
            return(package);
        }
Example #9
0
        /// <summary>
        /// Creates a package spec with a mock Assembly file, tagged as a Duality plugin.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="version"></param>
        /// <param name="targetFramework"></param>
        /// <returns></returns>
        public static MockPackageSpec CreateDualityPlugin(string id, Version version = null, string targetFramework = null)
        {
            MockPackageSpec package = new MockPackageSpec(id, version ?? new Version(1, 0, 0, 0));

            package.Tags.Add(PackageManager.DualityTag);
            package.Tags.Add(PackageManager.PluginTag);
            package.AddFile(
                string.Format("{0}.dll", id),
                targetFramework != null ?
                string.Format("lib\\{0}", targetFramework) :
                "lib");
            package.LocalMapping.Add(
                targetFramework != null ?
                string.Format("lib\\{0}\\{1}.dll", targetFramework, id) :
                string.Format("lib\\{0}.dll", id),
                string.Format("Plugins\\{0}.dll", id));
            return(package);
        }
Example #10
0
        private IEnumerable <PackageOperationTestCase> UpdatePackageTestCases()
        {
            List <PackageOperationTestCase> cases = new List <PackageOperationTestCase>();

            // Duality plugin without any dependencies
            MockPackageSpec dualityPluginA_Old = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginA", new Version(1, 0, 0, 0));
            MockPackageSpec dualityPluginA_New = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginA", new Version(1, 1, 0, 0));

            cases.Add(new PackageOperationTestCase(
                          "Duality Plugin, No Dependencies",
                          new [] { dualityPluginA_Old },
                          dualityPluginA_Old,
                          new [] { dualityPluginA_New }));

            // Duality plugin with Duality plugin dependencies
            MockPackageSpec dualityPluginB_Old = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginB", new Version(1, 0, 0, 0));
            MockPackageSpec dualityPluginB_New = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginB", new Version(1, 1, 0, 0));

            dualityPluginB_Old.Dependencies.Add(dualityPluginA_Old.Name);
            dualityPluginB_New.Dependencies.Add(dualityPluginA_New.Name);

            cases.Add(new PackageOperationTestCase(
                          "Duality Plugin, With Duality Dependencies",
                          new [] { dualityPluginA_Old, dualityPluginB_Old },
                          dualityPluginB_Old,
                          new [] { dualityPluginA_New, dualityPluginB_New }));

            // Duality plugin depending on a non-Duality NuGet package
            MockPackageSpec otherLibraryA_Old  = MockPackageSpec.CreateLibrary("Some.Other.TestLibraryA", new Version(1, 0, 0, 0));
            MockPackageSpec otherLibraryA_New  = MockPackageSpec.CreateLibrary("Some.Other.TestLibraryA", new Version(1, 1, 0, 0));
            MockPackageSpec dualityPluginC_Old = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginC", new Version(1, 0, 0, 0));
            MockPackageSpec dualityPluginC_New = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginC", new Version(1, 1, 0, 0));

            dualityPluginC_Old.Dependencies.Add(otherLibraryA_Old.Name);
            dualityPluginC_New.Dependencies.Add(otherLibraryA_New.Name);

            cases.Add(new PackageOperationTestCase(
                          "Duality Plugin, With Lib Dependencies",
                          new [] { otherLibraryA_Old, dualityPluginC_Old },
                          dualityPluginC_Old,
                          new [] { otherLibraryA_New, dualityPluginC_New }));

            return(cases);
        }
Example #11
0
        [Test] public void UninstallNonExistent()
        {
            PackageManager packageManager = new PackageManager(this.workEnv, this.setup);

            // Prepare the test by setting up remote repository and pre-installed local packages
            MockPackageSpec        dualityPluginA = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginA");
            List <MockPackageSpec> repository     = new List <MockPackageSpec>();

            repository.Add(dualityPluginA);
            this.SetupReporistoryForTest(repository);

            // Uninstall a package that is not installed
            packageManager.UninstallPackage(dualityPluginA.Name);

            // Uninstall a package that does not exist at all
            packageManager.UninstallPackage(new PackageName("Unknown.Doesnt.Exist"));
            packageManager.UninstallPackage(new PackageName("Unknown.Doesnt.Exist", new Version(9, 8, 7, 6)));
            packageManager.UninstallPackage(new PackageName(dualityPluginA.Name.Id, new Version(9, 8, 7, 6)));
        }
Example #12
0
        /// <summary>
        /// Creates a package spec with a mock Assembly file, tagged as a Duality plugin.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="version"></param>
        /// <param name="targetFrameworks"></param>
        /// <returns></returns>
        public static MockPackageSpec CreateDualityPlugin(string id, string[] targetFrameworks, Version version = null)
        {
            MockPackageSpec package = new MockPackageSpec(id, version ?? new Version(1, 0, 0, 0));

            package.Tags.Add(PackageManager.DualityTag);
            package.Tags.Add(PackageManager.PluginTag);
            foreach (string folder in targetFrameworks)
            {
                package.AddFile(
                    string.Format("{0}.dll", id),
                    folder != null ?
                    string.Format("lib\\{0}", folder) :
                    "lib");
                package.LocalMapping.Add(
                    folder != null ?
                    string.Format("lib\\{0}\\{1}.dll", folder, id) :
                    string.Format("lib\\{0}.dll", id),
                    string.Format("Plugins\\{0}.dll", id));
            }

            return(package);
        }
Example #13
0
        public PackageOperationTestCase(string name, IEnumerable <MockPackageSpec> setup, MockPackageSpec target, IEnumerable <MockPackageSpec> results)
        {
            this.name           = name;
            this.target         = target;
            this.setup          = (setup ?? Enumerable.Empty <MockPackageSpec>()).ToList();
            this.results        = (results ?? Enumerable.Empty <MockPackageSpec>()).ToList();
            this.installed      = this.results.Except(this.setup).ToList();
            this.uninstalled    = this.setup.Except(this.results).ToList();
            this.dualityResults = this.results
                                  .Where(p => p.Tags.Contains(PackageManager.DualityTag))
                                  .ToList();

            this.repository = new HashSet <MockPackageSpec>();
            this.repository.Add(this.target);
            foreach (MockPackageSpec packageSpec in this.results)
            {
                this.repository.Add(packageSpec);
            }
            foreach (MockPackageSpec packageSpec in this.setup)
            {
                this.repository.Add(packageSpec);
            }
        }
Example #14
0
        private IEnumerable <PackageRestoreTestCase> PackageRestoreTestCases()
        {
            // Create a shared repository for all test cases to save some space and redundancy
            MockPackageSpec libraryA1 = MockPackageSpec.CreateLibrary("Some.Other.LibraryA", new Version(5, 0, 1, 0));
            MockPackageSpec libraryA2 = MockPackageSpec.CreateLibrary("Some.Other.LibraryA", new Version(6, 1, 0, 0));
            MockPackageSpec pluginA1  = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginA", new Version(1, 0, 1, 0));
            MockPackageSpec pluginA2  = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginA", new Version(2, 1, 0, 0));
            MockPackageSpec pluginB1  = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginB", new Version(1, 0, 2, 0));
            MockPackageSpec pluginB2  = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginB", new Version(2, 2, 0, 0));
            MockPackageSpec pluginC1  = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginC", new Version(1, 1, 2, 0));
            MockPackageSpec pluginC2  = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginC", new Version(2, 2, 1, 0));
            MockPackageSpec pluginD1  = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginD", new Version(1, 1, 3, 0));

            pluginA1.Dependencies.Add(libraryA1.Name);
            pluginA2.Dependencies.Add(libraryA2.Name);
            pluginB1.Dependencies.Add(pluginA1.Name);
            pluginB2.Dependencies.Add(pluginA2.Name);
            pluginD1.Dependencies.Add(pluginA1.Name);

            List <MockPackageSpec> repository = new List <MockPackageSpec>();

            repository.Add(libraryA1);
            repository.Add(libraryA2);
            repository.Add(pluginA1);
            repository.Add(pluginA2);
            repository.Add(pluginB1);
            repository.Add(pluginB2);
            repository.Add(pluginC1);
            repository.Add(pluginC2);
            repository.Add(pluginD1);

            List <PackageRestoreTestCase> cases = new List <PackageRestoreTestCase>();

            // Full restore of all packages to the newest available versions
            {
                List <PackageName> configSetup = new List <PackageName>();
                configSetup.Add(pluginA1.Name.VersionInvariant);
                configSetup.Add(pluginB1.Name.VersionInvariant);

                cases.Add(new PackageRestoreTestCase(
                              "Full Restore, Newest",
                              repository,
                              new MockPackageSpec[0],
                              configSetup,
                              new [] { libraryA2, pluginA2, pluginB2 }));
            }

            // Full restore of all packages to specific package versions
            {
                List <PackageName> configSetup = new List <PackageName>();
                configSetup.Add(pluginA1.Name);
                configSetup.Add(pluginB1.Name);

                cases.Add(new PackageRestoreTestCase(
                              "Full Restore, Specific",
                              repository,
                              new MockPackageSpec[0],
                              configSetup,
                              new [] { libraryA1, pluginA1, pluginB1 }));
            }

            // Partial restore of packages to newest available versions
            {
                List <PackageName> configSetup = new List <PackageName>();
                configSetup.Add(pluginA1.Name);
                configSetup.Add(pluginC1.Name.VersionInvariant);

                cases.Add(new PackageRestoreTestCase(
                              "Partial Restore, Newest",
                              repository,
                              new [] { libraryA1, pluginA1 },
                              configSetup,
                              new [] { libraryA1, pluginA1, pluginC2 }));
            }

            // Partial restore of packages to specific package versions
            {
                List <PackageName> configSetup = new List <PackageName>();
                configSetup.Add(pluginA1.Name);
                configSetup.Add(pluginB1.Name);

                cases.Add(new PackageRestoreTestCase(
                              "Partial Restore, Specific",
                              repository,
                              new [] { libraryA1, pluginA1 },
                              configSetup,
                              new [] { libraryA1, pluginA1, pluginB1 }));
            }

            // Partial restore of packages to newest available versions implicitly
            // leading to an update of already installed packages
            {
                List <PackageName> configSetup = new List <PackageName>();
                configSetup.Add(pluginA1.Name);
                configSetup.Add(pluginB1.Name.VersionInvariant);

                cases.Add(new PackageRestoreTestCase(
                              "Partial Restore, Implicit Update",
                              repository,
                              new [] { libraryA1, pluginA1 },
                              configSetup,
                              new [] { libraryA2, pluginA2, pluginB2 }));
            }

            // Full uninstall of all packages because they've been removed from the config
            {
                List <PackageName> configSetup = new List <PackageName>();

                cases.Add(new PackageRestoreTestCase(
                              "Full Uninstall",
                              repository,
                              new [] { libraryA2, pluginA2, pluginB2 },
                              configSetup,
                              new MockPackageSpec[0]));
            }

            // Uninstall of a leaf package
            {
                List <PackageName> configSetup = new List <PackageName>();
                configSetup.Add(pluginA2.Name);

                cases.Add(new PackageRestoreTestCase(
                              "Partial Uninstall, Leaf",
                              repository,
                              new [] { libraryA2, pluginA2, pluginB2 },
                              configSetup,
                              new [] { libraryA2, pluginA2 }));
            }

            // Uninstall of a package that others depend on
            {
                List <PackageName> configSetup = new List <PackageName>();
                configSetup.Add(pluginB2.Name);

                // Duality will first uninstall pluginA2, but then re-install it
                // while verifying pluginB2, so we expect both an install and an
                // uninstall for that package.
                cases.Add(new PackageRestoreTestCase(
                              "Dependency Uninstall, Reinstall",
                              repository,
                              new [] { libraryA2, pluginA2, pluginB2 },
                              configSetup,
                              new [] { libraryA2, pluginA2, pluginB2 },
                              new [] { libraryA2, pluginA2 },
                              new [] { libraryA2, pluginA2 }));
            }

            // Uninstall of a package which has an older version that others depend on
            {
                List <PackageName> configSetup = new List <PackageName>();
                configSetup.Add(pluginD1.Name);

                // Duality will first uninstall pluginA2, but then re-install an
                // older version of it because pluginD1 requires that as a dependency.
                cases.Add(new PackageRestoreTestCase(
                              "Dependency Uninstall, Revert to Old",
                              repository,
                              new [] { libraryA2, pluginA2, pluginD1 },
                              configSetup,
                              new [] { libraryA1, pluginA1, pluginD1 }));
            }

            return(cases);
        }
Example #15
0
        private IEnumerable <PackageOperationTestCase> InstallPackageTestCases()
        {
            // Note that NuGet by default does not recognize lib subfolders during installation.
            // The files will be packaged with subfolders, but their EffectivePath won't include
            // them - which is why, unless Duality addresses this at some point in the future,
            // all plugins will end up in the Plugins root folder, regardless of their previous
            // hierarchy.

            List <PackageOperationTestCase> cases = new List <PackageOperationTestCase>();

            // Duality plugin without any dependencies
            MockPackageSpec dualityPluginA = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginA");

            dualityPluginA.Files.Add("Subfolder\\TestPluginA.Second.dll", "lib\\Subfolder");
            dualityPluginA.Files.Add("Data\\TestPluginA\\SomeRes.Pixmap.res", "content\\TestPluginA");
            dualityPluginA.Files.Add("Source\\Foo\\SomeCode.cs", "source\\Foo");
            dualityPluginA.LocalMapping.Add("lib\\Subfolder\\TestPluginA.Second.dll", "Plugins\\TestPluginA.Second.dll");
            dualityPluginA.LocalMapping.Add("content\\TestPluginA\\SomeRes.Pixmap.res", "Data\\TestPluginA\\SomeRes.Pixmap.res");
            dualityPluginA.LocalMapping.Add("source\\Foo\\SomeCode.cs", "Source\\Code\\AdamsLair.Duality.TestPluginA\\Foo\\SomeCode.cs");

            cases.Add(new PackageOperationTestCase(
                          "Duality Plugin, No Dependencies",
                          dualityPluginA,
                          new [] { dualityPluginA }));

            // Duality plugin depending on another Duality plugin
            MockPackageSpec dualityPluginB = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginB");

            dualityPluginB.Dependencies.Add(dualityPluginA.Name);

            cases.Add(new PackageOperationTestCase(
                          "Duality Plugin, With Duality Dependencies",
                          dualityPluginB,
                          new [] { dualityPluginB, dualityPluginA }));

            // Duality plugin depending on a non-Duality NuGet package
            MockPackageSpec otherLibraryA = MockPackageSpec.CreateLibrary("Some.Other.TestLibraryA");

            otherLibraryA.Files.Add("Data\\TestLibraryA\\SomeFile.txt", "content\\TestLibraryA");
            otherLibraryA.LocalMapping.Add("content\\TestLibraryA\\SomeFile.txt", "TestLibraryA\\SomeFile.txt");

            MockPackageSpec dualityPluginC = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginC");

            dualityPluginC.Dependencies.Add(otherLibraryA.Name);

            cases.Add(new PackageOperationTestCase(
                          "Duality Plugin, With Lib Dependencies",
                          dualityPluginC,
                          new [] { dualityPluginC, otherLibraryA }));

            // Duality package that is not a plugin
            MockPackageSpec dualityNonPluginA = MockPackageSpec.CreateDualityCorePart("AdamsLair.Duality.TestNonPluginA");

            dualityNonPluginA.Files.Add("Data\\TestNonPluginA\\SomeFile.txt", "content\\TestNonPluginA");
            dualityNonPluginA.LocalMapping.Add("content\\TestNonPluginA\\SomeFile.txt", "TestNonPluginA\\SomeFile.txt");

            cases.Add(new PackageOperationTestCase(
                          "Duality Non-Plugin Package",
                          dualityNonPluginA,
                          new [] { dualityNonPluginA }));

            // Installing a package that was already installed
            cases.Add(new PackageOperationTestCase(
                          "Package Already Installed",
                          new[] { dualityPluginA },
                          dualityPluginA,
                          new[] { dualityPluginA }));

            // Installing a package where one of its dependencies was already installed
            cases.Add(new PackageOperationTestCase(
                          "Package Dependency Already Installed",
                          new[] { dualityPluginA },
                          dualityPluginB,
                          new[] { dualityPluginA, dualityPluginB }));

            // Installing a package where an old version of one of its dependencies is already installed
            MockPackageSpec dualityPluginA_Old = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginA", new Version(0, 9, 0, 0));

            cases.Add(new PackageOperationTestCase(
                          "Older Package Dependency Installed",
                          new[] { dualityPluginA_Old },
                          dualityPluginB,
                          new[] { dualityPluginA, dualityPluginB }));

            // Installing a package where a newer version of one of its dependencies is already installed
            MockPackageSpec dualityPluginA_New = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginA", new Version(1, 1, 0, 0));

            cases.Add(new PackageOperationTestCase(
                          "Newer Package Dependency Installed",
                          new[] { dualityPluginA_New },
                          dualityPluginB,
                          new[] { dualityPluginA_New, dualityPluginB }));

            return(cases);
        }
Example #16
0
        private IEnumerable <PackageOperationTestCase> UninstallPackageTestCases()
        {
            List <PackageOperationTestCase> cases = new List <PackageOperationTestCase>();

            // Duality plugin without any dependencies
            MockPackageSpec dualityPluginA = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginA");

            cases.Add(new PackageOperationTestCase(
                          "Duality Plugin, No Dependencies",
                          new [] { dualityPluginA },
                          dualityPluginA,
                          new MockPackageSpec[0]));

            // Duality plugin with Duality plugin dependencies
            MockPackageSpec dualityPluginB = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginB");

            dualityPluginB.Dependencies.Add(dualityPluginA.Name);

            cases.Add(new PackageOperationTestCase(
                          "Duality Plugin, With Duality Dependencies",
                          new [] { dualityPluginA, dualityPluginB },
                          dualityPluginB,
                          new [] { dualityPluginA }));

            // Duality plugin depending on a non-Duality NuGet package
            MockPackageSpec otherLibraryA  = MockPackageSpec.CreateLibrary("Some.Other.TestLibraryA");
            MockPackageSpec dualityPluginC = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginC");

            dualityPluginC.Dependencies.Add(otherLibraryA.Name);

            cases.Add(new PackageOperationTestCase(
                          "Duality Plugin, With Lib Dependencies",
                          new [] { dualityPluginC, otherLibraryA },
                          dualityPluginC,
                          new MockPackageSpec[0]));

            // Duality plugin that has a dependency that other plugins still need
            MockPackageSpec dualityPluginD = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginD");

            dualityPluginD.Dependencies.Add(dualityPluginA.Name);

            cases.Add(new PackageOperationTestCase(
                          "Shared Dependencies",
                          new [] { dualityPluginA, dualityPluginB, dualityPluginD },
                          dualityPluginD,
                          new [] { dualityPluginA, dualityPluginB }));

            // Duality plugin that has multiple non-Duality dependencies that depend on each other
            MockPackageSpec otherLibraryB  = MockPackageSpec.CreateLibrary("Some.Other.TestLibraryB");
            MockPackageSpec otherLibraryC  = MockPackageSpec.CreateLibrary("Some.Other.TestLibraryC");
            MockPackageSpec otherLibraryD  = MockPackageSpec.CreateLibrary("Some.Other.TestLibraryD");
            MockPackageSpec otherLibraryE  = MockPackageSpec.CreateLibrary("Some.Other.TestLibraryE");
            MockPackageSpec dualityPluginE = MockPackageSpec.CreateDualityPlugin("AdamsLair.Duality.TestPluginE");

            otherLibraryB.Dependencies.Add(otherLibraryD.Name);
            otherLibraryB.Dependencies.Add(otherLibraryE.Name);
            otherLibraryD.Dependencies.Add(otherLibraryC.Name);
            // Order is important - biggest dependency set comes centered to trigger most problems
            dualityPluginE.Dependencies.Add(otherLibraryC.Name);
            dualityPluginE.Dependencies.Add(otherLibraryB.Name);
            dualityPluginE.Dependencies.Add(otherLibraryE.Name);

            cases.Add(new PackageOperationTestCase(
                          "Interconnected Dependencies",
                          new [] { otherLibraryD, otherLibraryC, otherLibraryE, otherLibraryB, dualityPluginE },
                          dualityPluginE,
                          new MockPackageSpec[0]));

            return(cases);
        }
Example #17
0
 public PackageOperationTestCase(string name, MockPackageSpec target, IEnumerable <MockPackageSpec> results) : this(name, null, target, results)
 {
 }