public async Task WhenInputIsPlainText_ThenReadReturnsSingleToken() { var input = new string[] { "sample" }; var reader = new AnsiTokenReader(new EnumerationReader <string>(input)); var result = await reader.ReadAsync(CancellationToken.None); Assert.AreEqual(1, result.Count()); Assert.AreEqual(AnsiTextToken.TokenType.Text, result.First().Type); Assert.AreEqual("sample", result.First().Value); Assert.IsNull(await reader.ReadAsync(CancellationToken.None)); }
public async Task WhePassedAllAnsiSequences_ThenAllSequencesAreDetected() { var input = new string[] { string.Join("", AnsiSequences) }; var reader = new AnsiTokenReader(new EnumerationReader <string>(input)); var result = await reader.ReadAsync(CancellationToken.None); Assert.AreEqual(AnsiSequences.Length, result.Count()); Assert.IsTrue(result.All(t => t.Type == AnsiTextToken.TokenType.Command)); CollectionAssert.AreEqual( AnsiSequences, result.Select(t => "\u001B" + t.Value)); }
public async Task WhenCsiSequenceSplitOverTwoReadsAtEnd_ThenSecondReadReturnsCommand() { var input = new string[] { AnsiTokenReader.Escape.ToString(), "[2J" }; var reader = new AnsiTokenReader(new EnumerationReader <string>(input)); var result = await reader.ReadAsync(CancellationToken.None); Assert.AreEqual(0, result.Count()); result = await reader.ReadAsync(CancellationToken.None); Assert.AreEqual(1, result.Count()); Assert.AreEqual(AnsiTextToken.TokenType.Command, result.First().Type); Assert.AreEqual("[2J", result.First().Value); Assert.IsNull(await reader.ReadAsync(CancellationToken.None)); }