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); }
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); }
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); }
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); }