Exemplo n.º 1
0
 public void ShouldCompleteInT_WhenFinishBeforeTimeout()
 {
     Should.NotThrow(() => Should.CompleteIn(() =>
     {
         Thread.Sleep(TimeSpan.FromSeconds(1));
         return("");
     }, TimeSpan.FromSeconds(5)));
 }
Exemplo n.º 2
0
 public void ShouldCompleteInT_WhenFinishBeforeTimeout()
 {
     Should.NotThrow(() => Should.CompleteIn(() =>
     {
         Task.Delay(TimeSpan.FromSeconds(1)).Wait();
         return("");
     }, TimeSpan.FromSeconds(5)));
 }
Exemplo n.º 3
0
 public void ShouldCompleteInT_WhenFinishAfterTimeout()
 {
     Should.Throw <TimeoutException>(() => Should.CompleteIn(() =>
     {
         Thread.Sleep(TimeSpan.FromSeconds(2));
         return("");
     }, TimeSpan.FromSeconds(1)));
 }
Exemplo n.º 4
0
        public void ShouldCompleteIn_WhenFinishAfterTimeout()
        {
            var ex = Should.Throw <ShouldlyTimeoutException>(() =>
                                                             Should.CompleteIn(() => Task.Delay(TimeSpan.FromSeconds(5)).Wait(), TimeSpan.FromSeconds(1), "Some additional context"));

            ex.Message.ShouldContainWithoutWhitespace(@"
    Delegate
        should complete in
    00:00:01
        but did not
    Additional Info:
    Some additional context");
        }
Exemplo n.º 5
0
        public void ShouldCompleteInTask_WhenFinishAfterTimeout()
        {
            var ex = Should.Throw <ShouldlyTimeoutException>(() =>
                                                             Should.CompleteIn(
                                                                 () => Task.Factory.StartNew(() => Thread.Sleep(TimeSpan.FromSeconds(5))),
                                                                 TimeSpan.FromSeconds(1), "Some additional context"));

            ex.Message.ShouldContainWithoutWhitespace(@"
    Task
        should complete in
    00:00:01
        but did not
    Additional Info:
    Some additional context");
        }
Exemplo n.º 6
0
        public void ShouldCompleteInT_WhenFinishAfterTimeout()
        {
            var ex = Should.Throw <TimeoutException>(() => Should.CompleteIn(() =>
            {
                Thread.Sleep(TimeSpan.FromSeconds(5));
                return("");
            }, TimeSpan.FromSeconds(1), "Some additional context"));

            ex.Message.ShouldContainWithoutWhitespace(@"
    Delegate
        should complete in
    00:00:01
        but did not
    Additional Info:
    Some additional context");
        }
Exemplo n.º 7
0
 public void ShouldCompleteIn_WhenFinishBeforeTimeout()
 {
     Should.NotThrow(() => Should.CompleteIn(() => Task.Delay(TimeSpan.FromSeconds(0.5)).Wait(), TimeSpan.FromSeconds(5)));
 }
Exemplo n.º 8
0
 public void ShouldCompleteIn_WhenThrowsNonTimeoutException()
 {
     Should.Throw <NotImplementedException>(() => Should.CompleteIn(() => { throw new NotImplementedException(); }, TimeSpan.FromSeconds(1)));
 }
Exemplo n.º 9
0
 private static void FailingUserCode_CompleteIn()
 {
     // Throws a different exception type
     Should.CompleteIn(Task.Delay(15), TimeSpan.Zero);
 }
Exemplo n.º 10
0
 public void ShouldCompleteIn_WhenFinishBeforeTimeout()
 {
     Should.NotThrow(() => Should.CompleteIn(() => Thread.Sleep(TimeSpan.FromSeconds(0.5)), TimeSpan.FromSeconds(5)));
 }