Improve NpgsqlCodec whitespace and quotation rules
This commit is contained in:
parent
18e737e865
commit
4c7a6c2666
2 changed files with 44 additions and 21 deletions
|
|
@ -46,7 +46,7 @@ public class NpgsqlCodecTests
|
|||
{
|
||||
Hosts = new [] { new HostEndpoint{ Host = "db.example.com", Port = 5432 } },
|
||||
Database = "prod db",
|
||||
Username = "bob",
|
||||
Username = "bob ",
|
||||
Password = "p;ss\"word",
|
||||
SslMode = SslMode.VerifyFull,
|
||||
ApplicationName = "cli app",
|
||||
|
|
@ -58,11 +58,12 @@ public class NpgsqlCodecTests
|
|||
var s = res.Value;
|
||||
Assert.Contains("Host=db.example.com", s);
|
||||
Assert.Contains("Port=5432", s);
|
||||
Assert.Contains("Database=\"prod db\"", s);
|
||||
Assert.Contains("Username=bob", s);
|
||||
Assert.Contains("Password=\"p;ss\"\"word\"", s);
|
||||
Assert.Contains("Database=prod db", s);
|
||||
Assert.Contains("Username='bob '", s);
|
||||
// Contains double-quote, no single-quote -> prefer single-quoted per DbConnectionStringBuilder-like behavior
|
||||
Assert.Contains("Password='p;ss" + '"' + "word'", s);
|
||||
Assert.Contains("SSL Mode=VerifyFull", s);
|
||||
Assert.Contains("Application Name=\"cli app\"", s);
|
||||
Assert.Contains("Application Name=cli app", s);
|
||||
Assert.Contains("Timeout=9", s);
|
||||
Assert.Contains("Search Path=public", s);
|
||||
}
|
||||
|
|
@ -77,11 +78,12 @@ public class NpgsqlCodecTests
|
|||
var formatted = codec.TryFormat(parsed.Value);
|
||||
Assert.True(formatted.IsSuccess);
|
||||
var s = formatted.Value;
|
||||
Assert.Contains("Host=\"my host\"", s);
|
||||
Assert.Contains("Host=my host", s);
|
||||
Assert.Contains("Database=postgres", s);
|
||||
Assert.Contains("Username=me", s);
|
||||
Assert.Contains("Password=\"with;quote\"\"\"", s);
|
||||
Assert.Contains("Application Name=\"my app\"", s);
|
||||
// Contains double-quote, no single-quote -> prefer single-quoted per DbConnectionStringBuilder-like behavior; parsed value contains one double-quote
|
||||
Assert.Contains("Password='with;quote" + '"' + "'", s);
|
||||
Assert.Contains("Application Name=my app", s);
|
||||
Assert.Contains("SSL Mode=Prefer", s);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue