Aspectacular.Test.CoreTests.PollAdapterTest.TestSmartPollingCallback C# (CSharp) Méthode

TestSmartPollingCallback() private méthode

private TestSmartPollingCallback ( ) : void
Résultat void
        public void TestSmartPollingCallback()
        {
            DateTimeOffset threeSecondDelay = DateTimeOffset.Now.AddSeconds(3);

            const int maxDelayMillisec = 500;
            DateTimeOffset? message = null;
            BlockingObjectPoll<object> pollmeister;
            using (pollmeister = new BlockingObjectPoll<object>(() => PollCurrentTime(threeSecondDelay), maxDelayMillisec))
            {
                pollmeister.Subscribe(payload => message = payload == null ? (DateTimeOffset?)null : (DateTimeOffset)payload);
                Threading.Sleep(3100);
            }

            this.TestContext.WriteLine("Empty poll calls: {0:#,#0}, Calls with payload: {1:#,#0}", pollmeister.EmptyPollCallCount, pollmeister.PollCallCountWithPayload);

            Assert.IsTrue(message != null, "Message cannot be null.");
            int discrepMillisecBetweenHopedAndActual = (message.Value - threeSecondDelay).Milliseconds;
            Assert.IsTrue(discrepMillisecBetweenHopedAndActual <= maxDelayMillisec + 100, "After-wait delay is too long.");
            Assert.IsTrue(pollmeister.EmptyPollCallCount <= 12, "Number of poll hits is too low.");
            Assert.IsTrue(pollmeister.PollCallCountWithPayload >= 1, "There was no poll hit returning actual payload.");
        }