FakeNuGetProjectAction AddInstallPackageIntoProjectAction(FakeNuGetProject nugetProject, string packageId, string version) { var projectAction = new FakeNuGetProjectAction(nugetProject, packageId, version, NuGetProjectActionType.Install); packageManager.UpdateActions.Add(projectAction); return(projectAction); }
public async Task GetUpdatedPackages_UpdatingThreeOldAndroidPackagesInstallsOneAndUpdatesOneAndRemovesOneWithOneInstall_NoUpdatesRemain() { CreateUpdatedPackagesInWorkspace(); FakeNuGetProject project = AddNuGetProjectToSolution(); project.AddPackageReference("Xamarin.Android.Support.v13", "20.0.0.4"); project.AddPackageReference("Xamarin.Android.Support.v4", "20.0.0.4"); project.AddPackageReference("Xamarin.Android.Support.v7.AppCompat", "20.0.0.2"); packageMetadataResource.AddPackageMetadata("Xamarin.Android.Support.v13", "23.1.1.0"); packageMetadataResource.AddPackageMetadata("Xamarin.Android.Support.v4", "23.1.1.0"); packageMetadataResource.AddPackageMetadata("Xamarin.Android.Support.v7.AppCompat", "23.1.1.0"); await CheckForUpdates(); int originalUpdatesAvailable = updatedPackagesInWorkspace .GetUpdatedPackages(project.Project) .GetPackages() .Count(); project.InstalledPackages.Clear(); project.AddPackageReference("Xamarin.Android.Support.v4", "23.1.1.0"); project.AddPackageReference("Xamarin.Android.Support.v7.AppCompat", "23.1.1.0"); var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages(project.Project); updatedPackages.RemoveUpdatedPackages(project.InstalledPackages); Assert.AreEqual(3, originalUpdatesAvailable); Assert.AreEqual(0, updatedPackages.GetPackages().Count()); }
FakeNuGetProject CreateNuGetProjectForProject() { var nugetProject = new FakeNuGetProject(project); solutionManager.NuGetProjects[project] = nugetProject; return(nugetProject); }
FakeNuGetProject AddNuGetProject() { var project = new FakeNuGetProject(new FakeDotNetProject()); solutionManager.NuGetProjects [project.Project] = project; return(project); }
void CreateAction( string packageId = "Test", string version = "2.1") { project = new FakeDotNetProject(@"d:\projects\MyProject\MyProject.csproj"); solutionManager = new FakeSolutionManager(); nugetProject = new FakeNuGetProject(project); solutionManager.NuGetProjects[project] = nugetProject; var repositoryProvider = solutionManager.SourceRepositoryProvider; var source = new PackageSource("http://test.com"); repositoryProvider.AddRepository(source); primaryRepositories = repositoryProvider.Repositories; action = new TestableReinstallNuGetPackageAction( project, solutionManager); packageManagementEvents = action.PackageManagementEvents; fileRemover = action.FileRemover; action.PackageId = packageId; action.Version = new NuGetVersion(version); uninstallPackageManager = action.UninstallAction.PackageManager; installPackageManager = action.InstallAction.PackageManager; }
void CreateAction(string projectName = "MyProject", params ProjectReference[] projectReferences) { project = new FakeDotNetProject(@"d:\projects\MyProject\MyProject.csproj"); project.Name = projectName; project.References.AddRange(projectReferences); solutionManager = new FakeSolutionManager(); nugetProject = new FakeNuGetProject(project); solutionManager.NuGetProjects[project] = nugetProject; var metadataResourceProvider = new FakePackageMetadataResourceProvider(); packageMetadataResource = metadataResourceProvider.PackageMetadataResource; var source = new PackageSource("http://test.com"); var providers = new INuGetResourceProvider[] { metadataResourceProvider }; var sourceRepository = new SourceRepository(source, providers); primaryRepositories = new [] { sourceRepository }.ToList(); solutionManager.SourceRepositoryProvider.Repositories.AddRange(primaryRepositories); action = new TestableUpdateAllNuGetPackagesInProjectAction( solutionManager, project); packageManager = action.PackageManager; packageManagementEvents = action.PackageManagementEvents; fileRemover = action.FileRemover; restoreManager = action.RestoreManager; }
void CreateAction( string packageId = "Test", string version = "2.1") { project = new FakeDotNetProject(@"d:\projects\MyProject\MyProject.csproj"); solutionManager = new FakeSolutionManager(); nugetProject = new FakeNuGetProject(project); solutionManager.NuGetProjects[project] = nugetProject; var metadataResourceProvider = new FakePackageMetadataResourceProvider(); packageMetadataResource = metadataResourceProvider.PackageMetadataResource; var source = new PackageSource("http://test.com"); var providers = new INuGetResourceProvider[] { metadataResourceProvider }; var sourceRepository = new SourceRepository(source, providers); primaryRepositories = new [] { sourceRepository }.ToList(); action = new TestableInstallNuGetPackageAction( primaryRepositories, solutionManager, project); packageManager = action.PackageManager; packageManagementEvents = action.PackageManagementEvents; fileRemover = action.FileRemover; action.PackageId = packageId; action.Version = new NuGetVersion(version); }
public async Task CheckForUpdates_ProjectHasStablePackageWhichHasUpdatedPrereleasePackage_NoUpdatesFound() { CreateUpdatedPackagesInWorkspace(); FakeNuGetProject project = AddNuGetProjectToSolution(); project.AddPackageReference("MyPackage", "1.0.1"); packageMetadataResource.AddPackageMetadata("MyPackage", "1.1.0-alpha"); await CheckForUpdates(); var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages(project.Project); Assert.AreEqual(0, updatedPackages.GetPackages().Count()); }
public async Task CheckForUpdates_NoPackagesUpdated_NoUpdates() { CreateUpdatedPackagesInWorkspace(); FakeNuGetProject project = AddNuGetProjectToSolution(); project.AddPackageReference("MyPackage", "1.0"); await CheckForUpdates(); var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages(dotNetProject); Assert.IsFalse(updatedPackagesInWorkspace.AnyUpdates()); Assert.AreEqual(0, updatedPackages.GetPackages().Count()); }
void CreateAction(string packageId = "Test") { project = new FakeDotNetProject(@"d:\projects\MyProject\MyProject.csproj"); solutionManager = new FakeSolutionManager(); nugetProject = new FakeNuGetProject(project); solutionManager.NuGetProjects[project] = nugetProject; action = new TestableUninstallNuGetPackageAction( solutionManager, project); packageManager = action.PackageManager; action.PackageId = packageId; }
public async Task GetInstalledPackages_PackageHasNoVersion_PackageIsNotIncluded() { var project = new FakeDotNetProject(@"d:\projects\MyProject\MyProject.csproj"); var nugetProject = new FakeNuGetProject(project); nugetProject.AddPackageReference("One", "1.2"); nugetProject.AddPackageReference("Two", version: null); var projects = new [] { nugetProject }; var context = new PackageLoadContext(null, false, projects); var packages = await context.GetInstalledPackagesAsync(); Assert.IsTrue(packages.ContainsId("One")); Assert.IsFalse(packages.ContainsId("Two")); }
public async Task CheckForUpdates_ProjectHasPreReleasePackageWhichHasUpdatedStablePackage_OneStableUpdateFound() { CreateUpdatedPackagesInWorkspace(); FakeNuGetProject project = AddNuGetProjectToSolution(); project.AddPackageReference("MyPackage", "1.0.1-alpha"); packageMetadataResource.AddPackageMetadata("MyPackage", "1.0.1"); await CheckForUpdates(); var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages(dotNetProject); Assert.AreEqual(1, updatedPackages.GetPackages().Count()); Assert.AreEqual("MyPackage", updatedPackages.GetPackages().First().Id); Assert.AreEqual("1.0.1", updatedPackages.GetPackages().First().Version.ToString()); }
public async Task GetUpdatedPackages_PackageReferenceHasNoVersion_NoUpdatedPackagesFoundForProject() { CreateUpdatedPackagesInWorkspace(); FakeNuGetProject project = AddNuGetProjectToSolution(); project.AddPackageReference("MyPackage", version: null); packageMetadataResource.AddPackageMetadata("MyPackage", "1.1"); await CheckForUpdates(); var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages(dotNetProject); Assert.AreEqual(project.Project, updatedPackages.Project); Assert.IsNotNull(updatedPackages.Project); Assert.AreEqual(0, updatedPackages.GetPackages().Count()); Assert.AreEqual(0, errorsLogged.Count); }
void CreateAction(params string[] packageIds) { project = new FakeDotNetProject(@"d:\projects\MyProject\MyProject.csproj"); project.Name = "MyProject"; solutionManager = new FakeSolutionManager(); nugetProject = new FakeNuGetProject(project); solutionManager.NuGetProjects[project] = nugetProject; action = new TestableUninstallNuGetPackagesAction( solutionManager, project); packageManager = action.PackageManager; action.AddPackageIds(packageIds); }
public async Task CheckForUpdates_NoPackagesUpdated_UpdatedPackagesAvailableEventIsNotFired() { CreateUpdatedPackagesInWorkspace(); FakeNuGetProject project = AddNuGetProjectToSolution(); project.AddPackageReference("MyPackage", "1.0"); bool fired = false; packageManagementEvents.UpdatedPackagesAvailable += (sender, e) => { fired = true; }; await CheckForUpdates(); Assert.IsFalse(fired); }
public async Task Clear_OnePackageUpdatedButEverythingCleared_NoUpdatedPackagesFoundForProject() { CreateUpdatedPackagesInWorkspace(); FakeNuGetProject project = AddNuGetProjectToSolution(); project.AddPackageReference("MyPackage", "1.0"); packageMetadataResource.AddPackageMetadata("MyPackage", "1.1"); await CheckForUpdates(); updatedPackagesInWorkspace.Clear(); var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages(dotNetProject); Assert.AreEqual(project.Project, updatedPackages.Project); Assert.IsNotNull(updatedPackages.Project); Assert.AreEqual(0, updatedPackages.GetPackages().Count()); }
public async Task CheckForUpdates_OnePackageUpdated_UpdatedPackagesAvailableEventIsFired() { CreateUpdatedPackagesInWorkspace(); FakeNuGetProject project = AddNuGetProjectToSolution(); project.AddPackageReference("MyPackage", "1.0"); packageMetadataResource.AddPackageMetadata("MyPackage", "1.1"); bool updatesAvailableEventFired = false; packageManagementEvents.UpdatedPackagesAvailable += (sender, e) => { updatesAvailableEventFired = true; }; await CheckForUpdates(); Assert.IsTrue(updatesAvailableEventFired); }
public async Task GetUpdatedPackages_OnePackageUpdatedAndPackageIsUninstalled_NoUpdatesAvailableForUninstalledPackage() { CreateUpdatedPackagesInWorkspace(); FakeNuGetProject project = AddNuGetProjectToSolution(); project.AddPackageReference("MyPackage", "1.0"); packageMetadataResource.AddPackageMetadata("MyPackage", "1.1"); await CheckForUpdates(); project.InstalledPackages.Clear(); var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages(dotNetProject); int updatedPackagesCountBeforeUpdating = updatedPackages.GetPackages().Count(); updatedPackages.RemoveUpdatedPackages(project.InstalledPackages); Assert.AreEqual(1, updatedPackagesCountBeforeUpdating); Assert.AreEqual(0, updatedPackages.GetPackages().Count()); }
public async Task GetUpdatedPackages_OnePackageHasUpdatesAndNewerVersionButNotLatestIsInstalled_UpdatesStillShowAsAvailable() { CreateUpdatedPackagesInWorkspace(); FakeNuGetProject project = AddNuGetProjectToSolution(); project.AddPackageReference("MyPackage", "1.0"); packageMetadataResource.AddPackageMetadata("MyPackage", "1.9"); await CheckForUpdates(); project.InstalledPackages.Clear(); project.AddPackageReference("MyPackage", "1.1"); var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages(dotNetProject); updatedPackages.RemoveUpdatedPackages(project.InstalledPackages); Assert.AreEqual(1, updatedPackages.GetPackages().Count()); Assert.AreEqual("MyPackage", updatedPackages.GetPackages().First().Id); Assert.AreEqual("1.9", updatedPackages.GetPackages().First().Version.ToString()); }
public async Task CheckForUpdates_OnePackageUpdatedButSolutionClosedBeforeResultsReturned_UpdatedPackagesAvailableEventIsNotFiredAndNoPackageUpdatesAvailable() { CreateUpdatedPackagesInWorkspace(); FakeNuGetProject project = AddNuGetProjectToSolution(); project.AddPackageReference("MyPackage", "1.0"); packageMetadataResource.AddPackageMetadata("MyPackage", "1.1"); bool fired = false; packageManagementEvents.UpdatedPackagesAvailable += (sender, e) => { fired = true; }; taskRunner.AfterCheckForUpdatesAction = () => { updatedPackagesInWorkspace.Clear(); }; await CheckForUpdates(); Assert.IsFalse(fired); Assert.IsFalse(updatedPackagesInWorkspace.AnyUpdates()); }
void CreateAction( List <FakeDotNetProject> projects, List <SourceRepository> secondarySources = null) { solutionManager = new FakeSolutionManager(); foreach (var currentProject in projects) { project = currentProject; nugetProject = new FakeNuGetProject(currentProject); solutionManager.NuGetProjects [project] = nugetProject; } var metadataResourceProvider = new FakePackageMetadataResourceProvider(); packageMetadataResource = metadataResourceProvider.PackageMetadataResource; var source = new PackageSource("http://test.com"); var providers = new INuGetResourceProvider [] { metadataResourceProvider }; var sourceRepository = new SourceRepository(source, providers); primaryRepositories = new [] { sourceRepository }.ToList(); solutionManager.SourceRepositoryProvider.Repositories.AddRange(secondarySources ?? primaryRepositories); action = new TestableUpdateMultipleNuGetPackagesAction( primaryRepositories, solutionManager); foreach (var currentProject in projects) { action.AddProject(currentProject); } packageManager = action.PackageManager; packageManagementEvents = action.PackageManagementEvents; fileRemover = action.FileRemover; restoreManager = action.RestoreManager; }
public async Task GetUpdatedPackages_OnePackageUpdatedSameUnderlyingDotNetProjectButDifferentProxy_OneUpdatedPackageFoundForProject() { CreateUpdatedPackagesInWorkspace(); FakeNuGetProject project = AddNuGetProjectToSolution(); project.AddPackageReference("MyPackage", "1.0"); var updatedPackage = packageMetadataResource.AddPackageMetadata("MyPackage", "1.1").Identity; var expectedPackages = new [] { updatedPackage }; var newProject = new FakeDotNetProject(); dotNetProject.EqualsAction = p => { return(p == newProject); }; await CheckForUpdates(); var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages(newProject); Assert.IsNotNull(updatedPackages.Project); CollectionAssert.AreEqual(expectedPackages, updatedPackages.GetPackages()); Assert.AreNotEqual(newProject, updatedPackages.Project); }
public async Task CheckForUpdates_OnePackageUpdated_OneUpdatedPackageFoundForProject() { CreateUpdatedPackagesInWorkspace(); FakeNuGetProject project = AddNuGetProjectToSolution(); project.AddPackageReference("MyPackage", "1.0"); packageMetadataResource.AddPackageMetadata("MyPackage", "1.1"); packageMetadataResource.AddPackageMetadata("MyPackage", "1.2"); var updatedPackage = packageMetadataResource.AddPackageMetadata("MyPackage", "1.2").Identity; var expectedPackages = new [] { updatedPackage }; await CheckForUpdates(); var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages(dotNetProject); Assert.AreEqual(project.Project, updatedPackages.Project); Assert.IsNotNull(updatedPackages.Project); CollectionAssert.AreEqual(expectedPackages, updatedPackages.GetPackages()); }
public async Task CheckForUpdates_TwoSourceRepositoriesAndFirstOneThrowsException_UpdatedPackageFoundFromNonFailingSourceRepository() { CreateUpdatedPackagesInWorkspace(); FakeNuGetProject project = AddNuGetProjectToSolution(); project.AddPackageReference("MyPackage", "1.0"); packageMetadataResource.AddPackageMetadata("MyPackage", "1.1"); var ex = new ApplicationException("Error"); var sourceRepository = CreateExceptionThrowingSourceRepository(ex); taskRunner.SolutionManager.SourceRepositoryProvider.Repositories.Insert(0, sourceRepository); await CheckForUpdates(); var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages(dotNetProject); var package = updatedPackages.GetPackages().Single(); Assert.AreEqual("MyPackage", package.Id); Assert.AreEqual("1.1", package.Version.ToString()); }
public async Task CheckForUpdates_ProjectHasStableAndPreReleasePackagesBothWithUpdatese_TwoUpdatesFound() { CreateUpdatedPackagesInWorkspace(); FakeNuGetProject project = AddNuGetProjectToSolution(); project.AddPackageReference("MyPackage", "1.0.1-alpha"); project.AddPackageReference("AnotherPackage", "1.0"); packageMetadataResource.AddPackageMetadata("MyPackage", "1.0.1-beta"); packageMetadataResource.AddPackageMetadata("AnotherPackage", "1.1"); await CheckForUpdates(); var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages(dotNetProject); var anotherPackageUpdate = updatedPackages.GetPackages().FirstOrDefault(p => p.Id == "AnotherPackage"); var myPackageUpdate = updatedPackages.GetPackages().FirstOrDefault(p => p.Id == "MyPackage"); Assert.AreEqual(2, updatedPackages.GetPackages().Count()); Assert.IsNotNull(anotherPackageUpdate); Assert.AreEqual("1.1", anotherPackageUpdate.Version.ToString()); Assert.IsNotNull(myPackageUpdate); Assert.AreEqual("1.0.1-beta", myPackageUpdate.Version.ToString()); }
public async Task GetUpdatedPackages_TwoPackagesInstalledOneUpdatedWhichUpdatesItsDependency_NoUpdatesAvailable() { CreateUpdatedPackagesInWorkspace(); FakeNuGetProject project = AddNuGetProjectToSolution(); project.AddPackageReference("One", "1.0"); project.AddPackageReference("Two", "1.0"); packageMetadataResource.AddPackageMetadata("One", "1.1"); packageMetadataResource.AddPackageMetadata("Two", "1.1"); await CheckForUpdates(); project.InstalledPackages.Clear(); project.AddPackageReference("One", "1.1"); project.AddPackageReference("Two", "1.1"); var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages(dotNetProject); int updatedPackagesCountBeforeUpdating = updatedPackages.GetPackages().Count(); updatedPackages.RemoveUpdatedPackages(project.InstalledPackages); Assert.AreEqual(2, updatedPackagesCountBeforeUpdating); Assert.AreEqual(0, updatedPackages.GetPackages().Count()); }
public async Task GetUpdatedPackages_OnePackageReferencedWithConstraintAndUpdatesAvailable_LatestVersionReturnedBasedOnConstraint() { CreateUpdatedPackagesInWorkspace(); FakeNuGetProject project = AddNuGetProjectToSolution(); var versionRange = new VersionRange( minVersion: new NuGetVersion("1.0"), includeMinVersion: true, maxVersion: new NuGetVersion("2.0"), includeMaxVersion: true); project.AddPackageReference("Test", "1.0", versionRange); var package = packageMetadataResource.AddPackageMetadata("Test", "2.0").Identity; packageMetadataResource.AddPackageMetadata("Test", "3.0"); var expectedPackages = new [] { package }; await CheckForUpdates(); var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages(dotNetProject); CollectionAssert.AreEqual(expectedPackages, updatedPackages.GetPackages()); }
public async Task GetUpdatedPackages_SecondSolutionOpenedWhilstCheckingForUpdatesForFirstSolution_UpdatesFoundForProjectsInBothSolutions() { CreateUpdatedPackagesInWorkspace(); FakeNuGetProject project = AddNuGetProjectToSolution(); project.AddPackageReference("MyPackage", "1.0"); packageMetadataResource.AddPackageMetadata("MyPackage", "1.1"); packageMetadataResource.AddPackageMetadata("AnotherPackage", "1.2"); var firstDotNetProject = dotNetProject; FakeDotNetProject secondDotNetProject = null; taskRunner.AfterCheckForUpdatesAction = () => { if (secondDotNetProject == null) { solution = new FakeSolution(); FakeNuGetProject anotherProject = AddNuGetProjectToSolution(); anotherProject.AddPackageReference("AnotherPackage", "0.1"); secondDotNetProject = dotNetProject; updatedPackagesInWorkspace.CheckForUpdates(solution); } }; await CheckForUpdates(); // Wait for second solution checks. await taskRunner.CheckForUpdatesTask; var updatedPackagesForProjectInFirstSolution = updatedPackagesInWorkspace.GetUpdatedPackages(firstDotNetProject); var updatedPackagesForProjectInSecondSolution = updatedPackagesInWorkspace.GetUpdatedPackages(secondDotNetProject); Assert.AreEqual(1, updatedPackagesForProjectInFirstSolution.GetPackages().Count()); Assert.AreEqual("MyPackage", updatedPackagesForProjectInFirstSolution.GetPackages().First().Id); Assert.AreEqual("1.1", updatedPackagesForProjectInFirstSolution.GetPackages().First().Version.ToString()); Assert.AreEqual(1, updatedPackagesForProjectInSecondSolution.GetPackages().Count()); Assert.AreEqual("AnotherPackage", updatedPackagesForProjectInSecondSolution.GetPackages().First().Id); Assert.AreEqual("1.2", updatedPackagesForProjectInSecondSolution.GetPackages().First().Version.ToString()); }
void CreateProject() { project = new FakeDotNetProject(@"d:\projects\MyProject\MyProject.csproj".ToNativePath()); nugetProject = new FakeNuGetProject(project); }
void CreateProjectReferenceMaintainer(FakeNuGetProject fakeNuGetProject) { maintainer = new ProjectReferenceMaintainer(fakeNuGetProject); }