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));
        }
        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));
        }