2
using System.Collections.Generic;
7
namespace TexDotNet.Tests
9
using TokenStream = IEnumerable<TexToken>;
11
public class TestExamplesReader : IDisposable
13
private StreamReader streamReader;
15
private bool disposed = false;
17
public TestExamplesReader(string path)
18
: this(new FileStream(path, FileMode.Open, FileAccess.Read))
22
public TestExamplesReader(Stream stream)
24
this.BaseStream = stream;
25
this.streamReader = new StreamReader(this.BaseStream);
30
GC.SuppressFinalize(true);
34
public Stream BaseStream
45
protected void Dispose(bool disposing)
51
this.streamReader.Dispose();
52
this.BaseStream.Dispose();
59
public IEnumerable<TestExample> ReadAllExamples()
62
while ((curItem = ReadExample()) != null)
66
public TestExample ReadExample()
68
var text = streamReader.ReadLine();
72
var expectedTokenString = streamReader.ReadLine();
73
var expectedTokens = expectedTokenString.Split(' ').Select(tokenString =>
75
return TexToken.FromSymbol(TexSymbolKind.Unknown, -1, null);
78
streamReader.ReadLine();
80
return new TestExample(text, expectedTokens);