public async Task WriteBatchCallsSqlConnectionWrappeCreateSqlBulkCopyWithDisableTriggersTrue() { // Arrange var logEvents = CreateLogEvents(); var expectedDestinationTableName = string.Format(CultureInfo.InvariantCulture, "[{0}].[{1}]", _schemaName, _tableName); var sut = new SqlBulkBatchWriter(_tableName, _schemaName, true, _sqlConnectionFactoryMock.Object, _logEventDataGeneratorMock.Object); // Act await sut.WriteBatch(logEvents, _dataTable).ConfigureAwait(false); // Assert _sqlConnectionWrapperMock.Verify(c => c.CreateSqlBulkCopy(true, expectedDestinationTableName), Times.Once); }
public SqlBulkBatchWriterTests() { _sqlConnectionFactoryMock = new Mock <ISqlConnectionFactory>(); _logEventDataGeneratorMock = new Mock <ILogEventDataGenerator>(); _sqlConnectionWrapperMock = new Mock <ISqlConnectionWrapper>(); _sqlBulkCopyWrapper = new Mock <ISqlBulkCopyWrapper>(); _sqlConnectionFactoryMock.Setup(f => f.Create()).Returns(_sqlConnectionWrapperMock.Object); _sqlConnectionWrapperMock.Setup(c => c.CreateSqlBulkCopy(It.IsAny <bool>(), It.IsAny <string>())).Returns(_sqlBulkCopyWrapper.Object); _dataTable = new DataTable(_tableName); _sut = new SqlBulkBatchWriter(_tableName, _schemaName, false, _sqlConnectionFactoryMock.Object, _logEventDataGeneratorMock.Object); }