public void TextViewCreated(IWpfTextView textView) { if (textView?.Caret == null) { return; } _repository.LoadXml(textView.TextSnapshot.GetText(), _activeDocument.AbsolutePath); textView.Closed += ResetXml; textView.Caret.PositionChanged += StoreCurrentNode; textView.Caret.PositionChanged += _statusbar.SetText; }
public void ResetXmlOnLoad() { // Arrange var repository = new XmlRepository(); repository.LoadXml("<this-is-xml />", null); // Act repository.LoadXml("This is not XML.", null); // Assert Assert.That(repository.GetRootElement(), Is.Null); }
public void TriesToIgnoreDtdProcessingAsAFallback() { // Arrange var xml = "<?xml version='1.0'?><!DOCTYPE datasets SYSTEM 'http://127.0.0.1/this-DTD-does-not-exist.dtd'><root />"; var repository = new XmlRepository(); // Act repository.LoadXml(xml, "http://127.0.0.1"); // Assert Assert.That(repository.GetRootElement(), Is.Not.Null); }
public void HandlesValidDtdUriReferencesGracefully() { // Arrange var xml = XHTML; var repository = new XmlRepository(); var stopwatch = new Stopwatch(); // Act stopwatch.Start(); repository.LoadXml(xml, null); stopwatch.Stop(); // Assert Assert.That(repository.GetRootElement(), Is.Not.Null); Assert.That(stopwatch.Elapsed, Is.LessThan(TimeSpan.FromSeconds(2))); }
public void HandlesAbsoluteDtdReferencesGracefully() { // Arrange var xmlFilePath = Path.GetTempFileName(); File.WriteAllText(xmlFilePath, XML); var dtdFilePath = Path.GetTempFileName(); File.WriteAllText(dtdFilePath, DTD); var xml = File.ReadAllText(xmlFilePath).Replace(DtdFilePlaceholder, dtdFilePath); var repository = new XmlRepository(); // Act repository.LoadXml(xml, null); // Assert Assert.That(repository.GetRootElement(), Is.Not.Null); }
public void ResetXmlOnLoad() { // Arrange var repository = new XmlRepository(); repository.LoadXml("<this-is-xml />"); // Act repository.LoadXml("This is not XML."); // Assert Assert.That(repository.GetRootElement(), Is.Null); }