using pgLabII.PgUtils.ConnectionStrings; namespace pgLabII.PgUtils.Tests.ConnectionStrings; public class PqConnectionStringParserTests { private readonly UnitTestTokenizer tokenizer = new(); private const string kw = "ab"; private const string val = "cd"; public PqConnectionStringParserTests() { tokenizer .AddString(kw) .AddEquals() .AddString(val) .AddEof(); } [Fact] public void Success() { var parser = new PqConnectionStringParser(tokenizer); IDictionary output = parser.Parse(); Assert.Single(output); Assert.True(output.TryGetValue(kw, out string? result)); Assert.Equal(val, result); } [Fact] public void StaticParse() { var output = PqConnectionStringParser.Parse("foo=bar"); Assert.Single(output); Assert.True(output.TryGetValue("foo", out string? result)); Assert.Equal("bar", result); } // There are few tests here as this is a predictive parser and all error handling is done // in the tokenizer }