Ejemplo n.º 1
0
        public void Stop_Restart_Success(bool designMode)
        {
            var timer    = new SubTimer();
            var mockSite = new Mock <ISite>(MockBehavior.Strict);

            mockSite
            .Setup(s => s.DesignMode)
            .Returns(designMode);
            timer.Site = mockSite.Object;
            Assert.Equal(designMode, timer.DesignMode);

            // Start
            timer.Start();
            Assert.True(timer.Enabled);

            // Stop.
            timer.Stop();
            Assert.False(timer.Enabled);

            // Start again.
            timer.Start();
            Assert.True(timer.Enabled);

            // Stop again.
            timer.Stop();
            Assert.False(timer.Enabled);
        }
Ejemplo n.º 2
0
        public void Timer_Stop_MultipleTimes_Success(bool designMode)
        {
            using var timer = new SubTimer();
            var mockSite = new Mock <ISite>(MockBehavior.Strict);

            mockSite
            .Setup(s => s.DesignMode)
            .Returns(designMode);
            timer.Site = mockSite.Object;
            Assert.Equal(designMode, timer.DesignMode);

            // Start
            timer.Start();
            Assert.True(timer.Enabled);

            // Stop.
            timer.Stop();
            Assert.False(timer.Enabled);

            // Stop again.
            timer.Stop();
            Assert.False(timer.Enabled);

            // NB: disposing the component with strictly mocked object causes tests to fail
            // Moq.MockException : ISite.Container invocation failed with mock behavior Strict. All invocations on the mock must have a corresponding setup.
            timer.Site = null;
        }