PageRenderTime 14ms CodeModel.GetById 9ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 1namespace 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
 9    public class ThrowingOperation : AbstractOperation
10    {
11        private readonly int rowsAfterWhichToThrow = new Random().Next(1, 6);
12
13        public int RowsAfterWhichToThrow
14        {
15            get { return rowsAfterWhichToThrow; }
16        }
17
18        public override IEnumerable<Row> Execute(IEnumerable<Row> rows)
19        {
20            for (int i = 0; i < RowsAfterWhichToThrow; i++)
21            {
22                Row row = new Row();
23                row["id"] = i;
24                yield return row;
25            }
26            throw new InvalidDataException("problem");
27        }
28    }
29}