public void StartWork_NoTriggersFound_ShouldNotTriggerButDieWithinSetTime()
        {
            _callBack.GetTriggers(Arg.Any <string>()).Returns(l => null);
            var sut = new GetTriggersFromHomeSeerHandler(_iniSettings, _logging, _callBack, 1);

            sut.StartWork();

            Thread.Sleep(1600);
            _callBack.Received(1).GetTriggers(Arg.Any <string>());
            sut.IsRunning.ShouldBeFalse();
        }
Ejemplo n.º 2
0
        private void GetPluginTriggersFromHomeSeer()
        {
            //Todo: Get Triggers should be added to some kind of queue?
            var triggersInPlugin = _callback.GetTriggers(Utility.PluginName);

            if (triggersInPlugin != null & triggersInPlugin.Length > 0)
            {
                CreateExistingTriggers(triggersInPlugin.ToList());
            }
        }
        private void DoWork()
        {
            _isRunning = true;
            do
            {
                Thread.Sleep(_sleepTime);
                if (SystemDateTime.Now() >= _timeForFetching)
                {
                    var triggersInPlugin = _callback.GetTriggers(Utility.PluginName);
                    if (triggersInPlugin != null)
                    {
                        OnTriggerDataReady(triggersInPlugin);
                    }
                    _stopRunning = true;
                }
            } while (!_stopRunning);

            _isRunning = false;
        }