public void Install_should_uninstall_and_install_if_different_version_package_has_already_been_installed() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var proj = fixture.Freeze <Project>(); var pwPkg = new ProjectWidePackage("Prig", "2.0.0", proj); var mocks = new MockRepository(MockBehavior.Strict); { var m = mocks.Create <IVsPackageInstallerServices>(); m.Setup(_ => _.IsPackageInstalledEx(proj, "Prig", "2.0.0")).Returns(false); m.Setup(_ => _.IsPackageInstalled(proj, "Prig")).Returns(true); fixture.Inject(m); } { var m = mocks.Create <IVsPackageUninstaller>(); m.Setup(_ => _.UninstallPackage(proj, "Prig", false)); fixture.Inject(m); } { var m = mocks.Create <IVsPackageInstaller>(); m.Setup(_ => _.InstallPackage(default(string), proj, "Prig", "2.0.0", false)); fixture.Inject(m); } var pwInstllr = fixture.NewProjectWideInstaller(); // Act pwInstllr.Install(pwPkg); // Assert mocks.VerifyAll(); }
void RemovePrigAssemblyCore(PrigViewModel vm, string deletionalInclude) { vm.BeginProjectWideProcessProgress(ProjectWideProcesses.PrigAssemblyRemoving); var machinePreq = new MachinePrerequisite(Resources.NuGetRootPackageVersion); machinePreq.ProfilerStatusChecking += profLoc => vm.ReportProfilerStatusCheckingProgress(13u, profLoc); if (!MachineWideInstaller.HasBeenInstalled(machinePreq)) { vm.ShowSkippedProjectWideProcessMessage(SkippedReasons.NotRegisteredYet, deletionalInclude); vm.EndSkippedProjectWideProcessProgress(SkippedReasons.NotRegisteredYet, deletionalInclude); return; } if (!vm.ConfirmRemovingPrigAssembly(deletionalInclude)) { return; } var proj = MonitoringSelectionService.GetCurrentProject(); var pwPkg = new ProjectWidePackage(Resources.NuGetRootPackageId, Resources.NuGetRootPackageVersion, proj); pwPkg.PackagePreparing += () => vm.ReportPackagePreparingProgress(25u); pwPkg.PackageInstalling += metadata => vm.ReportPackageInstallingProgress(50u, metadata); pwPkg.PackageInstalled += metadata => vm.ReportPackageInstalledProgress(50u, metadata); pwPkg.PackageReferenceAdded += metadata => vm.ReportPackageReferenceAddedProgress(50u, metadata); ProjectWideInstaller.Install(pwPkg); var command = string.Format( @" Import-Module ([IO.Path]::Combine($env:URASANDESU_PRIG_PACKAGE_FOLDER, 'tools\Urasandesu.Prig')) Start-PrigSetup -DeletionalInclude {0} -Project $Project ", deletionalInclude); var mci = new ManagementCommandInfo(command, proj); mci.CommandExecuting += () => vm.ReportProcessingProjectWideProcessProgress(75u, deletionalInclude); mci.CommandExecuted += () => { vm.ShowCompletedProjectWideProcessMessage(deletionalInclude); vm.EndCompletedProjectWideProcessProgress(deletionalInclude); }; ManagementCommandExecutor.Execute(mci); }
public void Install_should_call_installation_steps_by_a_fixed_sequence() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var proj = fixture.Freeze <Project>(); var pwPkg = new ProjectWidePackage("Prig", "2.0.0", proj); var callback = default(Action); var metadataArr = fixture.CreateMany <IVsPackageMetadata>(3).ToArray(); { var m = fixture.Freeze <Mock <IVsPackageInstallerEvents> >(); callback = () => { m.Raise(_ => _.PackageInstalling += null, metadataArr[0]); m.Raise(_ => _.PackageInstalled += null, metadataArr[1]); m.Raise(_ => _.PackageReferenceAdded += null, metadataArr[2]); }; } { var m = fixture.Freeze <Mock <IVsPackageInstaller> >(); m.Setup(_ => _.InstallPackage(It.IsAny <string>(), It.IsAny <Project>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())).Callback(callback); } var mocks = new MockRepository(MockBehavior.Strict); var order = new MockOrder(); pwPkg.PackageInstalling += mocks.InOrder <VsPackageEventHandler>(order, m => m.Setup(_ => _(metadataArr[0]))).Object; pwPkg.PackageInstalled += mocks.InOrder <VsPackageEventHandler>(order, m => m.Setup(_ => _(metadataArr[1]))).Object; pwPkg.PackageReferenceAdded += mocks.InOrder <VsPackageEventHandler>(order, m => m.Setup(_ => _(metadataArr[2]))).Object; var pwInstllr = fixture.NewProjectWideInstaller(); // Act pwInstllr.Install(pwPkg); // Assert mocks.VerifyAll(); }
void RemovePrigAssemblyCore(PrigViewModel vm, string deletionalInclude) { vm.BeginProjectWideProcessProgress(ProjectWideProcesses.PrigAssemblyRemoving); var machinePreq = new MachinePrerequisite(Resources.NuGetRootPackageVersion); machinePreq.ProfilerStatusChecking += profLoc => vm.ReportProfilerStatusCheckingProgress(13u, profLoc); if (!MachineWideInstaller.HasBeenInstalled(machinePreq)) { vm.ShowSkippedProjectWideProcessMessage(SkippedReasons.NotRegisteredYet, deletionalInclude); vm.EndSkippedProjectWideProcessProgress(SkippedReasons.NotRegisteredYet, deletionalInclude); return; } if (!vm.ConfirmRemovingPrigAssembly(deletionalInclude)) return; var proj = MonitoringSelectionService.GetCurrentProject(); var pwPkg = new ProjectWidePackage(Resources.NuGetRootPackageId, Resources.NuGetRootPackageVersion, proj); pwPkg.PackagePreparing += () => vm.ReportPackagePreparingProgress(25u); pwPkg.PackageInstalling += metadata => vm.ReportPackageInstallingProgress(50u, metadata); pwPkg.PackageInstalled += metadata => vm.ReportPackageInstalledProgress(50u, metadata); pwPkg.PackageReferenceAdded += metadata => vm.ReportPackageReferenceAddedProgress(50u, metadata); ProjectWideInstaller.Install(pwPkg); var command = string.Format( @" Import-Module ([IO.Path]::Combine($env:URASANDESU_PRIG_PACKAGE_FOLDER, 'tools\Urasandesu.Prig')) Start-PrigSetup -DeletionalInclude {0} -Project $Project ", deletionalInclude); var mci = new ManagementCommandInfo(command, proj); mci.CommandExecuting += () => vm.ReportProcessingProjectWideProcessProgress(75u, deletionalInclude); mci.CommandExecuted += () => { vm.ShowCompletedProjectWideProcessMessage(deletionalInclude); vm.EndCompletedProjectWideProcessProgress(deletionalInclude); }; ManagementCommandExecutor.Execute(mci); }