private void CreateTable(SinkOptions sinkOptions, SinkDependencies sinkDependencies) { if (sinkOptions.AutoCreateSqlTable) { sinkDependencies.SqlTableCreator.CreateTable(_eventTable); } }
public MSSqlServerAuditSinkTests() { _sinkOptions = new SinkOptions { TableName = _tableName, SchemaName = _schemaName }; _columnOptions = new Serilog.Sinks.MSSqlServer.ColumnOptions(); _dataTable = new DataTable(_tableName); _dataTableCreatorMock = new Mock <IDataTableCreator>(); _dataTableCreatorMock.Setup(d => d.CreateDataTable()) .Returns(_dataTable); _sqlTableCreatorMock = new Mock <ISqlTableCreator>(); _sqlLogEventWriter = new Mock <ISqlLogEventWriter>(); _sinkDependencies = new SinkDependencies { DataTableCreator = _dataTableCreatorMock.Object, SqlTableCreator = _sqlTableCreatorMock.Object, SqlLogEventWriter = _sqlLogEventWriter.Object }; }
private static void CreateTable(MSSqlServerSinkOptions sinkOptions, SinkDependencies sinkDependencies) { if (sinkOptions.AutoCreateSqlTable) { using (var eventTable = sinkDependencies.DataTableCreator.CreateDataTable()) { sinkDependencies.SqlTableCreator.CreateTable(eventTable); } } }
// Internal constructor with injectable dependencies for better testability internal MSSqlServerAuditSink( MSSqlServerSinkOptions sinkOptions, ColumnOptions columnOptions, SinkDependencies sinkDependencies) { ValidateParameters(sinkOptions, columnOptions); CheckSinkDependencies(sinkDependencies); _sqlLogEventWriter = sinkDependencies.SqlLogEventWriter; CreateTable(sinkOptions, sinkDependencies); }
// Internal constructor with injectable dependencies for better testability internal MSSqlServerSink( MSSqlServerSinkOptions sinkOptions, SinkDependencies sinkDependencies) { ValidateParameters(sinkOptions); CheckSinkDependencies(sinkDependencies); _sqlBulkBatchWriter = sinkDependencies.SqlBulkBatchWriter; _eventTable = sinkDependencies.DataTableCreator.CreateDataTable(); CreateTable(sinkOptions, sinkDependencies); }
// Internal constructor with injectable dependencies for better testability internal MSSqlServerSink( SinkOptions sinkOptions, SinkDependencies sinkDependencies) : base(sinkOptions?.BatchPostingLimit ?? DefaultBatchPostingLimit, sinkOptions?.BatchPeriod ?? DefaultPeriod) { ValidateParameters(sinkOptions); CheckSinkDependencies(sinkDependencies); _sqlBulkBatchWriter = sinkDependencies.SqlBulkBatchWriter; _eventTable = sinkDependencies.DataTableCreator.CreateDataTable(); CreateTable(sinkOptions, sinkDependencies); }
private static void CheckSinkDependencies(SinkDependencies sinkDependencies) { if (sinkDependencies == null) { throw new ArgumentNullException(nameof(sinkDependencies)); } if (sinkDependencies.DataTableCreator == null) { throw new InvalidOperationException($"DataTableCreator is not initialized!"); } if (sinkDependencies.SqlTableCreator == null) { throw new InvalidOperationException($"SqlTableCreator is not initialized!"); } if (sinkDependencies.SqlLogEventWriter == null) { throw new InvalidOperationException($"SqlLogEventWriter is not initialized!"); } }
public MSSqlServerSinkTests() { _sinkOptions = new MSSqlServerSinkOptions { TableName = _tableName, SchemaName = _schemaName }; _dataTable = new DataTable(_tableName); _dataTableCreatorMock = new Mock <IDataTableCreator>(); _dataTableCreatorMock.Setup(d => d.CreateDataTable()) .Returns(_dataTable); _sqlTableCreatorMock = new Mock <ISqlTableCreator>(); _sqlBulkBatchWriter = new Mock <ISqlBulkBatchWriter>(); _sinkDependencies = new SinkDependencies { DataTableCreator = _dataTableCreatorMock.Object, SqlTableCreator = _sqlTableCreatorMock.Object, SqlBulkBatchWriter = _sqlBulkBatchWriter.Object }; }