public void should_parse_responses() { // Arrange var stringBuilder = new StringBuilder(); var httpLogWriter = new HttpLogWriter(new StringWriter(stringBuilder)); var httpClient = new HttpClient(httpLogWriter, new RestClient()); var config = new Config(); string xml = TestHelpers.ReadEmbeddedFile("parseresponses.xml", XmlExamplesFolder); var stringReader = new StringReader(xml); var reader = new TestCaseReader(); var caseCollection = reader.Read(stringReader); var runner = new TestSessionRunner(config, httpClient, new ConsoleResultWriter()); // Act TestCaseSession result = runner.Run(caseCollection); // Assert DumpAsYaml(result); }
public void should_do_something() { // Arrange var stringBuilder = new StringBuilder(); var httpLogWriter = new HttpLogWriter(new StringWriter(stringBuilder)); var httpClient = new HttpClient(httpLogWriter, new RestClient()); var config = new Config(); string xml = TestHelpers.ReadEmbeddedFile("wikipedia-simple.xml", XmlExamplesFolder); var stringReader = new StringReader(xml); var reader = new LegacyTestCaseReader(); var caseCollection = reader.Read(stringReader); var runner = new TestSessionRunner(config, httpClient, new ConsoleResultWriter()); // Act runner.Run(caseCollection); // Assert Console.WriteLine(stringBuilder); }
/// <summary> /// Starts the test case XML file run. /// </summary> internal void StartSession(SessionRunnerTaskInfo item) { try { // TODO: this run could be for a user run only, not the entire team (read the XML from their folder?) string username = item.Username; string teamName = item.TeamName; // Read in the XML file from the team folder, e.g. "c:\testcases\myteam\test1.xml" string fullPath = Path.Combine(_appConfig.TestCasesBaseDirectory, teamName, item.Request.Filename); string xml = File.ReadAllText(fullPath); using (var stringReader = new StringReader(xml)) { var testCaseReader = new TestCaseReader(); CaseCollection caseCollection = testCaseReader.Read(stringReader); var config = new Config(); var logStringBuilder = new StringBuilder(); var httpLogWriter = new HttpLogWriter(new StringWriter(logStringBuilder)); var httpClient = new HttpClient(httpLogWriter, new RestClient()); var runner = new TestSessionRunner(config, httpClient, new TextFileResultWriter()); item.Runner = runner; runner.Run(caseCollection); } } catch (Exception e) { item.Errors = e.ToString(); } }
private HttpLogWriter GetHttpLogWriter(StringBuilder stringBuilder) { var logWriter = new HttpLogWriter(new StringWriter(stringBuilder)); return logWriter; }
/// <summary> /// Creates a new <see cref="TestSessionRunner"/> using the defaults. /// </summary> /// <returns></returns> public static TestSessionRunner CreateNew() { var config = new Config(); var logStringBuilder = new StringBuilder(); var httpLogWriter = new HttpLogWriter(new StringWriter(logStringBuilder)); var httpClient = new HttpClient(httpLogWriter, new RestClient()); return new TestSessionRunner(config, httpClient, new TextFileResultWriter()); }