-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
InProcessMessaging - fix unsubscribe (#248)
* dipose subscription * update Build.ps1 * unsubscribe_should_stop_broker_task
- Loading branch information
1 parent
8e7668f
commit 8fe2bbd
Showing
6 changed files
with
93 additions
and
15 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
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
61 changes: 61 additions & 0 deletions
61
test/UnitTests/Messaging/NBB.Messaging.InProcessMessaging.Tests/InProcessMessagingTests.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,61 @@ | ||
// Copyright (c) TotalSoft. | ||
// This source code is licensed under the MIT license. | ||
|
||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using NBB.Messaging.Abstractions; | ||
using System; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace NBB.Messaging.InProcessMessaging.Tests | ||
{ | ||
public class InProcessMessagingTests | ||
{ | ||
[Fact] | ||
public async Task subsequent_msg_bus_subscriptions_for_same_topic() | ||
{ | ||
//Arrange | ||
using var sp = BuildServiceProvider(); | ||
var msgBus = sp.GetRequiredService<IMessageBus>(); | ||
|
||
Func<Task> subscribe = async () => | ||
{ | ||
using var sub = await msgBus.SubscribeAsync(e => Task.CompletedTask, options: MessagingSubscriberOptions.Default with { TopicName = "SomeTopic" }); | ||
}; | ||
|
||
//Act | ||
await subscribe(); | ||
await subscribe(); //should not throw already subscribed | ||
|
||
} | ||
|
||
//[Fact] | ||
//public async Task unsubscribe_should_stop_broker_task() | ||
//{ | ||
// //Arrange | ||
// using var sp = BuildServiceProvider(); | ||
// var msgBus = sp.GetRequiredService<IMessageBus>(); | ||
|
||
// //Act | ||
// var sub = await msgBus.SubscribeAsync(e => Task.CompletedTask, options: MessagingSubscriberOptions.Default with { TopicName = "SomeTopic" }); | ||
// sub.Dispose(); | ||
// await Task.Delay(10000); | ||
|
||
// //Assert | ||
|
||
|
||
//} | ||
|
||
private ServiceProvider BuildServiceProvider() | ||
{ | ||
var services = new ServiceCollection(); | ||
services.AddLogging(); | ||
services.AddSingleton<IConfiguration>(new ConfigurationBuilder().Build()); | ||
services.AddMessageBus().AddInProcessTransport(); | ||
|
||
return services.BuildServiceProvider(); | ||
|
||
} | ||
} | ||
} |
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