Files
inkblot/InkBlot.Tests/ContentTextTest.cs

38 lines
1.3 KiB
C#

using InkBlot.ParseHierarchy;
using Shouldly;
namespace InkBlot.Tests;
public class ContentTextTest
{
[Theory]
[InlineData("Hello!", "Hello!", 0)]
[InlineData("Hel-lo!", "Hel-lo!", 0)]
[InlineData("Hel\\lo!", "Hello!", 0)]
[InlineData("Hel<lo!", "Hel<lo!", 0)]
// TODO: check error situations better when diverts (->), threads (<-) and tags (#) are supported
// [InlineData("Hel->lo!", "", 1)]
// [InlineData("Hel<-lo!", "", 1)]
[InlineData("Hel#lo!", "", 1)]
public void TestBaseContentSuccess(string inkInput, string result, int numErrors)
{
// parse the story
var fileReader = new InMemoryFileReader([
("main.ink", inkInput)
]);
using var loggerFactory = Helpers.GetLoggerFactory();
var (story, diagnosticsEnumerable) = InkBlotParser.Parse(fileReader, loggerFactory, "main.ink");
var diagnostics = diagnosticsEnumerable.ToArray();
// check the diagnostic counts match
if (numErrors == 0)
diagnostics.ShouldBe([]);
else
diagnostics.Count().ShouldBe(numErrors);
// check the contents match (only if there was no diagnostic)
if (numErrors != 0) return;
var contents = story.StoryNodes.ToArray();
contents.ShouldBe([new Content(result)]);
}
}