Complete Json impl for Postgres

This commit is contained in:
2025-04-06 14:10:12 -04:00
parent 5e5dbd3b80
commit 1dcc35d0f0
7 changed files with 2231 additions and 322 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -9,7 +9,7 @@ using static CommonExtensionsAndTypesForNpgsqlFSharp;
using static Runner;
/// <summary>
/// C# tests for the PostgreSQL implementation of <tt>BitBadger.Documents</tt>
/// C# tests for the PostgreSQL implementation of <c>BitBadger.Documents</c>
/// </summary>
public static class PostgresCSharpTests
{
@@ -323,21 +323,21 @@ public static class PostgresCSharpTests
/// <summary>
/// Add the test documents to the database
/// </summary>
internal static async Task LoadDocs()
private static async Task LoadDocs()
{
foreach (var doc in JsonDocument.TestDocuments) await Document.Insert(SqliteDb.TableName, doc);
}
/// <summary>Set up a stream writer for a test</summary>
internal static StreamWriter WriteStream(Stream stream)
private static StreamWriter WriteStream(Stream stream)
{
StreamWriter writer = new(stream);
writer.AutoFlush = true;
return writer;
}
/// Get the text of the given stream
internal static string StreamText(Stream stream)
/// <summary>Get the text of the given stream</summary>
private static string StreamText(Stream stream)
{
stream.Position = 0L;
using StreamReader reader = new(stream);
@@ -1298,20 +1298,20 @@ public static class PostgresCSharpTests
Expect.stringEnds(json, "]", "The array should have ended with `]`");
}
/// Verify the presence of a document by its ID
/// <summary>Verify the presence of a document by its ID</summary>
private static void VerifyDocById(string json, string docId)
{
Expect.stringContains(json, $"{{\"Id\": \"{docId}\",", $"Document `{docId}` not present");
}
/// Verify the presence of a document by its ID
/// <summary>Verify the presence of a document by its ID</summary>
private static void VerifySingleById(string json, string docId)
{
VerifyBeginEnd(json);
Expect.stringContains(json, $"{{\"Id\": \"{docId}\",", $"Document `{docId}` not present");
}
/// Verify the presence of any of the given document IDs in the given JSON
/// <summary>Verify the presence of any of the given document IDs in the given JSON</summary>
private static void VerifyAnyById(string json, IEnumerable<string> docIds)
{
var theIds = docIds.ToList();
@@ -1320,7 +1320,7 @@ public static class PostgresCSharpTests
Expect.isTrue(false, $"Could not find any of IDs {ids} in {json}");
}
/// Verify the JSON for `all` returning data
/// <summary>Verify the JSON for `all` returning data</summary>
private static void VerifyAllData(string json)
{
VerifyBeginEnd(json);
@@ -1328,19 +1328,19 @@ public static class PostgresCSharpTests
foreach (var docId in ids) VerifyDocById(json, docId);
}
/// Verify an empty JSON array
/// <summary>Verify an empty JSON array</summary>
private static void VerifyEmpty(string json)
{
Expect.equal(json, "[]", "There should be no documents returned");
}
/// Verify an empty JSON document
/// <summary>Verify an empty JSON document</summary>
private static void VerifyNoDoc(string json)
{
Expect.equal(json, "{}", "There should be no document returned");
}
/// Verify the JSON for an ordered query
/// <summary>Verify the JSON for an ordered query</summary>
private static void VerifyExpectedOrder(string json, string idFirst, string idSecond, string? idThird = null,
string? idFourth = null, string? idFifth = null)
{