public void TestPacer2() { var agent = new PacerAgent(new BlitzkriegSoftware.Pacing.Library.Models.RedisConfiguration(), KeyPrefix); Assert.IsTrue(agent.IsValid); var ts = new TimeSpan(0, 0, 0, 1, 0); agent.MarkPacing(KeySuffix, ts); var runnable = agent.Runnable(KeySuffix); Assert.IsFalse(runnable); }
public void PacerSimulator(int jobTimeMin, int jobTimeMax, int maxMessages, int paceMilliseconds) { var jobs = new Dictionary <int, JobInfo>(); var agent = new PacerAgent(new BlitzkriegSoftware.Pacing.Library.Models.RedisConfiguration(), KeyPrefix); var intervalMS = new TimeSpan(0, 0, 0, 0, paceMilliseconds); _testContext.WriteLine($"Pacing at {paceMilliseconds} ms.\n"); for (int m = 0; m < maxMessages; m++) { _testContext.WriteLine($"\nLoop: {(m + 1)}"); #region "Pacing" // Pacing (wait until pace interval) while (!agent.Runnable(KeySuffix)) { ; } // Reset pacing agent.MarkPacing(KeySuffix, intervalMS); #endregion #region "Unit of Work" #pragma warning disable SCS0005 // Weak random generator (not a problem here) var td = dice.Next(jobTimeMin, jobTimeMax); #pragma warning restore SCS0005 // Weak random generator var job = new JobInfo(m, td); jobs.Add(m, job); #endregion #region "Show Job Status" foreach (var j in jobs.Values) { if (j.Status == JobStatus.Dead) { jobs.Remove(j.Id); } else { _testContext.WriteLine("\t" + j.Describe()); } } #endregion } }
public void TestPacer1() { var agent = new PacerAgent(new BlitzkriegSoftware.Pacing.Library.Models.RedisConfiguration(), KeyPrefix); Assert.IsTrue(agent.IsValid); var ts = new TimeSpan(0, 0, 0, 1, 0); agent.MarkPacing(KeySuffix, ts); var sleepTS = ts.Add(new TimeSpan(0, 0, 0, 5)); System.Threading.Thread.Sleep(sleepTS); var runnable = agent.Runnable(KeySuffix); Assert.IsTrue(runnable); }