示例#1
0
        public void TestGetValueWhichDoesTimeOut()
        {
            BlockingCell k = new BlockingCell();

            ResetTimer();
            Assert.Throws <TimeoutException>(() => k.GetValue(TimingInterval));
        }
示例#2
0
        public void TestGetValueWhichDoesTimeOutWithTimeSpan()
        {
            BlockingCell k = new BlockingCell();

            ResetTimer();
            Assert.Throws <TimeoutException>(() => k.GetValue(TimeSpan.FromMilliseconds(TimingInterval)));
        }
示例#3
0
        public void TestBackgroundUpdateFails()
        {
            BlockingCell k = new BlockingCell();

            SetAfter(TimingInterval * 2, k, 123);

            ResetTimer();
            Assert.Throws <TimeoutException>(() => k.GetValue(TimingInterval));
        }
示例#4
0
        public void TestGetValueWhichDoesNotTimeOut()
        {
            BlockingCell k = new BlockingCell();

            k.Value = 123;

            ResetTimer();
            var v = k.GetValue(TimingInterval);

            Assert.Greater(SafetyMargin, ElapsedMs());
            Assert.AreEqual(123, v);
        }
示例#5
0
        public void TestBackgroundUpdateSucceedsWithInfiniteTimeoutTimeSpan()
        {
            BlockingCell k = new BlockingCell();

            SetAfter(TimingInterval, k, 123);

            ResetTimer();
            var v = k.GetValue(Timeout.InfiniteTimeSpan);

            Assert.Less(TimingInterval - SafetyMargin, ElapsedMs());
            Assert.AreEqual(123, v);
        }
示例#6
0
        public void TestGetValueWithTimeoutInfinite()
        {
            BlockingCell k = new BlockingCell();

            SetAfter(TimingInterval, k, 123);

            ResetTimer();
            var v = k.GetValue(Timeout.Infinite);

            Assert.Less(TimingInterval - SafetyMargin, ElapsedMs());
            Assert.AreEqual(123, v);
        }
        public void TestTimeoutNegative()
        {
            BlockingCell k = new BlockingCell();

            ResetTimer();
            object v;
            bool   r = k.GetValue(-10000, out v);

            Assert.Greater(SafetyMargin, ElapsedMs());
            Assert.IsTrue(!r);
            Assert.AreEqual(null, v);
        }
        public void TestTimeoutLong()
        {
            BlockingCell k = new BlockingCell();

            ResetTimer();
            object v;
            bool   r = k.GetValue(TimingInterval, out v);

            Assert.Less(TimingInterval - SafetyMargin, ElapsedMs());
            Assert.IsTrue(!r);
            Assert.AreEqual(null, v);
        }
        public void TestTimeoutShort()
        {
            BlockingCell k = new BlockingCell();

            k.Value = 123;

            ResetTimer();
            object v;
            bool   r = k.GetValue(TimingInterval, out v);

            Assert.Greater(SafetyMargin, ElapsedMs());
            Assert.IsTrue(r);
            Assert.AreEqual(123, v);
        }
        public void TestBgLong()
        {
            BlockingCell k = new BlockingCell();

            SetAfter(TimingInterval * 2, k, 123);

            ResetTimer();
            object v;
            bool   r = k.GetValue(TimingInterval, out v);

            Assert.Greater(TimingInterval + SafetyMargin, ElapsedMs());
            Assert.IsTrue(!r);
            Assert.AreEqual(null, v);
        }
        public void TestBgShort()
        {
            BlockingCell k = new BlockingCell();

            SetAfter(TimingInterval, k, 123);

            ResetTimer();
            object v;
            bool   r = k.GetValue(TimingInterval * 2, out v);

            Assert.Less(TimingInterval - SafetyMargin, ElapsedMs());
            Assert.IsTrue(r);
            Assert.AreEqual(123, v);
        }
示例#12
0
        public virtual Command GetReply(TimeSpan timeout)
        {
            var result = (Either)m_cell.GetValue(timeout);

            switch (result.Alternative)
            {
            case EitherAlternative.Left:
                return((Command)result.Value);

            case EitherAlternative.Right:
                throw new OperationInterruptedException((ShutdownEventArgs)result.Value);

            default:
                ReportInvalidInvariant(result);
                return(null);
            }
        }
示例#13
0
 public ShutdownEventArgs Wait(TimeSpan timeout)
 {
     return((ShutdownEventArgs)m_cell.GetValue(timeout));
 }