-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Shuttle/async
- initial async refactoring
- Loading branch information
Showing
8 changed files
with
240 additions
and
169 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,45 +1,63 @@ | ||
using System.Data.Common; | ||
using System.Data.SqlClient; | ||
using System.Threading.Tasks; | ||
using Microsoft.Data.SqlClient; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using NUnit.Framework; | ||
using Shuttle.Core.Data; | ||
using Shuttle.Esb; | ||
using Shuttle.Esb.Sql.Queue; | ||
using Shuttle.Esb.Tests; | ||
|
||
namespace Shuttle.Esb.Sql.Idempotence.Tests | ||
namespace Shuttle.Esb.Sql.Idempotence.Tests; | ||
|
||
[TestFixture] | ||
public class IdempotenceTest : IdempotenceFixture | ||
{ | ||
[TestFixture] | ||
public class IdempotenceTest : IdempotenceFixture | ||
[SetUp] | ||
public void SetUp() | ||
{ | ||
[Test] | ||
[TestCase(false, false)] | ||
[TestCase(false, true)] | ||
[TestCase(true, false)] | ||
[TestCase(true, true)] | ||
public void Should_be_able_to_perform_full_processing(bool isTransactionalEndpoint, bool enqueueUniqueMessages) | ||
{ | ||
DbProviderFactories.RegisterFactory("System.Data.SqlClient", SqlClientFactory.Instance); | ||
DbProviderFactories.RegisterFactory("Microsoft.Data.SqlClient", SqlClientFactory.Instance); | ||
} | ||
|
||
var services = new ServiceCollection(); | ||
[Test] | ||
[TestCase(false, false)] | ||
[TestCase(false, true)] | ||
[TestCase(true, false)] | ||
[TestCase(true, true)] | ||
public void Should_be_able_to_perform_full_processing(bool isTransactionalEndpoint, bool enqueueUniqueMessages) | ||
{ | ||
TestIdempotenceProcessing(GetServiceCollection(), @"sql://idempotence/{0}", isTransactionalEndpoint, enqueueUniqueMessages); | ||
} | ||
|
||
services.AddDataAccess(builder => | ||
{ | ||
builder.AddConnectionString("Idempotence", "System.Data.SqlClient", | ||
"server=.;database=shuttle;user id=sa;password=Pass!000"); | ||
}); | ||
[Test] | ||
[TestCase(false, false)] | ||
[TestCase(false, true)] | ||
[TestCase(true, false)] | ||
[TestCase(true, true)] | ||
public async Task Should_be_able_to_perform_full_processing_async(bool isTransactionalEndpoint, bool enqueueUniqueMessages) | ||
{ | ||
await TestIdempotenceProcessingAsync(GetServiceCollection(), @"sql://idempotence/{0}", isTransactionalEndpoint, enqueueUniqueMessages); | ||
} | ||
|
||
private static ServiceCollection GetServiceCollection() | ||
{ | ||
var services = new ServiceCollection(); | ||
|
||
services.AddSqlQueue(builder => | ||
services.AddDataAccess(builder => | ||
{ | ||
builder.AddConnectionString("Idempotence", "Microsoft.Data.SqlClient", | ||
"server=.;database=shuttle;user id=sa;password=Pass!000;TrustServerCertificate=true"); | ||
}); | ||
|
||
services.AddSqlQueue(builder => | ||
{ | ||
builder.AddOptions("idempotence", new SqlQueueOptions | ||
{ | ||
builder.AddOptions("idempotence", new SqlQueueOptions | ||
{ | ||
ConnectionStringName = "Idempotence" | ||
}); | ||
ConnectionStringName = "Idempotence" | ||
}); | ||
}); | ||
|
||
services.AddSqlIdempotence(); | ||
services.AddSqlIdempotence(); | ||
|
||
TestIdempotenceProcessing(services, @"sql://idempotence/{0}", isTransactionalEndpoint, enqueueUniqueMessages); | ||
} | ||
return services; | ||
} | ||
} |
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
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
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
Oops, something went wrong.