forked from ayende/rhino-etl
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
Rhino.Etl.Tests/Fibonacci/Batch/BatchFibonacciFromConnectionStringSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
namespace Rhino.Etl.Tests.Fibonacci.Batch | ||
{ | ||
using Core; | ||
using Errors; | ||
using Output; | ||
|
||
public class BatchFibonacciFromConnectionStringSettings : BatchFibonacci | ||
{ | ||
public BatchFibonacciFromConnectionStringSettings(int max, Should should) | ||
: base(max, should) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes this instance. | ||
/// </summary> | ||
protected override void Initialize() | ||
{ | ||
Register(new FibonacciOperation(this.Max)); | ||
if (this.Should == Should.Throw) | ||
Register(new ThrowingOperation()); | ||
Register(new BatchFibonacciToDatabaseFromConnectionStringSettings()); | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
Rhino.Etl.Tests/Fibonacci/Batch/BatchFibonacciToDatabaseBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Configuration; | ||
|
||
namespace Rhino.Etl.Tests.Fibonacci.Batch | ||
{ | ||
using System.Data.SqlClient; | ||
using Core; | ||
using Rhino.Etl.Core.Operations; | ||
|
||
public abstract class BatchFibonacciToDatabaseBase : SqlBatchOperation | ||
{ | ||
protected BatchFibonacciToDatabaseBase(string connectionString) | ||
: base(connectionString) | ||
{ | ||
} | ||
|
||
protected BatchFibonacciToDatabaseBase(ConnectionStringSettings connectionStringSettings) | ||
: base(connectionStringSettings) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Prepares the command from the given row | ||
/// </summary> | ||
/// <param name="row">The row.</param> | ||
/// <param name="command">The command.</param> | ||
protected override void PrepareCommand(Row row, SqlCommand command) | ||
{ | ||
command.CommandText = "INSERT INTO Fibonacci (id) VALUES(@id)"; | ||
command.Parameters.AddWithValue("@id", row["id"]); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Rhino.Etl.Tests/Fibonacci/Batch/BatchFibonacciToDatabaseFromConnectionStringSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Configuration; | ||
|
||
namespace Rhino.Etl.Tests.Fibonacci.Batch | ||
{ | ||
using System.Data.SqlClient; | ||
using Core; | ||
using Rhino.Etl.Core.Operations; | ||
|
||
public class BatchFibonacciToDatabaseFromConnectionStringSettings : BatchFibonacciToDatabaseBase | ||
{ | ||
public BatchFibonacciToDatabaseFromConnectionStringSettings() | ||
: base(ConfigurationManager.ConnectionStrings["test"]) | ||
{ | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
Rhino.Etl.Tests/Fibonacci/Bulk/BulkInsertFibonacciToDatabaseFromConnectionStringSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace Rhino.Etl.Tests.Fibonacci.Bulk | ||
{ | ||
using Core; | ||
using Errors; | ||
using Output; | ||
|
||
public class BulkInsertFibonacciToDatabaseFromConnectionStringSettings : EtlProcess | ||
{ | ||
private readonly int max; | ||
private readonly Should should; | ||
|
||
public BulkInsertFibonacciToDatabaseFromConnectionStringSettings(int max, Should should) | ||
{ | ||
this.max = max; | ||
this.should = should; | ||
} | ||
|
||
/// <summary> | ||
/// Initializes this instance. | ||
/// </summary> | ||
protected override void Initialize() | ||
{ | ||
Register(new FibonacciOperation(max)); | ||
if (should == Should.Throw) | ||
Register(new ThrowingOperation()); | ||
Register(new FibonacciBulkInsertFromConnectionStringSettings()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.Configuration; | ||
using Rhino.Etl.Core.Operations; | ||
|
||
namespace Rhino.Etl.Tests.Fibonacci.Bulk | ||
{ | ||
public abstract class FibonacciBulkInsertBase : SqlBulkInsertOperation | ||
{ | ||
protected FibonacciBulkInsertBase(string connectionString) | ||
: base(connectionString, "Fibonacci") | ||
{ | ||
} | ||
|
||
protected FibonacciBulkInsertBase(ConnectionStringSettings connectionStringSettings) | ||
: base(connectionStringSettings, "Fibonacci") | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Prepares the schema of the target table | ||
/// </summary> | ||
protected override void PrepareSchema() | ||
{ | ||
Schema["id"] = typeof (int); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Rhino.Etl.Tests/Fibonacci/Bulk/FibonacciBulkInsertFromConnectionStringSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Configuration; | ||
using Rhino.Etl.Core.Operations; | ||
|
||
namespace Rhino.Etl.Tests.Fibonacci.Bulk | ||
{ | ||
public class FibonacciBulkInsertFromConnectionStringSettings : FibonacciBulkInsertBase | ||
{ | ||
public FibonacciBulkInsertFromConnectionStringSettings() | ||
: base(ConfigurationManager.ConnectionStrings["test"]) | ||
{ | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
Rhino.Etl.Tests/Fibonacci/Output/OutputFibonacciToDatabaseFromConnectionStringSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Configuration; | ||
|
||
namespace Rhino.Etl.Tests.Fibonacci.Output | ||
{ | ||
using Core; | ||
using Errors; | ||
|
||
public class OutputFibonacciToDatabaseFromConnectionStringSettings : EtlProcess | ||
{ | ||
private readonly int max; | ||
private readonly Should should; | ||
public readonly ThrowingOperation ThrowingOperation = new ThrowingOperation(); | ||
public readonly FibonacciOutput OutputOperation = new FibonacciOutput(ConfigurationManager.ConnectionStrings["Test"]); | ||
|
||
public OutputFibonacciToDatabaseFromConnectionStringSettings(int max, Should should) | ||
{ | ||
this.max = max; | ||
this.should = should; | ||
} | ||
|
||
/// <summary> | ||
/// Initializes this instance. | ||
/// </summary> | ||
protected override void Initialize() | ||
{ | ||
Register(new FibonacciOperation(max)); | ||
if (should == Should.Throw) | ||
Register(ThrowingOperation); | ||
Register(OutputOperation); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
Rhino.Etl.Tests/Integration/UsersToPeopleFromConnectionStringSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Configuration; | ||
|
||
namespace Rhino.Etl.Tests.Integration | ||
{ | ||
using Core; | ||
|
||
public class UsersToPeopleFromConnectionStringSettings : EtlProcess | ||
{ | ||
protected override void Initialize() | ||
{ | ||
// Get the connection string settings for the test database | ||
ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["test"]; | ||
Register(new ReadUsers(connectionStringSettings)); | ||
Register(new SplitName()); | ||
Register(new WritePeople(connectionStringSettings)); | ||
} | ||
} | ||
} |