public void CanListenPositionChangeEvents()
        {
            // ARRANGE
            var waitEvent = new ManualResetEvent(false);
            var messageBus = new MessageBus();
            NmeaPositionMocker mocker;
            int count = 0;
            messageBus.AsObservable<GeoPosition>()
                .ObserveOn(Scheduler.ThreadPool)
                .Subscribe(position => count++);

            // ACT
            Action<TimeSpan> delayAction = _ => Thread.Sleep(0); // do not wait to make test faster
            using (Stream stream = new FileStream(TestHelper.NmeaFilePath, FileMode.Open))
            {
                mocker = new NmeaPositionMocker(stream, messageBus);
                mocker.OnDone += (s, e) => waitEvent.Set();
                mocker.Start(delayAction);
            }

            // ASSERT
            if(!waitEvent.WaitOne(TimeSpan.FromSeconds(60)))
                throw new TimeoutException();
            mocker.Stop();
            Assert.AreEqual(16, count);
        }
Пример #2
0
 /// <summary> Reads nmea file and sends fake geo positions via message bus. </summary>
 private void RunMocker()
 {
     Action<TimeSpan> delayAction = Thread.Sleep;
     using (Stream stream = new FileStream(TestHelper.NmeaFilePath, FileMode.Open))
     {
         var mocker = new NmeaPositionMocker(stream, _messageBus);
         mocker.OnDone += (s, e) => _waitEvent.Set();
         mocker.Start(delayAction);
     }
 }