public void Write_should_contain_test_and_result_information() { // Arrange var stringBuilder = new StringBuilder(); var stringWriter = new StringWriter(stringBuilder); var resultWriter = new TextResultWriter(stringWriter); var result = new TestCaseResult() { ActualUrl = "http://www.actualurl.com", Message = "my message", ResponseTime = TimeSpan.FromSeconds(2), ResponseCodeSuccess = true, TestCase = new Case() { Url = "http://www.originalurl.com", Id = 99, ShortDescription = "shortdescription" } }; // Act resultWriter.Write(result); // Assert string output = stringBuilder.ToString(); Assert.That(output, Is.StringContaining(new String('-', 80))); Assert.That(output, Is.StringContaining("Case 99 (shortdescription)")); Assert.That(output, Is.StringContaining("")); Assert.That(output, Is.StringContaining(" - Original url: " + result.TestCase.Url)); Assert.That(output, Is.StringContaining(" - Actual url: " + result.ActualUrl)); Assert.That(output, Is.StringContaining(" - Response code success: Passed")); Assert.That(output, Is.StringContaining(" - Time taken: " + result.ResponseTime)); Assert.That(output, Is.StringContaining(" - Success: Passed")); Assert.That(output, Is.StringContaining(" - Message: " + result.Message)); }
public void WriteHeader_should_append_message_and_seperator() { // Arrange var stringBuilder = new StringBuilder(); var stringWriter = new StringWriter(stringBuilder); var resultWriter = new TextResultWriter(stringWriter); // Act resultWriter.WriteHeader("my string {0}", 1); // Assert string output = stringBuilder.ToString(); Assert.That(output, Is.StringContaining(new String('-', 80))); Assert.That(output, Is.StringContaining("my string 1")); }
public void Write_should_contain_handle_empty_verify_results() { // Arrange var stringBuilder = new StringBuilder(); var stringWriter = new StringWriter(stringBuilder); var resultWriter = new TextResultWriter(stringWriter); var result = new TestCaseResult() { TestCase = new Case() { Url = "", Id = 99, ShortDescription = "" } }; // Act resultWriter.Write(result); // Assert string output = stringBuilder.ToString(); Assert.That(output, Is.StringContaining("Verify negatives")); Assert.That(output, Is.StringContaining("- (none found)")); }
public void should_post() { // Arrange //_streamWriter = new StreamWriter(new FileStream(filename, FileMode.OpenOrCreate, FileAccess.Write)); var stringBuilder = new StringBuilder(); var stringWriter = new StringWriter(stringBuilder); var config = new Config(); config.GlobalHttpLog = LogType.All; var httpClient = new HttpClient(new HttpLogWriter(stringWriter), new RestClient()); var resultWriter = new TextResultWriter(stringWriter); string xml = TestHelpers.ReadEmbeddedFile("roadkill-login.xml", XmlExamplesFolder); var stringReader = new StringReader(xml); var reader = new TestCaseReader(); var runner = new TestSessionRunner(config, httpClient, resultWriter); var caseCollection = reader.Read(stringReader); // Act TestCaseSession session = runner.Run(caseCollection); // Assert DumpAsXml(session); DumpAsYaml(session); Console.WriteLine(stringBuilder); }
public void Write_should_contain_verify_negative_results() { // Arrange var stringBuilder = new StringBuilder(); var stringWriter = new StringWriter(stringBuilder); var resultWriter = new TextResultWriter(stringWriter); var result = new TestCaseResult() { TestCase = new Case() { Url = "", Id = 99, ShortDescription = "" } }; result.VerifyPositiveResults.Add(new VerificationItem("x1", "myregex1", VerifyType.Positive) { Success = true }); result.VerifyPositiveResults.Add(new VerificationItem("x2", "myregex2", VerifyType.Positive) { Success = true }); // Act resultWriter.Write(result); // Assert string output = stringBuilder.ToString(); Assert.That(output, Is.StringContaining("Verify negatives")); Assert.That(output, Is.StringContaining("- Success: Passed")); Assert.That(output, Is.StringContaining("- x1 - True")); Assert.That(output, Is.StringContaining("- x2 - True")); }