Skip to content

Commit

Permalink
make integ test less flaky
Browse files Browse the repository at this point in the history
  • Loading branch information
onlyann committed Sep 6, 2017
1 parent a015f1d commit 3c2d812
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions tests/ServiceStack.AzureServiceBus.Tests/MqServerIntroTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ public class HelloIntro : IReturn<HelloIntroResponse>
public string Name { get; set; }
}

public class HelloGlobal : IReturn<HelloGlobalResponse>
{
public string Name { get; set; }
}

public class HelloGlobalResponse
{
public string Result { get; set; }
}

public class HelloFail : IReturn<HelloFailResponse>
{
public string Name { get; set; }
Expand Down Expand Up @@ -432,8 +442,8 @@ public async Task Global_request_and_response_get_called()
using (var mqServer = CreateMqServer())
{
await Task.WhenAll(
mqServer.MessageFactory.PurgeQueueAsync<HelloIntro>(),
mqServer.MessageFactory.PurgeQueuesAsync(QueueNames<HelloIntroResponse>.In));
mqServer.MessageFactory.PurgeQueueAsync<HelloGlobal>(),
mqServer.MessageFactory.PurgeQueuesAsync(QueueNames<HelloGlobalResponse>.In));

var azureServer = mqServer as AzureBusServer;
azureServer.RequestFilter = msg =>
Expand All @@ -444,23 +454,23 @@ await Task.WhenAll(

azureServer.ResponseFilter = response =>
{
if (response is HelloIntroResponse helloResp)
if (response is HelloGlobalResponse helloResp)
{
helloResp.Result += "!!!";
}

return response;
};

mqServer.RegisterHandler<HelloIntro>(m =>
new HelloIntroResponse { Result = $"Hello, {m.Meta["prefix"]} {m.GetBody().Name}".Fmt() });
mqServer.RegisterHandler<HelloGlobal>(m =>
new HelloGlobalResponse { Result = $"Hello, {m.Meta["prefix"]} {m.GetBody().Name}".Fmt() });
mqServer.Start();

using (var mqClient = mqServer.CreateMessageQueueClient())
{
mqClient.Publish(new HelloIntro { Name = "World" });
mqClient.Publish(new HelloGlobal { Name = "World" });

IMessage<HelloIntroResponse> responseMsg = mqClient.Get<HelloIntroResponse>(QueueNames<HelloIntroResponse>.In);
IMessage<HelloGlobalResponse> responseMsg = mqClient.Get<HelloGlobalResponse>(QueueNames<HelloGlobalResponse>.In);
mqClient.Ack(responseMsg);
Assert.That(responseMsg.GetBody().Result, Is.EqualTo("Hello, Global World!!!"));
}
Expand Down

0 comments on commit 3c2d812

Please sign in to comment.