public async Task MyCustomBlock_AddsOneToDataItems() { var myCustomBlock = Chapter4.CreateMyCustomBlock(); myCustomBlock.Post(3); myCustomBlock.Post(13); myCustomBlock.Complete(); Assert.AreEqual(4, myCustomBlock.Receive()); Assert.AreEqual(14, myCustomBlock.Receive()); await myCustomBlock.Completion; }
public async Task MyCustomBlock_Fault_DiscardsDataAndFaults() { var myCustomBlock = Chapter4.CreateMyCustomBlock(); myCustomBlock.Post(3); myCustomBlock.Post(13); myCustomBlock.Fault(new InvalidOperationException()); try { await myCustomBlock.Completion; } catch (AggregateException ex) { AssertExceptionIs <InvalidOperationException>(ex.Flatten().InnerException, false); } }