예제 #1
0
        public void PackageDirectoriesAreMarkedForDeletionIsTrueWhenDeletemeFileInRootOfPackageRepository()
        {
            // Arrange
            var fileSystem = new MockFileSystem();
            fileSystem.CreateDirectory("A.1.0.0");
            fileSystem.AddFile("A.1.0.0.deleteme");

            var deleteOnRestartManager = new DeleteOnRestartManager(() => fileSystem);

            // Assert
            Assert.True(deleteOnRestartManager.PackageDirectoriesAreMarkedForDeletion);
        }
예제 #2
0
        public ConsoleHostNuGetPackageManager(IMonoDevelopSolutionManager solutionManager)
        {
            var restartManager = new DeleteOnRestartManager();

            settings = solutionManager.Settings;

            packageManager = new NuGetPackageManager(
                solutionManager.CreateSourceRepositoryProvider(),
                settings,
                new MonoDevelopSolutionManagerWrapper(solutionManager),
                restartManager
                );
        }
        public void PackageDirectoriesAreMarkedForDeletionIsTrueWhenDeletemeFileInRootOfPackageRepository()
        {
            // Arrange
            var fileSystem = new MockFileSystem();

            fileSystem.CreateDirectory("A.1.0.0");
            fileSystem.AddFile("A.1.0.0.deleteme");

            var deleteOnRestartManager = new DeleteOnRestartManager(() => fileSystem);

            // Assert
            Assert.True(deleteOnRestartManager.GetPackageDirectoriesMarkedForDeletion().Any());
        }
예제 #4
0
        public void PackageDirectoriesAreMarkedForDeletionIsFalsesWhenNoDeletemeFileInRootOfPackageRepository()
        {
            // Arrange
            var fileSystem = new MockFileSystem();
            fileSystem.CreateDirectory("A.1.0.0");
            fileSystem.AddFile("A.1.0.0");

            var deleteOnRestartManager = new DeleteOnRestartManager(() => fileSystem);

            // Act
            // Assert
            Assert.False(deleteOnRestartManager.GetPackageDirectoriesMarkedForDeletion().Any());
        }
        public void PackageDirectoriesAreMarkedForDeletionIsFalsesWhenNoDeletemeFileInRootOfPackageRepository()
        {
            // Arrange
            var fileSystem = new MockFileSystem();

            fileSystem.CreateDirectory("A.1.0.0");
            fileSystem.AddFile("A.1.0.0");

            var deleteOnRestartManager = new DeleteOnRestartManager(() => fileSystem);

            // Act
            // Assert
            Assert.False(deleteOnRestartManager.PackageDirectoriesAreMarkedForDeletion);
        }
예제 #6
0
        public void MarkPackageDirectoryForDeletionDoesNotAddDeletemeFileWhenDirectoryRemovalSuccessful()
        {
            // Arrange
            IPackage package = NuGet.Test.PackageUtility.CreatePackage("foo", "1.0.0");
            var fileSystem = new MockFileSystem();
            var pathResolver = new DefaultPackagePathResolver(fileSystem);
            string packageDirectoryPath = pathResolver.GetPackageDirectory(package);

            var deleteOnRestartManager = new DeleteOnRestartManager(() => fileSystem, () => pathResolver);

            // Act
            deleteOnRestartManager.MarkPackageDirectoryForDeletion(package, _ => package);

            // Assert
            Assert.False(fileSystem.DirectoryExists(packageDirectoryPath));
            Assert.False(fileSystem.FileExists(packageDirectoryPath + _deletionMarkerSuffix));
        }
        public void MarkPackageDirectoryForDeletionDoesNotAddDeletemeFileWhenDirectoryRemovalSuccessful()
        {
            // Arrange
            IPackage package              = NuGet.Test.PackageUtility.CreatePackage("foo", "1.0.0");
            var      fileSystem           = new MockFileSystem();
            var      pathResolver         = new DefaultPackagePathResolver(fileSystem);
            string   packageDirectoryPath = pathResolver.GetPackageDirectory(package);

            var deleteOnRestartManager = new DeleteOnRestartManager(() => fileSystem, () => pathResolver);

            // Act
            deleteOnRestartManager.MarkPackageDirectoryForDeletion(package);

            // Assert
            Assert.False(fileSystem.DirectoryExists(packageDirectoryPath));
            Assert.False(fileSystem.FileExists(packageDirectoryPath + _deletionMarkerSuffix));
        }
