public void CallingEnableCurrentSolutionDoNotDownloadPackageIfPresentInLocalCache()
        {
            // Arrange
            string tempSolutionPath = CreateTempFolder();

            // setup SolutionManager
            var solutionManager = new Mock<ISolutionManager>();
            solutionManager.Setup(p => p.IsSolutionOpen).Returns(true);
            solutionManager.Setup(p => p.SolutionDirectory).Returns(tempSolutionPath);

            // setup file system
            var fileSystem = new PhysicalFileSystem(tempSolutionPath);
            var fileSystemProvider = new Mock<IFileSystemProvider>(MockBehavior.Strict);
            fileSystemProvider.Setup(p => p.GetFileSystem(tempSolutionPath)).Returns(fileSystem);

            var nugetFolderFileSystem = new PhysicalFileSystem(tempSolutionPath + "\\.nuget");
            fileSystemProvider.Setup(p => p.GetFileSystem(tempSolutionPath + "\\.nuget")).Returns(nugetFolderFileSystem);

            // setup DTE
            var dte = new Mock<DTE>();

            var projectItems = new Mock<ProjectItems>();
            var solutionFolder = new Mock<Project>();
            solutionFolder.Setup(s => s.Name).Returns(".nuget");
            solutionFolder.SetupGet(s => s.ProjectItems).Returns(projectItems.Object);

            var solution = new Mock<Solution>();
            solution.As<Solution2>().Setup(p => p.AddSolutionFolder(".nuget")).Returns(solutionFolder.Object);

            var projects = new MockProjects(new Project[0]);
            solution.As<Solution2>().Setup(s => s.Projects).Returns(projects);
            dte.SetupGet(p => p.Solution).Returns(solution.Object);

            // setup package repository
            var packageRepository = new MockPackageRepository();
            var packageA = new Mock<IPackage>(MockBehavior.Strict);
            packageA.Setup(p => p.Id).Returns("NuGet.Build");
            packageA.Setup(p => p.Version).Returns(new SemanticVersion("1.0"));
            packageA.Setup(p => p.IsLatestVersion).Returns(true);
            packageA.Setup(p => p.Listed).Returns(true);

            var packageB = new Mock<IPackage>(MockBehavior.Strict);
            packageB.Setup(p => p.Id).Returns("NuGet.CommandLine");
            packageB.Setup(p => p.Version).Returns(new SemanticVersion("2.0"));
            packageB.Setup(p => p.IsLatestVersion).Returns(true);
            packageB.Setup(p => p.Listed).Returns(true);

            packageRepository.AddPackage(packageA.Object);
            packageRepository.AddPackage(packageB.Object);

            var packageRepositoryFactory = new Mock<IPackageRepositoryFactory>(MockBehavior.Strict);
            packageRepositoryFactory.Setup(p => p.CreateRepository("x:\\nugetsource")).Returns(packageRepository);

            var packageSourceProvider = new Mock<IPackageSourceProvider>();
            packageSourceProvider.Setup(p => p.LoadPackageSources()).Returns(new[]
                                                                             {
                                                                                 new PackageSource("x:\\nugetsource"),
                                                                                 new PackageSource("y:\\me", "unabled", isEnabled: false), 
                                                                             });

            var localCache = new MockPackageRepository();
            localCache.Add(PackageUtility.CreatePackage(
               "NuGet.Build",
               version: "1.0",
               tools: new string[] { "NuGet.targets" },
               dependencies: new PackageDependency[] { new PackageDependency("NuGet.CommandLine") },
               listed: true));
            localCache.Add(PackageUtility.CreatePackage(
                "NuGet.CommandLine",
                version: "2.0",
                tools: new string[] { "NuGet.exe" },
                listed: true));

            var packageRestore = CreateInstance(
                dte.Object,
                solutionManager.Object,
                fileSystemProvider.Object,
                packageRepositoryFactory.Object,
                localCache: localCache,
                packageSourceProvider: packageSourceProvider.Object);

            // Act 
            packageRestore.EnableCurrentSolutionForRestore(fromActivation: false);

            // Assert
            packageA.Verify(p => p.GetFiles(), Times.Never());
            packageB.Verify(p => p.GetFiles(), Times.Never());
        }
        public void CallingEnableCurrentSolutionDownloadPrereleasePackagesButDoNotUnlistedPackage()
        {
            // Arrange
            string tempSolutionPath = CreateTempFolder();

            // setup SolutionManager
            var solutionManager = new Mock<ISolutionManager>();
            solutionManager.Setup(p => p.IsSolutionOpen).Returns(true);
            solutionManager.Setup(p => p.SolutionDirectory).Returns(tempSolutionPath);

            // setup file system
            var fileSystem = new PhysicalFileSystem(tempSolutionPath);
            var fileSystemProvider = new Mock<IFileSystemProvider>();
            fileSystemProvider.Setup(p => p.GetFileSystem(tempSolutionPath)).Returns(fileSystem);

            var nugetFolderFileSystem = new PhysicalFileSystem(tempSolutionPath + "\\.nuget");
            fileSystemProvider.Setup(p => p.GetFileSystem(tempSolutionPath + "\\.nuget")).Returns(nugetFolderFileSystem);

            // default app settings
            var defaultAppSettings = new Mock<ISettings>();
            defaultAppSettings.Setup(s => s.GetValue("packageRestore", "enabled")).Returns("false");

            // setup DTE
            var dte = new Mock<DTE>();

            var projectItems = new Mock<ProjectItems>();
            var solutionFolder = new Mock<Project>();
            solutionFolder.Setup(s => s.Name).Returns(".nuget");
            solutionFolder.SetupGet(s => s.ProjectItems).Returns(projectItems.Object);

            var solution = new Mock<Solution>();
            solution.As<Solution2>().Setup(p => p.AddSolutionFolder(".nuget")).Returns(solutionFolder.Object);

            var projects = new MockProjects(new Project[0]);
            solution.As<Solution2>().Setup(s => s.Projects).Returns(projects);
            dte.SetupGet(p => p.Solution).Returns(solution.Object);

            // setup package repository
            var packageRepository = new MockPackageRepository();
            packageRepository.Add(PackageUtility.CreatePackage(
                "NuGet.Build",
                version: "1.0",
                tools: new string[] { "NuGet.targets" },
                dependencies: new PackageDependency[] { new PackageDependency("NuGet.CommandLine") }));

            // this package contains 'invalid.targets' in the tools folder. 
            // it shouldn't be installed because it is unlisted.
            packageRepository.Add(PackageUtility.CreatePackage(
                "NuGet.Build",
                version: "2.0",
                tools: new string[] { "invalid.targets" },
                dependencies: new PackageDependency[] { new PackageDependency("NuGet.CommandLine") },
                listed: false));

            // this verify that we accepts prerelease packages
            packageRepository.Add(PackageUtility.CreatePackage(
                "NuGet.CommandLine",
                version: "1.0-alpha",
                tools: new string[] { "NuGet.exe" }));
            var packageRepositoryFactory = new Mock<IPackageRepositoryFactory>();
            packageRepositoryFactory.Setup(p => p.CreateRepository(NuGetConstants.DefaultFeedUrl)).Returns(packageRepository);
            var packageSourceProvider = new Mock<IPackageSourceProvider>();
            packageSourceProvider.Setup(p => p.LoadPackageSources()).Returns(new[]
                                                                             {
                                                                                 new PackageSource(NuGetConstants.DefaultFeedUrl)
                                                                             });
            var packageRestore = CreateInstance(
                dte.Object,
                solutionManager.Object,
                fileSystemProvider.Object,
                packageRepositoryFactory.Object,
                packageSourceProvider: packageSourceProvider.Object,
                settings: defaultAppSettings.Object);

            // Act 
            packageRestore.EnableCurrentSolutionForRestore(fromActivation: false);

            // Assert

            // verify that the files are copied to the .nuget sub folder under solution
            Assert.True(Directory.Exists(Path.Combine(tempSolutionPath, ".nuget")));
            Assert.True(File.Exists(Path.Combine(tempSolutionPath, ".nuget\\NuGet.exe")));
            Assert.True(File.Exists(Path.Combine(tempSolutionPath, ".nuget\\NuGet.targets")));

            // verify that solution folder 'nuget' is added to solution
            solution.As<Solution2>().Verify(p => p.AddSolutionFolder(".nuget"));
            projectItems.Verify(p => p.AddFromFile(tempSolutionPath + "\\.nuget\\NuGet.exe"));
            projectItems.Verify(p => p.AddFromFile(tempSolutionPath + "\\.nuget\\NuGet.targets"));

            // verify that the Source Control mode is disabled
            var settings = new Settings(nugetFolderFileSystem);
            Assert.True(settings.IsSourceControlDisabled());

            // verify that package restore consent is not set
            defaultAppSettings.Verify(
                s => s.SetValue("packageRestore", "enabled", It.Is<string>(v => v == "true" || v == "1")), Times.Never());
        }
        public void CallingEnableCurrentSolutionWillAddPackagesToMachineCache()
        {
            // Arrange
            string tempSolutionPath = CreateTempFolder();

            // setup SolutionManager
            var solutionManager = new Mock<ISolutionManager>();
            solutionManager.Setup(p => p.IsSolutionOpen).Returns(true);
            solutionManager.Setup(p => p.SolutionDirectory).Returns(tempSolutionPath);

            // setup file system
            var fileSystem = new PhysicalFileSystem(tempSolutionPath);
            var fileSystemProvider = new Mock<IFileSystemProvider>();
            fileSystemProvider.Setup(p => p.GetFileSystem(tempSolutionPath)).Returns(fileSystem);

            var nugetFolderFileSystem = new PhysicalFileSystem(tempSolutionPath + "\\.nuget");
            fileSystemProvider.Setup(p => p.GetFileSystem(tempSolutionPath + "\\.nuget")).Returns(nugetFolderFileSystem);

            // setup DTE
            var dte = new Mock<DTE>();

            var projectItems = new Mock<ProjectItems>();
            var solutionFolder = new Mock<Project>();
            solutionFolder.Setup(s => s.Name).Returns(".nuget");
            solutionFolder.SetupGet(s => s.ProjectItems).Returns(projectItems.Object);

            var solution = new Mock<Solution>();
            solution.As<Solution2>().Setup(p => p.AddSolutionFolder(".nuget")).Returns(solutionFolder.Object);

            var projects = new MockProjects(new Project[0]);
            solution.As<Solution2>().Setup(s => s.Projects).Returns(projects);
            dte.SetupGet(p => p.Solution).Returns(solution.Object);

            // setup package repository
            var packageRepository = new MockPackageRepository();
            packageRepository.Add(PackageUtility.CreatePackage(
                "NuGet.Build",
                version: "1.0",
                tools: new string[] { "NuGet.targets" },
                dependencies: new PackageDependency[] { new PackageDependency("NuGet.CommandLine") }));
            packageRepository.Add(PackageUtility.CreatePackage(
                "NuGet.CommandLine",
                version: "2.0",
                tools: new string[] { "NuGet.exe" }));
            var packageRepositoryFactory = new Mock<IPackageRepositoryFactory>();
            packageRepositoryFactory.Setup(p => p.CreateRepository("x:\\nugetsource")).Returns(packageRepository);

            var packageSourceProvider = new Mock<IPackageSourceProvider>();
            packageSourceProvider.Setup(p => p.LoadPackageSources()).Returns(new[]
                                                                             {
                                                                                 new PackageSource("x:\\nugetsource")
                                                                             });
 
            var localCache = new MockPackageRepository();

            var packageRestore = CreateInstance(
                dte.Object,
                solutionManager.Object,
                fileSystemProvider.Object,
                packageRepositoryFactory.Object,
                localCache: localCache,
                packageSourceProvider: packageSourceProvider.Object);

            // Act 
            packageRestore.EnableCurrentSolutionForRestore(fromActivation: false);

            // Assert
            var cachePackages = localCache.GetPackages().ToList();
            Assert.Equal(2, cachePackages.Count);
            Assert.Equal("NuGet.Build", cachePackages[0].Id);
            Assert.Equal(new SemanticVersion("1.0"), cachePackages[0].Version);
            Assert.Equal("NuGet.CommandLine", cachePackages[1].Id);
            Assert.Equal(new SemanticVersion("2.0"), cachePackages[1].Version);
        }
