public void GetBetween_PerformanceTest() { const int itemCount = 100000; const int requestCount = 10000; var random = new Random(42); var collection = new IntervalCollection <int>(); { int start; int end; for (var i = 0; i < itemCount; i++) { start = random.Next(1000); end = start + random.Next(1, 50); collection.Add(new TestInterval(start, end)); } } var stopwatch = Stopwatch.StartNew(); var selectedCount = 0; for (var i = 0; i < requestCount; i++) { var start = random.Next(1000); var end = start + random.Next(50); var result = collection.GetBetween(start, end); selectedCount += result.Count; } stopwatch.Stop(); Assert.Inconclusive($"Executed {nameof(collection.GetBetween)}() {requestCount} times to select {selectedCount} results from {itemCount} items in {stopwatch.Elapsed}"); }
public void GetBetween_NoItems_ReturnsEmptyCollection() { var collection = new IntervalCollection <int>(); var result = collection.GetBetween(0, 8); Assert.AreEqual(0, result.Count); }