Ejemplo n.º 1
0
        public void ShouldNotDie()
        {
            XmlConfigurator.Configure(new FileInfo("log4j.xml"));

            ProcessContextFactory pcf = new ProcessContextFactory();
            pcf.Start();

            List<object> work = new List<object>();

            IProcessContext processContext = pcf.CreateAndStart("foo bar");

            Command good = delegate
                               {
                                   int threadId = Thread.CurrentThread.GetHashCode();
                                   logger.Info("executing " + threadId);
                                   work.Add(this);
                               };
            Command bad = delegate
                              {
                                  int threadId = Thread.CurrentThread.GetHashCode();
                                  logger.Info("throwing " + threadId);
                                  throw new Exception();
                              };

            processContext.Enqueue(good);
            processContext.Enqueue(bad);
            processContext.Enqueue(good);
            processContext.Enqueue(bad);
            processContext.Join();
            Assert.AreEqual(1, work.Count);
        }
Ejemplo n.º 2
0
 public void ScheduleOnInterval_ShouldRepeatsCalls()
 {
     ProcessContextFactory factory = new ProcessContextFactory();
     factory.Start();
     IProcessContext fooProcess = factory.CreateAndStart("foo");
     fooProcess.ScheduleOnInterval(Normal, 0, 10);
     Thread.Sleep(1000);
     Assert.IsTrue(count > 1);
 }
Ejemplo n.º 3
0
        public void ScheduleOnInterval_ShouldBlockSubsequentCalls()
        {
            ProcessContextFactory factory = new ProcessContextFactory();
            factory.Start();
            IProcessContext fooProcess = factory.CreateAndStart("foo");
            fooProcess.ScheduleOnInterval(Sleeps, 0, 10);

            Thread.Sleep(1000);
            Assert.AreEqual(1, count);
        }
Ejemplo n.º 4
0
        public void CreatePooled_ShouldBlockSubsequentCalls()
        {
            ProcessContextFactory factory = new ProcessContextFactory();
            factory.Start();
            IProcessBus pooled = factory.CreatePooled();
            object topic = pooled.CreateUniqueTopic();

            Thread.Sleep(1000);
            Assert.AreEqual(1, count);
        }