static void LogResult(PerformanceBudgetResult result) { if(result.IsOver) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Over Budget!"); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(result.GetDetailedOutput()); } else { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Under Budget!"); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(result.GetDetailedOutput()); } }
public void Get_Detailed_Output_Without_Steps(string name, decimal budgetMs, decimal durationMs, string expected) { var result = new PerformanceBudgetResult(name, budgetMs, durationMs, null); string actual = result.GetDetailedOutput(); Assert.Equal(expected, actual); }
public void Get_Detailed_Output_With_Duplicate_Steps() { string expected = "Budget was set to 2.000ms\r\nDuration was 1.000ms\r\nAction was under performance budget by 50.000% (1.000ms).\r\n Step: duplicate occured 3 times and took 1.000ms on average. 1 did not finish.\r\n"; var steps = new List<PerformanceStepResult>() { new PerformanceStepResult("duplicate", 1.0M), new PerformanceStepResult("duplicate", 1.0M), new PerformanceStepResult("duplicate", null), }; var result = new PerformanceBudgetResult(null, 2.0M, 1.0M, null) { Steps = steps }; string actual = result.GetDetailedOutput(); Assert.Equal(expected, actual); }
public void Get_Detailed_Output_With_Steps() { string expected = "Budget was set to 2.000ms\r\nDuration was 1.000ms\r\nAction was under performance budget by 50.000% (1.000ms).\r\n Step: one took 1.000ms\r\n"; var steps = new List<PerformanceStepResult>() { new PerformanceStepResult("one", 1.0M) }; var result = new PerformanceBudgetResult(null, 2.0M, 1.0M, null) { Steps = steps }; string actual = result.GetDetailedOutput(); Assert.Equal(expected, actual); }