static void Main(string[] args) { // Run test cases. int numberOfTests = 6; for (int i = 1; i <= numberOfTests; i++) { var testCaseRunner = new TestCaseRunner(i); // Display the test case header. testCaseRunner.WriteTestHeader(); Console.WriteLine("Press enter to run this test case."); Console.ReadLine(); // Run the test case. testCaseRunner.RunTest(); if (i < numberOfTests) { Console.WriteLine("Voila.\nPress enter to clear console and print next test case."); Console.ReadLine(); Console.Clear(); } } // Prevent console window from closing immediately. Console.WriteLine("Press enter to exit this application. Thank you."); Console.ReadLine(); }
public void SubmitApplication() { var tc = new TestCaseRunner(1, "SubmitApplication"); var log = tc.RunTestAsync(SubmitApplicationHelper.SubmitApplicationProcess); Console.WriteLine(log.ToString()); }
public void TestPassSuccess() { TestCaseRunner testCaseRunner = new TestCaseRunner("complete_tests_pass.json"); //Assert.IsTrue(testCaseRunner.RunTestCases()); Assert.IsTrue(testCaseRunner.DidAllTestCasesPass()); }
private async void RunTests() { EnableButtons(false); List <ConfigFile> lstConfigFiles = BaseTestCase.LoadConfigFile("config_file.json"); string _testcasetype = string.Empty; foreach (var item in lstConfigFiles) { try { _testcasetype = item.TestCaseType; string testResultString = string.Format(item.Purpose + "\r\n\r\n"); testCaseRunner = new TestCaseRunner(item.FilePath); testCaseRunner.TestCaseOutputEventHandler += TestCaseRunner_TestCaseOutputEventHandler; testCaseRunner.RunTestCases(); } catch (Exception ex) { await Dispatcher.InvokeAsync(new Action(() => TestResultVM.TestResultObservableCollection.Add(new TestCaseResult { Target = item.TestName, InputJsonFileName = item.FilePath, Result = "Fail", Description = ex.Message }))); } } EnableButtons(true); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } var dllDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); var targetDirectory = Path.Combine(dllDirectory, "PhantomJs", "pdf-out"); if (!Directory.Exists(targetDirectory)) { Directory.CreateDirectory(targetDirectory); } var htmlToPdfConverter = app.ApplicationServices.GetService <IHtmlToPdfConverter>(); var options = app.ApplicationServices.GetService <HtmlToPdfConverterOptions>(); var testRunner = new TestCaseRunner(); app.Run(async(context) => { var results = testRunner.RunAll(htmlToPdfConverter, targetDirectory); var json = JsonSerializer.Serialize(results); await context.Response.WriteAsync(json); }); }
internal static void RunTestsFor(string syntaxId, ICodeFormatter formatter, XmlOutputVerifier verifier) { foreach (DirectoryInfo testCasesForOneSyntax in TestHelper.FileTestCasesDirectory.GetDirectories(syntaxId)) { if (testCasesForOneSyntax.Name == ".svn") { continue; } TestCaseRunner r = new TestCaseRunner(testCasesForOneSyntax.Name, testCasesForOneSyntax, formatter, verifier); r.HighlightAndVerifyAllTestCases(); } }
private List <Results> CompareTables(List <Results> testResultList) { List <Results> finalResults = new List <Results>(); for (int i = 0; i < testResultList.Count; i++) { finalResults.Add(TestCaseRunner.RunRowCountTestCase(testResultList[i])); finalResults.Add(TestCaseRunner.RunSchemaTestCase(testResultList[i])); finalResults.Add(TestCaseRunner.RunEqualityTestCase(testResultList[i])); } return(finalResults); }
private static void RunTests(string configFileName) { List <ConfigFile> lstConfigFiles = BaseTestCase.LoadConfigFile(configFileName); string _testcasetype = string.Empty; foreach (var item in lstConfigFiles) { try { _testcasetype = item.TestCaseType; //string testResultString = string.Format(item.Purpose + "\r\n\r\n"); //Console.WriteLine(testResultString); // make configurable? //Replace curl with C# default httpWebRequest API testCaseRunner = new TestCaseRunner(item.FilePath); //testCaseRunner.PathToCurl = "curl.exe"; testCaseRunner.TestCaseOutputEventHandler += TestCaseRunner_TestCaseOutputEventHandler; //TODO: hook up string streaming testCaseRunner.RunTestCases(); //testResultString = string.Format(item.TestName + " test case status : {0} \r\n\r\n", testCaseRunner.DidAllTestCasesPass()); //Console.WriteLine(testResultString); } catch (Exception ex) { Console.WriteLine(string.Format("\t" + ex.Message + "\r\n\r\n")); } } Console.WriteLine("Do you want to export test case result? [yes/no]"); string option = Console.ReadLine(); if (option == "yes") { string filename = "TestCaseResult" + DateTime.Now.ToString("yyyy''MM''dd'T'HH''mm''ss") + ".csv"; if (itemList == null || itemList.Count == 0) { return; } var sb = new StringBuilder(); string csvHeaderRow = String.Join(",", typeof(TestCaseResult).GetProperties(BindingFlags.Public | BindingFlags.Instance).Select(x => x.Name).ToArray <string>()) + Environment.NewLine; sb.AppendLine(csvHeaderRow); foreach (var data in itemList) { sb.AppendLine(data.Target + "," + data.ProxyURL + "," + data.ProxyType + "," + data.InputJsonFileName + "," + data.ExpectedStatusCode + "," + data.ActualStatusCode + "," + data.Result + "," + data.Description); } File.WriteAllText(filename, sb.ToString()); Console.WriteLine(string.Format("Test case data has been exported to {0} file in current directory", filename)); } }
public static IEnumerable <TestCaseResult> RunTestCases() { var htmlToPdfConverter = CreateHtmlToPdfConverter(); var currentDirectory = Directory.GetCurrentDirectory(); var targetDirectory = Path.Combine(currentDirectory, "PhantomJs", "pdf-out"); if (!Directory.Exists(targetDirectory)) { Directory.CreateDirectory(targetDirectory); } var testRunner = new TestCaseRunner(); return(testRunner.RunAll(htmlToPdfConverter, targetDirectory)); }
public void TestCaseRunner() { foreach (var item in TestCases()) { var message = $"No.{item.testNumber}"; TestCaseRunner actual; try { actual = new TestCaseRunner(item.description); } catch (Exception ex) { Assert.AreEqual(item.expectedExceptionType, ex.GetType(), message); continue; } Assert.AreEqual(item.description, actual.Description); Assert.AreEqual(item.expectedExceptionType, null, message); } // テストケース定義。 (int testNumber, string description, Type expectedExceptionType)[] TestCases() => new[] {