public void ImportDocumentTest2() { MeiDocument testDoc = MeiImport.ImportDocument("..\\..\\files\\MeiImportTest2.xml"); Assert.IsNotNull(testDoc.SchemaLocation); Assert.IsNotNull(from node in testDoc.Nodes().OfType <XProcessingInstruction>() select node.Target != "xml-model"); }
public void ImportDocumentTest3() { MeiDocument testDoc = MeiImport.ImportDocument("..\\..\\files\\MeiImportTest3.xml"); IEnumerable <XProcessingInstruction> models = from node in testDoc.Nodes().OfType <XProcessingInstruction>().Where(node => node.Target == "xml-model") select node; List <string> href_compare = new List <string>(); Match hrefs; foreach (XProcessingInstruction model in models) { //Get schemaLocation from pImodel.Data //See example here: https://msdn.microsoft.com/de-de/library/t9e807fx(v=vs.110).aspx string HRefPattern = "href\\s*=\\s*(?:[\"'](?<1>[^\"']*)[\"']|(?<1>\\S+))"; try { hrefs = Regex.Match(model.Data, HRefPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled, TimeSpan.FromSeconds(1)); while (hrefs.Success) { href_compare.Add(hrefs.Groups[1].ToString()); hrefs = hrefs.NextMatch(); } } catch (RegexMatchTimeoutException) { break; } } Assert.AreEqual(testDoc.SchemaLocation, string.Empty); CollectionAssert.AllItemsAreUnique(href_compare); }