public void result_for_two_tasks_is_correct() { // Arrange var monitor = new FlatPerformanceMonitor <int>(); var task1 = 1; var task2 = 2; // Act monitor.StartTask(task1); Thread.Sleep(20); monitor.StopTask(task1); Thread.Sleep(10); monitor.StartTask(task2); Thread.Sleep(20); monitor.StopTask(task2); Thread.Sleep(10); // Assert var result = monitor.GetResult(); Assert.That(result[task1].Duration.TotalMilliseconds, Is.InRange(18, 22)); Assert.That(result[task2].Duration.TotalMilliseconds, Is.InRange(18, 22)); }
public void result_contains_started_task() { // Arrange var monitor = new FlatPerformanceMonitor <int>(); var task = 1; // Act monitor.StartTask(task); var result = monitor.GetResult(); // Assert Assert.AreEqual(1, result.Count); Assert.True(result.ContainsKey(task)); }
public void started_task_is_monitored() { // Arrange var monitor = new FlatPerformanceMonitor <int>(); var task = 1; // Act monitor.StartTask(task); Thread.Sleep(10); // Assert var result = monitor.GetResult(); Assert.Greater(result[task].Duration.Ticks, 0); }
public void result_for_started_task_is_correct() { // Arrange var monitor = new FlatPerformanceMonitor <int>(); var task = 1; // Act monitor.StartTask(task); Thread.Sleep(20); // Assert var result = monitor.GetResult(); Assert.That(result[task].Duration.TotalMilliseconds, Is.InRange(18, 22)); }
public void result_contains_started_tasks() { // Arrange var monitor = new FlatPerformanceMonitor <int>(); var tasks = new[] { 1, 2, 3 }; // Act foreach (var task in tasks) { monitor.StartTask(task); } var result = monitor.GetResult(); // Assert Assert.AreEqual(3, result.Count); foreach (var task in tasks) { Assert.True(result.ContainsKey(task)); } }