Exemplo n.º 4
0
        public void CallingEnableCurrentSolutionDownloadPrereleasePackagesButDoNotUnlistedPackage()
        {
            // Arrange
            string tempSolutionPath = CreateTempFolder();

            // setup SolutionManager
            var solutionManager = new Mock <ISolutionManager>();

            solutionManager.Setup(p => p.IsSolutionOpen).Returns(true);
            solutionManager.Setup(p => p.SolutionDirectory).Returns(tempSolutionPath);

            // setup file system
            var fileSystem         = new PhysicalFileSystem(tempSolutionPath);
            var fileSystemProvider = new Mock <IFileSystemProvider>();

            fileSystemProvider.Setup(p => p.GetFileSystem(tempSolutionPath)).Returns(fileSystem);

            var nugetFolderFileSystem = new PhysicalFileSystem(tempSolutionPath + "\\.nuget");

            fileSystemProvider.Setup(p => p.GetFileSystem(tempSolutionPath + "\\.nuget")).Returns(nugetFolderFileSystem);

            // default app settings
            var defaultAppSettings = new Mock <ISettings>();

            defaultAppSettings.Setup(s => s.GetValue("packageRestore", "enabled")).Returns("false");

            // setup DTE
            var dte = new Mock <DTE>();

            var projectItems   = new Mock <ProjectItems>();
            var solutionFolder = new Mock <Project>();

            solutionFolder.Setup(s => s.Name).Returns(".nuget");
            solutionFolder.SetupGet(s => s.ProjectItems).Returns(projectItems.Object);

            var solution = new Mock <Solution>();

            solution.As <Solution2>().Setup(p => p.AddSolutionFolder(".nuget")).Returns(solutionFolder.Object);

            var projects = new MockProjects(new Project[0]);

            solution.As <Solution2>().Setup(s => s.Projects).Returns(projects);
            dte.SetupGet(p => p.Solution).Returns(solution.Object);

            // setup package repository
            var packageRepository = new MockPackageRepository();

            packageRepository.Add(PackageUtility.CreatePackage(
                                      "NuGet.Build",
                                      version: "1.0",
                                      tools: new string[] { "NuGet.targets" },
                                      dependencies: new PackageDependency[] { new PackageDependency("NuGet.CommandLine") }));

            // this package contains 'invalid.targets' in the tools folder.
            // it shouldn't be installed because it is unlisted.
            packageRepository.Add(PackageUtility.CreatePackage(
                                      "NuGet.Build",
                                      version: "2.0",
                                      tools: new string[] { "invalid.targets" },
                                      dependencies: new PackageDependency[] { new PackageDependency("NuGet.CommandLine") },
                                      listed: false));

            // this verify that we accepts prerelease packages
            packageRepository.Add(PackageUtility.CreatePackage(
                                      "NuGet.CommandLine",
                                      version: "1.0-alpha",
                                      tools: new string[] { "NuGet.exe" }));
            var packageRepositoryFactory = new Mock <IPackageRepositoryFactory>();

            packageRepositoryFactory.Setup(p => p.CreateRepository(NuGetConstants.DefaultFeedUrl)).Returns(packageRepository);
            var packageSourceProvider = new Mock <IVsPackageSourceProvider>();

            packageSourceProvider.Setup(p => p.LoadPackageSources()).Returns(new[]
            {
                new PackageSource(NuGetConstants.DefaultFeedUrl)
            });
            var packageRestore = CreateInstance(
                dte.Object,
                solutionManager.Object,
                fileSystemProvider.Object,
                packageRepositoryFactory.Object,
                packageSourceProvider: packageSourceProvider.Object,
                settings: defaultAppSettings.Object);

            // Act
            packageRestore.EnableCurrentSolutionForRestore(fromActivation: false);

            // Assert

            // verify that the files are copied to the .nuget sub folder under solution
            Assert.True(Directory.Exists(Path.Combine(tempSolutionPath, ".nuget")));
            Assert.True(File.Exists(Path.Combine(tempSolutionPath, ".nuget\\NuGet.exe")));
            Assert.True(File.Exists(Path.Combine(tempSolutionPath, ".nuget\\NuGet.targets")));

            // verify that solution folder 'nuget' is added to solution
            solution.As <Solution2>().Verify(p => p.AddSolutionFolder(".nuget"));
            projectItems.Verify(p => p.AddFromFile(tempSolutionPath + "\\.nuget\\NuGet.exe"));
            projectItems.Verify(p => p.AddFromFile(tempSolutionPath + "\\.nuget\\NuGet.targets"));

            // verify that the Source Control mode is disabled
            var settings = new Settings(nugetFolderFileSystem);

            Assert.True(settings.IsSourceControlDisabled());

            // verify that package restore consent is not set
            defaultAppSettings.Verify(
                s => s.SetValue("packageRestore", "enabled", It.Is <string>(v => v == "true" || v == "1")), Times.Never());
        }
