public void WriteToServerShouldPerformBulkMerge(bool isUpdateOnly)
        {
            // Arrange
            const string tempTableName     = "#tmp_bulk";
            var          bulkInsertService = new Mock <IBulkInsertService <TestClass> >();
            var          commandService    = new Mock <ICommandService <TestClass> >();

            var service = new BulkMergeService <TestClass>(bulkInsertService.Object, commandService.Object);

            // Act
            service.WriteToServer(_records, _mergeKeys, isUpdateOnly);

            // Assert Create and Drop Temp table create
            Expression <Func <AlterTableStatement <TestClass>, bool> > isCreateTableStatement
                = s => s.TableName == tempTableName && s.Type == AlterTableStatement <TestClass> .AlterType.Create;
            Expression <Func <AlterTableStatement <TestClass>, bool> > isDropTableStatement
                = s => s.TableName == tempTableName && s.Type == AlterTableStatement <TestClass> .AlterType.Drop;

            commandService.Verify(m => m.Alter(It.Is(isCreateTableStatement)), Times.Once);
            commandService.Verify(m => m.Alter(It.Is(isDropTableStatement)), Times.Once);

            // Assert Bulk Insert
            bulkInsertService.Verify(m => m.WriteToServer(_records, tempTableName), Times.Once);

            // Assert Merge
            Expression <Func <MergeStatement <TestClass>, bool> > isMergeStatement = s => s.Keys == _mergeKeys && s.TemporaryTableName == tempTableName;

            commandService.Verify(m => m.Merge(It.Is(isMergeStatement)), Times.Once);

            bulkInsertService.VerifyNoOtherCalls();
            commandService.VerifyNoOtherCalls();
        }
        public void WriteToServerThrowsArgumentExceptionWhenRecordsIsEmpty()
        {
            // Arrange
            var bulkInsertService = new Mock <IBulkInsertService <TestClass> >().Object;
            var commandService    = new Mock <ICommandService <TestClass> >().Object;

            var service = new BulkMergeService <TestClass>(bulkInsertService, commandService);

            // Act and Assert
            Assert.Throws <ArgumentException>(
                () => service.WriteToServer(new List <TestClass>(), _mergeKeys, true)
                );
        }