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); }
public void Timer_Stop_Restart_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); // Start again. timer.Start(); Assert.True(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; }
public void Timer_Enabled_SetDesignModeAfterEnabling_GetReturnsExpected(bool value) { using var timer = new SubTimer(); var mockSite = new Mock <ISite>(MockBehavior.Strict); mockSite .Setup(s => s.DesignMode) .Returns(true); timer.Site = mockSite.Object; Assert.True(timer.DesignMode); timer.Start(); mockSite .Setup(s => s.DesignMode) .Returns(false); timer.Enabled = value; Assert.Equal(value, timer.Enabled); // Set same. timer.Enabled = value; Assert.Equal(value, 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; }
public void Enabled_SetDesignModeAfterEnabling_GetReturnsExpected(bool value) { var timer = new SubTimer(); var mockSite = new Mock <ISite>(MockBehavior.Strict); mockSite .Setup(s => s.DesignMode) .Returns(true); timer.Site = mockSite.Object; Assert.True(timer.DesignMode); timer.Start(); mockSite .Setup(s => s.DesignMode) .Returns(false); timer.Enabled = value; Assert.Equal(value, timer.Enabled); // Set same. timer.Enabled = value; Assert.Equal(value, timer.Enabled); }