public void CheckBothPassedAndFailedResults() { var sut = new TestRun("someFileName", "myComputer"); var time = new TimeInfo(DateTime.Now - new TimeSpan(500), DateTime.Now); sut.AddTestResult("MyTest", true, time, "All fine", ""); sut.AddTestResult("MySecondTest", false, time, "Didnt work", "Wrong"); Assert.That(sut.Results.UnitTestResults.Count, Is.EqualTo(2), "No results added to unittestresults"); Assert.That(sut.TestDefinitions.UnitTests.Count, Is.EqualTo(2), "No testdefinitions added"); Assert.That(sut.TestEntries.TestEntryList.Count, Is.EqualTo(2), "No test entries added"); var utr = sut.Results.UnitTestResults.First(); Assert.That(utr, Is.Not.Null, "UnitTestResult is empty/null"); Assert.That(sut.ResultSummary.Counters.Failed, Is.EqualTo(1)); Assert.That(sut.ResultSummary.Counters.Passed, Is.EqualTo(1)); Assert.That(sut.ResultSummary.Counters.Total, Is.EqualTo(2)); var xml = sut.SerializeObjectWithOutNamespace(ns); Assert.That(xml.Contains("UnitTestResults"), Is.False, "Contains UnitTestResults string, should only be array elements"); Assert.That(xml.Contains("<UnitTestResult"), "xml.Contains('<UnitTestResult')"); }
public void CheckAddingResults() { var sut = new TestRun("someFileName", "myComputer"); var time = new TimeInfo(DateTime.Now - new TimeSpan(500), DateTime.Now); sut.AddTestResult("MyTest", true, time, "All fine", ""); Assert.That(sut.Results.UnitTestResults.Count, Is.EqualTo(1), "No results added to unittestresults"); Assert.That(sut.TestDefinitions.UnitTests.Count, Is.EqualTo(1), "No testdefinitions added"); Assert.That(sut.TestEntries.TestEntryList.Count, Is.EqualTo(1), "No test entries added"); var utr = sut.Results.UnitTestResults.First(); Assert.That(utr, Is.Not.Null, "UnitTestResult is empty/null"); var xml = sut.SerializeObjectWithOutNamespace(ns); Assert.That(xml.Contains("UnitTestResults"), Is.False, "Contains UnitTestResults string, should only be array elements"); Assert.That(xml.Contains("<UnitTestResult"), "xml.Contains('<UnitTestResult')"); var tr = ExtractSegment(xml, "<UnitTestResult", "</UnitTestResult"); Assert.That(tr.Contains("testName=\"MyTest"), "tr.Contains('testName=\'MyTest')"); }