PageRenderTime 328ms CodeModel.GetById 161ms app.highlight 2ms RepoModel.GetById 163ms app.codeStats 1ms

/Rhino.Etl.Tests/Util/DictionaryEnumeratorDataReaderFixture.cs

http://github.com/ayende/rhino-etl
C# | 33 lines | 31 code | 2 blank | 0 comment | 0 complexity | c91cdc6c7d000b70c4b89756c89b06b5 MD5 | raw file
 1namespace Rhino.Etl.Tests.Util
 2{
 3    using System;
 4    using System.Collections.Generic;
 5    using Core;
 6    using Xunit;
 7    using Mocks;
 8    using Rhino.Etl.Core.DataReaders;
 9
10    
11    public class DictionaryEnumeratorDataReaderFixture
12    {
13        [Fact]
14        public void WillDisposeInternalEnumeratorAndEnumerableWhenDisposed()
15        {
16            MockRepository mocks = new MockRepository();
17            IEnumerable<Row> enumerable = mocks.DynamicMultiMock<IEnumerable<Row>>(typeof(IDisposable));
18            IEnumerator<Row> enumerator = mocks.DynamicMock<IEnumerator<Row>>();
19            using(mocks.Record())
20            {
21                SetupResult.For(enumerable.GetEnumerator()).Return(enumerator);
22                enumerator.Dispose();
23                ((IDisposable)enumerable).Dispose();
24            }
25            using (mocks.Playback())
26            {
27                DictionaryEnumeratorDataReader reader =
28                    new DictionaryEnumeratorDataReader(new Dictionary<string, Type>(), enumerable);
29                reader.Dispose();
30            }
31        }
32    }
33}