Line data Source code
1 : using cdmdotnet.Logging;
2 : using cdmdotnet.Logging.Configuration;
3 : using cdmdotnet.StateManagement.Threaded;
4 : using Cqrs.Bus;
5 : using Cqrs.Authentication;
6 : using Cqrs.Configuration;
7 : using Cqrs.Tests.Substitutes;
8 : using NUnit.Framework;
9 :
10 : namespace Cqrs.Tests.Bus
11 : {
12 : [TestFixture]
13 : public class When_publishing_events
14 0 : {
15 : private InProcessBus<ISingleSignOnToken> _bus;
16 :
17 : [SetUp]
18 0 : public void Setup()
19 : {
20 : _bus = new InProcessBus<ISingleSignOnToken>(new AuthenticationTokenHelper(new ThreadedContextItemCollectionFactory()), new NullCorrelationIdHelper(), new TestDependencyResolver(null), new ConsoleLogger(new LoggerSettingsConfigurationSection(), new NullCorrelationIdHelper()), new ConfigurationManager(), new BusHelper(new ConfigurationManager()));
21 : }
22 :
23 : [Test]
24 0 : public void Should_publish_to_all_handlers()
25 : {
26 : var handler = new TestAggregateDidSomethingHandler();
27 : _bus.RegisterHandler<TestAggregateDidSomething>(handler.Handle, handler.GetType());
28 : _bus.RegisterHandler<TestAggregateDidSomething>(handler.Handle, handler.GetType());
29 : _bus.Publish(new TestAggregateDidSomething());
30 : Assert.AreEqual(2, handler.TimesRun);
31 : }
32 :
33 : [Test]
34 0 : public void Should_work_with_no_handlers()
35 : {
36 : _bus.Publish(new TestAggregateDidSomething());
37 : }
38 : }
39 : }
|