예제 #1
0
        private void StateChangeEventHandler(object sender, StateChangeEventArgs e)
        {
            IDbConnectionStateListener listener = ConnectionStateListener;

            if (listener != null)
            {
                listener.AfterStateChange((IDbConnection)sender, e.OriginalState, e.CurrentState);
            }
        }
예제 #2
0
        [Test] public void CallsListenerWhenConnectionIsDbConnection()
        {
            var connection = _mockery.StrictMock <DbConnection>();

            _testee.ConnectionStateListener = _listener;
            Expect.Call(_dbProvider.CreateConnection()).Return(connection);
            ((IDbConnection)connection).Open();
            Expect.Call(() => _listener.AfterStateChange(connection, ConnectionState.Closed, ConnectionState.Open));
            connection.StateChange += null;
            var eventRaiser = LastCall.IgnoreArguments().GetEventRaiser();

            _mockery.ReplayAll();
            var conn = _testee.CreateConnection();

            conn.Open();
            eventRaiser.Raise(connection, new StateChangeEventArgs(ConnectionState.Closed, ConnectionState.Open));
            _mockery.VerifyAll();
        }