private void CheckAndPublish()
        {
            if (!_informationEntriesQueue.Any() || _publishingInProgress)
            {
                return;
            }

            _publishingInProgress = true;

            var nextEntry = _informationEntriesQueue.Dequeue();

            _subscriptionService.OnInformationReceived(nextEntry);

            if (nextEntry.DisplayLengthInSeconds.HasValue)
            {
                Task.Run(
                    async() =>
                {
                    await Task.Delay(nextEntry.DisplayLengthInSeconds.Value * 1000);
                    var emptyInfo = _viewDataAdapter.Adapt(InformationEntry.CreateEmpty());
                    _subscriptionService.OnInformationReceived(emptyInfo);
                    _publishingInProgress = false;
                    CheckAndPublish();
                });
            }
            else
            {
                _publishingInProgress = false;
            }
        }
Beispiel #2
0
        private void CheckAndPublish()
        {
            if (!_informationEntriesQueue.Any() || _publishingInProgress)
            {
                return;
            }

            _publishingInProgress = true;

            var nextEntry = _informationEntriesQueue.Dequeue();

            _configurationService.Subscribers.ForEach(subs => subs.Invoke(nextEntry));

            if (nextEntry.LengthInSeconds.HasValue)
            {
                Task.Run(
                    async() =>
                {
                    await Task.Delay(nextEntry.LengthInSeconds.Value * 1000);
                    var emptyInfo = InformationEntry.CreateEmpty();
                    _configurationService.Subscribers.ForEach(subs => subs.Invoke(emptyInfo));
                    _publishingInProgress = false;
                    CheckAndPublish();
                });
            }
            else
            {
                _publishingInProgress = false;
            }
        }
        public void CreatingEmpty_CreatesEmptyInfoEntry()
        {
            // Act
            var actualInfoEntry = InformationEntry.CreateEmpty();

            // Assert
            Assert.AreEqual(false, actualInfoEntry.ShowBusy);
            Assert.AreEqual(string.Empty, actualInfoEntry.Message);
            Assert.IsNull(actualInfoEntry.DisplayLengthInSeconds);
            Assert.AreEqual(InformationEntryType.Info, actualInfoEntry.EntryType);
        }