Esempio n. 1
0
 public async Task ErrorsAtOtherExceptions()
 {
     using (var messages = StreamWithMessages(IntMessage.Compose(42)))
         using (var closingStream = new ReadThenThrowStream(messages, new Exception("Alderaan destroyed")))
         {
             int result    = -1;
             var completed = new TaskCompletionSource <Exception>();
             using (closingStream.ReadMessages("name").SelectSome(IntMessage.TryParse)
                    .Subscribe(
                        i => result = i,
                        e => completed.SetResult(e),
                        () => completed.SetResult(null)))
             {
                 var exception = await completed.Task;
                 Assert.AreEqual(42, result);
                 Assert.AreEqual("Alderaan destroyed", exception.Message);
             }
         }
 }
Esempio n. 2
0
 public async Task CompletesAtClosedConnection()
 {
     using (var messages = StreamWithMessages(IntMessage.Compose(42)))
         using (var closingStream = new ReadThenThrowStream(messages, new IOException("", _forciblyClosedConnection)))
         {
             int result    = -1;
             var completed = new TaskCompletionSource <Exception>();
             using (closingStream.ReadMessages("name").SelectSome(IntMessage.TryParse)
                    .Subscribe(
                        i => result = i,
                        e => completed.SetResult(e),
                        () => completed.SetResult(null)))
             {
                 var exception = await completed.Task;
                 Assert.AreEqual(42, result);
                 Assert.IsNull(exception);
             }
         }
 }