public ItemProvider(ItemProviderSettings settings, TypeManager typeManager, ILogWriter log) { var entityProviderLog = log.NewRegion(nameof(EntityProvider)); var pool = new PostgreSqlConnectionPool(settings.PostgreSqlConnectionString, settings.MaxConnections, settings.Timeout); var sqlProvider = new PostgreSqlProvider(pool, entityProviderLog.NewRegion("PostgreSQL"), settings.Schema); sqlProvider.EnsureSchemaExists(); this.provider = new EntityProvider(sqlProvider, entityProviderLog); this.log = log; this.context = new ItemContext(typeManager); }
public void BeforeEach() { var log = new CustomLogData(l => Debug.WriteLine(l)); var logwriter = new RegionBasedLogWriter(log, nameof(PostgreSqlProviderTests)); logwriter.StartStopwatch(); provider = new PostgreSqlProvider(connectionPool, logwriter, SCHEMA); provider.EnsureSchemaExists(); var tables = provider.GetTableNamesBySchema(SCHEMA); foreach (var table in tables) { provider.DropTable(table); } }
public void BeforeEach() { var log = new CustomLogData(l => Debug.WriteLine(l)); logwriter = new RegionBasedLogWriter(log, "Spec"); sqlProvider = new PostgreSqlProvider(connectionPool, logwriter.NewRegion(nameof(PostgreSqlProvider)), SCHEMA); sqlProvider.EnsureSchemaExists(); typeManager = new TypeManager(); typeManager.Register <DeviceType>(); typeManager.Register <SensorType>(); entityProvider = new EntityProvider(sqlProvider, logwriter.NewRegion(nameof(EntityProvider))); provider = new ItemProvider(entityProvider, typeManager, logwriter.NewRegion(nameof(ItemProvider))); var tables = sqlProvider.GetTableNamesBySchema(SCHEMA); foreach (var table in tables) { sqlProvider.DropTable(table); } }