Exemplo n.º 5
0
        public void CallingEnableCurrentSolutionDoNotDownloadPackageIfPresentInLocalCache()
        {
            // Arrange
            string tempSolutionPath = CreateTempFolder();

            // setup SolutionManager
            var solutionManager = new Mock <ISolutionManager>();

            solutionManager.Setup(p => p.IsSolutionOpen).Returns(true);
            solutionManager.Setup(p => p.SolutionDirectory).Returns(tempSolutionPath);

            // setup file system
            var fileSystem         = new PhysicalFileSystem(tempSolutionPath);
            var fileSystemProvider = new Mock <IFileSystemProvider>(MockBehavior.Strict);

            fileSystemProvider.Setup(p => p.GetFileSystem(tempSolutionPath)).Returns(fileSystem);

            var nugetFolderFileSystem = new PhysicalFileSystem(tempSolutionPath + "\\.nuget");

            fileSystemProvider.Setup(p => p.GetFileSystem(tempSolutionPath + "\\.nuget")).Returns(nugetFolderFileSystem);

            // setup DTE
            var dte = new Mock <DTE>();

            var projectItems   = new Mock <ProjectItems>();
            var solutionFolder = new Mock <Project>();

            solutionFolder.Setup(s => s.Name).Returns(".nuget");
            solutionFolder.SetupGet(s => s.ProjectItems).Returns(projectItems.Object);

            var solution = new Mock <Solution>();

            solution.As <Solution2>().Setup(p => p.AddSolutionFolder(".nuget")).Returns(solutionFolder.Object);

            var projects = new MockProjects(new Project[0]);

            solution.As <Solution2>().Setup(s => s.Projects).Returns(projects);
            dte.SetupGet(p => p.Solution).Returns(solution.Object);

            // setup package repository
            var packageRepository = new MockPackageRepository();
            var packageA          = new Mock <IPackage>(MockBehavior.Strict);

            packageA.Setup(p => p.Id).Returns("NuGet.Build");
            packageA.Setup(p => p.Version).Returns(new SemanticVersion("1.0"));
            packageA.Setup(p => p.IsLatestVersion).Returns(true);
            packageA.Setup(p => p.Listed).Returns(true);

            var packageB = new Mock <IPackage>(MockBehavior.Strict);

            packageB.Setup(p => p.Id).Returns("NuGet.CommandLine");
            packageB.Setup(p => p.Version).Returns(new SemanticVersion("2.0"));
            packageB.Setup(p => p.IsLatestVersion).Returns(true);
            packageB.Setup(p => p.Listed).Returns(true);

            packageRepository.AddPackage(packageA.Object);
            packageRepository.AddPackage(packageB.Object);

            var packageRepositoryFactory = new Mock <IPackageRepositoryFactory>(MockBehavior.Strict);

            packageRepositoryFactory.Setup(p => p.CreateRepository("x:\\nugetsource")).Returns(packageRepository);

            var packageSourceProvider = new Mock <IVsPackageSourceProvider>();

            packageSourceProvider.Setup(p => p.LoadPackageSources()).Returns(new[]
            {
                new PackageSource("x:\\nugetsource"),
                new PackageSource("y:\\me", "unabled", isEnabled: false),
            });

            var localCache = new MockPackageRepository();

            localCache.Add(PackageUtility.CreatePackage(
                               "NuGet.Build",
                               version: "1.0",
                               tools: new string[] { "NuGet.targets" },
                               dependencies: new PackageDependency[] { new PackageDependency("NuGet.CommandLine") },
                               listed: true));
            localCache.Add(PackageUtility.CreatePackage(
                               "NuGet.CommandLine",
                               version: "2.0",
                               tools: new string[] { "NuGet.exe" },
                               listed: true));

            var packageRestore = CreateInstance(
                dte.Object,
                solutionManager.Object,
                fileSystemProvider.Object,
                packageRepositoryFactory.Object,
                localCache: localCache,
                packageSourceProvider: packageSourceProvider.Object);

            // Act
            packageRestore.EnableCurrentSolutionForRestore(fromActivation: false);

            // Assert
            packageA.Verify(p => p.GetFiles(), Times.Never());
            packageB.Verify(p => p.GetFiles(), Times.Never());
        }
