-
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.
Use correct index position when not reading the message body as a str…
…eam (#1179) (#1180) * Add acceptance test to reproduce issue * Better test name * Fix the bug * Use strings to avoid breking the net472 build with the old client * Exclude tests on the old client * Include .NET Framework * Cross compile also other legacy test project * Proper range --------- Co-authored-by: danielmarbach <[email protected]>
- Loading branch information
1 parent
e35db2e
commit 5f7c0ec
Showing
4 changed files
with
100 additions
and
12 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
88 changes: 88 additions & 0 deletions
88
...NServiceBus.Transport.SqlServer.AcceptanceTests/When_using_column_encrypted_connection.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,88 @@ | ||
namespace NServiceBus.Transport.SqlServer.AcceptanceTests | ||
{ | ||
using System; | ||
#if SYSTEMDATASQLCLIENT | ||
using System.Data.SqlClient; | ||
#else | ||
using Microsoft.Data.SqlClient; | ||
#endif | ||
using System.Threading.Tasks; | ||
using AcceptanceTesting; | ||
using AcceptanceTesting.Customization; | ||
using NServiceBus.AcceptanceTests; | ||
using NUnit.Framework; | ||
|
||
public class When_using_column_encrypted_connection : NServiceBusAcceptanceTest | ||
{ | ||
[Test] | ||
public async Task Should_work() | ||
{ | ||
#if SYSTEMDATASQLCLIENT && NET | ||
Assert.Ignore("System.Data.SqlClient doesn't support this setting on .NET (works on .NET Framework)"); | ||
#endif | ||
var ctx = await Scenario.Define<Context>() | ||
.WithEndpoint<Endpoint>(b => b.When((bus, c) => bus.SendLocal(new Message()))) | ||
.Done(c => c.MessageReceived) | ||
.Run(); | ||
|
||
Assert.True(ctx.MessageReceived, "Message should be properly received"); | ||
} | ||
|
||
static string GetConnectionString() => | ||
Environment.GetEnvironmentVariable("SqlServerTransportConnectionString") ?? @"Data Source=.\SQLEXPRESS;Initial Catalog=nservicebus;Integrated Security=True"; | ||
|
||
public class Endpoint : EndpointConfigurationBuilder | ||
{ | ||
public Endpoint() | ||
{ | ||
var transport = new SqlServerTransport(async cancellationToken => | ||
{ | ||
var connectionString = GetConnectionString(); | ||
|
||
if (!connectionString.EndsWith(";")) | ||
{ | ||
connectionString += ";"; | ||
} | ||
|
||
connectionString += "Column Encryption Setting=enabled"; | ||
|
||
var connection = new SqlConnection(connectionString); | ||
|
||
await connection.OpenAsync(cancellationToken); | ||
|
||
return connection; | ||
}); | ||
|
||
EndpointSetup(new CustomizedServer(transport), (c, sd) => | ||
{ | ||
c.OverridePublicReturnAddress($"{Conventions.EndpointNamingConvention(typeof(Endpoint))}@dbo@nservicebus"); | ||
}); | ||
} | ||
|
||
class Handler : IHandleMessages<Message> | ||
{ | ||
readonly Context scenarioContext; | ||
public Handler(Context scenarioContext) | ||
{ | ||
this.scenarioContext = scenarioContext; | ||
} | ||
|
||
public Task Handle(Message message, IMessageHandlerContext context) | ||
{ | ||
scenarioContext.MessageReceived = true; | ||
|
||
return Task.FromResult(0); | ||
} | ||
} | ||
} | ||
|
||
public class Context : ScenarioContext | ||
{ | ||
public bool MessageReceived { get; set; } | ||
} | ||
|
||
public class Message : 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