Esempio n. 1
0
        public void FindLocalPackageThrowsWhenOnlyUnusedVersionOfPackageIsPresentInPackagesFolder()
        {
            // Arrange
            var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var pathResolver = new DefaultPackagePathResolver(projectSystem);
            var projectManager = new ProjectManager(sourceRepository, pathResolver, projectSystem, localRepository.Object);
            var project = TestUtils.GetProject("foo");
            var projects = new Project[] { project };

            var packageA10 = PackageUtility.CreatePackage("A", "1.0", new string[] { "hello.txt" });
            var packageA20 = PackageUtility.CreatePackage("A", "2.0", new string[] { "hello.txt" });
            var packageA30 = PackageUtility.CreatePackage("A", "3.0", new string[] { "hello.txt" });
            localRepository.Object.AddPackage(packageA10);
            localRepository.Object.AddPackage(packageA20);
            sourceRepository.AddPackage(packageA10);
            sourceRepository.AddPackage(packageA20);
            sourceRepository.AddPackage(packageA30);

            var packageManager = new VsPackageManager(
                TestUtils.GetSolutionManager(true, "foo", projects),
                sourceRepository,
                new Mock<IFileSystemProvider>().Object,
                projectSystem,
                localRepository.Object,
                new Mock<IDeleteOnRestartManager>().Object,
                new Mock<VsPackageInstallerEvents>().Object);

            bool appliesToProject;
            ExceptionAssert.Throws<PackageNotInstalledException>(() => packageManager.FindLocalPackage("A", out appliesToProject), 
                String.Format(CultureInfo.CurrentCulture, VsResources.PackageNotInstalledInAnyProject, "A"));
        }
Esempio n. 2
0
        public void FindLocalPackageWhenAnUnusedVersionOfPackageIsPresentInPackagesFolder()
        {
            // Arrange
            var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();
            localRepository.Setup(m => m.IsReferenced("A", new SemanticVersion("2.0"))).Returns(true);
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var pathResolver = new DefaultPackagePathResolver(projectSystem);
            var projectManager = new ProjectManager(sourceRepository, pathResolver, projectSystem, localRepository.Object);
            var project = TestUtils.GetProject("foo");
            var projects = new Project[] { project };

            var packageA10 = PackageUtility.CreatePackage("A", "1.0", new string[] { "hello.txt" });
            var packageA20 = PackageUtility.CreatePackage("A", "2.0", new string[] { "hello.txt" });
            var packageA30 = PackageUtility.CreatePackage("A", "3.0", new string[] { "hello.txt" });
            localRepository.Object.AddPackage(packageA10);
            sourceRepository.AddPackage(packageA10);
            sourceRepository.AddPackage(packageA20);
            sourceRepository.AddPackage(packageA30);

            var packageManager = new VsPackageManager(
                TestUtils.GetSolutionManager(true, "foo", projects),
                sourceRepository,
                new Mock<IFileSystemProvider>().Object,
                projectSystem,
                localRepository.Object,
                new Mock<IDeleteOnRestartManager>().Object,
                new Mock<VsPackageInstallerEvents>().Object);

            packageManager.InstallPackage(projectManager, "A", packageA20.Version, true, true, null);

            bool appliesToProject;
            IPackage package = packageManager.FindLocalPackage("A", out appliesToProject);
            Assert.True(package.Version.Version.Major == 2);
            Assert.True(appliesToProject);
        }