Пример #1
0
        public void GivenDelayAction_WhenSingleAction_ShouldReceive()
        {
            bool testFlag    = false;
            var  delayAction = new DelayAction(TimeSpan.FromSeconds(1));

            delayAction.Post(() => testFlag = true);

            Thread.Sleep(TimeSpan.FromMilliseconds(200));
            testFlag.Should().BeFalse();

            Thread.Sleep(TimeSpan.FromMilliseconds(200));
            testFlag.Should().BeFalse();

            Thread.Sleep(TimeSpan.FromMilliseconds(200));
            testFlag.Should().BeFalse();

            Thread.Sleep(TimeSpan.FromMilliseconds(200));
            testFlag.Should().BeFalse();

            Thread.Sleep(TimeSpan.FromMilliseconds(200));
            testFlag.Should().BeTrue();

            testFlag = false;
            Thread.Sleep(TimeSpan.FromSeconds(2));
            testFlag.Should().BeFalse();
        }
Пример #2
0
        public void GivenDelayAction_WhenMultipleAction_ShouldReceive()
        {
            int testValue   = 0;
            var delayAction = new DelayAction(TimeSpan.FromSeconds(1));

            delayAction.Post(() => testValue = 1);

            Thread.Sleep(TimeSpan.FromMilliseconds(400));
            testValue.Should().Be(0);

            delayAction.Post(() => testValue = 2);

            Thread.Sleep(TimeSpan.FromMilliseconds(400));
            testValue.Should().Be(0);

            delayAction.Post(() => testValue = 3);

            Thread.Sleep(TimeSpan.FromMilliseconds(1500));
            testValue.Should().Be(3);
        }
Пример #3
0
 private void OnSearchChange(string value) => _delayAction.Post(() => _actionQueue.Post(() => Context.SearchByIdUrl = value));