コード例 #1
0
        public void Should_Return_True_For_Delay_Withing_Interval()
        {
            var sample = new DebouncingSample();

            Assert.False(sample.DebounceDuring100ms());
            Assert.True(sample.DebounceDuring100ms());
        }
コード例 #2
0
        public async Task Should_Return_False_For_Delay_Over_Interval()
        {
            var sample = new DebouncingSample();

            Assert.False(sample.DebounceDuring100ms());

            await Task.Delay(110).ConfigureAwait(false);

            Assert.False(sample.DebounceDuring100ms());
        }
コード例 #3
0
        public async Task Interval_Should_Not_Slide_With_Each_Call()
        {
            var sample = new DebouncingSample();

            Assert.False(sample.DebounceDuring100ms());

            await Task.Delay(50).ConfigureAwait(false);

            Assert.True(sample.DebounceDuring100ms());

            await Task.Delay(60).ConfigureAwait(false);

            Assert.False(sample.DebounceDuring100ms());

            await Task.Delay(50).ConfigureAwait(false);

            Assert.True(sample.DebounceDuring100ms());

            await Task.Delay(60).ConfigureAwait(false);

            Assert.False(sample.DebounceDuring100ms());
        }