public void Install_should_raise_the_event_to_register_NuGet_source_before_and_after() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var mwInstl = new MachineWideInstallation("2.0.0"); var toolsPath = @"C:\ProgramData\chocolatey\lib\Prig\tools"; fixture.FreezeUninstalledEnvironment(toolsPath); var stdout = fixture.Create<string>(); { var m = fixture.Freeze<Mock<INuGetExecutor>>(); m.Setup(_ => _.StartSourcing(It.IsAny<string>(), It.IsAny<string>())).Returns(stdout); } var mocks = new MockRepository(MockBehavior.Strict); var order = new MockOrder(); mwInstl.NuGetSourceRegistering += mocks.InOrder<Action<string, string>>(order, m => m.Setup(_ => _("Prig Source", toolsPath))).Object; mwInstl.NuGetSourceRegistered += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(stdout))).Object; var mwInstllr = fixture.NewMachineWideInstaller(); // Act mwInstllr.Install(mwInstl); // Assert mocks.VerifyAll(); }
public void Install_should_register_environment_variables() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var mwInstl = new MachineWideInstallation("2.0.0"); fixture.FreezeUninstalledEnvironment(); { var pkgDir = @"C:\ProgramData\chocolatey\lib\Prig"; var m = fixture.Freeze<Mock<IEnvironmentRepository>>(); m.Setup(_ => _.GetPackageFolder()).Returns(pkgDir).Verifiable(); m.Setup(_ => _.GetPackageFolderKey()).ReturnsUsingFixture(fixture).Verifiable(); var variableValue = pkgDir; m.Setup(_ => _.StorePackageFolder(variableValue)).Verifiable(); } var mwInstllr = fixture.NewMachineWideInstaller(); // Act mwInstllr.Install(mwInstl); // Assert fixture.Freeze<Mock<IEnvironmentRepository>>().Verify(); }
public void Uninstall_should_unregister_profiler() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var mwUninstl = new MachineWideUninstallation("2.0.0"); var profLocs = new[] { new ProfilerLocation(RegistryView.Registry32, fixture.Create<string>()), new ProfilerLocation(RegistryView.Registry64, fixture.Create<string>()) }; fixture.FreezeInstalledEnvironment(profLocs); { var m = fixture.Freeze<Mock<IRegsvr32Executor>>(); m.Setup(_ => _.StartUninstalling(profLocs[0].PathOfInstalling)).ReturnsUsingFixture(fixture); m.Setup(_ => _.StartUninstalling(profLocs[1].PathOfInstalling)).ReturnsUsingFixture(fixture); } var mwInstllr = fixture.NewMachineWideInstaller(); // Act mwInstllr.Uninstall(mwUninstl); // Assert fixture.Freeze<Mock<IRegsvr32Executor>>().VerifyAll(); }
public void Install_should_register_NuGet_source() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var mwInstl = new MachineWideInstallation("2.0.0"); fixture.FreezeUninstalledEnvironment(toolsPath: @"C:\ProgramData\chocolatey\lib\Prig\tools"); { var name = @"Prig Source"; var source = @"C:\ProgramData\chocolatey\lib\Prig\tools"; var m = fixture.Freeze<Mock<INuGetExecutor>>(); m.Setup(_ => _.StartSourcing(name, source)).Returns(fixture.Create<string>()); } var mwInstllr = fixture.NewMachineWideInstaller(); // Act mwInstllr.Install(mwInstl); // Assert fixture.Freeze<Mock<INuGetExecutor>>().VerifyAll(); }
public void Install_should_install_the_newest_TestWindow_as_default_source_in_VS2015Update1() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var mwInstl = new MachineWideInstallation("2.0.0"); fixture.FreezeUninstalledEnvironment(); var msvsdirPath = @"^C:\\Program Files \(x86\)\\Microsoft Visual Studio \d+\.\d+\\"; var testWindowVS2015x86 = msvsdirPath + @"Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow$"; var testWindowVS2015x64 = msvsdirPath + @"Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\x64$"; { var m = fixture.Freeze<Mock<IEnvironmentRepository>>(); m.Setup(_ => _.ExistsDirectory(It.IsRegex(testWindowVS2015x64))).Returns(true); } { var m = new Mock<IPrigExecutor>(MockBehavior.Strict); m.Setup(_ => _.StartInstalling("TestWindow", It.IsRegex(testWindowVS2015x86))).ReturnsUsingFixture(fixture); m.Setup(_ => _.StartInstalling("TestWindow1", It.IsRegex(testWindowVS2015x64))).ReturnsUsingFixture(fixture); fixture.Inject(m); } var mwInstllr = fixture.NewMachineWideInstaller(); // Act mwInstllr.Install(mwInstl); // Assert fixture.Freeze<Mock<IPrigExecutor>>().VerifyAll(); }
public void Install_should_call_installation_steps_by_a_fixed_sequence() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var mwInstl = new MachineWideInstallation("2.0.0"); fixture.FreezeUninstalledEnvironment(); var profLocs = new[] { new ProfilerLocation(RegistryView.Registry32, fixture.Create<string>()) }; { var m = fixture.Freeze<Mock<IEnvironmentRepository>>(); m.Setup(_ => _.GetProfilerLocations()).Returns(profLocs); m.Setup(_ => _.OpenRegistryBaseKey(RegistryHive.ClassesRoot, profLocs[0].RegistryView)).Returns(RegistryKeyMixin.DummyX86ClassesRootKey); m.Setup(_ => _.OpenRegistrySubKey(RegistryKeyMixin.DummyX86ClassesRootKey, ProfilerLocation.InprocServer32Path)).Returns(RegistryKeyMixin.DummyX86InProcServer32Key); m.Setup(_ => _.GetRegistryValue(RegistryKeyMixin.DummyX86InProcServer32Key, null)).Returns(fixture.Create<string>()); } var mocks = new MockRepository(MockBehavior.Strict); var order = new MockOrder(); mwInstl.Preparing += mocks.InOrder<Action>(order, m => m.Setup(_ => _())).Object; mwInstl.ProfilerStatusChecking += mocks.InOrder<Action<ProfilerLocation>>(order, m => m.Setup(_ => _(It.IsAny<ProfilerLocation>()))).Object; mwInstl.NuGetPackageCreating += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object; mwInstl.NuGetPackageCreated += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object; mwInstl.NuGetSourceRegistering += mocks.InOrder<Action<string, string>>(order, m => m.Setup(_ => _(It.IsAny<string>(), It.IsAny<string>()))).Object; mwInstl.NuGetSourceRegistered += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object; mwInstl.EnvironmentVariableRegistering += mocks.InOrder<Action<string, string>>(order, m => m.Setup(_ => _(It.IsAny<string>(), It.IsAny<string>()))).Object; mwInstl.EnvironmentVariableRegistered += mocks.InOrder<Action<string, string>>(order, m => m.Setup(_ => _(It.IsAny<string>(), It.IsAny<string>()))).Object; mwInstl.ProfilerRegistering += mocks.InOrder<Action<ProfilerLocation>>(order, m => m.Setup(_ => _(It.IsAny<ProfilerLocation>()))).Object; mwInstl.ProfilerRegistered += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object; mwInstl.DefaultSourceInstalling += mocks.InOrder<Action<string, string>>(order, m => m.Setup(_ => _(It.IsAny<string>(), It.IsAny<string>()))).Object; mwInstl.DefaultSourceInstalled += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object; mwInstl.Completed += mocks.InOrder<Action<MachineWideProcessResults>>(order, m => m.Setup(_ => _(It.IsAny<MachineWideProcessResults>()))).Object; var mwInstllr = fixture.NewMachineWideInstaller(); // Act mwInstllr.Install(mwInstl); // Assert mocks.VerifyAll(); }
public void HasBeenInstalled_should_throw_ArgumentNullException_if_null_is_passed() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var mwInstllr = fixture.NewMachineWideInstaller(); // Act, Assert Assert.Throws<ArgumentNullException>(() => mwInstllr.HasBeenInstalled(null)); }
public void Install_should_not_register_profiler_if_profiler_locations_are_empty() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var mwInstl = new MachineWideInstallation("2.0.0"); fixture.FreezeUninstalledEnvironment(); var profLocs = new ProfilerLocation[0]; { var m = fixture.Freeze<Mock<IEnvironmentRepository>>(); m.Setup(_ => _.GetProfilerLocations()).Returns(profLocs); } fixture.Inject(new Mock<IRegsvr32Executor>()); var mwInstllr = fixture.NewMachineWideInstaller(); // Act mwInstllr.Install(mwInstl); // Assert { var m = fixture.Freeze<Mock<IRegsvr32Executor>>(); m.Verify(_ => _.StartInstalling(It.IsAny<string>()), Times.Never()); } }
public void Uninstall_should_call_uninstallation_steps_by_a_fixed_sequence() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var mwUninstl = new MachineWideUninstallation("2.0.0"); fixture.FreezeInstalledEnvironment(); var mocks = new MockRepository(MockBehavior.Strict); var order = new MockOrder(); mwUninstl.Preparing += mocks.InOrder<Action>(order, m => m.Setup(_ => _())).Object; mwUninstl.ProfilerStatusChecking += mocks.InOrder<Action<ProfilerLocation>>(order, m => m.Setup(_ => _(It.IsAny<ProfilerLocation>()))).Object; mwUninstl.DefaultSourceUninstalling += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object; mwUninstl.DefaultSourceUninstalled += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object; mwUninstl.ProfilerUnregistering += mocks.InOrder<Action<ProfilerLocation>>(order, m => m.Setup(_ => _(It.IsAny<ProfilerLocation>()))).Object; mwUninstl.ProfilerUnregistered += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object; mwUninstl.EnvironmentVariableUnregistering += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object; mwUninstl.EnvironmentVariableUnregistered += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object; mwUninstl.NuGetSourceUnregistering += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object; mwUninstl.NuGetSourceUnregistered += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(It.IsAny<string>()))).Object; mwUninstl.Completed += mocks.InOrder<Action<MachineWideProcessResults>>(order, m => m.Setup(_ => _(It.IsAny<MachineWideProcessResults>()))).Object; var mwInstllr = fixture.NewMachineWideInstaller(); // Act mwInstllr.Uninstall(mwUninstl); // Assert mocks.VerifyAll(); }
public void HasBeenInstalled_should_raise_the_checking_event_even_if_profiler_has_not_registered_yet() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var machinePreq = new MachinePrerequisite("2.0.0"); var profLocs = new[] { new ProfilerLocation(RegistryView.Registry32, fixture.Create<string>()) }; { var m = new Mock<IEnvironmentRepository>(MockBehavior.Strict); m.Setup(_ => _.GetProfilerLocations()).Returns(profLocs); m.Setup(_ => _.OpenRegistryBaseKey(RegistryHive.ClassesRoot, profLocs[0].RegistryView)).Returns(RegistryKeyMixin.DummyX86ClassesRootKey); m.Setup(_ => _.OpenRegistrySubKey(RegistryKeyMixin.DummyX86ClassesRootKey, ProfilerLocation.InprocServer32Path)).Returns(default(RegistryKey)); fixture.Inject(m); } { var m = new Mock<Action<ProfilerLocation>>(MockBehavior.Strict); m.Setup(_ => _(profLocs[0])); fixture.Inject(m); machinePreq.ProfilerStatusChecking += m.Object; } var mwInstllr = fixture.NewMachineWideInstaller(); // Act mwInstllr.HasBeenInstalled(machinePreq); // Assert fixture.Freeze<Mock<Action<ProfilerLocation>>>().VerifyAll(); }
public void Uninstall_should_unregister_NuGet_source() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var mwUninstl = new MachineWideUninstallation("2.0.0"); fixture.FreezeInstalledEnvironment(); { var name = @"Prig Source"; var m = fixture.Freeze<Mock<INuGetExecutor>>(); m.Setup(_ => _.StartUnsourcing(name)).Returns(fixture.Create<string>()); } var mwInstllr = fixture.NewMachineWideInstaller(); // Act mwInstllr.Uninstall(mwUninstl); // Assert fixture.Freeze<Mock<INuGetExecutor>>().VerifyAll(); }
public void Uninstall_should_unregister_environment_variables() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var mwUninstl = new MachineWideUninstallation("2.0.0"); fixture.FreezeInstalledEnvironment(); { var m = fixture.Freeze<Mock<IEnvironmentRepository>>(); m.Setup(_ => _.GetPackageFolderKey()).ReturnsUsingFixture(fixture).Verifiable(); m.Setup(_ => _.RemovePackageFolder()).Verifiable(); } var mwInstllr = fixture.NewMachineWideInstaller(); // Act mwInstllr.Uninstall(mwUninstl); // Assert fixture.Freeze<Mock<IEnvironmentRepository>>().Verify(); }
public void Uninstall_should_raise_the_event_to_unregister_profiler_before_and_after() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var mwUninstl = new MachineWideUninstallation("2.0.0"); var profLocs = new[] { new ProfilerLocation(RegistryView.Registry32, fixture.Create<string>()), new ProfilerLocation(RegistryView.Registry64, fixture.Create<string>()) }; fixture.FreezeInstalledEnvironment(profLocs); var stdouts = fixture.CreateMany<string>(2).ToArray(); { var m = fixture.Freeze<Mock<IRegsvr32Executor>>(); m.Setup(_ => _.StartUninstalling(profLocs[0].PathOfInstalling)).Returns(stdouts[0]); m.Setup(_ => _.StartUninstalling(profLocs[1].PathOfInstalling)).Returns(stdouts[1]); } var mocks = new MockRepository(MockBehavior.Strict); var order1 = new MockOrder(); var order2 = new MockOrder(); mwUninstl.ProfilerUnregistering += mocks.Create<Action<ProfilerLocation>>(). InOrder(order1, m => m.Setup(_ => _(profLocs[0]))). InOrder(order2, m => m.Setup(_ => _(profLocs[1]))).Object; mwUninstl.ProfilerUnregistered += mocks.Create<Action<string>>(). InOrder(order1, m => m.Setup(_ => _(stdouts[0]))). InOrder(order2, m => m.Setup(_ => _(stdouts[1]))).Object; var mwInstllr = fixture.NewMachineWideInstaller(); // Act mwInstllr.Uninstall(mwUninstl); // Assert mocks.VerifyAll(); }
public void Install_should_raise_the_event_to_register_environment_variables_before_and_after() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var mwInstl = new MachineWideInstallation("2.0.0"); fixture.FreezeUninstalledEnvironment(); var pkgDir = @"C:\ProgramData\chocolatey\lib\Prig"; var variableName = "URASANDESU_PRIG_PACKAGE_FOLDER"; var variableValue = pkgDir; { var m = fixture.Freeze<Mock<IEnvironmentRepository>>(); m.Setup(_ => _.GetPackageFolder()).Returns(pkgDir); m.Setup(_ => _.GetPackageFolderKey()).Returns(variableName); m.Setup(_ => _.StorePackageFolder(variableValue)); } var mocks = new MockRepository(MockBehavior.Strict); var order = new MockOrder(); mwInstl.EnvironmentVariableRegistering += mocks.InOrder<Action<string, string>>(order, m => m.Setup(_ => _(variableName, variableValue))).Object; mwInstl.EnvironmentVariableRegistered += mocks.InOrder<Action<string, string>>(order, m => m.Setup(_ => _(variableName, variableValue))).Object; var mwInstllr = fixture.NewMachineWideInstaller(); // Act mwInstllr.Install(mwInstl); // Assert mocks.VerifyAll(); }
public void Install_should_skip_installation_if_it_has_been_already_installed() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var mwInstl = new MachineWideInstallation("2.0.0"); fixture.FreezeInstalledEnvironment(); fixture.Inject(new Mock<INuGetExecutor>(MockBehavior.Strict)); fixture.Inject(new Mock<IRegsvr32Executor>(MockBehavior.Strict)); fixture.Inject(new Mock<IPrigExecutor>(MockBehavior.Strict)); var mwInstllr = fixture.NewMachineWideInstaller(); // Act, Assert mwInstllr.Install(mwInstl); }
public void Install_should_register_profiler() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var mwInstl = new MachineWideInstallation("2.0.0"); fixture.FreezeUninstalledEnvironment(); var profLocs = new[] { new ProfilerLocation(RegistryView.Registry32, fixture.Create<string>()), new ProfilerLocation(RegistryView.Registry64, fixture.Create<string>()) }; { var m = fixture.Freeze<Mock<IEnvironmentRepository>>(); m.Setup(_ => _.GetProfilerLocations()).Returns(profLocs); m.Setup(_ => _.OpenRegistryBaseKey(RegistryHive.ClassesRoot, profLocs[0].RegistryView)).Returns(RegistryKeyMixin.DummyX86ClassesRootKey); m.Setup(_ => _.OpenRegistrySubKey(RegistryKeyMixin.DummyX86ClassesRootKey, ProfilerLocation.InprocServer32Path)).Returns(RegistryKeyMixin.DummyX86InProcServer32Key); m.Setup(_ => _.GetRegistryValue(RegistryKeyMixin.DummyX86InProcServer32Key, null)).Returns(fixture.Create<string>()); } { var m = fixture.Freeze<Mock<IRegsvr32Executor>>(); m.Setup(_ => _.StartInstalling(profLocs[0].PathOfInstalling)).ReturnsUsingFixture(fixture); m.Setup(_ => _.StartInstalling(profLocs[1].PathOfInstalling)).ReturnsUsingFixture(fixture); } var mwInstllr = fixture.NewMachineWideInstaller(); // Act mwInstllr.Install(mwInstl); // Assert fixture.Freeze<Mock<IRegsvr32Executor>>().VerifyAll(); { var m = fixture.Freeze<Mock<IEnvironmentRepository>>(); m.Verify(_ => _.OpenRegistryBaseKey(RegistryHive.ClassesRoot, profLocs[0].RegistryView), Times.Once()); m.Verify(_ => _.OpenRegistrySubKey(RegistryKeyMixin.DummyX86ClassesRootKey, ProfilerLocation.InprocServer32Path), Times.Once()); } }
public void Install_should_register_package_folder() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var mwInstl = new MachineWideInstallation("2.0.0"); fixture.FreezeUninstalledEnvironment(); { var m = fixture.Freeze<Mock<IEnvironmentRepository>>(); m.Setup(_ => _.RegisterPackageFolder()).Verifiable(); } var mwInstllr = fixture.NewMachineWideInstaller(); // Act mwInstllr.Install(mwInstl); // Assert fixture.Freeze<Mock<IEnvironmentRepository>>().Verify(); }
public void Install_should_raise_the_event_to_register_profiler_before_and_after() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var mwInstl = new MachineWideInstallation("2.0.0"); fixture.FreezeUninstalledEnvironment(); var profLocs = new[] { new ProfilerLocation(RegistryView.Registry32, fixture.Create<string>()), new ProfilerLocation(RegistryView.Registry64, fixture.Create<string>()) }; { var m = fixture.Freeze<Mock<IEnvironmentRepository>>(); m.Setup(_ => _.GetProfilerLocations()).Returns(profLocs); m.Setup(_ => _.OpenRegistryBaseKey(RegistryHive.ClassesRoot, profLocs[0].RegistryView)).Returns(RegistryKeyMixin.DummyX86ClassesRootKey); m.Setup(_ => _.OpenRegistrySubKey(RegistryKeyMixin.DummyX86ClassesRootKey, ProfilerLocation.InprocServer32Path)).Returns(RegistryKeyMixin.DummyX86InProcServer32Key); m.Setup(_ => _.GetRegistryValue(RegistryKeyMixin.DummyX86InProcServer32Key, null)).Returns(fixture.Create<string>()); m.Setup(_ => _.OpenRegistryBaseKey(RegistryHive.ClassesRoot, profLocs[1].RegistryView)).Returns(RegistryKeyMixin.DummyX64ClassesRootKey); m.Setup(_ => _.OpenRegistrySubKey(RegistryKeyMixin.DummyX64ClassesRootKey, ProfilerLocation.InprocServer32Path)).Returns(RegistryKeyMixin.DummyX64InProcServer32Key); m.Setup(_ => _.GetRegistryValue(RegistryKeyMixin.DummyX64InProcServer32Key, null)).Returns(fixture.Create<string>()); } var stdouts = fixture.CreateMany<string>(2).ToArray(); { var m = fixture.Freeze<Mock<IRegsvr32Executor>>(); m.Setup(_ => _.StartInstalling(profLocs[0].PathOfInstalling)).Returns(stdouts[0]); m.Setup(_ => _.StartInstalling(profLocs[1].PathOfInstalling)).Returns(stdouts[1]); } var mocks = new MockRepository(MockBehavior.Strict); var order1 = new MockOrder(); var order2 = new MockOrder(); mwInstl.ProfilerRegistering += mocks.Create<Action<ProfilerLocation>>(). InOrder(order1, m => m.Setup(_ => _(profLocs[0]))). InOrder(order2, m => m.Setup(_ => _(profLocs[1]))).Object; mwInstl.ProfilerRegistered += mocks.Create<Action<string>>(). InOrder(order1, m => m.Setup(_ => _(stdouts[0]))). InOrder(order2, m => m.Setup(_ => _(stdouts[1]))).Object; var mwInstllr = fixture.NewMachineWideInstaller(); // Act mwInstllr.Install(mwInstl); // Assert mocks.VerifyAll(); }
public void Install_should_create_Nupkg() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var mwInstl = new MachineWideInstallation("2.0.0"); fixture.FreezeUninstalledEnvironment(toolsPath: @"C:\ProgramData\chocolatey\lib\Prig\tools"); { var nuspec = @"C:\ProgramData\chocolatey\lib\Prig\tools\NuGet\Prig.nuspec"; var outputDirectory = @"C:\ProgramData\chocolatey\lib\Prig\tools"; var m = fixture.Freeze<Mock<INuGetExecutor>>(); m.Setup(_ => _.StartPacking(nuspec, outputDirectory)).Returns(fixture.Create<string>()); } var mwInstllr = fixture.NewMachineWideInstaller(); // Act mwInstllr.Install(mwInstl); // Assert fixture.Freeze<Mock<INuGetExecutor>>().VerifyAll(); }
public void Install_should_raise_the_event_to_install_the_newest_TestWindow_before_and_after_in_VS2015Update1() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var mwInstl = new MachineWideInstallation("2.0.0"); fixture.FreezeUninstalledEnvironment(); var msvsdirPath = @"^C:\\Program Files \(x86\)\\Microsoft Visual Studio \d+\.\d+\\"; var testWindowVS2015x86 = msvsdirPath + @"Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow$"; var testWindowVS2015x64 = msvsdirPath + @"Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\x64$"; { var m = fixture.Freeze<Mock<IEnvironmentRepository>>(); m.Setup(_ => _.ExistsDirectory(It.IsRegex(testWindowVS2015x64))).Returns(true); } var stdouts = fixture.CreateMany<string>(2).ToArray(); { var m = fixture.Freeze<Mock<IPrigExecutor>>(); m.Setup(_ => _.StartInstalling("TestWindow", It.IsRegex(testWindowVS2015x86))).Returns(stdouts[0]); m.Setup(_ => _.StartInstalling("TestWindow1", It.IsRegex(testWindowVS2015x64))).Returns(stdouts[1]); } var mocks = new MockRepository(MockBehavior.Strict); var order1 = new MockOrder(); var order2 = new MockOrder(); mwInstl.DefaultSourceInstalling += mocks.Create<Action<string, string>>(). InOrder(order1, m => m.Setup(_ => _("TestWindow", It.IsRegex(testWindowVS2015x86)))). InOrder(order2, m => m.Setup(_ => _("TestWindow1", It.IsRegex(testWindowVS2015x64)))).Object; mwInstl.DefaultSourceInstalled += mocks.Create<Action<string>>(). InOrder(order1, m => m.Setup(_ => _(stdouts[0]))). InOrder(order2, m => m.Setup(_ => _(stdouts[1]))).Object; var mwInstllr = fixture.NewMachineWideInstaller(); // Act mwInstllr.Install(mwInstl); // Assert mocks.VerifyAll(); }
public void Install_should_raise_the_event_to_create_Nupkg_before_and_after() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var mwInstl = new MachineWideInstallation("2.0.0"); fixture.FreezeUninstalledEnvironment(); var stdout = fixture.Create<string>(); { var m = fixture.Freeze<Mock<INuGetExecutor>>(); m.Setup(_ => _.StartPacking(It.IsAny<string>(), It.IsAny<string>())).Returns(stdout); } var mocks = new MockRepository(MockBehavior.Strict); var order = new MockOrder(); mwInstl.NuGetPackageCreating += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _("Prig"))).Object; mwInstl.NuGetPackageCreated += mocks.InOrder<Action<string>>(order, m => m.Setup(_ => _(stdout))).Object; var mwInstllr = fixture.NewMachineWideInstaller(); // Act mwInstllr.Install(mwInstl); // Assert mocks.VerifyAll(); }
public void Install_should_raise_the_events_for_the_installation_steps_if_skipped() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var mwInstl = new MachineWideInstallation("2.0.0"); fixture.FreezeInstalledEnvironment(); var mocks = new MockRepository(MockBehavior.Strict); var order = new MockOrder(); mwInstl.Completed += mocks.InOrder<Action<MachineWideProcessResults>>(order, m => m.Setup(_ => _(MachineWideProcessResults.Skipped))).Object; var mwInstllr = fixture.NewMachineWideInstaller(); // Act mwInstllr.Install(mwInstl); // Assert mocks.VerifyAll(); }
public void Uninstall_should_uninstall_all_sources() { // Arrange var fixture = new Fixture().Customize(new AutoMoqCustomization()); var mwUninstl = new MachineWideUninstallation("2.0.0"); fixture.FreezeInstalledEnvironment(); { var m = fixture.Freeze<Mock<IPrigExecutor>>(); m.Setup(_ => _.StartUninstalling("All")).ReturnsUsingFixture(fixture); } var mwInstllr = fixture.NewMachineWideInstaller(); // Act mwInstllr.Uninstall(mwUninstl); // Assert fixture.Freeze<Mock<IPrigExecutor>>().VerifyAll(); }