public void ConnectionStringSet(DbConnection connection, DbConnectionPropertyInterceptionContext <string> interceptionContext)
        {
            //throw new NotImplementedException();
            string conn = "DATA SOURCE=" + _host + ":1521/ise;PASSWORD="******";USER ID=" + _user;

            connection.ConnectionString = conn;
        }
        public void Cloning_the_interception_context_preserves_contextual_information_but_not_mutable_state()
        {
            var objectContext = new ObjectContext();
            var dbContext = DbContextMockHelper.CreateDbContext(objectContext);

            var interceptionContext = new DbConnectionPropertyInterceptionContext<int>();
            interceptionContext.SuppressExecution();
            interceptionContext.Exception = new Exception("Cheez Whiz");
            interceptionContext.UserState = "Tilsit";

            interceptionContext = interceptionContext
                .WithDbContext(dbContext)
                .WithObjectContext(objectContext)
                .WithValue(23)
                .AsAsync();

            Assert.Equal(new[] { objectContext }, interceptionContext.ObjectContexts);
            Assert.Equal(new[] { dbContext }, interceptionContext.DbContexts);
            Assert.True(interceptionContext.IsAsync);
            Assert.Equal(23, interceptionContext.Value);

            Assert.Null(interceptionContext.Exception);
            Assert.Null(interceptionContext.OriginalException);
            Assert.False(interceptionContext.IsExecutionSuppressed);
            Assert.Null(interceptionContext.UserState);
        }
Beispiel #3
0
        private DbConnection CreateConnection()
        {
            DbConnection connection = this._providerFactory.CreateConnection();
            DbConnectionPropertyInterceptionContext <string> interceptionContext = new DbConnectionPropertyInterceptionContext <string>().WithValue(this._usersContextInfo.ConnectionString);

            if (this._usersContext != null)
            {
                interceptionContext = interceptionContext.WithDbContext(this._usersContext);
            }
            DbInterception.Dispatch.Connection.SetConnectionString(connection, interceptionContext);
            return(connection);
        }
        public void Initially_has_no_state()
        {
            var interceptionContext = new DbConnectionPropertyInterceptionContext<int>();

            Assert.Empty(interceptionContext.DbContexts);
            Assert.Null(interceptionContext.Exception);
            Assert.False(interceptionContext.IsAsync);
            Assert.False(interceptionContext.IsExecutionSuppressed);
            Assert.Equal(0, interceptionContext.Value);
            Assert.Empty(interceptionContext.ObjectContexts);
            Assert.Null(interceptionContext.OriginalException);
            Assert.Equal((TaskStatus)0, interceptionContext.TaskStatus);
            Assert.Null(interceptionContext.UserState);
        }
Beispiel #5
0
        private DbConnection CreateConnection()
        {
            var connection = _providerFactory.CreateConnection();

            var interceptionContext = new DbConnectionPropertyInterceptionContext <string>().WithValue(_usersContextInfo.ConnectionString);

            if (_contextForInterception != null)
            {
                interceptionContext = interceptionContext.WithDbContext(_contextForInterception);
            }

            DbInterception.Dispatch.Connection.SetConnectionString(connection, interceptionContext);

            return(connection);
        }
 public void ConnectionStringSet(DbConnection connection, DbConnectionPropertyInterceptionContext<string> interceptionContext)
 {
 }
Beispiel #7
0
        private DbConnection CreateConnection()
        {
            var connection = _connection == null
                ? _providerFactory.CreateConnection()
                : DbProviderServices.GetProviderServices(_connection).CloneDbConnection(_connection, _providerFactory);

            var interceptionContext = new DbConnectionPropertyInterceptionContext<string>().WithValue(_usersContextInfo.ConnectionString);
            if (_usersContext != null)
            {
                interceptionContext = interceptionContext.WithDbContext(_usersContext);
            }

            DbInterception.Dispatch.Connection.SetConnectionString(connection, interceptionContext);

            return connection;
        }
 public void ConnectionStringSet(DbConnection connection, DbConnectionPropertyInterceptionContext <string> interceptionContext)
 {
 }
        public void SetConnectionString_executes_operation_and_dispatches_to_interceptors()
        {
            var mockConnection = new Mock<DbConnection>();
            var mockInterceptor = new Mock<IDbConnectionInterceptor>();
            var dispatcher = new DbConnectionDispatcher();
            var internalDispatcher = dispatcher.InternalDispatcher;
            internalDispatcher.Add(mockInterceptor.Object);

            var interceptionContext = new DbConnectionPropertyInterceptionContext<string>().WithValue("foo");
            dispatcher.SetConnectionString(mockConnection.Object, interceptionContext);

            mockConnection.VerifySet(m => m.ConnectionString = "foo", Times.Once());
            mockInterceptor.Verify(m => m.ConnectionStringSetting(mockConnection.Object, It.IsAny<DbConnectionPropertyInterceptionContext<string>>()), Times.Once());
            mockInterceptor.Verify(m => m.ConnectionStringSet(mockConnection.Object, It.IsAny<DbConnectionPropertyInterceptionContext<string>>()), Times.Once());
        }
        /// <summary>
        /// Sends <see cref="IDbConnectionInterceptor.ConnectionStringSetting" /> and
        /// <see cref="IDbConnectionInterceptor.ConnectionStringSet" /> to any <see cref="IDbConnectionInterceptor" />
        /// registered on <see cref="DbInterception" /> before/after
        /// setting <see cref="DbConnection.ConnectionString" />.
        /// </summary>
        /// <param name="connection">The connection on which the operation will be executed.</param>
        /// <param name="interceptionContext">Information about the context of the call being made, including the value to be set.</param>
        public virtual void SetConnectionString(
            DbConnection connection, DbConnectionPropertyInterceptionContext<string> interceptionContext)
        {
            Check.NotNull(connection, "connection");
            Check.NotNull(interceptionContext, "interceptionContext");

            InternalDispatcher.Dispatch<DbConnection, DbConnectionPropertyInterceptionContext<string>>(
                connection,
                (t, c) => t.ConnectionString = c.Value,
                new DbConnectionPropertyInterceptionContext<string>(interceptionContext),
                (i, t, c) => i.ConnectionStringSetting(t, c),
                (i, t, c) => i.ConnectionStringSet(t, c));
        }
Beispiel #11
0
 public void ConnectionStringSetting(DbConnection connection,
                                     DbConnectionPropertyInterceptionContext <string> interceptionContext)
 {
     Debug.WriteLine("Connection ConnectionStringSetting.");
 }
 public void ConnectionStringSetting(DbConnection connection, DbConnectionPropertyInterceptionContext <string> interceptionContext)
 {
     //throw new NotImplementedException();
     string str = connection.ConnectionString;
 }
 public abstract void ConnectionStringSetting(
     DbConnection connection, DbConnectionPropertyInterceptionContext<string> interceptionContext);