예제 #1
0
        public void TestDbConnectionTraceForAfterInlineInsert()
        {
            // Prepare
            var trace      = new Mock <ITrace>();
            var connection = new CustomDbConnection();

            // Setup
            trace.Setup(t => t.AfterInlineInsert(It.IsAny <CancellableTraceLog>()));

            // Act
            connection.InlineInsert <TraceEntity>(new { Id = 1, Name = "Name" }, trace: trace.Object, statementBuilder: new SqlStatementBuilder());

            // Assert
            trace.Verify(t => t.AfterInlineInsert(It.IsAny <TraceLog>()), Times.Once);
        }
예제 #2
0
        public void TestDbConnectionStatementBuilderForInlineInsert()
        {
            // Prepare
            var statementBuilder = new Mock <IStatementBuilder>();
            var connection       = new CustomDbConnection();

            // Setup
            statementBuilder.Setup(builder =>
                                   builder.CreateInlineInsert <DataEntity>(
                                       It.IsAny <QueryBuilder <DataEntity> >(),
                                       It.IsAny <IEnumerable <Field> >()));

            // Act
            connection.InlineInsert <DataEntity>(new { Id = 1, Name = "Name" }, statementBuilder: statementBuilder.Object);

            // Assert
            statementBuilder.Verify(builder =>
                                    builder.CreateInlineInsert <DataEntity>(
                                        It.IsAny <QueryBuilder <DataEntity> >(),
                                        It.IsAny <IEnumerable <Field> >()), Times.Once);
        }