public void TheGuideSystem_GetBIEvents_ExpectListOfEvents() { var rows = new List<DataReaderFactory.TestDatabaseRow>(); rows.Add(BIEventTestDatabaseRow.CreatePostNeedsRiskAssessmentRow(11, _DT, 12, 13, 14, 15, 16, 17, DateTime.Parse("2010-09-12"), "hello", 23)); rows.Add(BIEventTestDatabaseRow.CreatePostNeedsRiskAssessmentRow(50, _DT, null, 53, 54, 55, 56, 57, DateTime.Parse("2015-09-12"), "goodbye", 63)); rows.Add(BIEventTestDatabaseRow.CreatePostToForumRow(70, _DT, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, DateTime.Parse("2020-09-12"), "eh?")); DataReaderFactory.CreateMockedDataBaseObjects(_mocks, "getbievents", out _mockcreator, out _mockreader, rows); var riskModSystem = _mocks.Stub<IRiskModSystem>(); var g = new TheGuideSystem(_mockcreator, riskModSystem); var eventList = g.GetBIEvents(); Assert.AreEqual(3, eventList.Count); Assert.IsTrue(eventList[0] is BIPostNeedsRiskAssessmentEvent); Assert.IsTrue(eventList[1] is BIPostNeedsRiskAssessmentEvent); Assert.IsTrue(eventList[2] is BIPostToForumEvent); Assert.AreEqual(EventTypes.ET_POSTNEEDSRISKASSESSMENT, eventList[0].EventType); Assert.AreEqual(EventTypes.ET_POSTNEEDSRISKASSESSMENT, eventList[1].EventType); Assert.AreEqual(EventTypes.ET_POSTTOFORUM, eventList[2].EventType); }
void BIEventProcessor_Tick(object sender, ElapsedEventArgs e) { if (Monitor.TryEnter(_locker)) { DateTime tickStart = DateTime.Now; TickCounter += 1; BIEventLogger.Log(TraceEventType.Verbose,"============== Tick start: " + TickCounter); RiskModSystem riskModSys = null; TheGuideSystem theGuideSys = null; List<BIEvent> events = null; try { riskModSys = new RiskModSystem(RiskModDataReaderCreator, DisableRiskMod); theGuideSys = new TheGuideSystem(TheGuideDataReaderCreator, riskModSys); events = theGuideSys.GetBIEvents(); if (events.Count > 0) { ProcessEvents(events,NumThreads); if (RecRiskModDecOnThreadEntries) RecordRiskModDecisionsOnThreadEntries(theGuideSys, events); } } catch (Exception ex) { BIEventLogger.LogException(ex); } finally { try { // Remove events we managed to process, even if an Exception was caught var processedEvents = GetProcessedEventsList(events); if (processedEvents.Count > 0) theGuideSys.RemoveBIEvents(processedEvents); } catch (Exception ex) { BIEventLogger.LogException(ex); } TimeSpan tickTime = DateTime.Now - tickStart; BIEventLogger.Log(TraceEventType.Verbose,"^^^^^^^^^^^^^^ Tick end: " + TickCounter + " (" + tickTime.TotalSeconds+"s)"); Monitor.Exit(_locker); } } }