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

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

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

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

            // Setup
            statementBuilder.Setup(builder =>
                                   builder.CreateUpdate <DataEntity>(
                                       It.IsAny <QueryBuilder <DataEntity> >(),
                                       It.IsAny <QueryGroup>()));

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

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