PageRenderTime 358ms CodeModel.GetById 171ms app.highlight 13ms RepoModel.GetById 169ms app.codeStats 0ms

/Rhino.Etl.Tests/SqlBulkInsertOperationFixture.cs

http://github.com/ayende/rhino-etl
C# | 66 lines | 55 code | 11 blank | 0 comment | 0 complexity | b546c1f97f4cd034021f9dd1161b4030 MD5 | raw file
 1using System.Configuration;
 2using System.Data.SqlClient;
 3using Rhino.Etl.Core.Operations;
 4using Rhino.Mocks;
 5
 6namespace Rhino.Etl.Tests
 7{
 8    using System;
 9    using System.Collections.Generic;
10    using Xunit;
11    using Rhino.Etl.Tests.Fibonacci.Bulk;
12    using Rhino.Etl.Tests.Fibonacci.Output;
13
14    
15    public class SqlBulkInsertOperationFixture : BaseFibonacciTest
16    {
17        [Fact]
18        public void CanInsertToDatabaseFromInMemoryCollection()
19        {
20            BulkInsertFibonacciToDatabase fibonacci = new BulkInsertFibonacciToDatabase(25,Should.WorkFine);
21            fibonacci.Execute();
22
23            Assert25ThFibonacci();
24        }
25
26        [Fact]
27        public void CanInsertToDatabaseFromConnectionStringSettingsAndInMemoryCollection()
28        {
29            BulkInsertFibonacciToDatabaseFromConnectionStringSettings fibonacci = new BulkInsertFibonacciToDatabaseFromConnectionStringSettings(25, Should.WorkFine);
30            fibonacci.Execute();
31
32            Assert25ThFibonacci();
33        }
34
35        [Fact]
36        public void WhenErrorIsThrownWillRollbackTransaction()
37        {
38            BulkInsertFibonacciToDatabase fibonaci = new BulkInsertFibonacciToDatabase(25, Should.Throw);
39            fibonaci.Execute();
40            Assert.Equal(1, new List<Exception>(fibonaci.GetAllErrors()).Count);
41            AssertFibonacciTableEmpty();
42        }
43    }
44
45    public class BulkInsertNotificationTests
46    {
47        [Fact]
48        public void    CheckNotifyBatchSizeTakenFromBatchSize()
49        {
50            FibonacciBulkInsert    fibonacci =    new    FibonacciBulkInsert();
51            fibonacci.BatchSize    = 50;
52
53            Assert.Equal(fibonacci.BatchSize, fibonacci.NotifyBatchSize);
54        }
55
56        [Fact]
57        public void    CheckNotifyBatchSizeNotTakenFromBatchSize()
58        {
59            FibonacciBulkInsert    fibonacci =    new    FibonacciBulkInsert();
60            fibonacci.BatchSize    = 50;
61            fibonacci.NotifyBatchSize =    25;
62
63            Assert.Equal(25, fibonacci.NotifyBatchSize);
64        }
65    }
66}