private StepFrame CreateStepFrame(TestMethod method) { StepFrame stepFrame = new StepFrame(); stepFrame.Text = method.ToString(); stepFrame.Dock = DockStyle.Fill; switch (method) { case TestMethod.Write: stepFrame.Icon = Properties.Resources.w_24x24; break; case TestMethod.Read: stepFrame.Icon = Properties.Resources.r_24x24; break; case TestMethod.SecondaryRead: stepFrame.Icon = Properties.Resources.sr_24x24; break; default: break; } // Hide time, CPU, memory and I/O view from the layout. stepFrame.LayoutPanel.ColumnStyles[1] = new ColumnStyle(SizeType.Absolute, 0); stepFrame.LayoutPanel.ColumnStyles[3] = new ColumnStyle(SizeType.Absolute, 0); stepFrame.LayoutPanel.ColumnStyles[4] = new ColumnStyle(SizeType.Absolute, 0); stepFrame.LayoutPanel.ColumnStyles[5] = new ColumnStyle(SizeType.Absolute, 0); return(stepFrame); }
/// <summary> /// call a method of ReplaceWithNewGuid /// </summary> /// <param name="replaceWithGuid">instance of ReplaceWithNewGuid</param> /// <param name="testMethod">invoke method</param> /// <param name="input">input data</param> /// <returns>result of ReplaceWithNewGuid</returns> private string CallMethodOfReplaceWithNewGuid(ReplaceWithNewGuid replaceWithGuid, TestMethod testMethod, string input) { var output = string.Empty; switch (testMethod) { case TestMethod.ReplaceNewGuid: output = replaceWithGuid.ReplaceNewGuid(input); break; case TestMethod.ReplaceSameGuidToSameGuid: output = replaceWithGuid.ReplaceSameGuidToSameGuid(input); break; default: throw new ArgumentException(testMethod.ToString()); } return(output); }
/// <summary> /// The string representation of the ScenarioResult. /// </summary> /// <returns>Returns a verbose string representation of the result.</returns> public override string ToString() { StringBuilder s = new StringBuilder(); s.AppendLine("Started: " + Started.ToString()); s.AppendLine("Finished: " + Finished.ToString()); TimeSpan duration = Finished.Subtract(Started); s.AppendLine("Duration: " + duration.ToString()); s.AppendLine("TestMethod: " + TestMethod.ToString()); s.AppendLine("TestClass: " + TestClass.ToString()); s.AppendLine("Result: " + Result.ToString()); if (Exception != null) { s.AppendLine(); s.AppendLine("Exception:"); s.AppendLine(Exception.Message); s.AppendLine(Exception.StackTrace); } return(s.ToString()); }
private static void Report(BenchmarkSession benchmark, TestMethod method) { try { string databaseName = benchmark.Database.Name; Console.WriteLine(); var speed = benchmark.GetAverageSpeed(method); var size = (benchmark.DatabaseSize / (1024.0 * 1024.0)); var elapsedTime = new TimeSpan(benchmark.GetElapsedTime(method).Ticks); var peakWorkingSet = (benchmark.GetPeakWorkingSet(method) / (1024.0 * 1024.0)); Logger.Info(String.Format("------------------{0} {1}------------------", databaseName, method.ToString())); Logger.Info(String.Format("Average speed: {0:#,#} rec/sec", speed)); Logger.Info(String.Format("Size: {0:f1} MB", size)); Logger.Info(String.Format("Elapsed time: {0}", elapsedTime)); Logger.Info(String.Format("Peak memory usage: {0:f0} MB", peakWorkingSet)); Logger.Info("---------------------------------------"); Console.WriteLine(); } catch (Exception exc) { Logger.Error("Report results failed...", exc); } }
private static bool TestType(Type typeToTest, string typeName, TestMethod selectedTestMethod, int currentTestNo) { var testMethodName = selectedTestMethod.ToString("F"); var passed = false; var fgColor = IsUnix ? ConsoleColor.Black : Console.ForegroundColor; try { Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("++++++++++++++++++++++++++++++++++++++++++++++++"); Console.WriteLine("Test no: " + currentTestNo); Console.WriteLine("++++++++++++++++++++++++++++++++++++++++++++++++"); Console.ForegroundColor = fgColor; Console.ForegroundColor = ConsoleColor.Cyan; Console.Write("Type's "); Console.WriteLine(testMethodName + ": "); Console.WriteLine("------------------------------------------------"); Console.ForegroundColor = fgColor; Console.WriteLine(typeName); var result = TypeNameParser.Parse(typeName, false); var tn = (result != null ? result.Scope : null); Console.ForegroundColor = ConsoleColor.Cyan; Console.Write("Parser's "); Console.WriteLine(testMethodName + ": "); Console.WriteLine("------------------------------------------------"); Console.ForegroundColor = fgColor; var tns = (string)null; if (tn != null) { switch (selectedTestMethod) { case TestMethod.AssemblyQualifiedName: tns = tn.AssemblyQualifiedName; break; case TestMethod.FullName: tns = tn.FullName; break; case TestMethod.ToString: tns = tn.ShortName; break; } } Console.WriteLine(tns); Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("------------------------------------------------"); Console.ForegroundColor = fgColor; passed = ((typeName ?? String.Empty).Trim() == tns); if (passed) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("PARSING PASSED"); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("PARSING FAILED !!!"); } var type = (result.Scope != null) ? result.Scope.ResolveType(false, true) : null; passed = (type != null && type == typeToTest); if (passed) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("RESOLVE PASSED"); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("RESOLVE FAILED !!!"); } } finally { Console.ForegroundColor = fgColor; } return(passed); }
private StepFrame CreateStepFrame(TestMethod method) { StepFrame stepFrame = new StepFrame(); stepFrame.Text = method.ToString(); stepFrame.Dock = DockStyle.Fill; switch (method) { case TestMethod.Write: stepFrame.Icon = Properties.Resources.w_24x24; break; case TestMethod.Read: stepFrame.Icon = Properties.Resources.r_24x24; break; case TestMethod.SecondaryRead: stepFrame.Icon = Properties.Resources.sr_24x24; break; default: break; } // Hide time, CPU, memory and I/O view from the layout. stepFrame.LayoutPanel.ColumnStyles[1] = new ColumnStyle(SizeType.Absolute, 0); stepFrame.LayoutPanel.ColumnStyles[3] = new ColumnStyle(SizeType.Absolute, 0); stepFrame.LayoutPanel.ColumnStyles[4] = new ColumnStyle(SizeType.Absolute, 0); stepFrame.LayoutPanel.ColumnStyles[5] = new ColumnStyle(SizeType.Absolute, 0); return stepFrame; }