@@ -195,6 +195,40 @@ public void SendThenErrorDoesRetry()
195195 Assert . Equal ( obj , receivedObject ) ;
196196 }
197197
198+ [ Fact ]
199+ public void MultipleErrorsAttachedToCorrectItems ( )
200+ {
201+ var cts = new CancellationTokenSource ( 10000 ) ;
202+
203+ var obj1 = FakeData . New ( ) ;
204+ var obj2 = FakeData . New ( ) ;
205+
206+ bool gotCorrectExceptionForItem1 = false ;
207+ bool gotCorrectExceptionForItem2 = false ;
208+
209+ processor . Error += ( exception , item ) =>
210+ {
211+ Assert . NotNull ( exception ) ;
212+
213+ gotCorrectExceptionForItem1 |= Equals ( item . Data , obj1 . Data ) && exception . Message == "1" ;
214+ gotCorrectExceptionForItem2 |= Equals ( item . Data , obj2 . Data ) && exception . Message == "2" ;
215+ } ;
216+
217+ processor . PushToQueue ( new [ ] { obj1 , obj2 } ) ;
218+
219+ processor . Received += o =>
220+ {
221+ if ( Equals ( o . Data , obj1 . Data ) ) throw new Exception ( "1" ) ;
222+ if ( Equals ( o . Data , obj2 . Data ) ) throw new Exception ( "2" ) ;
223+ } ;
224+
225+ processor . Run ( cts . Token ) ;
226+
227+ Assert . Equal ( 0 , processor . GetQueueSize ( ) ) ;
228+ Assert . True ( gotCorrectExceptionForItem1 ) ;
229+ Assert . True ( gotCorrectExceptionForItem2 ) ;
230+ }
231+
198232 [ Fact ]
199233 public void SendThenErrorForeverDoesDrop ( )
200234 {
0 commit comments