diff --git a/src/Stove/Events/Bus/EventBus.cs b/src/Stove/Events/Bus/EventBus.cs
index 88ef00d..5249a4a 100644
--- a/src/Stove/Events/Bus/EventBus.cs
+++ b/src/Stove/Events/Bus/EventBus.cs
@@ -21,6 +21,11 @@ namespace Stove.Events.Bus
///
public class EventBus : IEventBus
{
+ ///
+ /// Gets the default instance.
+ ///
+ public static EventBus Default = new EventBus();
+
///
/// All registered handler factories.
/// Key: Type of the event
diff --git a/src/Stove/StoveCoreRegistrationExtensions.cs b/src/Stove/StoveCoreRegistrationExtensions.cs
index f130c1e..8cbf0fc 100644
--- a/src/Stove/StoveCoreRegistrationExtensions.cs
+++ b/src/Stove/StoveCoreRegistrationExtensions.cs
@@ -92,6 +92,19 @@ public static IIocBuilder UseStoveEventBus([NotNull] this IIocBuilder builder)
return builder;
}
+
+ ///
+ /// Uses the stove default event bus.
+ ///
+ /// The builder.
+ ///
+ [NotNull]
+ public static IIocBuilder UseStoveDefaultEventBus([NotNull] this IIocBuilder builder)
+ {
+ builder.RegisterServices(r => r.Register(context => EventBus.Default, Lifetime.Singleton));
+ return builder;
+ }
+
///
/// Uses the stove background jobs.
///
diff --git a/test/Stove.Tests.SampleApplication/BasicRepository_Tests.cs b/test/Stove.Tests.SampleApplication/BasicRepository_Tests.cs
index bf2017b..4d3e9a8 100644
--- a/test/Stove.Tests.SampleApplication/BasicRepository_Tests.cs
+++ b/test/Stove.Tests.SampleApplication/BasicRepository_Tests.cs
@@ -4,6 +4,7 @@
using Stove.Domain.Repositories;
using Stove.Domain.Uow;
+using Stove.Events.Bus;
using Stove.Events.Bus.Entities;
using Stove.Events.Bus.Handlers;
using Stove.Extensions;
@@ -90,6 +91,37 @@ public void uow_complete_handle_eventbus_should_work_with_repository_insert()
}
}
+ [Fact]
+ public void uow_complete_handle_eventbus_should_work_with_repository_insert2()
+ {
+ var uowManager = LocalResolver.Resolve();
+ var userRepository = LocalResolver.Resolve>();
+
+ using (IUnitOfWorkCompleteHandle uow = uowManager.Begin())
+ {
+ for (var i = 0; i < 1000; i++)
+ {
+ userRepository.Insert(new User
+ {
+ Email = "ouzsykn@hotmail.com",
+ Surname = "Sykn",
+ Name = "Oğuz"
+ });
+ }
+
+ uow.Complete();
+ }
+
+ using (IUnitOfWorkCompleteHandle uow = uowManager.Begin())
+ {
+ userRepository.GetAll().ForEach(user => user.Surname = "Soykan");
+ userRepository.Count(x => x.Email == "ouzsykn@hotmail.com").ShouldBe(1000);
+ userRepository.FirstOrDefault(x => x.Email == "ouzsykn@hotmail.com").ShouldNotBeNull();
+
+ uow.Complete();
+ }
+ }
+
public class UserCreatedEventHandler : IEventHandler>,
IEventHandler>,
ITransientDependency