예제 #8
0
        public void MarkPackageDirectoryForDeletionDoesNotAddDeletemeFileWhenFileModified()
        {
            // Arrange
            IPackage package = NuGet.Test.PackageUtility.CreatePackage(id: "foo", version: "1.0.0", content: new string[] {}, assemblyReferences: new string[] {}, tools: new[] { "modifiedFile.txt" });
            var fileSystem = new MockFileSystem();
            var pathResolver = new DefaultPackagePathResolver(fileSystem);
            string packageDirectoryPath = pathResolver.GetPackageDirectory(package);
            string modifiedFilePath = Path.Combine("tools", "modifiedFile.txt");

            fileSystem.AddFile(Path.Combine(packageDirectoryPath, pathResolver.GetPackageFileName(package)), Stream.Null);
            fileSystem.AddFile(Path.Combine(packageDirectoryPath, modifiedFilePath), "Modified Content".AsStream());

            var deleteOnRestartManager = new DeleteOnRestartManager(() => fileSystem, () => pathResolver);

            // Act
            deleteOnRestartManager.MarkPackageDirectoryForDeletion(package, _ => package);

            // Assert
            Assert.True(fileSystem.DirectoryExists(packageDirectoryPath));
            Assert.True(fileSystem.FileExists(Path.Combine(packageDirectoryPath, modifiedFilePath)));
            Assert.False(fileSystem.FileExists(packageDirectoryPath + _deletionMarkerSuffix));
        }
        public void MarkPackageDirectoryForDeletionAddsDeletemeFileWhenDirectoryRemovalUnsuccessful()
        {
            // Arrange
            IPackage package              = NuGet.Test.PackageUtility.CreatePackage(id: "foo", version: "1.0.0", content: new string[] { }, assemblyReferences: new string[] { }, tools: new[] { "lockedFile.txt" });
            var      fileSystem           = new MockFileSystem();
            var      pathResolver         = new DefaultPackagePathResolver(fileSystem);
            string   packageDirectoryPath = pathResolver.GetPackageDirectory(package);
            string   lockedFilePath       = Path.Combine("tools", "lockedFile.txt");

            fileSystem.AddFile(Path.Combine(packageDirectoryPath, pathResolver.GetPackageFileName(package)), Stream.Null);
            fileSystem.AddFile(Path.Combine(packageDirectoryPath, packageDirectoryPath + Constants.ManifestExtension), Stream.Null);
            fileSystem.AddFile(Path.Combine(packageDirectoryPath, lockedFilePath), lockedFilePath.AsStream());

            var deleteOnRestartManager = new DeleteOnRestartManager(() => fileSystem, () => pathResolver);

            // Act
            deleteOnRestartManager.MarkPackageDirectoryForDeletion(package);

            // Assert
            Assert.True(fileSystem.DirectoryExists(packageDirectoryPath));
            Assert.True(fileSystem.FileExists(packageDirectoryPath + _deletionMarkerSuffix));
        }
예제 #10
0
        public void MarkPackageDirectoryForDeletionAddsDeletemeFileWhenDirectoryRemovalUnsuccessful()
        {
            // Arrange
            IPackage package = NuGet.Test.PackageUtility.CreatePackage(id: "foo", version: "1.0.0", content: new string[] { }, assemblyReferences: new string[] { }, tools: new[] { "lockedFile.txt" });
            var fileSystem = new MockFileSystem();
            var pathResolver = new DefaultPackagePathResolver(fileSystem);
            string packageDirectoryPath = pathResolver.GetPackageDirectory(package);
            string lockedFilePath = Path.Combine("tools", "lockedFile.txt");

            fileSystem.AddFile(Path.Combine(packageDirectoryPath, pathResolver.GetPackageFileName(package)), Stream.Null);
            fileSystem.AddFile(Path.Combine(packageDirectoryPath, packageDirectoryPath + Constants.ManifestExtension), Stream.Null);
            fileSystem.AddFile(Path.Combine(packageDirectoryPath, lockedFilePath), lockedFilePath.AsStream());

            var deleteOnRestartManager = new DeleteOnRestartManager(() => fileSystem, () => pathResolver);

            // Act
            deleteOnRestartManager.MarkPackageDirectoryForDeletion(package);

            // Assert
            Assert.True(fileSystem.DirectoryExists(packageDirectoryPath));
            Assert.True(fileSystem.FileExists(packageDirectoryPath + _deletionMarkerSuffix));
        }
