Beispiel #1
0
        public void ConnectionEngineCanStartAndStop()
        {
            var logger = new MockLogger();
            var db     = new SQLServerClientDatabase(TestConnectionString, new MockLogger(), SharedMockedCoreSettings);

            var engine = new ConnectionEngine(db, logger, 0, SharedMockedCoreSettings);

            engine.BeginStart();
            engine.BeginStop();
        }
Beispiel #2
0
        public void ConnectionEngineTriggersStoppedEventWhenEngineHasStopped()
        {
            var logger = new MockLogger();
            var db     = new SQLServerClientDatabase(TestConnectionString, new MockLogger(), SharedMockedCoreSettings);

            var engine = new ConnectionEngine(db, logger, 0, SharedMockedCoreSettings);

            var signalStoppedEvent = new AutoResetEvent(false);

            engine.Stopped += (s, e) => { signalStoppedEvent.Set(); };
            engine.BeginStart();
            engine.BeginStop();

            var engineStoppedSignaled = signalStoppedEvent.WaitOne(TimeSpan.FromSeconds(5));

            Assert.IsTrue(engineStoppedSignaled);
        }
Beispiel #3
0
        /// <summary>
        /// Starts the connection engine.
        /// </summary>
        /// <returns>True if successful, otherwise false.</returns>
        private bool StartConnectionEngine()
        {
            try
            {
                ConnectionEngineInstance          = new ConnectionEngine(ClientDatabase, CoreLog, 0, CoreSettings);
                ConnectionEngineInstance.Stopped += Connection_Stopped;
                ConnectionEngineInstance.BeginStart();

                CoreLog.WriteSystemEvent(
                    string.Format("Connection Engine has started."),
                    EventLogEntryType.Information, ArchivialLibrary.Constants.EventIDs.StartedConnectionEngine, true);

                return(true);
            }
            catch (Exception ex)
            {
                var message = "Failed to start the connection engine.";
                var context = CoreLog.GenerateFullContextStackTrace();
                CoreLog.WriteSystemEvent(message, ex, context, ArchivialLibrary.Constants.EventIDs.FailedConnectionEngine, true);
                return(false);
            }
        }