TimeSpan calcTimeSpan(Throttle t, uint id) { DateTime start = DateTime.Now; for(int i = 0; i < 10; i++) { t?.SleepTillReady(id); } return DateTime.Now - start; }
private void throttleTest(uint id) { TimeSpan spanWithoutThrottle = calcTimeSpan(null, id); Throttle throttle = new Throttle(TimeSpan.FromSeconds(1)); TimeSpan spanWithThrottle = calcTimeSpan(throttle, id); Assert.IsTrue(spanWithThrottle > spanWithoutThrottle); Assert.IsTrue(spanWithThrottle > new TimeSpan(0, 0, 9)); }
public IrcClient(string ip, uint port, string userName, string password) : base(ip, (int)port) { throttle = new Throttle(TimeSpan.FromSeconds(2)); inputStream = new StreamReader(GetStream()); outputStream = new StreamWriter(GetStream()); WriteLine("PASS " + password + Environment.NewLine + "NICK " + userName + Environment.NewLine + "USER " + userName + " 8 * :" + userName); }