public void AssertDataLimitPassedIsFired() { var settings = new Settings(10, 100); var capSetts = new CaptureSettings("somt", new Dictionary<string, string>(), settings); ServiceProvider.TwitterProvider = new DataTests.MockService(); var session = new CaptureSession(capSetts); bool firstIntervalElapsed = false; settings.MaxDataPointsPassed += (sender, e) => firstIntervalElapsed = true; Timer timer = new System.Timers.Timer(1010); timer.Elapsed += (sender, e) => Assert.AreEqual(true, firstIntervalElapsed); session.StartCapture(); timer.Start(); while (!firstIntervalElapsed) { System.Threading.Thread.Sleep(5); } Assert.AreEqual(2, settings.IgnoreDataUpdateThreshold); bool secondIntervalElapsed = false; settings.MaxDataPointsPassed += (sender, e) => secondIntervalElapsed = true; System.Threading.Thread.Sleep(1250); Assert.AreEqual(true, secondIntervalElapsed); }
public void AssertAllDataIsKeptInView() { var settings = new Settings(10, 100); var capSetts = new CaptureSettings("somt", new Dictionary<string, string>(), settings); ServiceProvider.TwitterProvider = new DataTests.MockService(); var session = new CaptureSession(capSetts); var model = new StaticSessionViewModel(); model.StartListening(session); settings.MaxDataPointsPassed += (sender, args) => Assert.AreEqual(5, model.DeltaCount.Count); System.Threading.Thread.Sleep(100000); }
public void AssertSettingsAreCorrectlyStarted() { var settings = new Settings(10, 100); var capSetts = new CaptureSettings("somt", new Dictionary<string, string>(), settings); ServiceProvider.TwitterProvider = new DataTests.MockService(); var session = new CaptureSession(capSetts); Assert.AreEqual(false, settings.Started); session.StartCapture(); Assert.AreEqual(true, settings.Started); session.StopCapture(); Assert.AreEqual(false, settings.Started); }
public CaptureSession(CaptureSettings settings) { this._settings = settings; this._provider = ServiceProvider.TwitterProvider; this._countAtInterval = new ObservableCollection<KeyValuePair<DateTime, int>>(); this._captureSubjects = new ObservableCollection<CaptureSubject>(); foreach(var subjectKey in this._settings.CompareKeys.Keys) { this._captureSubjects.Add(new CaptureSubject(subjectKey, this._settings.CompareKeys[subjectKey], this.Settings.Settings, ColorProvider.GetNextColor())); } this._countAtIntervalTimer = new System.Timers.Timer(this._settings.Settings.CountInterval); this._countAtIntervalTimer.Elapsed += _countAtIntervalTimer_Elapsed; this._statuses = new ObservableCollection<Status>(); }
private void PrepareForCapture() { var settings = new CaptureSettings(this.Settings); var capSession = new CaptureSession(settings); this.SessionStarted = true; this.Session.StartSession(capSession); this.OnPropertyChanged("SessionStarted"); this.OnPropertyChanged("SessionNotStarted"); }
public void UpdateCaptureSettings(CaptureSettings settings) { settings.Settings = this._settings.Settings; foreach(var settingsRow in settings.CompareKeys) { var subject = this._captureSubjects.Where(kvp => kvp.Key == settingsRow.Key).FirstOrDefault(); if(subject != null) { subject.UpdateKeywords(settingsRow.Value); } else { this._captureSubjects.Add(new CaptureSubject(settingsRow.Key, settingsRow.Value, this._settings.Settings, ColorProvider.GetNextColor())); } } var subjectsNoLongerTracked = this._captureSubjects.Where(sub => !settings.CompareKeys.Keys.Contains(sub.Key)); foreach(var subject in subjectsNoLongerTracked) { subject.StopAccepting(); } this._settings = settings; var searchString = this.MakeSearchString(); this._provider.SetSearchString(searchString); this._provider.SetCultureString(settings.Culture); }
public void UpdateCaptureSettings(CaptureSettingsViewModel settingsModel) { var settings = new CaptureSettings(settingsModel); this.Session.UpdateCaptureSettings(settings); }