Пример #1
0
        public void PackageRestore(PackageRestoreTestCase testCase)
        {
            PackageManager packageManager = new PackageManager(this.workEnv, this.setup);

            this.SetupReporistoryForTest(testCase.Repository);
            this.SetupPackagesForTest(packageManager, testCase.PreSetup);

            packageManager.LocalSetup.Packages.Clear();
            packageManager.LocalSetup.Packages.AddRange(testCase.DesiredSetup.Select(name => new LocalPackage(name)));

            using (PackageEventListener listener = new PackageEventListener(packageManager))
            {
                // Uninstall packages that are installed but no longer present in the local setup config
                packageManager.UninstallNonRegisteredPackages();

                // Install, update or check packages that are in the local setup config
                List <LocalPackage> packagesToVerify = packageManager.LocalSetup.Packages.ToList();
                packageManager.OrderByDependencies(packagesToVerify);
                foreach (LocalPackage package in packagesToVerify)
                {
                    packageManager.VerifyPackage(package);
                }

                listener.AssertChanges(
                    testCase.Installed,
                    testCase.Uninstalled);
            }

            Assert.IsFalse(packageManager.IsPackageSyncRequired, "Package setup out of sync");
            this.AssertLocalSetup(packageManager.LocalSetup, testCase.DualityResults);
            this.AssertUpdateSchedule(testCase.Installed, testCase.Uninstalled);
        }
Пример #2
0
        public void UpdatePackage(PackageOperationTestCase testCase)
        {
            PackageManager packageManager = new PackageManager(this.workEnv, this.setup);

            // Prepare the test by setting up remote repository and pre-installed local packages
            this.SetupReporistoryForTest(testCase.Repository);
            this.SetupPackagesForTest(packageManager, testCase.Setup);

            using (PackageEventListener listener = new PackageEventListener(packageManager))
            {
                // Update the package to test
                packageManager.UpdatePackage(testCase.Target.Name);

                // Assert that the expected events were fired
                listener.AssertChanges(
                    testCase.Installed,
                    testCase.Uninstalled);
            }

            // Assert client state / setup after the install was done
            Assert.IsFalse(packageManager.IsPackageSyncRequired, "Package setup out of sync");
            this.AssertLocalSetup(packageManager.LocalSetup, testCase.DualityResults);
            this.AssertUpdateSchedule(testCase.Installed, testCase.Uninstalled);
        }