Beispiel #1
0
        public void Internal_Thread_Start_Stop_test()
        {
            LazyTimer lazybones = new LazyTimer(ONE_SECOND);
            TimerTester evaluator = new TimerTester("Internal thread test"); // need this for a subscriber for ticks.
            evaluator.Subscribe(lazybones);

            Assert.IsFalse(evaluator.HasTirggered());

            // make sure our internal thread works.
            lazybones.Start();
            Thread.Sleep(ONE_SECOND);
            lazybones.Stop();

            Assert.IsTrue(evaluator.HasTirggered());
        }
Beispiel #2
0
        public void Test_Multi_Subscribers()
        {
            LazyTimer lazybones = new LazyTimer(ONE_SECOND);
            TimerTester evaluator1 = new TimerTester("Subscriber 1");
            TimerTester evaluator2 = new TimerTester("Subscriber 2");
            evaluator1.Subscribe(lazybones);
            evaluator2.Subscribe(lazybones);

            Assert.IsFalse(evaluator1.HasTirggered());
            Assert.IsFalse(evaluator2.HasTirggered());

            // make sure our internal thread works.
            lazybones.Start();
            Thread.Sleep(ONE_SECOND);
            lazybones.Stop();

            Assert.IsTrue(evaluator1.HasTirggered());
            Assert.IsTrue(evaluator2.HasTirggered());
        }