public InstallationModelTester( MockWixStateProvider wixState, MockJavaEnvironmentStateProvider javaState, MockElasticsearchEnvironmentStateProvider esState, NoopServiceStateProvider serviceState, NoopPluginStateProvider pluginState, MockFileSystem fileSystem, NoopSession session, string[] args) { if (wixState == null) { throw new ArgumentNullException(nameof(wixState)); } if (javaState == null) { throw new ArgumentNullException(nameof(javaState)); } if (esState == null) { throw new ArgumentNullException(nameof(esState)); } this.JavaState = javaState; this.EsState = esState; this.PluginState = pluginState; this.JavaConfig = new JavaConfiguration(javaState); this.EsConfig = ElasticsearchYamlConfiguration.FromFolder(esState.ConfigDirectory, fileSystem); this.JvmConfig = LocalJvmOptionsConfiguration.FromFolder(esState.ConfigDirectory, fileSystem); this.InstallationModel = new InstallationModel( wixState, JavaConfig, esState, serviceState, pluginState, EsConfig, JvmConfig, session, args); this.FileSystem = fileSystem; }
[Fact] void InstallSuppliedUsernameAndPassword() { var model = WithValidPreflightChecks() .OnStep(m => m.ServiceModel, s => { s.User = "******"; s.Password = "******"; s.StartWhenWindowsStarts = false; }); ; var serviceConfig = new NoopServiceStateProvider(); model.AssertTask( (m, s, fs) => new InstallServiceTask(m, s, fs, serviceConfig), (m, t) => { var c = serviceConfig.SeenServiceConfig; c.Should().NotBeNull(); c.ConfigDirectory.Should().Be(m.LocationsModel.ConfigDirectory); c.HomeDirectory.Should().Be(m.LocationsModel.InstallDir); c.ExeLocation.Should().Be(Path.Combine(m.LocationsModel.InstallDir, "bin", "elasticsearch.exe")); c.ServiceAccount.Should().Be(ServiceAccount.User); c.StartMode.Should().Be(ServiceStartMode.Manual); c.UserName.Should().Be("mpdreamz"); c.Password.Should().Be("my super pazz"); } ); }
[Fact] void NotCalledWhenNotInstallingAsService() { var model = WithValidPreflightChecks() .OnStep(m => m.ServiceModel, s => s.InstallAsService = false); var serviceConfig = new NoopServiceStateProvider(); model.AssertTask( (m, s, fs) => new InstallServiceTask(m, s, fs, serviceConfig), (m, t) => { serviceConfig.SeenServiceConfig.Should().BeNull(); } ); }
[Fact] void InstallByDefault() { var model = WithValidPreflightChecks(); var serviceConfig = new NoopServiceStateProvider(); model.AssertTask( (m, s, fs) => new InstallServiceTask(m, s, fs, serviceConfig), (m, t) => { var c = serviceConfig.SeenServiceConfig; c.Should().NotBeNull(); c.HomeDirectory.Should().Be(m.LocationsModel.InstallDir); c.ConfigDirectory.Should().Be(m.LocationsModel.ConfigDirectory); c.ExeLocation.Should().Be(Path.Combine(m.LocationsModel.InstallDir, "bin", "elasticsearch.exe")); c.ServiceAccount.Should().Be(ServiceAccount.LocalSystem); } ); }