예제 #11
0
        public void MarkPackageDirectoryForDeletionDoesNotAddDeletemeFileWhenFileAdded()
        {
            // Arrange
            IPackage package              = NuGet.Test.PackageUtility.CreatePackage(id: "foo", version: "1.0.0");
            var      fileSystem           = new MockFileSystem();
            var      pathResolver         = new DefaultPackagePathResolver(fileSystem);
            string   packageDirectoryPath = pathResolver.GetPackageDirectory(package);
            string   addedFilePath        = Path.Combine("tools", "addedFile.txt");

            fileSystem.AddFile(Path.Combine(packageDirectoryPath, pathResolver.GetPackageFileName(package)), Stream.Null);
            fileSystem.AddFile(Path.Combine(packageDirectoryPath, addedFilePath), "Added Content".AsStream());

            var deleteOnRestartManager = new DeleteOnRestartManager(() => fileSystem, () => pathResolver);

            // Act
            deleteOnRestartManager.MarkPackageDirectoryForDeletion(package, _ => package);

            // Assert
            Assert.True(fileSystem.DirectoryExists(packageDirectoryPath));
            Assert.True(fileSystem.FileExists(Path.Combine(packageDirectoryPath, addedFilePath)));
            Assert.False(fileSystem.FileExists(packageDirectoryPath + _deletionMarkerSuffix));
        }
        public void DeleteMarkedPackageDirectoriesRemovesDirectoriesAndAssociatedDeletemeFiles()
        {
            // Arrange
            IPackage packageA = NuGet.Test.PackageUtility.CreatePackage("A", "1.0.0");
            IPackage packageB = NuGet.Test.PackageUtility.CreatePackage("B", "1.0.0");

            var fileSystemProvider = new MockFileSystemProvider();
            var fileSystem         = fileSystemProvider.GetFileSystem("packages");

            var    pathResolver      = new DefaultPackagePathResolver(fileSystem);
            string packageADirectory = pathResolver.GetPackageDirectory(packageA);
            string packageBDirectory = pathResolver.GetPackageDirectory(packageB);
            string packageAFilePath  = Path.Combine(packageADirectory, pathResolver.GetPackageFileName(packageA));
            string packageBFilePath  = Path.Combine(packageBDirectory, pathResolver.GetPackageFileName(packageB));

            var mockRepositorySettings = new Mock <IRepositorySettings>();

            mockRepositorySettings.SetupGet(m => m.RepositoryPath).Returns("packages");

            fileSystem.AddFile(packageAFilePath, Stream.Null);
            fileSystem.AddFile(packageBFilePath, Stream.Null);
            fileSystem.AddFile(packageADirectory + _deletionMarkerSuffix, Stream.Null);

            var deleteOnRestartManager = new DeleteOnRestartManager(() => fileSystemProvider.GetFileSystem(mockRepositorySettings.Object.RepositoryPath),
                                                                    () => pathResolver);

            // Act
            deleteOnRestartManager.DeleteMarkedPackageDirectories();

            // Assert
            Assert.False(fileSystem.FileExists(packageAFilePath));
            Assert.False(fileSystem.DirectoryExists(packageADirectory));
            Assert.False(fileSystem.FileExists(packageADirectory + _deletionMarkerSuffix));
            Assert.True(fileSystem.FileExists(packageBFilePath));
            Assert.True(fileSystem.DirectoryExists(packageBDirectory));
            Assert.False(fileSystem.FileExists(packageBDirectory + _deletionMarkerSuffix));
        }
예제 #13
0
        public void DeleteMarkedPackageDirectoriesRemovesDirectoriesAndAssociatedDeletemeFiles()
        {
            // Arrange
            IPackage packageA = NuGet.Test.PackageUtility.CreatePackage("A", "1.0.0");
            IPackage packageB = NuGet.Test.PackageUtility.CreatePackage("B", "1.0.0");

            var fileSystemProvider = new MockFileSystemProvider();
            var fileSystem = fileSystemProvider.GetFileSystem("packages");

            var pathResolver = new DefaultPackagePathResolver(fileSystem);
            string packageADirectory = pathResolver.GetPackageDirectory(packageA);
            string packageBDirectory = pathResolver.GetPackageDirectory(packageB);
            string packageAFilePath = Path.Combine(packageADirectory, pathResolver.GetPackageFileName(packageA));
            string packageBFilePath = Path.Combine(packageBDirectory, pathResolver.GetPackageFileName(packageB));

            var mockRepositorySettings = new Mock<IRepositorySettings>();
            mockRepositorySettings.SetupGet(m => m.RepositoryPath).Returns("packages");

            fileSystem.AddFile(packageAFilePath, Stream.Null);
            fileSystem.AddFile(packageBFilePath, Stream.Null);
            fileSystem.AddFile(packageADirectory + _deletionMarkerSuffix, Stream.Null);

            var deleteOnRestartManager = new DeleteOnRestartManager(() => fileSystemProvider.GetFileSystem(mockRepositorySettings.Object.RepositoryPath),
                                                                    () => pathResolver);

            // Act
            deleteOnRestartManager.DeleteMarkedPackageDirectories();

            // Assert
            Assert.False(fileSystem.FileExists(packageAFilePath));
            Assert.False(fileSystem.DirectoryExists(packageADirectory));
            Assert.False(fileSystem.FileExists(packageADirectory + _deletionMarkerSuffix));
            Assert.True(fileSystem.FileExists(packageBFilePath));
            Assert.True(fileSystem.DirectoryExists(packageBDirectory));
            Assert.False(fileSystem.FileExists(packageBDirectory + _deletionMarkerSuffix));
        }