Ejemplo n.º 1
0
		public void TestStop_Twise_Harmless()
		{
			using ( var target = new TimeoutWatcher() )
			using ( var waitHandle = new ManualResetEventSlim() )
			{
				target.Timeout += ( sender, e ) => waitHandle.Set();
				target.Start( _timeout );
				target.Stop();
				Assert.That( waitHandle.Wait( ( int )( _timeout.TotalMilliseconds * 2 ) ), Is.False );
				target.Stop();
				Assert.That( target.IsTimeout, Is.False );
			}
		}
 public void TestStop_Twise_Harmless()
 {
     using (var target = new TimeoutWatcher())
         using (var waitHandle = new ManualResetEventSlim())
         {
             target.Timeout += (sender, e) => waitHandle.Set();
             target.Start(_timeout);
             target.Stop();
             Assert.That(waitHandle.Wait(( int )(_timeout.TotalMilliseconds * 2)), Is.False);
             target.Stop();
             Assert.That(target.IsTimeout, Is.False);
         }
 }
Ejemplo n.º 3
0
		public void TestStart_StoppedTimeout_TimeoutEventNotOccurred_IsTimeoutToBeFalse()
		{
			using ( var target = new TimeoutWatcher() )
			using ( var waitHandle = new ManualResetEventSlim() )
			{
				target.Timeout += ( sender, e ) => waitHandle.Set();
				target.Start( _timeout );
				target.Stop();
				Assert.That( waitHandle.Wait( ( int )( _timeout.TotalMilliseconds * 2 ) ), Is.False );
				Assert.That( target.IsTimeout, Is.False );
			}
		}
 public void TestStop_AfterTimeout_Harmless()
 {
     using (var target = new TimeoutWatcher())
         using (var waitHandle = new ManualResetEventSlim())
         {
             target.Timeout += (sender, e) => waitHandle.Set();
             target.Start(_timeout);
             Assert.That(waitHandle.Wait(TimeSpan.FromSeconds(1)));
             target.Stop();
             Assert.That(target.IsTimeout, Is.True);
         }
 }
 public void TestStart_StoppedTimeout_TimeoutEventNotOccurred_IsTimeoutToBeFalse()
 {
     using (var target = new TimeoutWatcher())
         using (var waitHandle = new ManualResetEventSlim())
         {
             target.Timeout += (sender, e) => waitHandle.Set();
             target.Start(_timeout);
             target.Stop();
             Assert.That(waitHandle.Wait(( int )(_timeout.TotalMilliseconds * 2)), Is.False);
             Assert.That(target.IsTimeout, Is.False);
         }
 }
Ejemplo n.º 6
0
		public void TestStop_AfterTimeout_Harmless()
		{
			using ( var target = new TimeoutWatcher() )
			using ( var waitHandle = new ManualResetEventSlim() )
			{
				target.Timeout += ( sender, e ) => waitHandle.Set();
				target.Start( _timeout );
				Assert.That( waitHandle.Wait( TimeSpan.FromSeconds( 1 ) ) );
				target.Stop();
				Assert.That( target.IsTimeout, Is.True );
			}
		}