public void AttributeIsFound(string xml, int linePosition, string expectedAttributeName) { // Arrange var repository = new XmlRepository(); var rootElement = XElement.Parse(xml, LoadOptions.SetLineInfo); const int lineNumber = 1; // Act var attribute = repository.GetAttribute(rootElement, lineNumber, linePosition); var attributeName = attribute == null ? string.Empty : attribute.Name.ToString(); // Assert Assert.That(attributeName, Is.EqualTo(expectedAttributeName)); }
private void StoreCurrentNode(string xml, int lineNumber, int linePosition) { try { _repository.LoadXml(xml, _activeDocument.AbsolutePath); var rootElement = _repository.GetRootElement(); var selectedElement = _repository.GetElement(rootElement, lineNumber, linePosition); var selectedAttribute = _repository.GetAttribute(selectedElement, lineNumber, linePosition); _repository.SetSelected((XObject)selectedAttribute ?? selectedElement); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } }
public void MultiLineElementAttributeIsFound(int lineNumber, int linePosition, string expectedAttributeName) { // Arrange var xml = @"<configuration xmlns:patch=""http://www.sitecore.net/xmlconfig/""> <sitecore> <sites> <site name=""website""> <patch:attribute name=""rootPath"">/sitecore/content/Original</patch:attribute> </site> <site name=""OtherWebsite"" patch:after=""site[@name='website']"" virtualFolder=""/"" physicalFolder=""/"" rootPath=""/sitecore/content/OtherWebsite"" startItem=""/Home"" database=""web"" domain=""extranet"" allowDebug=""true"" cacheHtml=""true"" htmlCacheSize=""10MB"" enablePreview=""true"" enableWebEdit=""true"" enableDebugger=""true"" disableClientData=""false""/> </sites> </sitecore> </configuration>"; var rootElement = XElement.Parse(xml, LoadOptions.SetLineInfo); var siteElement = rootElement.DescendantsAndSelf("site").LastOrDefault(); var repository = new XmlRepository(); // Act var attribute = repository.GetAttribute(siteElement, lineNumber, linePosition); var attributeName = attribute == null ? string.Empty : attribute.Name.ToString(); // Assert Assert.That(attributeName, Is.EqualTo(expectedAttributeName)); }