Change NpgsqlCodec to rely on the DbConnectionStringBuilder class for basic parsing and formatting.
This commit is contained in:
parent
4c7a6c2666
commit
d78de23ebc
2 changed files with 47 additions and 139 deletions
|
|
@ -0,0 +1,29 @@
|
|||
using System.Data.Common;
|
||||
using Npgsql;
|
||||
|
||||
namespace pgLabII.PgUtils.Tests.ConnectionStrings;
|
||||
|
||||
public class DbConnectionStringBuilderTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("abc", "abc")]
|
||||
[InlineData(" abc ", "abc")]
|
||||
[InlineData("\"abc \"", "abc ")]
|
||||
public void TestDecode(string input, string expected)
|
||||
{
|
||||
DbConnectionStringBuilder sb = new() { ConnectionString = $"key={input}" };
|
||||
string result = (string)sb["key"];
|
||||
Assert.Equal(expected, result);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("abc", "key=abc")]
|
||||
[InlineData("abc ", "key=\"abc \"")]
|
||||
[InlineData("a\"c", "key='a\"c'")]
|
||||
public void TestEncode(string input, string expected)
|
||||
{
|
||||
DbConnectionStringBuilder sb = new();
|
||||
sb["key"] = input;
|
||||
Assert.Equal(expected, sb.ConnectionString);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue