DotnetStandardStreams/source/DotnetStandardStreamsTests/ListTextSourceTests.cs

43 lines
875 B
C#

using DotnetStandardStreams;
namespace DotnetStandardStreamsTests;
public class ListTextSourceTests
{
[Fact]
public void ReadsFromList()
{
ITextSource reader = new ListTextSource(["1", "2", "", "3"]);
string s0 = reader.Read();
s0.ShouldNotBeNull();
s0.ShouldBe("1");
reader.Eof().ShouldBe(false);
string s1 = reader.Read();
s1.ShouldNotBeNull();
s1.ShouldBe("2");
reader.Eof().ShouldBe(false);
string s2 = reader.Read();
s2.ShouldNotBeNull();
s2.ShouldBe(string.Empty);
reader.Eof().ShouldBe(false);
string s3 = reader.Read();
s3.ShouldNotBeNull();
s3.ShouldBe("3");
reader.Eof().ShouldBe(false);
string s4 = reader.Read();
s4.ShouldBe("");
reader.Eof().ShouldBe(true);
}
[Fact]
public void ReadsFromEmptyList()
{
ITextSource reader = new ListTextSource([]);
_ = reader.Read();
reader.Eof().ShouldBe(true);
}
}