/////////////////////////////////////////////////////////////////////// /// <summary> /// Creates and initializes the default log event handler. /// </summary> private static void InitializeDefaultHandler() { lock (syncRoot) { if (_defaultHandler == null) { _defaultHandler = new SQLiteLogEventHandler(LogEventHandler); } } }
public void SubscribeUnsubscribeLog() { int logCount = 0; SQLiteErrorCode lastErrorCode = SQLiteErrorCode.Ok; using (SQLiteConnection conn = new SQLiteConnection(m_csb.ConnectionString)) { conn.Open(); try { conn.Execute(@"create table []"); } catch (SQLiteException) { } SQLiteLogEventHandler handler = (s, e) => { logCount++; lastErrorCode = (SQLiteErrorCode)e.ErrorCode; }; SQLiteLog.Log += handler; try { conn.Execute(@"create table []"); } catch (SQLiteException) { } Assert.AreEqual(1, logCount); Assert.AreEqual(SQLiteErrorCode.Error, lastErrorCode); SQLiteLog.Log -= handler; lastErrorCode = SQLiteErrorCode.Ok; try { conn.Execute(@"create table []"); } catch (SQLiteException) { } Assert.AreEqual(1, logCount); Assert.AreEqual(SQLiteErrorCode.Ok, lastErrorCode); } }
/////////////////////////////////////////////////////////////////////// /// <summary> /// Creates and initializes the default log event handler. /// </summary> private static void InitializeDefaultHandler() { lock (syncRoot) { if (_defaultHandler == null) _defaultHandler = new SQLiteLogEventHandler(LogEventHandler); } }