-
Notifications
You must be signed in to change notification settings - Fork 36
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 #451 from Particular/release-4.1.0
Release 4.1.0
- Loading branch information
Showing
15 changed files
with
396 additions
and
28 deletions.
There are no files selected for viewing
109 changes: 109 additions & 0 deletions
109
src/NServiceBus.SqlServer.AcceptanceTests/When_passing_custom_transaction_via_sendoptions.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,109 @@ | ||
namespace NServiceBus.SqlServer.AcceptanceTests | ||
{ | ||
using System; | ||
using System.Data.SqlClient; | ||
using System.Threading.Tasks; | ||
using AcceptanceTesting; | ||
using NServiceBus.AcceptanceTests; | ||
using NServiceBus.AcceptanceTests.EndpointTemplates; | ||
using NUnit.Framework; | ||
using Transport.SQLServer; | ||
|
||
public class When_passing_custom_transaction_via_sendoptions : NServiceBusAcceptanceTest | ||
{ | ||
static string ConnectionString = Environment.GetEnvironmentVariable("SqlServerTransportConnectionString"); | ||
|
||
[Test] | ||
public async Task Should_be_used_by_send_operations() | ||
{ | ||
var context = await Scenario.Define<MyContext>() | ||
.WithEndpoint<AnEndpoint>(c => c.When(async bus => | ||
{ | ||
using (var connection = new SqlConnection(ConnectionString)) | ||
{ | ||
connection.Open(); | ||
using (var rolledbackTransaction = connection.BeginTransaction()) | ||
{ | ||
var options = new SendOptions(); | ||
options.UseCustomSqlConnectionAndTransaction(connection, rolledbackTransaction); | ||
await bus.Send(new FromRolledbackTransaction(), options); | ||
rolledbackTransaction.Rollback(); | ||
} | ||
using (var commitedTransaction = connection.BeginTransaction()) | ||
{ | ||
var options = new SendOptions(); | ||
options.UseCustomSqlConnectionAndTransaction(connection, commitedTransaction); | ||
await bus.Send(new FromCommitedTransaction(), options); | ||
commitedTransaction.Commit(); | ||
} | ||
} | ||
})) | ||
.Done(c => c.ReceivedFromCommitedTransaction) | ||
.Run(TimeSpan.FromMinutes(1)); | ||
|
||
Assert.IsFalse(context.ReceivedFromRolledbackTransaction); | ||
} | ||
|
||
class FromCommitedTransaction : IMessage | ||
{ | ||
} | ||
|
||
class FromRolledbackTransaction : IMessage | ||
{ | ||
} | ||
|
||
class MyContext : ScenarioContext | ||
{ | ||
public bool ReceivedFromCommitedTransaction { get; set; } | ||
public bool ReceivedFromRolledbackTransaction { get; set; } | ||
} | ||
|
||
class AnEndpoint : EndpointConfigurationBuilder | ||
{ | ||
public AnEndpoint() | ||
{ | ||
EndpointSetup<DefaultServer>(c => | ||
{ | ||
c.LimitMessageProcessingConcurrencyTo(1); | ||
var routing = c.ConfigureTransport().Routing(); | ||
var anEndpointName = AcceptanceTesting.Customization.Conventions.EndpointNamingConvention(typeof(AnEndpoint)); | ||
routing.RouteToEndpoint(typeof(FromCommitedTransaction), anEndpointName); | ||
routing.RouteToEndpoint(typeof(FromRolledbackTransaction), anEndpointName); | ||
}); | ||
} | ||
|
||
class ReplyHandler : IHandleMessages<FromRolledbackTransaction>, | ||
IHandleMessages<FromCommitedTransaction> | ||
{ | ||
public MyContext Context { get; set; } | ||
|
||
public Task Handle(FromRolledbackTransaction message, IMessageHandlerContext context) | ||
{ | ||
Context.ReceivedFromRolledbackTransaction = true; | ||
|
||
return Task.FromResult(0); | ||
} | ||
|
||
public Task Handle(FromCommitedTransaction message, IMessageHandlerContext context) | ||
{ | ||
Context.ReceivedFromCommitedTransaction = true; | ||
|
||
return Task.FromResult(0); | ||
} | ||
} | ||
} | ||
|
||
|
||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/NServiceBus.SqlServer.AcceptanceTests/When_using_computed_message_body_column.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,54 @@ | ||
namespace NServiceBus.SqlServer.AcceptanceTests | ||
{ | ||
using System.Threading.Tasks; | ||
using AcceptanceTesting; | ||
using NServiceBus.AcceptanceTests; | ||
using NServiceBus.AcceptanceTests.EndpointTemplates; | ||
using NUnit.Framework; | ||
using Transport.SQLServer; | ||
|
||
public class When_using_computed_message_body_column : NServiceBusAcceptanceTest | ||
{ | ||
[Test] | ||
public async Task Simple_send_is_received() | ||
{ | ||
var context = await Scenario.Define<Context>() | ||
.WithEndpoint<Endpoint>(b => b.When((session, c) => session.SendLocal(new MyMessage()))) | ||
.Done(c => c.WasCalled) | ||
.Run(); | ||
|
||
Assert.IsTrue(context.WasCalled); | ||
} | ||
class Context : ScenarioContext | ||
{ | ||
public bool WasCalled { get; set; } | ||
} | ||
|
||
class Endpoint : EndpointConfigurationBuilder | ||
{ | ||
public Endpoint() | ||
{ | ||
EndpointSetup<DefaultServer>(config => | ||
{ | ||
var transportConfig = config.UseTransport<SqlServerTransport>(); | ||
transportConfig.CreateMessageBodyComputedColumn(); | ||
}); | ||
} | ||
|
||
public class MyMessageHandler : IHandleMessages<MyMessage> | ||
{ | ||
public Context Context { get; set; } | ||
|
||
public Task Handle(MyMessage message, IMessageHandlerContext context) | ||
{ | ||
Context.WasCalled = true; | ||
return Task.FromResult(0); | ||
} | ||
} | ||
} | ||
|
||
public class MyMessage : IMessage | ||
{ | ||
} | ||
} | ||
} |
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
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.