29 lines
810 B
C#
29 lines
810 B
C#
|
|
using System.Data.Common;
|
|||
|
|
|
|||
|
|
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);
|
|||
|
|
}
|
|||
|
|
}
|