public void TestAppHostWithDatasources() { var appHost = BdoHostFactory.CreateBindOpenDefaultHost( options => options .AddDataStore(store => store .RegisterDatasources(m => m .AddFromConfiguration(options) .AddFromNetCoreConfiguration(GlobalVariables.NetCoreConfiguration))) .SetLogger(p => p.AddFile(options).AddTrace(), true)); Assert.That(appHost.IsLoaded, "Application host not load failed"); var datasourceA = appHost.GetDatasourceDepot()?["db.testA"]; Assert.That(datasourceA?.Name == "db.testA", "Bad data source loading"); Assert.That(appHost.GetDatasourceDepot()?.GetConnectionString("db.testA") != StringHelper.__NoneString, "Bad data source loading"); Assert.That(appHost.GetDatasourceDepot()?.GetConnectionString("db.testA", "database.mssqlserver$client") != StringHelper.__NoneString, "Bad data source loading"); var datasourceB = appHost.GetDatasourceDepot()?["db.testB"]; Assert.That(datasourceB?.Name == "db.testB", "Bad data source loading from .NET Core configuration"); Assert.That(appHost.GetDatasourceDepot()?.GetConnectionString("db.testB") != StringHelper.__NoneString, "Bad data source loading from .NET Core configuration"); Assert.That(appHost.GetDatasourceDepot().Get()?.Name == "db.testA", "Bad data source loading"); Assert.That(appHost.GetDatasourceDepot().GetConnectionString() != StringHelper.__NoneString, "Bad data source loading"); }
// BindOpen host -------------------------- /// <summary> /// Adds a BindOpen default service. /// </summary> /// <param name="services">The collection of services to populate.</param> /// <param name="setupAction">The setup action to consider.</param> /// <returns></returns> public static IServiceCollection AddBindOpen( this IServiceCollection services, Action <ITBdoHostOptions <BdoDefaultAppSettings> > setupAction = null) { var host = BdoHostFactory.CreateBindOpenDefaultHost(setupAction); services.AddSingleton <IBdoHost>(_ => host); return(services); }
/// <summary> /// Adds a BindOpen service. /// </summary> /// <param name="services">The collection of services to populate.</param> /// <param name="setupAction">The setup action to consider.</param> /// <returns></returns> public static IServiceCollection AddBindOpen <S>( this IServiceCollection services, Action <ITBdoHostOptions <S> > setupAction = null) where S : class, IBdoAppSettings, new() { var host = BdoHostFactory.CreateBindOpenHost <S>(setupAction); services.AddSingleton <IBdoHost>(_ => host); return(services); }
public void TestAppHostWithNoOptions() { var appHost = BdoHostFactory.CreateBindOpenDefaultHost( options => options .SetLogger(p => p.AddFile(options), true)); Assert.That(appHost.IsLoaded, "Application host not load failed"); Assert.That(appHost.Options.HostSettings.ApplicationInstanceName == "test.console", "Application host settings not loaded correctly"); Assert.That(appHost.Options.HostSettings.LogsExpirationDayNumber == 1, "Application host settings not loaded correctly"); Assert.That(appHost.Options.AppSettings.Get <string>("test.folderPath") != null, "Application host settings not loaded correctly"); }