Beispiel #1
0
        public void CanUpdateThrottlingToEnableIt()
        {
            using (var mre = new ThrottledManualResetEventSlim(null))
            {
                mre.Update(TimeSpan.FromSeconds(5));

                Assert.Equal(TimeSpan.FromSeconds(5), mre.ThrottlingInterval);

                mre.Set();

                Assert.True(mre.Wait((int)TimeSpan.FromSeconds(7).TotalMilliseconds, CancellationToken.None));
            }
        }
Beispiel #2
0
        public void CanUpdateThrottlingToDisableIt()
        {
            using (var mre = new ThrottledManualResetEventSlim(TimeSpan.FromSeconds(10)))
            {
                mre.Set();

                mre.Update(null);

                Assert.Null(mre.ThrottlingInterval);
                Assert.True(mre.IsSet);
            }

            using (var mre = new ThrottledManualResetEventSlim(null))
            {
                mre.Update(null);
                Assert.False(mre.IsSet);
            }
        }