コード例 #1
0
        public void ObserverGetsUpdatedByIncDecAndSet()
        {
            MockOberserver observer = new Mock.MockOberserver();

            try {
                _clock.Attach(observer);
                _clock.IncDec(1, 0, 0);
                Assert.IsTrue(ObserverUpdated(observer));
                observer.UpdateOccured = false;
                _clock.Set(1, 2, 3);
                Assert.IsTrue(ObserverUpdated(observer));
            } finally {
                _clock.Detach(observer);
            }
        }
コード例 #2
0
        public void OberserverGetsUpdatedByTimer()
        {
            _clock.Start();
            MockOberserver observer = new Mock.MockOberserver();

            _clock.Attach(observer);

            try {
                Assert.IsTrue(ObserverUpdated(observer));

                observer.UpdateOccured = false;
                _clock.Stop();

                Assert.IsFalse(ObserverUpdated(observer));
            } finally {
                _clock.Detach(observer);
                _clock.Stop();
            }
        }
コード例 #3
0
        public void DetachThrowsExceptionWhenDetachingUnknownObserver()
        {
            MockOberserver observer = new Mock.MockOberserver();

            _clock.Detach(observer);
        }