Exemplo n.º 6
0
        public void CallingEnableCurrentSolutionWillAddPackagesToMachineCache()
        {
            // Arrange
            string tempSolutionPath = CreateTempFolder();

            // setup SolutionManager
            var solutionManager = new Mock <ISolutionManager>();

            solutionManager.Setup(p => p.IsSolutionOpen).Returns(true);
            solutionManager.Setup(p => p.SolutionDirectory).Returns(tempSolutionPath);

            // setup file system
            var fileSystem         = new PhysicalFileSystem(tempSolutionPath);
            var fileSystemProvider = new Mock <IFileSystemProvider>();

            fileSystemProvider.Setup(p => p.GetFileSystem(tempSolutionPath)).Returns(fileSystem);

            var nugetFolderFileSystem = new PhysicalFileSystem(tempSolutionPath + "\\.nuget");

            fileSystemProvider.Setup(p => p.GetFileSystem(tempSolutionPath + "\\.nuget")).Returns(nugetFolderFileSystem);

            // setup DTE
            var dte = new Mock <DTE>();

            var projectItems   = new Mock <ProjectItems>();
            var solutionFolder = new Mock <Project>();

            solutionFolder.Setup(s => s.Name).Returns(".nuget");
            solutionFolder.SetupGet(s => s.ProjectItems).Returns(projectItems.Object);

            var solution = new Mock <Solution>();

            solution.As <Solution2>().Setup(p => p.AddSolutionFolder(".nuget")).Returns(solutionFolder.Object);

            var projects = new MockProjects(new Project[0]);

            solution.As <Solution2>().Setup(s => s.Projects).Returns(projects);
            dte.SetupGet(p => p.Solution).Returns(solution.Object);

            // setup package repository
            var packageRepository = new MockPackageRepository();

            packageRepository.Add(PackageUtility.CreatePackage(
                                      "NuGet.Build",
                                      version: "1.0",
                                      tools: new string[] { "NuGet.targets" },
                                      dependencies: new PackageDependency[] { new PackageDependency("NuGet.CommandLine") }));
            packageRepository.Add(PackageUtility.CreatePackage(
                                      "NuGet.CommandLine",
                                      version: "2.0",
                                      tools: new string[] { "NuGet.exe" }));
            var packageRepositoryFactory = new Mock <IPackageRepositoryFactory>();

            packageRepositoryFactory.Setup(p => p.CreateRepository("x:\\nugetsource")).Returns(packageRepository);

            var packageSourceProvider = new Mock <IVsPackageSourceProvider>();

            packageSourceProvider.Setup(p => p.LoadPackageSources()).Returns(new[]
            {
                new PackageSource("x:\\nugetsource")
            });

            var localCache = new MockPackageRepository();

            var packageRestore = CreateInstance(
                dte.Object,
                solutionManager.Object,
                fileSystemProvider.Object,
                packageRepositoryFactory.Object,
                localCache: localCache,
                packageSourceProvider: packageSourceProvider.Object);

            // Act
            packageRestore.EnableCurrentSolutionForRestore(fromActivation: false);

            // Assert
            var cachePackages = localCache.GetPackages().ToList();

            Assert.Equal(2, cachePackages.Count);
            Assert.Equal("NuGet.Build", cachePackages[0].Id);
            Assert.Equal(new SemanticVersion("1.0"), cachePackages[0].Version);
            Assert.Equal("NuGet.CommandLine", cachePackages[1].Id);
            Assert.Equal(new SemanticVersion("2.0"), cachePackages[1].Version);
        }
        public void CallingEnableCurrentSolutionSetupEverythingCorrectly()
        {
            // Arrange
            string tempSolutionPath = CreateTempFolder();

            // setup SolutionManager
            var solutionManager = new Mock<ISolutionManager>();
            solutionManager.Setup(p => p.IsSolutionOpen).Returns(true);
            solutionManager.Setup(p => p.SolutionDirectory).Returns(tempSolutionPath);

            // setup file system
            var fileSystem = new PhysicalFileSystem(tempSolutionPath);
            var fileSystemProvider = new Mock<IFileSystemProvider>();
            fileSystemProvider.Setup(p => p.GetFileSystem(tempSolutionPath)).Returns(fileSystem);

            var nugetFolderFileSystem = new PhysicalFileSystem(tempSolutionPath + "\\.nuget");
            fileSystemProvider.Setup(p => p.GetFileSystem(tempSolutionPath + "\\.nuget")).Returns(nugetFolderFileSystem);

            // setup DTE
            var dte = new Mock<DTE>();

            var projectItems = new Mock<ProjectItems>();
            var solutionFolder = new Mock<Project>();
            solutionFolder.Setup(s => s.Name).Returns(".nuget");
            solutionFolder.SetupGet(s => s.ProjectItems).Returns(projectItems.Object);

            var solution = new Mock<Solution>();
            solution.As<Solution2>().Setup(p => p.AddSolutionFolder(".nuget")).Returns(solutionFolder.Object);

            var projects = new MockProjects(new Project[0]);
            solution.As<Solution2>().Setup(s => s.Projects).Returns(projects);
            dte.SetupGet(p => p.Solution).Returns(solution.Object);

            // setup package repository
            var packageRepository = new MockPackageRepository();
            packageRepository.Add(PackageUtility.CreatePackage(
                "NuGet.Build",
                version: "1.0",
                tools: new string[] { "NuGet.targets" },
                dependencies: new PackageDependency[] { new PackageDependency("NuGet.CommandLine") }));
            packageRepository.Add(PackageUtility.CreatePackage(
                "NuGet.CommandLine",
                version: "1.0",
                tools: new string[] { "NuGet.exe" }));
            var packageRepositoryFactory = new Mock<IPackageRepositoryFactory>();
            packageRepositoryFactory.Setup(p => p.CreateRepository(NuGetConstants.DefaultFeedUrl)).Returns(packageRepository);

            var packageRestore = CreateInstance(
                dte.Object,
                solutionManager.Object,
                fileSystemProvider.Object,
                packageRepositoryFactory.Object);

            // Act 
            packageRestore.EnableCurrentSolutionForRestore(quietMode: true);

            // Assert

            // verify that the files are copied to the .nuget sub folder under solution
            Assert.True(Directory.Exists(Path.Combine(tempSolutionPath, ".nuget")));
            Assert.True(File.Exists(Path.Combine(tempSolutionPath, ".nuget\\NuGet.exe")));
            Assert.True(File.Exists(Path.Combine(tempSolutionPath, ".nuget\\NuGet.targets")));

            // verify that solution folder 'nuget' is added to solution
            solution.As<Solution2>().Verify(p => p.AddSolutionFolder(".nuget"));
            projectItems.Verify(p => p.AddFromFile(tempSolutionPath + "\\.nuget\\NuGet.exe"));
            projectItems.Verify(p => p.AddFromFile(tempSolutionPath + "\\.nuget\\NuGet.targets"));

            // verify that the Source Control mode is disabled
            var settings = new Settings(nugetFolderFileSystem);
            Assert.True(settings.IsSourceControlDisabled());

            // clean up
            Directory.Delete(tempSolutionPath, recursive: true);
        }