-
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.
Fix delayed message table bug in original implementation (#865)
* Fix delayed message table bug * More uses of DateTimeOffset
- Loading branch information
1 parent
c8a8f88
commit 00a3c3b
Showing
3 changed files
with
93 additions
and
17 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
src/NServiceBus.Transport.SqlServer.AcceptanceTests/When_deferring_multiple_messages.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,78 @@ | ||
namespace NServiceBus.AcceptanceTests.DelayedDelivery | ||
{ | ||
using System; | ||
using System.Threading.Tasks; | ||
using AcceptanceTesting; | ||
using EndpointTemplates; | ||
using Features; | ||
using NUnit.Framework; | ||
|
||
public class When_deferring_multiple_messages : NServiceBusAcceptanceTest | ||
{ | ||
[Test] | ||
public async Task Adaptive_polling_should_work() | ||
{ | ||
var delay = TimeSpan.FromSeconds(2); | ||
var longDelay = TimeSpan.FromDays(1); | ||
|
||
var context = await Scenario.Define<Context>() | ||
.WithEndpoint<Endpoint>(b => b.When(async (session, c) => | ||
{ | ||
var longOptions = new SendOptions(); | ||
longOptions.DelayDeliveryWith(longDelay); | ||
longOptions.RouteToThisEndpoint(); | ||
await session.Send(new MyMessage { Which = "Long" }, longOptions); | ||
var options = new SendOptions(); | ||
options.DelayDeliveryWith(delay); | ||
options.RouteToThisEndpoint(); | ||
await session.Send(new MyMessage { Which = "Short" }, options); | ||
})) | ||
.Done(c => c.WasCalled) | ||
.Run(); | ||
|
||
Assert.True(context.WasCalled); | ||
Assert.AreEqual("Short", context.WhichWasCalled); | ||
} | ||
|
||
public class Context : ScenarioContext | ||
{ | ||
public bool WasCalled { get; set; } | ||
public string WhichWasCalled { get; set; } | ||
} | ||
|
||
public class Endpoint : EndpointConfigurationBuilder | ||
{ | ||
public Endpoint() | ||
{ | ||
EndpointSetup<DefaultServer>(config => config.EnableFeature<TimeoutManager>()); | ||
} | ||
|
||
public class MyMessageHandler : IHandleMessages<MyMessage> | ||
{ | ||
public MyMessageHandler(Context testContext) | ||
{ | ||
this.testContext = testContext; | ||
} | ||
|
||
public Task Handle(MyMessage message, IMessageHandlerContext context) | ||
{ | ||
testContext.WasCalled = true; | ||
testContext.WhichWasCalled = message.Which; | ||
return Task.FromResult(0); | ||
} | ||
|
||
Context testContext; | ||
} | ||
} | ||
|
||
public class MyMessage : IMessage | ||
{ | ||
public string Which { get; set; } | ||
} | ||
} | ||
} |
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