public void Slice_WithSelectedSection_SelectedSectionMoves(string commandText, int toRemove, int caretPosition, int expectedSelectedSection) { CoreParser parser = new CoreParser(); ICoreParseResult parseResult = parser.Parse(commandText, caretPosition); ICoreParseResult result = parseResult.Slice(toRemove); Assert.Equal(expectedSelectedSection, result.SelectedSection); }
public void Slice_WithVariousSliceLengths_CorrectCommandTextOutput(string commandText, int toRemove, string expectedCommandText) { CoreParser parser = new CoreParser(); ICoreParseResult parseResult = parser.Parse(commandText, commandText.Length); ICoreParseResult result = parseResult.Slice(toRemove); Assert.Equal(expectedCommandText, result.CommandText); }
public void Slice_WithCaretInSlicedRegion_CaretIsZero() { CoreParser parser = new CoreParser(); string commandText = "set header content-type application/json"; ICoreParseResult parseResult = parser.Parse(commandText, 5); ICoreParseResult result = parseResult.Slice(2); Assert.Equal(0, result.CaretPositionWithinCommandText); }
public void Slice_WithZero_ReturnsThis() { CoreParser parser = new CoreParser(); string commandText = "set header content-type application/json"; ICoreParseResult parseResult = parser.Parse(commandText, commandText.Length); ICoreParseResult result = parseResult.Slice(0); Assert.Same(parseResult, result); }
public void Slice_WithTooMany_ReturnsDefaultResult() { CoreParser parser = new CoreParser(); string commandText = "set header content-type application/json"; ICoreParseResult parseResult = parser.Parse(commandText, commandText.Length); ICoreParseResult result = parseResult.Slice(100); Assert.Equal(0, result.CaretPositionWithinCommandText); Assert.Equal(0, result.CaretPositionWithinSelectedSection); Assert.Equal(string.Empty, result.CommandText); Assert.Single(result.Sections); Assert.Contains(string.Empty, result.Sections); Assert.Equal(0, result.SelectedSection); Assert.Single(result.SectionStartLookup); Assert.Equal(0, result.SectionStartLookup.Single().Key); Assert.Equal(0, result.SectionStartLookup.Single().Value); }