public void Path_IsChildOf_Relative_Failure(string path, string ancestorPath) { XSPath actual = XSPath.Parse(path); XSPath actualAncestor = XSPath.Parse(ancestorPath); Assert.False(actual.IsChildOf(actualAncestor), "IsChildOf"); }
public void Path_IsChildOf_Absolute_Success(string path, string ancestorPath) { XSPath actual = XSPath.Parse(path); XSPath actualAncestor = XSPath.Parse(ancestorPath); Assert.True(actual.IsChildOf(actualAncestor), "IsChildOf"); }
public void Path_EndsWith_Relative_Success(string path, string ancestorPath) { XSPath actual = XSPath.Parse(path); XSPath actualAncestor = XSPath.Parse(ancestorPath); Assert.True(actual.EndsWith(actualAncestor), "EndsWith"); }
public void Path_StartsWith_Absolute_Success(string path, string basePath) { XSPath actual = XSPath.Parse(path); XSPath actualBase = XSPath.Parse(basePath); Assert.True(actual.StartsWith(actualBase), "StartsWith"); }
public void CanCompleteAttribute(string testFileName, int line, int column, string expectedElementName, PaddingType expectedPadding) { Position testPosition = new Position(line, column); string testXml = LoadTestFile("TestFiles", testFileName + ".xml"); TextPositions positions = new TextPositions(testXml); XmlDocumentSyntax document = Parser.ParseText(testXml); XmlLocator locator = new XmlLocator(document, positions); XmlLocation location = locator.Inspect(testPosition); Assert.NotNull(location); XSPath elementPath = XSPath.Parse(expectedElementName); XSElement element; XSAttribute replaceAttribute; PaddingType needsPadding; Assert.True( location.CanCompleteAttribute(out element, out replaceAttribute, out needsPadding, onElementWithPath: elementPath), "CanCompleteAttribute" ); Assert.NotNull(element); Assert.Null(replaceAttribute); Assert.Equal(expectedPadding, needsPadding); }
public void Can_Append_String_Segment_To_Path_Relative(string path, string segment, string expectedPath) { XSPath actual = XSPath.Parse(path); actual += segment; Assert.Equal(expectedPath, actual.Path); }
public void Can_Parse_Path_Relative(string path, int expectedSegmentCount) { XSPath actual = XSPath.Parse(path); Assert.NotNull(actual); Assert.True(actual.IsRelative, "IsRelative"); Assert.Equal(expectedSegmentCount, actual.Segments.Count); }
public void CanCompleteElementInParentWithRelativePath(string testFileName, int line, int column, string expectedParent) { Position testPosition = new Position(line, column); string testXml = LoadTestFile("TestFiles", testFileName + ".xml"); TextPositions positions = new TextPositions(testXml); XmlDocumentSyntax document = Parser.ParseText(testXml); XmlLocator locator = new XmlLocator(document, positions); XmlLocation location = locator.Inspect(testPosition); Assert.NotNull(location); XSPath expectedParentPath = XSPath.Parse(expectedParent); XSElement replaceElement; Assert.True( location.CanCompleteElement(out replaceElement, parentPath: expectedParentPath), "CanCompleteElement" ); Assert.NotNull(replaceElement); Assert.Equal(expectedParent, replaceElement.ParentElement?.Name); }