Inheritance: IVsPackageManagerFactory
        public static void GetLocalRepositoryWhenSolutionDirectoryIsNotFound()
        {
            // Arrange
            var mockRepositoryFactory = new Mock<IPackageRepositoryFactory>();
            var mockSourceProvider = new Mock<IVsPackageSourceProvider>();
            var mockAggregateRepository = new Mock<AggregateRepository>(Enumerable.Empty<IPackageRepository>());
            var solutionManager = new Mock<ISolutionManager>();
            solutionManager.Setup(s => s.SolutionDirectory).Returns(String.Empty);
            var fileSystemProvider = new Mock<IFileSystemProvider>();
            var repositorySettings = new RepositorySettings(solutionManager.Object, fileSystemProvider.Object, new Mock<IVsSourceControlTracker>().Object, null);
            var packageManagerFactory = new VsPackageManagerFactory(
                new Mock<ISolutionManager>().Object, 
                mockRepositoryFactory.Object, 
                mockSourceProvider.Object,
                new Mock<IFileSystemProvider>().Object, 
                repositorySettings, 
                new Mock<VsPackageInstallerEvents>().Object, 
                mockAggregateRepository.Object,
                frameworkMultiTargeting: null,
				machineWideSettings: null);

            // Act & Assert
            // Get RepositoryPath throws InvalidOperationException and GetLocalRepository() handles it to return null
            // To make a delegate out of property repositorySettings.RepositoryPath, calling String.IsNullOrEmpty
            ExceptionAssert.Throws<InvalidOperationException>(() => String.IsNullOrEmpty(repositorySettings.RepositoryPath), "Unable to locate the solution directory. Please ensure that the solution has been saved.");
            Assert.Null(ProjectRetargetingUtility.GetLocalRepository(packageManagerFactory));
        }
        public void InstallPackageCmdletCreatesFallbackRepository()
        {
            // Arrange
            var productUpdateService = new Mock<IProductUpdateService>();
            IPackageRepository repoA = new MockPackageRepository(), repoB = new MockPackageRepository();
            var package = NuGet.Test.PackageUtility.CreatePackage("P1", dependencies: new[] { new PackageDependency("P2") });
            repoA.AddPackage(package);
            repoB.AddPackage(NuGet.Test.PackageUtility.CreatePackage("P2"));
            var sharedRepo = new Mock<ISharedPackageRepository>();
            var recentRepo = new Mock<IRecentPackageRepository>();
            var repositoryFactory = new Mock<IPackageRepositoryFactory>();
            repositoryFactory.Setup(c => c.CreateRepository("A")).Returns(repoA);
            repositoryFactory.Setup(c => c.CreateRepository("B")).Returns(repoB);
            var sourceProvider = GetPackageSourceProvider(new PackageSource("A"), new PackageSource("B"));
            var fileSystemProvider = new Mock<IFileSystemProvider>();
            fileSystemProvider.Setup(c => c.GetFileSystem(It.IsAny<string>())).Returns(new MockFileSystem());
            var repositorySettings = new Mock<IRepositorySettings>();
            repositorySettings.Setup(c => c.RepositoryPath).Returns(String.Empty);

            var solutionManager = new Mock<ISolutionManager>();
            var packageManagerFactory = new VsPackageManagerFactory(solutionManager.Object, repositoryFactory.Object, sourceProvider, fileSystemProvider.Object, repositorySettings.Object, null, new Mock<VsPackageInstallerEvents>().Object, new MockPackageRepository());

            var cmdlet = new InstallPackageCommand(TestUtils.GetSolutionManagerWithProjects("foo"), packageManagerFactory, repositoryFactory.Object, sourceProvider, null, productUpdateService.Object, new Mock<IVsCommonOperations>().Object);
            cmdlet.Id = "P1";
            cmdlet.Source = "A";

            // Act
            cmdlet.Execute();

            // Assert
            // If we've come this far, P1 is successfully installed.
            Assert.True(true);
        }