void CreatePackageManager(IProject project, PackageReferenceRepositoryHelper packageRefRepositoryHelper)
		{
			options = new TestablePackageManagementOptions();
			options.PackagesDirectory = "packages";
			
			repositoryPaths = new SolutionPackageRepositoryPath(project, options);
			var pathResolver = new DefaultPackagePathResolver(repositoryPaths.PackageRepositoryPath);
			
			fakeFileSystem = new FakeFileSystem();
			
			fakeFeedSourceRepository = new FakePackageRepository();
			fakeSolutionSharedRepository = packageRefRepositoryHelper.FakeSharedSourceRepository;
			
			fakePackageOperationResolverFactory = new FakePackageOperationResolverFactory();
			
			var fakeSolutionPackageRepository = new FakeSolutionPackageRepository();
			fakeSolutionPackageRepository.FileSystem = fakeFileSystem;
			fakeSolutionPackageRepository.PackagePathResolver = pathResolver;
			fakeSolutionPackageRepository.FakeSharedRepository = fakeSolutionSharedRepository;
			
			packageManager = new SharpDevelopPackageManager(fakeFeedSourceRepository,
				packageRefRepositoryHelper.FakeProjectSystem,
				fakeSolutionPackageRepository,
				fakePackageOperationResolverFactory);
		}
		void CreateNewActiveRepositoryWithDifferentPackages()
		{
			var package = new FakePackage("NewRepositoryPackageId");
			var newRepository = new FakePackageRepository();
			newRepository.FakePackages.Add(package);
			registeredPackageRepositories.FakeActiveRepository = newRepository;
		}
		void CreateUpdatePackageInAllProjects(string packageId, SemanticVersion version)
		{
			fakeSolution = new FakePackageManagementSolution();
			fakeSourceRepository = new FakePackageRepository();
			var packageReference = new PackageReference(packageId, version, null, null, false, false);
			updatePackageInAllProjects = new UpdatePackageInAllProjects(packageReference, fakeSolution, fakeSourceRepository);
		}
		void CreateNewActiveRepositoryWithDifferentPackages()
		{
			var package = new FakePackage("NewRepositoryPackageId");
			var newRepository = new FakePackageRepository();
			newRepository.FakePackages.Add(package);
			packageManagementService.FakeActivePackageRepository = newRepository;
		}
		FakePackageRepository AddRegisteredPackageRepository(string packageSourceUrl, string packageSourceName)
		{
			var packageSource = new PackageSource(packageSourceUrl, packageSourceName);
			AddRegisteredPackageSource(packageSource);
			FakePackageRepository fakeRepository = new FakePackageRepository();
			fakeMainCache.FakePackageRepositories.Add(packageSource.Source, fakeRepository);
			return fakeRepository;
		}
		IPackageRepository CreateRecentPackageRepositoryPassingAggregateRepository()
		{
			recentPackagesPassedToCreateRecentPackageRepository = new RecentPackageInfo[0];
			fakeAggregateRepositoryPassedToCreateRecentPackageRepository = new FakePackageRepository();
			
			return cache.CreateRecentPackageRepository(
				recentPackagesPassedToCreateRecentPackageRepository,
				fakeAggregateRepositoryPassedToCreateRecentPackageRepository);
		}
        public void CreateAggregatePackageRepository_OnePackageRepositoryPassed_ReturnsAggregateRepositoryFromFactory()
        {
            CreateCache();

            var repositories = new FakePackageRepository[] {
                new FakePackageRepository()
            };
            IPackageRepository aggregateRepository = cache.CreateAggregateRepository(repositories);

            FakePackageRepository expectedRepository = fakePackageRepositoryFactory.FakeAggregateRepository;

            Assert.AreEqual(expectedRepository, aggregateRepository);
        }
		void CreateProject(MSBuildBasedProject msbuildProject)
		{
			fakePackageManagerFactory = new FakePackageManagerFactory();
			fakePackageManager = fakePackageManagerFactory.FakePackageManager;
			fakeProjectManager = fakePackageManager.FakeProjectManager;
			fakeSourceRepository = new FakePackageRepository();
			fakePackageManagementEvents = new FakePackageManagementEvents();
			
			project = new PackageManagementProject(
				fakeSourceRepository,
				msbuildProject,
				fakePackageManagementEvents,
				fakePackageManagerFactory);
		}
        public void GetInstalledPackages_PackageInstalledInProjectAndProjectIsSelected_CreatesProjectUsingRepository()
        {
            CreateFakeSolution();
            List<IProject> projectsAddedToSolution = AddSolutionWithTwoProjectsToProjectService();
            fakeSolution.FakeActiveMSBuildProject = projectsAddedToSolution[0];
            CreateSelectedProjects();

            var expectedRepository = new FakePackageRepository();
            IQueryable<IPackage> packages = selectedProjects.GetPackages(expectedRepository);

            IPackageRepository repository = fakeSolution.RepositoryPassedToGetProject;

            Assert.AreEqual(expectedRepository, repository);
        }
        public void CreateAggregatePackageRepository_OnePackageRepositoryPassed_RepositoryUsedToCreateAggregateRepository()
        {
            CreateCache();

            var repositories = new FakePackageRepository[] {
                new FakePackageRepository()
            };
            cache.CreateAggregateRepository(repositories);

            IEnumerable<IPackageRepository> repositoriesUsedToCreateAggregateRepository =
                fakePackageRepositoryFactory.RepositoriesPassedToCreateAggregateRepository;

            Assert.AreEqual(repositories, repositoriesUsedToCreateAggregateRepository);
        }
		void CreateProject()
		{
			fakePackageManagerFactory = new FakePackageManagerFactory();
			fakePackageManager = fakePackageManagerFactory.FakePackageManager;
			fakeProjectManager = fakePackageManager.FakeProjectManager;
			fakeSourceRepository = new FakePackageRepository();
			fakeMSBuildProject = ProjectHelper.CreateTestProject();
			fakePackageManagementEvents = new FakePackageManagementEvents();
			
			project = new PackageManagementProject(
				fakeSourceRepository,
				fakeMSBuildProject,
				fakePackageManagementEvents,
				fakePackageManagerFactory);
		}
		public TestableUpdatedPackageViewModel(
			FakePackage package,
			FakePackageManagementService packageManagementService,
			FakeLicenseAcceptanceService licenseAcceptanceService,
			FakeMessageReporter messageReporter)
			: base(
				package,
				packageManagementService,
				licenseAcceptanceService,
				messageReporter)
		{
			this.FakePackage = package;
			this.FakePackageManagementService = packageManagementService;
			this.FakeLicenseAcceptanceService = licenseAcceptanceService;
			this.FakeMessageReporter = messageReporter;
			this.FakeSourcePackageRepository = FakePackageManagementService.FakeActivePackageRepository;
		}
		void CreatePackageManager(IProject project, PackageReferenceRepositoryHelper packageRefRepositoryHelper)
		{
			options = new PackageManagementOptions(new Properties());
			options.PackagesDirectory = "packages";
			
			repositoryPaths = new PackageRepositoryPaths(project, options);
			var pathResolver = new DefaultPackagePathResolver(repositoryPaths.SolutionPackagesPath);
			
			fakeFileSystem = new FakeFileSystem();
			
			fakeFeedSourceRepository = new FakePackageRepository();
			fakeSolutionSharedRepository = packageRefRepositoryHelper.FakeSharedSourceRepository;
			
			packageManager = new SharpDevelopPackageManager(fakeFeedSourceRepository,
				packageRefRepositoryHelper.FakeProjectSystem,
				fakeFileSystem,
				fakeSolutionSharedRepository,
				pathResolver);
		}
        public void GetInstalledPackages_PackageInstalledInProjectAndProjectIsSelected_ReturnsPackageInstalledInProject()
        {
            CreateFakeSolution();
            List<IProject> projectsAddedToSolution = AddSolutionWithTwoProjectsToProjectService();
            fakeSolution.FakeActiveMSBuildProject = projectsAddedToSolution[0];
            fakeSolution.FakeActiveMSBuildProject.Name = "MyProject";

            var package = new FakePackage("Test");
            var project = new FakePackageManagementProject("MyProject");
            project.FakePackages.Add(package);
            fakeSolution.FakeProjectsToReturnFromGetProject.Add("MyProject", project);
            CreateSelectedProjects();

            var repository = new FakePackageRepository();
            IQueryable<IPackage> packages = selectedProjects.GetPackages(repository);

            var expectedPackages = new FakePackage[] {
                package
            };

            PackageCollectionAssert.AreEqual(expectedPackages, packages);
        }
		void CreateUpdateAllPackagesInSolution()
		{
			fakeSolution = new FakePackageManagementSolution();
			fakeSourceRepository = new FakePackageRepository();
			updateAllPackagesInSolution = new UpdateAllPackagesInSolution(fakeSolution, fakeSourceRepository);
		}
        public void GetProjects_SolutionHasOneProject_MSBuildProjectUsedToCreateProject()
        {
            CreateSolution();
            TestableProject expectedProject = AddProjectToOpenProjects("MyProject");
            var repository = new FakePackageRepository();
            List<IPackageManagementProject> projects = solution.GetProjects(repository).ToList();

            MSBuildBasedProject project = fakeProjectFactory.FirstProjectPassedToCreateProject;

            Assert.AreEqual(expectedProject, project);
        }
 public FakeProjectManager()
 {
     LocalRepository  = new FakePackageRepository();
     SourceRepository = new FakePackageRepository();
 }
        public void GetUpdatedPackages_OnePackageReferencedWithConstraintAndUpdatesAvailable_LatestVersionReturnedBasedOnConstraint()
        {
            CreateProject();
            project.FakePackages.Add(new FakePackage("Test", "1.0"));
            var sourceRepository = new FakePackageRepository();
            FakePackage packageVersion2 = sourceRepository.AddFakePackageWithVersion("Test", "2.0");
            FakePackage [] expectedPackages = new [] {
                packageVersion2
            };
            sourceRepository.AddFakePackageWithVersion("Test", "3.0");
            var versionSpec = new VersionSpec();
            versionSpec.MinVersion = new SemanticVersion("1.0");
            versionSpec.IsMinInclusive = true;
            versionSpec.MaxVersion = new SemanticVersion("2.0");
            versionSpec.IsMaxInclusive = true;
            var constraintProvider = new DefaultConstraintProvider();
            constraintProvider.AddConstraint("Test", versionSpec);
            project.ConstraintProvider = constraintProvider;
            CreateUpdatedPackages(sourceRepository);

            IEnumerable<IPackage> packages = updatedPackages.GetUpdatedPackages();

            PackageCollectionAssert.AreEqual(expectedPackages, packages);
        }
		public FakeProjectManager()
		{
			LocalRepository = new FakePackageRepository();
			SourceRepository = new FakePackageRepository();
		}
		void CreatePackage()
		{
			package = new TestablePackageFromRepository();
			fakePackage = package.FakePackagePassedToConstructor;
			fakeRepository = package.FakePackageRepositoryPassedToConstructor;
		}
		void CreateViewModel()
		{
			viewModel = new TestableUpdatedPackageViewModel();
			fakePackageManagementService = viewModel.FakePackageManagementService;
			sourcePackageRepository = viewModel.FakeSourcePackageRepository;
		}
        public void GetProjects_SolutionHasOneProject_RepositoryUsedToCreateProject()
        {
            CreateSolution();
            AddProjectToOpenProjects("MyProject");
            var expectedRepository = new FakePackageRepository();
            List<IPackageManagementProject> projects = solution.GetProjects(expectedRepository).ToList();

            IPackageRepository repository = fakeProjectFactory.FirstRepositoryPassedToCreateProject;

            Assert.AreEqual(expectedRepository, repository);
        }
 public FakePackageManagementService()
 {
     FakeActiveProjectManager    = new FakeProjectManager();
     FakeActivePackageRepository = new FakePackageRepository();
     FakeActiveProjectManager.FakeSourceRepository = FakeActivePackageRepository;
 }
		public void RecentPackageRepository_OnePackageSource_OneRepositoryCreatedForPackageSourceAndUsedToCreateAggregateRepository()
		{
			CreatePackageSources();
			packageSourcesHelper.AddOnePackageSource("Source1");
			CreateCacheUsingPackageSources();
			
			FakePackageRepository repository = AddFakePackageRepositoryForPackageSource("Source1");
			var expectedRepositories = new FakePackageRepository[] {
				repository
			};
			
			IRecentPackageRepository recentRepository = cache.RecentPackageRepository;
			
			IEnumerable<IPackageRepository> repositoriesUsedToCreateAggregateRepository = 
				fakePackageRepositoryFactory.RepositoriesPassedToCreateAggregateRepository;
			
			var actualRepositoriesAsList = new List<IPackageRepository>(repositoriesUsedToCreateAggregateRepository);
			IPackageRepository[] actualRepositories = actualRepositoriesAsList.ToArray();
			
			CollectionAssert.AreEqual(expectedRepositories, actualRepositories);
		}
        public void GetProjects_SolutionHasTwoProjects_ReturnsTwoProjects()
        {
            CreateSolution();
            AddProjectToOpenProjects("One");
            AddProjectToOpenProjects("Two");
            var repository = new FakePackageRepository();
            List<IPackageManagementProject> projects = solution.GetProjects(repository).ToList();

            Assert.AreEqual(2, projects.Count);
        }
        public void GetProject_PackagesRepositoryAndProjectPassed_CreatesProjectUsingProjectPassed()
        {
            CreateSolution();
            TestableProject expectedProject = AddProjectToOpenProjects("Test");
            var repository = new FakePackageRepository();

            solution.GetProject(repository, expectedProject);

            MSBuildBasedProject project = fakeProjectFactory.FirstProjectPassedToCreateProject;

            Assert.AreEqual(expectedProject, project);
        }
		public FakePackageRepository AddFakePackageRepositoryForPackageSource(string source)
		{
			var repository = new FakePackageRepository();			
			FakePackageRepositories.Add(source, repository);
			return repository;
		}
        public void GetProject_PackagesRepositoryAndProjectPassed_CreatesProjectUsingRepository()
        {
            CreateSolution();
            TestableProject expectedProject = AddProjectToOpenProjects("Test");
            var expectedRepository = new FakePackageRepository();

            solution.GetProject(expectedRepository, expectedProject);

            IPackageRepository repository = fakeProjectFactory.FirstRepositoryPassedToCreateProject;

            Assert.AreEqual(expectedRepository, repository);
        }
        public void GetProject_RepositoryAndProjectNamePassed_ReturnsProject()
        {
            CreateSolution();
            AddProjectToOpenProjects("Test");
            var repository = new FakePackageRepository();

            IPackageManagementProject project = solution.GetProject(repository, "Test");

            FakePackageManagementProject expectedProject = fakeProjectFactory.FirstFakeProjectCreated;

            Assert.AreEqual(expectedProject, project);
        }
        public void GetProject_RepositoryAndProjectNamePassed_RepositoryUsedToCreateProject()
        {
            CreateSolution();
            AddProjectToOpenProjects("Test");
            var expectedRepository = new FakePackageRepository();

            solution.GetProject(expectedRepository, "Test");

            IPackageRepository actualRepository = fakeProjectFactory.FirstRepositoryPassedToCreateProject;

            Assert.AreEqual(expectedRepository, actualRepository);
        }
        public void GetProject_RepositoryAndProjectNameWithDifferentCasePassed_CreatesProjectUsingFoundProjectMatchingName()
        {
            CreateSolution();
            TestableProject expectedProject = AddProjectToOpenProjects("Test");
            var repository = new FakePackageRepository();

            solution.GetProject(repository, "TEST");

            MSBuildBasedProject project = fakeProjectFactory.FirstProjectPassedToCreateProject;

            Assert.AreEqual(expectedProject, project);
        }
		public void CreateAggregatePackageRepository_TwoRegisteredPackageRepositories_AllRegisteredRepositoriesUsedToCreateAggregateRepositoryFromFactory()
		{
			CreatePackageSources();
			packageSourcesHelper.AddTwoPackageSources("Source1", "Source2");
			CreateCacheUsingPackageSources();
			
			FakePackageRepository repository1 = AddFakePackageRepositoryForPackageSource("Source1");
			FakePackageRepository repository2 = AddFakePackageRepositoryForPackageSource("Source2");
			var expectedRepositories = new FakePackageRepository[] {
				repository1,
				repository2
			};
			
			cache.CreateAggregateRepository();
			
			IEnumerable<IPackageRepository> repositoriesUsedToCreateAggregateRepository = 
				fakePackageRepositoryFactory.RepositoriesPassedToCreateAggregateRepository;
			
			var actualRepositoriesAsList = new List<IPackageRepository>(repositoriesUsedToCreateAggregateRepository);
			IPackageRepository[] actualRepositories = actualRepositoriesAsList.ToArray();
			
			CollectionAssert.AreEqual(expectedRepositories, actualRepositories);
		}