void WalkPackage (IPackage package)
		{
			var localRepository = new FakePackageRepository ();
			var sourceRepository = new FakePackageRepository ();
			var walker = new InstallWalker (localRepository, sourceRepository, null, NullLogger.Instance, true, false, DependencyVersion.Lowest);
			walker.Walk (package);
		}
        public FakePackageRepository AddFakePackageRepositoryForPackageSource(string source)
        {
            var repository = new FakePackageRepository();

            FakePackageRepositories.Add(source, repository);
            return(repository);
        }
		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 ();
			fakePackageOperationResolver = fakePackageOperationResolverFactory.FakeInstallPackageOperationResolver;

			var fakeSolutionPackageRepository = new FakeSolutionPackageRepository ();
			fakeSolutionPackageRepository.FileSystem = fakeFileSystem;
			fakeSolutionPackageRepository.PackagePathResolver = pathResolver;
			fakeSolutionPackageRepository.FakeSharedRepository = fakeSolutionSharedRepository;

			packageManager = new MonoDevelopPackageManager (fakeFeedSourceRepository,
				packageRefRepositoryHelper.FakeProjectSystem,
				fakeSolutionPackageRepository,
				fakePackageOperationResolverFactory);
		}
		IPackageRepository CreateRecentPackageRepositoryPassingAggregateRepository ()
		{
			recentPackagesPassedToCreateRecentPackageRepository = new RecentPackageInfo[0];
			fakeAggregateRepositoryPassedToCreateRecentPackageRepository = new FakePackageRepository ();

			return cache.CreateRecentPackageRepository (
				recentPackagesPassedToCreateRecentPackageRepository,
				fakeAggregateRepositoryPassedToCreateRecentPackageRepository);
		}
        public IPackageRepository CreateRepository(string packageSource)
        {
            PackageSourcesPassedToCreateRepository.Add(packageSource);

            FakePackageRepository repository = null;

            if (FakePackageRepositories.TryGetValue(packageSource, out repository))
            {
                return(repository);
            }

            return(FakePackageRepository);
        }
		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 GetUpdatedPackages_OnePackageReferencedWithConstraintAndUpdatesAvailable_LatestVersionReturnedBasedOnConstraint ()
		{
			AddPackageReference ("Test", "1.0");
			FakePackage package = AddPackageToSourceRepository ("Test", "2.0");
			FakePackage [] expectedPackages = new [] {
				package
			};
			AddPackageToSourceRepository ("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;
			var repository = new FakePackageRepository ();
			repository.FakePackages = sourceRepositoryPackages;
			CreateUpdatedPackages (repository);

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

			PackageCollectionAssert.AreEqual (expectedPackages, packages);
		}
		public void GetProject_RepositoryAndProjectNameWithDifferentCasePassed_CreatesProjectUsingFoundProjectMatchingName ()
		{
			CreateSolution ();
			FakeDotNetProject expectedProject = AddProjectToOpenProjects ("Test");
			var repository = new FakePackageRepository ();

			solution.GetProject (repository, "TEST");

			IDotNetProject project = fakeProjectFactory.FirstProjectPassedToCreateProject;

			Assert.AreEqual (expectedProject, project);
		}
		public void GetActiveProject_RepositoryPassed_ReturnsProjectFromProjectFactory ()
		{
			CreateSolution ();
			var expectedRepository = new FakePackageRepository ();
			IPackageManagementProject project = solution.GetActiveProject (expectedRepository);

			FakePackageManagementProject expectedProject = fakeProjectFactory.FirstFakeProjectCreated;

			Assert.AreEqual (expectedProject, project);
		}
		public void GetActiveProject_RepositoryPassed_CreatesProjectUsingFallbackRepositoryWithAggregateAsFallback ()
		{
			CreateSolution ();
			var expectedRepository = new FakePackageRepository ();

			solution.GetActiveProject (expectedRepository);

			IPackageRepository repository = fakeProjectFactory.FirstRepositoryPassedToCreateProject;
			var fallbackRepository = repository as FallbackRepository;
			Assert.IsNotNull (fallbackRepository);
			Assert.AreEqual (expectedRepository, fallbackRepository.SourceRepository);
			Assert.AreEqual (fakeRegisteredPackageRepositories.FakeAggregateRepository, fallbackRepository.DependencyResolver);
		}
		public void CreateAggregateRepository_SolutionClosedAndEnabledPackageSourcesChangedAfterCacheCreated_AggregateRepositoryContainsCorrectEnabledPackageRepositories ()
		{
			CreatePackageSources ();
			packageSourcesHelper.AddTwoPackageSources ("Source1", "Source2");
			CreateCacheUsingPackageSources ();
			FakePackageRepository source1Repo = AddFakePackageRepositoryForPackageSource ("Source1");
			FakePackageRepository source2Repo = AddFakePackageRepositoryForPackageSource ("Source2");
			fakePackageRepositoryFactory.CreateAggregrateRepositoryAction = (repositories) => {
				return new AggregateRepository (repositories);
			};
			var initialAggregateRepository = cache.CreateAggregateRepository () as AggregateRepository;
			var expectedInitialRepositories = new FakePackageRepository [] {
				source1Repo,
				source2Repo
			};
			List<IPackageRepository> actualInitialRepositories = initialAggregateRepository.Repositories.ToList ();
			packageSourcesHelper.Options.ProjectService.RaiseSolutionUnloadedEvent ();
			packageSourcesHelper.Options.PackageSources.Clear ();
			packageSourcesHelper.Options.PackageSources.Add (new PackageSource ("Source3"));
			FakePackageRepository source3Repo = AddFakePackageRepositoryForPackageSource ("Source3");
			var expectedRepositories = new FakePackageRepository [] {
				source3Repo
			};

			var aggregateRepository = cache.CreateAggregateRepository () as AggregateRepository;
			List<IPackageRepository> actualRepositories = aggregateRepository.Repositories.ToList ();

			CollectionAssert.AreEqual (expectedInitialRepositories, actualInitialRepositories);
			CollectionAssert.AreEqual (expectedRepositories, actualRepositories);
		}
		FakePackageRepository AddRepository ()
		{
			var repository = new FakePackageRepository ();
			repositories.Add (repository);
			return repository;
		}
		public TestablePackageFromRepository (FakePackage package, FakePackageRepository repository)
			: base (package, repository)
		{
			this.FakePackagePassedToConstructor = package;
			this.FakePackageRepositoryPassedToConstructor = repository;
		}
		void CreateProject ()
		{
			fakeSourceRepository = new FakePackageRepository ();
			CreateProject (fakeSourceRepository);
		}
		void CreatePackage ()
		{
			package = new TestablePackageFromRepository ();
			fakePackage = package.FakePackagePassedToConstructor;
			fakeRepository = package.FakePackageRepositoryPassedToConstructor;
		}
Ejemplo n.º 16
0
 public bool IsCloneOf(FakePackageRepository packageRepository)
 {
     return(ClonedRepository == packageRepository);
 }
		public void Run_ActionDownloadsTwoPackages_DownloadingMessageLoggedOnceForEachDownloadOperationByProgressMonitor ()
		{
			CreateRunner ();
			AddInstallActionWithCustomExecuteAction (() => {
				var repository = new FakePackageRepository ();
				repositoryFactoryEvents.RaiseRepositoryCreatedEvent (new PackageRepositoryFactoryEventArgs (repository));

				var progress = new ProgressEventArgs ("Download1", 100);
				repository.RaiseProgressAvailableEvent (progress);

				progress = new ProgressEventArgs ("Download2", 50);
				repository.RaiseProgressAvailableEvent (progress);

				progress = new ProgressEventArgs ("Download2", 100);
				repository.RaiseProgressAvailableEvent (progress);
			});

			Run ();

			progressMonitor.AssertMessageIsLogged ("Download1");
			progressMonitor.AssertMessageIsLogged ("Download2");
			progressMonitor.AssertMessageIsNotLogged ("Download2" + Environment.NewLine + "Download2");
		}
		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 CreateUpdateAllPackagesInSolution ()
		{
			fakeSolution = new FakePackageManagementSolution ();
			fakeSourceRepository = new FakePackageRepository ();
			updateAllPackagesInSolution = new UpdateAllPackagesInSolution (fakeSolution, fakeSourceRepository);
		}
		void CreateCacheUsingPackageSources (ISharpDevelopPackageRepositoryFactory repositoryFactory)
		{
			nuGetPackageSource = new PackageSource ("http://nuget.org", "NuGet");
			machineCache = new FakePackageRepository ();
			cache = new PackageRepositoryCache (packageSourcesHelper.Options, machineCache, repositoryFactory);
		}
		void CreateNewActiveRepositoryWithDifferentPackages ()
		{
			var package = new FakePackage ("NewRepositoryPackageId");
			var newRepository = new FakePackageRepository ();
			newRepository.FakePackages.Add (package);
			registeredPackageRepositories.FakeActiveRepository = newRepository;
		}
Ejemplo n.º 22
0
 public FakeProjectManager()
 {
     LocalRepository  = new FakePackageRepository();
     SourceRepository = new FakePackageRepository();
 }
Ejemplo n.º 23
0
 public TestablePackageFromRepository(FakePackage package, FakePackageRepository repository)
     : base(package, repository)
 {
     this.FakePackagePassedToConstructor           = package;
     this.FakePackageRepositoryPassedToConstructor = repository;
 }
		public void GetActiveProject_RepositoryPassed_CreatesProjectUsingCurrentActiveProject ()
		{
			CreateSolution ();
			var expectedRepository = new FakePackageRepository ();
			FakeDotNetProject expectedProject = ProjectHelper.CreateTestProject ();
			fakeProjectService.CurrentProject = expectedProject;

			solution.GetActiveProject (expectedRepository);

			IDotNetProject project = fakeProjectFactory.FirstProjectPassedToCreateProject;

			Assert.AreEqual (expectedProject, project);
		}
Ejemplo n.º 25
0
		public FakeProjectManager ()
		{
			LocalRepository = new FakePackageRepository ();
			SourceRepository = new FakePackageRepository ();
		}
		public void GetProject_PackagesRepositoryAndProjectPassed_CreatesProjectUsingProjectPassed ()
		{
			CreateSolution ();
			FakeDotNetProject expectedProject = AddProjectToOpenProjects ("Test");
			var repository = new FakePackageRepository ();

			solution.GetProject (repository, expectedProject);

			IDotNetProject project = fakeProjectFactory.FirstProjectPassedToCreateProject;

			Assert.AreEqual (expectedProject, project);
		}
		public void GetActiveProject_RepositoryPassedWhenSolutionOpenButNoProjectSelected_ReturnsNull ()
		{
			CreateSolution ();
			fakeProjectService.CurrentProject = null;

			var repository = new FakePackageRepository ();
			IPackageManagementProject activeProject = solution.GetActiveProject (repository);

			Assert.IsNull (activeProject);
		}
		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 GetProjects_SolutionHasOneProject_MSBuildProjectUsedToCreateProject ()
		{
			CreateSolution ();
			FakeDotNetProject expectedProject = AddProjectToOpenProjects ("MyProject");
			var repository = new FakePackageRepository ();
			solution.GetProjects (repository).ToList ();

			IDotNetProject project = fakeProjectFactory.FirstProjectPassedToCreateProject;

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

			solution.GetProjects (expectedRepository).ToList ();

			IPackageRepository repository = fakeProjectFactory.FirstRepositoryPassedToCreateProject;
			var fallbackRepository = repository as FallbackRepository;
			Assert.AreEqual (expectedRepository, fallbackRepository.SourceRepository);
			Assert.AreEqual (fakeRegisteredPackageRepositories.FakeAggregateRepository, fallbackRepository.DependencyResolver);
		}
		public void CreateAggregatePackageRepository_TwoRegisteredPackageSourcesButOneDisabled_ReturnsAggregateRepositoryCreatedWithOnlyEnabledPackageSource ()
		{
			CreatePackageSources ();
			packageSourcesHelper.AddTwoPackageSources ("Source1", "Source2");
			packageSourcesHelper.RegisteredPackageSources [0].IsEnabled = false;
			CreateCacheUsingPackageSources ();
			AddFakePackageRepositoryForPackageSource ("Source1");
			FakePackageRepository repository2 = AddFakePackageRepositoryForPackageSource ("Source2");
			var expectedRepositories = new FakePackageRepository[] {
				repository2
			};

			cache.CreateAggregateRepository ();

			IEnumerable<IPackageRepository> repositoriesUsedToCreateAggregateRepository = 
				fakePackageRepositoryFactory.RepositoriesPassedToCreateAggregateRepository;

			var actualRepositoriesAsList = new List<IPackageRepository> (repositoriesUsedToCreateAggregateRepository);
			IPackageRepository[] actualRepositories = actualRepositoriesAsList.ToArray ();

			CollectionAssert.AreEqual (expectedRepositories, actualRepositories);
		}
		public void GetProjects_SolutionHasNoProjects_ReturnsNoProjects ()
		{
			CreateSolution ();
			var repository = new FakePackageRepository ();
			List<IPackageManagementProject> projects = solution.GetProjects (repository).ToList ();

			Assert.AreEqual (0, projects.Count);
		}
		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);
		}
		AggregateRepository CreateAggregateRepositoryWithOneRepository ()
		{
			var repositories = new FakePackageRepository [] {
				new FakePackageRepository ()
			};
			return new AggregateRepository (repositories);
		}
		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);
		}