Example #1
0
        public void UninstallProjectLevelPackageWithNoProjectManagerThrows()
        {
            // Arrange
            var localRepository = new Mock <MockPackageRepository>()
            {
                CallBase = true
            }.As <ISharedPackageRepository>();

            localRepository.Setup(m => m.IsReferenced("foo", It.IsAny <Version>())).Returns(true);
            var sourceRepository = new MockPackageRepository();
            var fileSystem       = new MockFileSystem();
            var pathResolver     = new DefaultPackagePathResolver(fileSystem);
            var package          = PackageUtility.CreatePackage("foo", "1.0", new[] { "hello" });

            localRepository.Object.AddPackage(package);
            sourceRepository.AddPackage(package);
            var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, fileSystem, localRepository.Object, new Mock <IRecentPackageRepository>().Object);

            // Act
            ExceptionAssert.Throws <InvalidOperationException>(() => packageManager.UninstallPackage(null, "foo", version: null, forceRemove: false, removeDependencies: false, logger: NullLogger.Instance), "No project was specified.");
        }
Example #2
0
        public void UninstallPackageRemovesPackageIfPackageIsNotReferenced()
        {
            // Arrange
            var localRepository = new Mock <MockPackageRepository>()
            {
                CallBase = true
            }.As <ISharedPackageRepository>();

            localRepository.Setup(m => m.IsReferenced("foo", It.IsAny <Version>())).Returns(false);
            var sourceRepository = new MockPackageRepository();
            var fileSystem       = new MockFileSystem();
            var pathResolver     = new DefaultPackagePathResolver(fileSystem);
            var package          = PackageUtility.CreatePackage("foo", "1.0", new[] { "hello" });

            localRepository.Object.AddPackage(package);
            sourceRepository.AddPackage(package);
            var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, fileSystem, localRepository.Object, new Mock <IRecentPackageRepository>().Object);

            // Act
            packageManager.UninstallPackage(null, "foo", version: null, forceRemove: false, removeDependencies: false, logger: NullLogger.Instance);

            // Assert
            Assert.IsFalse(packageManager.LocalRepository.Exists(package));
        }
        public void UninstallPackageCallsMarkPackageDirectoryForDeletion()
        {
            // Arrange
            var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();
            var sourceRepository = new MockPackageRepository();
            var packageA = PackageUtility.CreatePackage("A");
            var deleteOnRestartManager = new Mock<IDeleteOnRestartManager>(MockBehavior.Strict);
            deleteOnRestartManager.Setup(d => d.MarkPackageDirectoryForDeletion(packageA)).Verifiable();
            localRepository.Object.AddPackage(packageA);
            sourceRepository.AddPackage(packageA);
            var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, new Mock<IFileSystemProvider>().Object, new MockFileSystem(), localRepository.Object,
                deleteOnRestartManager.Object, new Mock<VsPackageInstallerEvents>().Object);

            // Act
            packageManager.UninstallPackage(null, "A", version: null, forceRemove: false, removeDependencies: false, logger: NullLogger.Instance);

            // Assert
            deleteOnRestartManager.Verify();
        }
        public void UninstallPackageRemovesPackageIfPackageIsNotReferenced()
        {
            // Arrange            
            var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();
            localRepository.Setup(m => m.IsReferenced("foo", It.IsAny<SemanticVersion>())).Returns(false);
            var sourceRepository = new MockPackageRepository();
            var fileSystem = new MockFileSystem();
            var pathResolver = new DefaultPackagePathResolver(fileSystem);
            var package = PackageUtility.CreatePackage("foo", "1.0", new[] { "hello" });
            localRepository.Object.AddPackage(package);
            sourceRepository.AddPackage(package);
            var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, new Mock<IFileSystemProvider>().Object, fileSystem, localRepository.Object, new Mock<IDeleteOnRestartManager>().Object, new Mock<VsPackageInstallerEvents>().Object);

            // Act
            packageManager.UninstallPackage(null, "foo", version: null, forceRemove: false, removeDependencies: false, logger: NullLogger.Instance);

            // Assert
            Assert.False(packageManager.LocalRepository.Exists(package));
        }
        public void UninstallProjectLevelPackageWithNoProjectManagerThrows()
        {
            // Arrange            
            var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();
            localRepository.Setup(m => m.IsReferenced("foo", It.IsAny<SemanticVersion>())).Returns(true);
            var sourceRepository = new MockPackageRepository();
            var fileSystem = new MockFileSystem();
            var pathResolver = new DefaultPackagePathResolver(fileSystem);
            var package = PackageUtility.CreatePackage("foo", "1.0", new[] { "hello" });
            localRepository.Object.AddPackage(package);
            sourceRepository.AddPackage(package);
            var packageManager = new VsPackageManager(TestUtils.GetSolutionManager(), sourceRepository, new Mock<IFileSystemProvider>().Object, fileSystem, localRepository.Object, new Mock<IDeleteOnRestartManager>().Object, new Mock<VsPackageInstallerEvents>().Object);

            // Act
            ExceptionAssert.Throws<InvalidOperationException>(() => packageManager.UninstallPackage(null, "foo", version: null, forceRemove: false, removeDependencies: false, logger: NullLogger.Instance), "No project was specified.");
        }