public void CountTest2() { var counter = new LogLineCounter(3); var beginning = DateTime.Now; counter.Count(CreateLogLine(beginning, _IPAddress1)); counter.Count(CreateLogLine(beginning.AddSeconds(10), _IPAddress2)); counter.Count(CreateLogLine(beginning.AddSeconds(20), _IPAddress3)); counter.Count(CreateLogLine(beginning.AddSeconds(30), _IPAddress4)); counter.Count(CreateLogLine(beginning.AddSeconds(40), _IPAddress5)); counter.Count(CreateLogLine(beginning.AddSeconds(50), _IPAddress1)); counter.Count(CreateLogLine(beginning.AddSeconds(60), _IPAddress1)); counter.Count(CreateLogLine(beginning.AddSeconds(120), _IPAddress1)); var addresses = counter.GetOverLimitativeIPAddresses().ToList(); Assert.Empty(addresses); }
public void CountTest3() { var counter = new LogLineCounter(3); var beginning = DateTime.Now; counter.Count(CreateLogLine(beginning, _IPAddress1)); counter.Count(CreateLogLine(beginning.AddSeconds(10), _IPAddress2)); counter.Count(CreateLogLine(beginning.AddSeconds(20), _IPAddress3)); counter.Count(CreateLogLine(beginning.AddSeconds(30), _IPAddress4)); counter.Count(CreateLogLine(beginning.AddSeconds(40), _IPAddress5)); counter.Count(CreateLogLine(beginning.AddSeconds(50), _IPAddress1)); counter.Count(CreateLogLine(beginning.AddSeconds(59), _IPAddress1)); counter.Count(CreateLogLine(beginning.AddSeconds(60), _IPAddress1)); counter.Count(CreateLogLine(beginning.AddSeconds(70), _IPAddress5)); counter.Count(CreateLogLine(beginning.AddSeconds(71), _IPAddress5)); counter.Count(CreateLogLine(beginning.AddSeconds(71), _IPAddress4)); counter.Count(CreateLogLine(beginning.AddSeconds(72), _IPAddress5)); counter.Count(CreateLogLine(beginning.AddSeconds(80), _IPAddress3)); counter.Count(CreateLogLine(beginning.AddSeconds(90), _IPAddress5)); var addresses = counter.GetOverLimitativeIPAddresses().ToList(); Assert.Equal(2, addresses.Count); Assert.Single(addresses, _IPAddress1); Assert.Single(addresses, _IPAddress5); }