public void Execute_ReferenceHasLocalCopyFalseWhenUninstalled_ReferenceHasLocalCopyFalseAfterBeingReinstalled() { CreateAction("MyPackage", "1.2.3.4"); AddUninstallPackageIntoProjectAction("MyPackage", "1.2.3.4"); AddInstallPackageIntoProjectAction("MyPackage", "1.2.3.4"); var firstReferenceBeingAdded = ProjectReference.CreateCustomReference(ReferenceType.Assembly, "NewAssembly"); var secondReferenceBeingAdded = ProjectReference.CreateCustomReference(ReferenceType.Assembly, "NUnit.Framework"); uninstallPackageManager.BeforeExecuteAction = () => { var referenceBeingRemoved = ProjectReference.CreateCustomReference(ReferenceType.Assembly, "NUnit.Framework"); referenceBeingRemoved.LocalCopy = false; packageManagementEvents.OnReferenceRemoving(referenceBeingRemoved); }; bool installActionMaintainsLocalCopyReferences = false; installPackageManager.BeforeExecuteAction = () => { installActionMaintainsLocalCopyReferences = action.InstallAction.PreserveLocalCopyReferences; packageManagementEvents.OnReferenceAdding(firstReferenceBeingAdded); packageManagementEvents.OnReferenceAdding(secondReferenceBeingAdded); }; action.Execute(); Assert.IsTrue(firstReferenceBeingAdded.LocalCopy); Assert.IsFalse(secondReferenceBeingAdded.LocalCopy); Assert.IsFalse(installActionMaintainsLocalCopyReferences, "Should be false since the reinstall action will maintain the local copies"); }
public void Execute_PackageAlreadyExistsWhenInstallingItAgainAndReferenceBeingInstalledOriginallyHadLocalCopyFalse_ReferenceAddedHasLocalCopyFalse() { var originalProjectReference = ProjectReference.CreateCustomReference(ReferenceType.Assembly, "nunit.framework"); originalProjectReference.LocalCopy = false; CreateAction("Test", "2.1", originalProjectReference); action.PreserveLocalCopyReferences = true; var firstReferenceBeingAdded = ProjectReference.CreateCustomReference(ReferenceType.Assembly, "NewAssembly"); var secondReferenceBeingAdded = ProjectReference.CreateCustomReference(ReferenceType.Assembly, "NUnit.Framework"); packageManager.BeforeExecuteActionTask = async() => { await nugetProject.ProjectReferenceMaintainer.RemoveReference(originalProjectReference); packageManagementEvents.OnReferenceRemoving(originalProjectReference); packageManagementEvents.OnReferenceAdding(firstReferenceBeingAdded); await nugetProject.ProjectReferenceMaintainer.AddReference(firstReferenceBeingAdded); packageManagementEvents.OnReferenceAdding(secondReferenceBeingAdded); await nugetProject.ProjectReferenceMaintainer.AddReference(secondReferenceBeingAdded); }; action.Execute(); var nunitFrameworkReference = project.References.FirstOrDefault(r => r.Reference == originalProjectReference.Reference); var newReference = project.References.FirstOrDefault(r => r.Reference == "NewAssembly"); Assert.IsTrue(newReference.LocalCopy); Assert.IsFalse(nunitFrameworkReference.LocalCopy); Assert.IsTrue(action.PreserveLocalCopyReferences); }
public void Execute_ReferenceBeingUpdatedHasLocalCopyTrue_ReferenceAddedHasLocalCopyTrue() { var originalProjectReference = ProjectReference.CreateCustomReference(ReferenceType.Assembly, "nunit.framework"); originalProjectReference.LocalCopy = true; CreateAction("Test", originalProjectReference); AddInstallPackageIntoProjectAction("Test", "1.2"); var firstReferenceBeingAdded = ProjectReference.CreateCustomReference(ReferenceType.Assembly, "NewAssembly"); var secondReferenceBeingAdded = ProjectReference.CreateCustomReference(ReferenceType.Assembly, "NUnit.Framework"); packageManager.BeforeExecuteActionTask = async() => { await nugetProject.ProjectReferenceMaintainer.RemoveReference(originalProjectReference); packageManagementEvents.OnReferenceRemoving(originalProjectReference); packageManagementEvents.OnReferenceAdding(firstReferenceBeingAdded); await nugetProject.ProjectReferenceMaintainer.AddReference(firstReferenceBeingAdded); packageManagementEvents.OnReferenceAdding(secondReferenceBeingAdded); await nugetProject.ProjectReferenceMaintainer.AddReference(secondReferenceBeingAdded); }; action.Execute(); var nunitFrameworkReference = project.References.FirstOrDefault(r => r.Reference == originalProjectReference.Reference); var newReference = project.References.FirstOrDefault(r => r.Reference == "NewAssembly"); Assert.IsTrue(newReference.LocalCopy); Assert.IsTrue(nunitFrameworkReference.LocalCopy); }
public void AddReference(string referencePath, Stream stream) { GuiSyncDispatch(() => { ProjectReference assemblyReference = CreateReference(referencePath); packageManagementEvents.OnReferenceAdding(assemblyReference); AddReferenceToProject(assemblyReference); }); }
public Task AddReferenceAsync(string referencePath) { return(GuiSyncDispatchAsync(async() => { ProjectReference assemblyReference = CreateReference(referencePath); packageManagementEvents.OnReferenceAdding(assemblyReference); await AddReferenceToProject(assemblyReference); })); }
public void Execute_PackageAlreadyExistsWhenInstallingItAgainAndReferenceBeingInstalledOriginallyHadLocalCopyFalse_ReferenceAddedHasLocalCopyFalse() { CreateAction(); action.PreserveLocalCopyReferences = true; var firstReferenceBeingAdded = ProjectReference.CreateCustomReference(ReferenceType.Assembly, "NewAssembly"); var secondReferenceBeingAdded = ProjectReference.CreateCustomReference(ReferenceType.Assembly, "NUnit.Framework"); packageManager.BeforeExecuteAction = () => { var referenceBeingRemoved = ProjectReference.CreateCustomReference(ReferenceType.Assembly, "NUnit.Framework"); referenceBeingRemoved.LocalCopy = false; packageManagementEvents.OnReferenceRemoving(referenceBeingRemoved); packageManagementEvents.OnReferenceAdding(firstReferenceBeingAdded); packageManagementEvents.OnReferenceAdding(secondReferenceBeingAdded); }; action.Execute(); Assert.IsTrue(firstReferenceBeingAdded.LocalCopy); Assert.IsFalse(secondReferenceBeingAdded.LocalCopy); Assert.IsTrue(action.PreserveLocalCopyReferences); }
public void Execute_ReferenceBeingUpdatedHasLocalCopyTrue_ReferenceAddedHasLocalCopyTrue() { CreateAction(); AddInstallPackageIntoProjectAction("Test", "1.2"); var firstReferenceBeingAdded = ProjectReference.CreateCustomReference(ReferenceType.Assembly, "NewAssembly"); var secondReferenceBeingAdded = ProjectReference.CreateCustomReference(ReferenceType.Assembly, "NUnit.Framework"); packageManager.BeforeExecuteAction = () => { var referenceBeingRemoved = ProjectReference.CreateCustomReference(ReferenceType.Assembly, "NUnit.Framework"); referenceBeingRemoved.LocalCopy = true; packageManagementEvents.OnReferenceRemoving(referenceBeingRemoved); packageManagementEvents.OnReferenceAdding(firstReferenceBeingAdded); packageManagementEvents.OnReferenceAdding(secondReferenceBeingAdded); }; action.Execute(); Assert.IsTrue(firstReferenceBeingAdded.LocalCopy); Assert.IsTrue(secondReferenceBeingAdded.LocalCopy); }
public void OnReferenceAdding(ProjectReference reference) { unsafeEvents.OnReferenceAdding(reference); }