public void CanProcessProcessStartedEvents()
        {
            Guid guid1 = Guid.NewGuid();
            Guid guid2 = Guid.NewGuid();
            Guid guid3 = Guid.NewGuid();

            Guid processA = ProcessGuids.ProcessA;
            Guid processB = ProcessGuids.ProcessB;

            ProcessStarted startA1 = new ProcessStarted(guid1, processA);
            ProcessStarted startB1 = new ProcessStarted(guid2, processB);
            ProcessStarted startA2 = new ProcessStarted(guid3, processA);

            IRepository<ProcessTypeCount> repo = GetRepositoryForTest();

            ProcessTypeCounterEventProcessor processor = new ProcessTypeCounterEventProcessor(
                repo
                );

            processor.Handle(startA1);
            processor.Handle(startB1);
            processor.Handle(startA2);

            ProcessTypeCount counterA = repo.Get(processA.ToString());
            Assert.IsNotNull(counterA);
            Assert.AreEqual(2, counterA.Count);

            ProcessTypeCount counterB = repo.Get(processB.ToString());
            Assert.IsNotNull(counterB);
            Assert.AreEqual(1, counterB.Count);

        }
        public void CanProcessAProcessEndededEvent()
        {
            Guid guid = Guid.NewGuid();
            Guid processType = ProcessGuids.ProcessA;
            ProcessStarted startEvent = new ProcessStarted(guid, processType);
            ProcessEnded endEvent = new ProcessEnded(guid, DateTime.UtcNow, false);

            IRepository<DailyActivity> repo = GetRepositoryForTest();

            DailyActivityEventProcessor processor = new DailyActivityEventProcessor(
                repo
                );

            processor.Handle(startEvent);
            processor.Handle(endEvent);

            DailyActivity activity = repo.Get(GetIdForFirstActivityPersisted(repo));

            Assert.IsNotNull(activity);
            Assert.AreEqual(0, activity.ActiveProcesses);
            Assert.AreEqual(1, activity.TotalProcessCount);
            Assert.AreEqual(1, activity.CompletionCount);
            Assert.AreEqual(0, activity.CompletedWithErrorCount);

        }
        public void CanInstallHandlersInTheContainer()
        {
            using (IWindsorContainer container = new WindsorContainer())
            {
                //This line just forces the domain events lib to be loaded, and handlers available in the app domain.
                IProcessEvents proc = new DailyActivityEventProcessor(new Mock<IRepository<DailyActivity>>().Object);

                container.Install(new HandlerInstaller(), new RepositoryInstaller());

                ProcessStarted started = new ProcessStarted(Guid.NewGuid(), Guid.NewGuid());
                var handlerType = typeof (IHandleEvent<>).MakeGenericType(started.GetType());

                IEnumerable<dynamic> handlers = container.ResolveAll(handlerType).Cast<dynamic>();

                Assert.IsNotNull(handlers);
                Assert.AreEqual(2, handlers.Count());

                var handler = handlers.FirstOrDefault(o => o.GetType() == typeof (DailyActivityEventProcessor));
                Assert.IsNotNull(handler);


            }


        }
        public void CanCreateInstanceOfProcessEndedEvent()
        {
            Guid processId = Guid.NewGuid();
            Guid processType = ProcessGuids.ProcessA;
            DateTime time = DateTime.UtcNow;


            ProcessStarted @event = new ProcessStarted(processId, processType);

            Assert.IsNotNull(@event);
            Assert.IsInstanceOf<Event>(@event);

            Assert.AreEqual(processId, @event.ProcessId);
            Assert.AreEqual(processType, @event.ProcessTypeId);

        }