Esempio n. 1
0
        public async Task Should_CreateTwoTimersAndDisposeFirstOne_When_TwoGlobalEventsAreScheduled()
        {
            var mockResult = MockTimerFactory(10, 10000);

            _target = mockResult.Debouncer;

            await _target.ScheduleEventAsync(CreateProtocolEvent(), false).ConfigureAwait(false);

            await _target.ScheduleEventAsync(CreateProtocolEvent(), false).ConfigureAwait(false);

            TestHelper.RetryAssert(() =>
            {
                var timers = mockResult.Timers.ToArray();
                Assert.AreEqual(1, timers.Length);
                VerifyTimerChange(timers[0], 10, Times.Exactly(2));
            });
            await Task.Delay(100).ConfigureAwait(false);

            VerifyTimerChange(mockResult.Timers.Single(), 10, Times.Exactly(2));
        }
Esempio n. 2
0
        public async Task Should_DelayButNotAddKeyspaceEvent_When_AGlobalEventIsScheduled()
        {
            var mockResult = MockTimerFactory(10, 10000);

            _target = mockResult.Debouncer;

            await _target.ScheduleEventAsync(CreateProtocolEvent(), false).ConfigureAwait(false);

            await _target.ScheduleEventAsync(CreateProtocolEvent("ks", true), false).ConfigureAwait(false);

            await _target.ScheduleEventAsync(CreateProtocolEvent("ks2", false), false).ConfigureAwait(false);

            TestHelper.RetryAssert(() =>
            {
                var timers = mockResult.Timers.ToArray();
                Assert.AreEqual(1, timers.Length);
                VerifyTimerChange(timers[0], 10, Times.Exactly(3));
            });
            await Task.Delay(100).ConfigureAwait(false);

            VerifyTimerChange(mockResult.Timers.Single(), 10, Times.Exactly(3));
            Assert.AreEqual(0, _target.GetQueue().Keyspaces.Count);
        }
Esempio n. 3
0
        public async Task Should_OnlyCreateOneTimerAndNotInvokeChange_When_OneKeyspaceEventIsScheduled(bool refreshEvent)
        {
            var mockResult = MockTimerFactory(10, 10000);

            _target = mockResult.Debouncer;

            await _target.ScheduleEventAsync(CreateProtocolEvent("ks", refreshEvent), false).ConfigureAwait(false);

            TestHelper.RetryAssert(() =>
            {
                VerifyTimerChange(mockResult.Timers.Single(), 10, Times.Once());
            });
            await Task.Delay(100).ConfigureAwait(false); // assert that no more timers are invoked

            VerifyTimerChange(mockResult.Timers.Single(), 10, Times.Once());
        }