-
Notifications
You must be signed in to change notification settings - Fork 647
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
1 parent
9b4a76d
commit 089cbd4
Showing
3 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
....AcceptanceTests/BasicMessaging/When_using_a_message_with_TimeToBeReceived_has_expired.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,62 @@ | ||
namespace NServiceBus.AcceptanceTests.BasicMessaging | ||
{ | ||
using System; | ||
using System.Threading; | ||
using EndpointTemplates; | ||
using AcceptanceTesting; | ||
using NUnit.Framework; | ||
|
||
public class When_using_a_message_with_TimeToBeReceived_has_expired : NServiceBusAcceptanceTest | ||
{ | ||
[Test] | ||
public void Message_should_not_be_received() | ||
{ | ||
var context = new Context(); | ||
|
||
var timeToWaitFor = DateTime.Now.AddSeconds(10); | ||
Scenario.Define(context) | ||
.WithEndpoint<Endpoint>(b => b.Given((bus, c) => bus.SendLocal(new MyMessage()))) | ||
.Done(c => DateTime.Now > timeToWaitFor ) | ||
.Run(); | ||
Assert.IsFalse(context.WasCalled); | ||
} | ||
|
||
public class Context : ScenarioContext | ||
{ | ||
public bool WasCalled { get; set; } | ||
} | ||
|
||
public class Endpoint : EndpointConfigurationBuilder | ||
{ | ||
public Endpoint() | ||
{ | ||
EndpointSetup<DefaultServer>(); | ||
} | ||
public class MyMessageHandler : IHandleMessages<MyMessage> | ||
{ | ||
static bool hasSkipped; | ||
public Context Context { get; set; } | ||
|
||
public IBus Bus { get; set; } | ||
|
||
public void Handle(MyMessage message) | ||
{ | ||
if (!hasSkipped) | ||
{ | ||
hasSkipped = true; | ||
Thread.Sleep(TimeSpan.FromSeconds(2)); | ||
Bus.HandleCurrentMessageLater(); | ||
return; | ||
} | ||
Context.WasCalled = true; | ||
} | ||
} | ||
} | ||
|
||
[Serializable] | ||
[TimeToBeReceived("00:00:01")] | ||
This comment has been minimized.
Sorry, something went wrong. |
||
public class MyMessage : IMessage | ||
{ | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...eptanceTests/BasicMessaging/When_using_a_message_with_TimeToBeReceived_has_not_expired.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,53 @@ | ||
namespace NServiceBus.AcceptanceTests.BasicMessaging | ||
{ | ||
using System; | ||
using EndpointTemplates; | ||
using AcceptanceTesting; | ||
using NUnit.Framework; | ||
|
||
public class When_using_a_message_with_TimeToBeReceived_has_not_expired : NServiceBusAcceptanceTest | ||
{ | ||
[Test] | ||
public void Message_should_be_received() | ||
{ | ||
var context = new Context(); | ||
|
||
Scenario.Define(context) | ||
.WithEndpoint<Endpoint>(b => b.Given((bus, c) => bus.SendLocal(new MyMessage()))) | ||
.Done(c => c.WasCalled) | ||
.Run(); | ||
|
||
Assert.IsTrue(context.WasCalled); | ||
} | ||
|
||
public class Context : ScenarioContext | ||
{ | ||
public bool WasCalled { get; set; } | ||
} | ||
|
||
public class Endpoint : EndpointConfigurationBuilder | ||
{ | ||
public Endpoint() | ||
{ | ||
EndpointSetup<DefaultServer>(); | ||
} | ||
public class MyMessageHandler : IHandleMessages<MyMessage> | ||
{ | ||
public Context Context { get; set; } | ||
|
||
public IBus Bus { get; set; } | ||
|
||
public void Handle(MyMessage message) | ||
{ | ||
Context.WasCalled = true; | ||
} | ||
} | ||
} | ||
|
||
[Serializable] | ||
[TimeToBeReceived("00:00:10")] | ||
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 doesn't seem to work for Rabbit http://builds.particular.net/viewLog.html?buildId=36672&tab=buildResultsDiv&buildTypeId=NServiceBusRabbitMQ_2RunAcceptanceTests
and I know @yvesgoeleven mentioned that it doesn't work for Azure either. Isn't 1 sec to short? (think rabbit discards right away)