public void UsingConnectionFactoryAndExceptionListenerAndReconnectOnException() { IConnectionFactory connectionFactory = (IConnectionFactory)mocks.CreateMock(typeof(IConnectionFactory)); TestConnection con = new TestConnection(); TestExceptionListener listener = new TestExceptionListener(); Expect.Call(connectionFactory.CreateConnection()).Return(con).Repeat.Twice(); mocks.ReplayAll(); SingleConnectionFactory scf = new SingleConnectionFactory(connectionFactory); scf.ExceptionListener = listener; scf.ReconnectOnException = true; IConnection con1 = scf.CreateConnection(); //Assert.AreSame(listener, ); con1.Start(); con.FireExcpetionEvent(new EMSException("")); IConnection con2 = scf.CreateConnection(); con2.Start(); scf.Dispose(); mocks.VerifyAll(); Assert.AreEqual(2, con.StartCount); Assert.AreEqual(2, con.CloseCount); Assert.AreEqual(1, listener.Count); }