本文整理汇总了C#中Fixture.NewMachineWideInstaller方法的典型用法代码示例。如果您正苦于以下问题:C# Fixture.NewMachineWideInstaller方法的具体用法?C# Fixture.NewMachineWideInstaller怎么用?C# Fixture.NewMachineWideInstaller使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fixture
的用法示例。
在下文中一共展示了Fixture.NewMachineWideInstaller方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Install_should_raise_the_event_to_register_NuGet_source_before_and_after
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();
}
示例2: Install_should_register_environment_variables
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();
}
示例3: Uninstall_should_unregister_profiler
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();
}
示例4: Install_should_register_NuGet_source
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();
}
示例5: Install_should_install_the_newest_TestWindow_as_default_source_in_VS2015Update1
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();
}
示例6: Install_should_call_installation_steps_by_a_fixed_sequence
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();
}
示例7: HasBeenInstalled_should_throw_ArgumentNullException_if_null_is_passed
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));
}
示例8: Install_should_not_register_profiler_if_profiler_locations_are_empty
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());
}
}
示例9: Uninstall_should_call_uninstallation_steps_by_a_fixed_sequence
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();
}
示例10: HasBeenInstalled_should_raise_the_checking_event_even_if_profiler_has_not_registered_yet
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();
}
示例11: Uninstall_should_unregister_NuGet_source
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();
}
示例12: Uninstall_should_unregister_environment_variables
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();
}
示例13: Uninstall_should_raise_the_event_to_unregister_profiler_before_and_after
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();
}
示例14: Install_should_raise_the_event_to_register_environment_variables_before_and_after
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();
}
示例15: Install_should_skip_installation_if_it_has_been_already_installed
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);
}