public void IgnoreAProcessEndedEventForAUnkownProcess()
        {
            Guid           guid        = Guid.NewGuid();
            Guid           guid2       = Guid.NewGuid();
            Guid           processType = ProcessGuids.ProcessA;
            ProcessStarted worEvent    = new ProcessStarted(guid, processType);
            ProcessEnded   worcEvent   = new ProcessEnded(guid2, DateTime.UtcNow, false);

            IRepository <DailyActivity> repo = GetRepositoryForTest();

            DailyActivityEventProcessor processor = new DailyActivityEventProcessor(
                repo
                );

            processor.Handle(worEvent);
            processor.Handle(worcEvent);

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

            Assert.IsNotNull(activity);
            Assert.AreEqual(1, activity.ActiveProcesses);
            Assert.AreEqual(1, activity.TotalProcessCount);
            Assert.AreEqual(0, 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 CanCreateInstanceOfDailyActivityEventProcessor()
        {
            IRepository<DailyActivity> repo = GetRepositoryForTest();
            DailyActivityEventProcessor processor = new DailyActivityEventProcessor(
                repo    
                );

            Assert.IsNotNull(processor);
            Assert.IsInstanceOf<IProcessEvents>(processor);
            Assert.IsInstanceOf<IHandleEvent<ProcessStarted>>(processor);
            Assert.IsInstanceOf<IHandleEvent<ProcessEnded>>(processor);

            //Make sure repository is initialized and no activity is registered
            var activity = (repo as ITestRepository<DailyActivity>).GetPersistedData();

            Assert.IsNotNull(activity);
            CollectionAssert.IsEmpty(activity.Keys);
        }
        public void CanCreateInstanceOfDailyActivityEventProcessor()
        {
            IRepository <DailyActivity> repo      = GetRepositoryForTest();
            DailyActivityEventProcessor processor = new DailyActivityEventProcessor(
                repo
                );

            Assert.IsNotNull(processor);
            Assert.IsInstanceOf <IProcessEvents>(processor);
            Assert.IsInstanceOf <IHandleEvent <ProcessStarted> >(processor);
            Assert.IsInstanceOf <IHandleEvent <ProcessEnded> >(processor);

            //Make sure repository is initialized and no activity is registered
            var activity = (repo as ITestRepository <DailyActivity>).GetPersistedData();

            Assert.IsNotNull(activity);
            CollectionAssert.IsEmpty(activity.Keys);
        }
Пример #5
0
        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 CanProcessAProcessStartedEvent()
        {
            Guid guid = Guid.NewGuid();
            Guid processType = ProcessGuids.ProcessA;
            ProcessStarted worEvent = new ProcessStarted(guid, processType);

            IRepository<DailyActivity> repo = GetRepositoryForTest();

            DailyActivityEventProcessor processor = new DailyActivityEventProcessor(
                repo
                );

            processor.Handle(worEvent);

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

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

        }
 public void NullRepositoryThrowsExceptionOnConstructorCall()
 {
     DailyActivityEventProcessor processor = new DailyActivityEventProcessor(
         null
         );
 }
 public void NullRepositoryThrowsExceptionOnConstructorCall()
 {
     DailyActivityEventProcessor processor = new DailyActivityEventProcessor(
         null
         );
 }