Line data Source code
1 : using System;
2 : using Cqrs.Authentication;
3 : using Cqrs.Configuration;
4 : using Cqrs.Domain;
5 : using Cqrs.Tests.Substitutes;
6 : using NUnit.Framework;
7 :
8 : namespace Cqrs.Tests.Bus
9 : {
10 : [TestFixture]
11 : public class When_registering_handlers
12 0 : {
13 : private BusRegistrar _register;
14 : private TestDependencyResolver _locator;
15 :
16 : [SetUp]
17 0 : public void Setup()
18 : {
19 : _locator = new TestDependencyResolver(null);
20 : _register = new BusRegistrar(_locator);
21 : if (TestHandleRegistrar.HandlerList.Count == 0)
22 : _register.Register(GetType());
23 : }
24 :
25 : [Test]
26 0 : public void Should_register_all_handlers()
27 : {
28 : Assert.AreEqual(6, TestHandleRegistrar.HandlerList.Count);
29 : }
30 :
31 : [Test]
32 0 : public void Should_be_able_to_run_all_handlers()
33 : {
34 : TestSagaUnitOfWork.TestSagasWithAddCountGetCountAndCommitCount.Add(Guid.Empty, new Tuple<ISaga<ISingleSignOnToken>, int, int, int>(new TestSaga(_locator, Guid.Empty), 0, 0, 0));
35 : foreach (var item in TestHandleRegistrar.HandlerList)
36 : {
37 : var @event = Activator.CreateInstance(item.Type);
38 : item.Handler(@event);
39 : }
40 : foreach (var handler in _locator.Handlers)
41 : {
42 : Assert.That(handler.TimesRun, Is.EqualTo(1));
43 : }
44 : }
45 : }
46 : }
|