public void IsShutdownRequestedIsSetCorrectly()
        {
            var target = new BeaconSendingContext(config, clientProvider, timingProvider);

            Assert.False(target.IsShutdownRequested);

            target.RequestShutdown();

            Assert.True(target.IsShutdownRequested);
        }
Exemple #2
0
        public void CanInterruptLongSleep()
        {
            // given
            var expected = 101717;
            var target   = new BeaconSendingContext(logger, config, clientProvider, timingProvider);

            target.RequestShutdown();
            target.Sleep(expected);

            // then
#if !NETCOREAPP1_0 || !NETCOREAPP1_1
            // normal sleep as thread interrupt exception exists
            timingProvider.Received(1).Sleep(expected);
#else
            // no interrupt exception exists, therefore "sliced" sleep break after first iteration
            timingProvider.Received(1).Sleep(Arg.Any <int>());
            timingProvider.Received(1).Sleep(BeaconSendingContext.DEFAULT_SLEEP_TIME_MILLISECONDS);
#endif
        }