public void CleanXmlPingTest(XmlResultJargon jargon) { var path = CreateResultSample(jargon, includePing: true); var cleanPath = path + "_clean"; resultParser.CleanXml(path, cleanPath); Assert.IsTrue(resultParser.IsValidXml(cleanPath, out var resultJargon), "is valid"); Assert.AreEqual(jargon, resultJargon, "jargon"); File.Delete(path); File.Delete(cleanPath); }
public void UpdateMissingDataTest() // only works with NUnitV3 { string appName = "TestApp"; var path = CreateResultSample(XmlResultJargon.NUnitV3); var cleanPath = path + "_clean"; XmlResultParser.CleanXml(path, cleanPath); var updatedXml = path + "_updated"; var logs = new [] { "/first/path", "/second/path", "/last/path" }; XmlResultParser.UpdateMissingData(cleanPath, updatedXml, appName, logs); // assert that the required info was updated Assert.IsTrue(File.Exists(updatedXml), "file exists"); var doc = XDocument.Load(updatedXml); var testSuiteElements = doc.Descendants().Where(e => e.Name == "test-suite" && e.Attribute("type")?.Value == "Assembly"); // assert root node contains the attachments var rootNode = testSuiteElements.FirstOrDefault(); Assert.IsNotNull(rootNode, "Root node"); var attachments = rootNode.Descendants().Where(e => e.Name == "attachment"); var failureCount = rootNode.Descendants().Where(e => e.Name == "test-case" && e.Attribute("result").Value == "Failed").Count(); Assert.AreEqual(logs.Length * (failureCount + 1), attachments.Count(), "attachment count"); // assert that name and full name are present and are the app name foreach (var node in testSuiteElements) { Assert.AreEqual(appName, node.Attribute("name").Value, "name"); Assert.AreEqual(appName, node.Attribute("fullname").Value, "fullname"); } File.Delete(path); File.Delete(cleanPath); File.Delete(updatedXml); }
public void CleanXmlTouchUnitTest() { // similar to CleanXmlPingTest but using TouchUnit, so we do not want to see the extra nodes var path = CreateResultSample(XmlResultJargon.TouchUnit, includePing: true); var cleanPath = path + "_clean"; XmlResultParser.CleanXml(path, cleanPath); Assert.IsTrue(XmlResultParser.IsValidXml(cleanPath, out var resultJargon), "is valid"); Assert.AreEqual(XmlResultJargon.NUnitV2, resultJargon, "jargon"); // load the xml, ensure we do not have the nodes we removed var doc = XDocument.Load(cleanPath); Assert.IsFalse(doc.Descendants().Where(e => e.Name == "TouchUnitTestRun").Any(), "TouchUnitTestRun"); Assert.IsFalse(doc.Descendants().Where(e => e.Name == "NUnitOutput").Any(), "NUnitOutput"); File.Delete(path); File.Delete(cleanPath); }