pq connection string parsing from other project
This commit is contained in:
parent
9a5feb9d54
commit
d803cd8003
10 changed files with 529 additions and 0 deletions
|
|
@ -0,0 +1,85 @@
|
|||
using pgLabII.PgUtils.ConnectionStrings;
|
||||
|
||||
namespace pgLabII.PgUtils.Tests.ConnectionStrings;
|
||||
|
||||
public class PqConnectionStringTokenizerTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("abc", "abc")]
|
||||
[InlineData("abc=", "abc")]
|
||||
[InlineData(" abc =", "abc")]
|
||||
public void GetKeyword_Success(string input, string expected)
|
||||
{
|
||||
PqConnectionStringTokenizer subject = new(input);
|
||||
|
||||
Assert.Equal(expected, subject.GetKeyword());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("=")]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
public void GetKeyword_Throws(string input)
|
||||
{
|
||||
PqConnectionStringTokenizer subject = new(input);
|
||||
Assert.Throws<PqConnectionStringParserException>(() => subject.GetKeyword());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("", true)]
|
||||
[InlineData(" ", true)]
|
||||
[InlineData(" \t", true)]
|
||||
[InlineData("d", false)]
|
||||
[InlineData("=", false)]
|
||||
[InlineData(".", false)]
|
||||
public void Eof(string input, bool expected)
|
||||
{
|
||||
PqConnectionStringTokenizer subject = new(input);
|
||||
|
||||
Assert.Equal(expected, subject.Eof);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("=")]
|
||||
[InlineData("=test")]
|
||||
[InlineData(" = ")]
|
||||
public void ConsumeEquals_Success(string input)
|
||||
{
|
||||
PqConnectionStringTokenizer subject = new(input);
|
||||
subject.ConsumeEquals();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData("t")]
|
||||
[InlineData(" test")]
|
||||
[InlineData(" ")]
|
||||
public void ConsumeEquals_Throws(string input)
|
||||
{
|
||||
PqConnectionStringTokenizer subject = new(input);
|
||||
Assert.Throws<PqConnectionStringParserException>(() => subject.ConsumeEquals());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("foo", "foo")]
|
||||
[InlineData("foo ", "foo")]
|
||||
[InlineData("foo=", "foo=")]
|
||||
[InlineData("1.2.3.4", "1.2.3.4")]
|
||||
[InlineData(@"'foo \'bar' ", "foo 'bar")]
|
||||
public void GetValue_Success(string input, string expected)
|
||||
{
|
||||
PqConnectionStringTokenizer subject = new(input);
|
||||
Assert.Equal(expected, subject.GetValue());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
[InlineData("'d")]
|
||||
[InlineData(@"'\d'")]
|
||||
public void GetValue_Throws(string input)
|
||||
{
|
||||
PqConnectionStringTokenizer subject = new(input);
|
||||
Assert.Throws<PqConnectionStringParserException>(() => subject.GetValue());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue