/Rhino.Etl.Tests/Errors/ThrowingOperation.cs

http://github.com/ayende/rhino-etl · C# · 29 lines · 26 code · 3 blank · 0 comment · 1 complexity · 4945d5b14f03979a2092ed07f4949138 MD5 · raw file

  1. namespace Rhino.Etl.Tests.Errors
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using Core;
  7. using Core.Operations;
  8. public class ThrowingOperation : AbstractOperation
  9. {
  10. private readonly int rowsAfterWhichToThrow = new Random().Next(1, 6);
  11. public int RowsAfterWhichToThrow
  12. {
  13. get { return rowsAfterWhichToThrow; }
  14. }
  15. public override IEnumerable<Row> Execute(IEnumerable<Row> rows)
  16. {
  17. for (int i = 0; i < RowsAfterWhichToThrow; i++)
  18. {
  19. Row row = new Row();
  20. row["id"] = i;
  21. yield return row;
  22. }
  23. throw new InvalidDataException("problem");
  24. }
  25. }
  26. }