public void MatchLinesMustGetAppropriateValue() { var lines = new List <string>() { "text > text", "> ", ">text", "\t> TEXT" }; var matching = _quoteMarkFeature.MatchLines(lines); Assert.Equal(QuoteMarkMatchingResult.NotEmpty, matching[0]); Assert.Equal(QuoteMarkMatchingResult.VEmpty, matching[1]); Assert.Equal(QuoteMarkMatchingResult.VNotEmpty, matching[2]); Assert.Equal(QuoteMarkMatchingResult.VNotEmpty, matching[3]); }
public Content Parse(IEnumerable <string> lines, bool hasInReplyToEmlHeader = true) { _lines = lines.ToList(); var matchingLines = _quoteMarkFeature.MatchLines(_lines); var headerLinesIndexes = _quoteHeaderLinesParser.Parse(_lines, matchingLines); // This condition means: for EMLs without In-Reply-To header or References header // search for quotation marks(>) only if quoteHeaderLines is null. It works well for // the test data, but it is weird.. because it skips quotation marks most of the time. // // As alternative this condition may be deleted, but it works // worse with some cases... var quoteMarkIndex = (!hasInReplyToEmlHeader && headerLinesIndexes != null) ? null : _quoteMarkParser.Parse(_lines, matchingLines); if (headerLinesIndexes == null && quoteMarkIndex == null) { return(new Content(_lines, null, null)); } if (headerLinesIndexes != null && quoteMarkIndex == null) { return(CreateContent(headerLinesIndexes.Value.Item1, headerLinesIndexes.Value.Item2 + 1, matchingLines)); } if (headerLinesIndexes == null) { return(CreateContent(quoteMarkIndex.Value, quoteMarkIndex.Value, matchingLines)); } int startHeaderLinesIndex = headerLinesIndexes.Value.Item1; int endHeaderLineIndex = headerLinesIndexes.Value.Item2; var relation = GetRelation( startHeaderLinesIndex, endHeaderLineIndex, quoteMarkIndex.Value ); switch (relation) { case Relation.QuoteMarkInHeaderLines: return(CreateContent( startHeaderLinesIndex, endHeaderLineIndex + 1, matchingLines )); case Relation.QuoteMarkFirst: return(GetContentQuoteMarkFirstCase( startHeaderLinesIndex, endHeaderLineIndex, quoteMarkIndex.Value, matchingLines )); case Relation.HeaderLinesFirst: return(GetContentHeaderLinesFirstCase( startHeaderLinesIndex, endHeaderLineIndex, quoteMarkIndex.Value, matchingLines )); default: throw new ArgumentOutOfRangeException(); } }