diff --git a/src/Sqlite/Library.fs b/src/Sqlite/Library.fs index 1ef745f..25dedcd 100644 --- a/src/Sqlite/Library.fs +++ b/src/Sqlite/Library.fs @@ -60,6 +60,11 @@ module Parameters = let fieldParam (value: obj) = SqliteParameter("@field", value) + /// An empty parameter sequence + [] + let noParams = + Seq.empty + /// Helper functions for handling results [] diff --git a/src/Tests.CSharp/SqliteCSharpTests.cs b/src/Tests.CSharp/SqliteCSharpTests.cs index 7c5d0fc..c0f9873 100644 --- a/src/Tests.CSharp/SqliteCSharpTests.cs +++ b/src/Tests.CSharp/SqliteCSharpTests.cs @@ -1,10 +1,11 @@ -using Microsoft.Data.Sqlite; +using Expecto.CSharp; +using Expecto; +using Microsoft.Data.Sqlite; using Microsoft.FSharp.Core; +using Docs = BitBadger.Documents; namespace BitBadger.Documents.Tests.CSharp; -using Expecto.CSharp; -using Expecto; using static Sqlite; /// @@ -12,7 +13,7 @@ using static Sqlite; /// public static class SqliteCSharpTests { - private static readonly List Documents = new() + private static readonly List TestDocuments = new() { new() { Id = "one", Value = "FIRST!", NumValue = 0 }, new() { Id = "two", Value = "another", NumValue = 10, Sub = new() { Foo = "green", Bar = "blue" } }, @@ -23,7 +24,7 @@ public static class SqliteCSharpTests private static async Task LoadDocs() { - foreach (var doc in Documents) await Insert(SqliteDb.TableName, doc); + foreach (var doc in TestDocuments) await Insert(SqliteDb.TableName, doc); } [Tests] @@ -44,6 +45,87 @@ public static class SqliteCSharpTests Configuration.UseConnectionString("Data Source=:memory:"); } }), + Runner.TestList("Custom", new[] + { + Runner.TestList("Single", new [] + { + Runner.TestCase("succeeds when a row is found", async () => + { + await using var db = await SqliteDb.BuildDb(); + await LoadDocs(); + + var doc = await Custom.Single( + $"SELECT data FROM {SqliteDb.TableName} WHERE data ->> 'Id' = @id", + new[] { Parameters.Id("one") }, Results.FromData); + if (doc is null) Expect.isTrue(false, "There should have been a document returned"); + Expect.equal(doc!.Id, "one", "The incorrect document was returned"); + }), + Runner.TestCase("succeeds when a row is not found", async () => + { + await using var db = await SqliteDb.BuildDb(); + await LoadDocs(); + + var doc = await Custom.Single( + $"SELECT data FROM {SqliteDb.TableName} WHERE data ->> 'Id' = @id", + new[] { Parameters.Id("eighty") }, Results.FromData); + Expect.isNull(doc, "There should not have been a document returned"); + }) + }), + Runner.TestList("List", new[] + { + Runner.TestCase("succeeds when data is found", async () => + { + await using var db = await SqliteDb.BuildDb(); + await LoadDocs(); + + var docs = await Custom.List(Docs.Query.SelectFromTable(SqliteDb.TableName), Parameters.None, + Results.FromData); + Expect.equal(docs.Count, 5, "There should have been 5 documents returned"); + }), + Runner.TestCase("succeeds when data is not found", async () => + { + await using var db = await SqliteDb.BuildDb(); + await LoadDocs(); + + var docs = await Custom.List( + $"SELECT data FROM {SqliteDb.TableName} WHERE data ->> 'NumValue' > @value", + new[] { new SqliteParameter("@value", 100) }, Results.FromData); + Expect.isEmpty(docs, "There should have been no documents returned"); + }) + }), + Runner.TestList("NonQuery", new[] + { + Runner.TestCase("succeeds when operating on data", async () => + { + await using var db = await SqliteDb.BuildDb(); + await LoadDocs(); + + await Custom.NonQuery($"DELETE FROM {SqliteDb.TableName}", Parameters.None); + + var remaining = await Count.All(SqliteDb.TableName); + Expect.equal(remaining, 0L, "There should be no documents remaining in the table"); + }), + Runner.TestCase("succeeds when no data matches where clause", async () => + { + await using var db = await SqliteDb.BuildDb(); + await LoadDocs(); + + await Custom.NonQuery( + $"DELETE FROM {SqliteDb.TableName} WHERE data ->> 'NumValue' > @value", + new[] { new SqliteParameter("@value", 100) }); + + var remaining = await Count.All(SqliteDb.TableName); + Expect.equal(remaining, 5L, "There should be 5 documents remaining in the table"); + }) + }), + Runner.TestCase("Scalar succeeds", async () => + { + await using var db = await SqliteDb.BuildDb(); + + var nbr = await Custom.Scalar("SELECT 5 AS test_value", Parameters.None, rdr => rdr.GetInt32(0)); + Expect.equal(nbr, 5, "The query should have returned the number 5"); + }) + }), Runner.TestList("Definition", new[] { Runner.TestCase("EnsureTable succeeds", async () => @@ -193,299 +275,254 @@ public static class SqliteCSharpTests }) }) }), - // testList "Find" [ - // testList "All" [ - // testTask "succeeds when there is data" { - // use! db = Db.buildDb () - // - // do! Insert(Db.tableName, JsonDocument(Id = "one", Value = "two")) - // do! Insert(Db.tableName, JsonDocument(Id = "three", Value = "four")) - // do! Insert(Db.tableName, JsonDocument(Id = "five", Value = "six")) - // - // let! results = Find.All Db.tableName - // Expect.hasCountOf results 3u isTrue "There should have been 3 documents returned" - // } - // testTask "succeeds when there is no data" { - // use! db = Db.buildDb () - // let! results = Find.All Db.tableName - // Expect.hasCountOf results 0u isTrue "There should have been no documents returned" - // } - // ] - // testList "ById" [ - // testTask "succeeds when a document is found" { - // use! db = Db.buildDb () - // do! loadDocs () - // - // let! doc = Find.ById(Db.tableName, "two") - // if isNull doc then Expect.isTrue false "There should have been a document returned" - // Expect.equal (doc :> JsonDocument).Id "two" "The incorrect document was returned" - // } - // testTask "succeeds when a document is not found" { - // use! db = Db.buildDb () - // do! loadDocs () - // - // let! doc = Find.ById(Db.tableName, "three hundred eighty-seven") - // Expect.isNull doc "There should not have been a document returned" - // } - // ] - // testList "ByField" [ - // testTask "succeeds when documents are found" { - // use! db = Db.buildDb () - // do! loadDocs () - // - // let! docs = Find.ByField(Db.tableName, "NumValue", Op.GT, 15) - // Expect.hasCountOf docs 2u isTrue "There should have been two documents returned" - // } - // testTask "succeeds when documents are not found" { - // use! db = Db.buildDb () - // do! loadDocs () - // - // let! docs = Find.ByField(Db.tableName, "Value", Op.EQ, "mauve") - // Expect.hasCountOf docs 0u isTrue "There should have been no documents returned" - // } - // ] - // testList "FirstByField" [ - // testTask "succeeds when a document is found" { - // use! db = Db.buildDb () - // do! loadDocs () - // - // let! doc = Find.FirstByField(Db.tableName, "Value", Op.EQ, "another") - // if isNull doc then Expect.isTrue false "There should have been a document returned" - // Expect.equal (doc :> JsonDocument).Id "two" "The incorrect document was returned" - // } - // testTask "succeeds when multiple documents are found" { - // use! db = Db.buildDb () - // do! loadDocs () - // - // let! doc = Find.FirstByField(Db.tableName, "Sub.Foo", Op.EQ, "green") - // if isNull doc then Expect.isTrue false "There should have been a document returned" - // Expect.contains [ "two"; "four" ] (doc :> JsonDocument).Id "An incorrect document was returned" - // } - // testTask "succeeds when a document is not found" { - // use! db = Db.buildDb () - // do! loadDocs () - // - // let! doc = Find.FirstByField(Db.tableName, "Value", Op.EQ, "absent") - // Expect.isNull doc "There should not have been a document returned" - // } - // ] - // ] - // testList "Update" [ - // testList "Full" [ - // testTask "succeeds when a document is updated" { - // use! db = Db.buildDb () - // do! loadDocs () - // - // let testDoc = JsonDocument(Id = "one", Sub = Some (SubDocument(Foo = "blue", Bar = "red"))) - // do! Update.Full(Db.tableName, "one", testDoc) - // let! after = Find.ById(Db.tableName, "one") - // if isNull after then Expect.isTrue false "There should have been a document returned post-update" - // let after = after :> JsonDocument - // Expect.equal after.Id "one" "The updated document is not correct" - // Expect.isSome after.Sub "The updated document should have had a sub-document" - // Expect.equal after.Sub.Value.Foo "blue" "The updated sub-document is not correct" - // Expect.equal after.Sub.Value.Bar "red" "The updated sub-document is not correct" - // } - // testTask "succeeds when no document is updated" { - // use! db = Db.buildDb () - // - // let! before = Find.All Db.tableName - // Expect.hasCountOf before 0u isTrue "There should have been no documents returned" - // - // // This not raising an exception is the test - // do! Update.Full( - // Db.tableName, - // "test", - // JsonDocument(Id = "x", Sub = Some (SubDocument(Foo = "blue", Bar = "red")))) - // } - // ] - // testList "FullFunc" [ - // testTask "succeeds when a document is updated" { - // use! db = Db.buildDb () - // do! loadDocs () - // - // do! Update.FullFunc( - // Db.tableName, - // System.Func _.Id, - // JsonDocument(Id = "one", Value = "le un", NumValue = 1, Sub = None)) - // let! after = Find.ById(Db.tableName, "one") - // if isNull after then Expect.isTrue false "There should have been a document returned post-update" - // let after = after :> JsonDocument - // Expect.equal after.Id "one" "The updated document is incorrect" - // Expect.equal after.Value "le un" "The updated document is incorrect" - // Expect.equal after.NumValue 1 "The updated document is incorrect" - // Expect.isNone after.Sub "The updated document should not have a sub-document" - // } - // testTask "succeeds when no document is updated" { - // use! db = Db.buildDb () - // - // let! before = Find.All Db.tableName - // Expect.hasCountOf before 0u isTrue "There should have been no documents returned" - // - // // This not raising an exception is the test - // do! Update.FullFunc( - // Db.tableName, - // System.Func _.Id, - // JsonDocument(Id = "one", Value = "le un", NumValue = 1, Sub = None)) - // } - // ] - // testList "PartialById" [ - // testTask "succeeds when a document is updated" { - // use! db = Db.buildDb () - // do! loadDocs () - // - // do! Update.PartialById(Db.tableName, "one", {| NumValue = 44 |}) - // let! after = Find.ById(Db.tableName, "one") - // if isNull after then Expect.isTrue false "There should have been a document returned post-update" - // let after = after :> JsonDocument - // Expect.equal after.Id "one" "The updated document is not correct" - // Expect.equal after.NumValue 44 "The updated document is not correct" - // } - // testTask "succeeds when no document is updated" { - // use! db = Db.buildDb () - // - // let! before = Find.All Db.tableName - // Expect.hasCountOf before 0u isTrue "There should have been no documents returned" - // - // // This not raising an exception is the test - // do! Update.PartialById(Db.tableName, "test", {| Foo = "green" |}) - // } - // ] - // testList "PartialByField" [ - // testTask "succeeds when a document is updated" { - // use! db = Db.buildDb () - // do! loadDocs () - // - // do! Update.PartialByField(Db.tableName, "Value", Op.EQ, "purple", {| NumValue = 77 |}) - // let! after = Count.ByField(Db.tableName, "NumValue", Op.EQ, 77) - // Expect.equal after 2L "There should have been 2 documents returned" - // } - // testTask "succeeds when no document is updated" { - // use! db = Db.buildDb () - // - // let! before = Find.All Db.tableName - // Expect.hasCountOf before 0u isTrue "There should have been no documents returned" - // - // // This not raising an exception is the test - // do! Update.PartialByField(Db.tableName, "Value", Op.EQ, "burgundy", {| Foo = "green" |}) - // } - // ] - // ] - // testList "Delete" [ - // testList "ById" [ - // testTask "succeeds when a document is deleted" { - // use! db = Db.buildDb () - // do! loadDocs () - // - // do! Delete.ById(Db.tableName, "four") - // let! remaining = Count.All Db.tableName - // Expect.equal remaining 4L "There should have been 4 documents remaining" - // } - // testTask "succeeds when a document is not deleted" { - // use! db = Db.buildDb () - // do! loadDocs () - // - // do! Delete.ById(Db.tableName, "thirty") - // let! remaining = Count.All Db.tableName - // Expect.equal remaining 5L "There should have been 5 documents remaining" - // } - // ] - // testList "ByField" [ - // testTask "succeeds when documents are deleted" { - // use! db = Db.buildDb () - // do! loadDocs () - // - // do! Delete.ByField(Db.tableName, "Value", Op.NE, "purple") - // let! remaining = Count.All Db.tableName - // Expect.equal remaining 2L "There should have been 2 documents remaining" - // } - // testTask "succeeds when documents are not deleted" { - // use! db = Db.buildDb () - // do! loadDocs () - // - // do! Delete.ByField(Db.tableName, "Value", Op.EQ, "crimson") - // let! remaining = Count.All Db.tableName - // Expect.equal remaining 5L "There should have been 5 documents remaining" - // } - // ] - // ] - // testList "Custom" [ - // testList "Single" [ - // testTask "succeeds when a row is found" { - // use! db = Db.buildDb () - // do! loadDocs () - // - // let! doc = - // Custom.Single( - // $"SELECT data FROM {Db.tableName} WHERE data ->> 'Id' = @id", - // [ SqliteParameter("@id", "one") ], - // FromData) - // if isNull doc then Expect.isTrue false "There should have been a document returned" - // Expect.equal (doc :> JsonDocument).Id "one" "The incorrect document was returned" - // } - // testTask "succeeds when a row is not found" { - // use! db = Db.buildDb () - // do! loadDocs () - // - // let! doc = - // Custom.Single( - // $"SELECT data FROM {Db.tableName} WHERE data ->> 'Id' = @id", - // [ SqliteParameter("@id", "eighty") ], - // FromData) - // Expect.isNull doc "There should not have been a document returned" - // } - // ] - // testList "List" [ - // testTask "succeeds when data is found" { - // use! db = Db.buildDb () - // do! loadDocs () - // - // let! docs = Custom.List(Query.SelectFromTable Db.tableName, [], FromData) - // Expect.hasCountOf docs 5u isTrue "There should have been 5 documents returned" - // } - // testTask "succeeds when data is not found" { - // use! db = Db.buildDb () - // do! loadDocs () - // - // let! docs = - // Custom.List( - // $"SELECT data FROM {Db.tableName} WHERE data ->> 'NumValue' > @value", - // [ SqliteParameter("@value", 100) ], - // FromData) - // Expect.isEmpty docs "There should have been no documents returned" - // } - // ] - // testList "NonQuery" [ - // testTask "succeeds when operating on data" { - // use! db = Db.buildDb () - // do! loadDocs () - // - // do! Custom.NonQuery($"DELETE FROM {Db.tableName}", []) - // - // let! remaining = Count.All Db.tableName - // Expect.equal remaining 0L "There should be no documents remaining in the table" - // } - // testTask "succeeds when no data matches where clause" { - // use! db = Db.buildDb () - // do! loadDocs () - // - // do! Custom.NonQuery( - // $"DELETE FROM {Db.tableName} WHERE data ->> 'NumValue' > @value", - // [ SqliteParameter("@value", 100) ]) - // - // let! remaining = Count.All Db.tableName - // Expect.equal remaining 5L "There should be 5 documents remaining in the table" - // } - // ] - // testTask "Scalar succeeds" { - // use! db = Db.buildDb () - // - // let! nbr = Custom.Scalar("SELECT 5 AS test_value", [], System.Func _.GetInt32(0)) - // Expect.equal nbr 5 "The query should have returned the number 5" - // } - // ] - // testList "Extensions" [ - // testTask "EnsureTable succeeds" { + Runner.TestList("Find", new[] + { + Runner.TestList("All", new[] + { + Runner.TestCase("succeeds when there is data", async () => + { + await using var db = await SqliteDb.BuildDb(); + + await Insert(SqliteDb.TableName, new JsonDocument { Id = "one", Value = "two" }); + await Insert(SqliteDb.TableName, new JsonDocument { Id = "three", Value = "four" }); + await Insert(SqliteDb.TableName, new JsonDocument { Id = "five", Value = "six" }); + + var results = await Find.All(SqliteDb.TableName); + Expect.equal(results.Count, 3, "There should have been 3 documents returned"); + }), + Runner.TestCase("succeeds when there is no data", async () => + { + await using var db = await SqliteDb.BuildDb(); + var results = await Find.All(SqliteDb.TableName); + Expect.equal(results.Count, 0, "There should have been no documents returned"); + }) + }), + Runner.TestList("ById", new[] + { + Runner.TestCase("succeeds when a document is found", async () => + { + await using var db = await SqliteDb.BuildDb(); + await LoadDocs(); + + var doc = await Find.ById(SqliteDb.TableName, "two"); + if (doc is null) Expect.isTrue(false, "There should have been a document returned"); + Expect.equal(doc!.Id, "two", "The incorrect document was returned"); + }), + Runner.TestCase("succeeds when a document is not found", async () => + { + await using var db = await SqliteDb.BuildDb(); + await LoadDocs(); + + var doc = await Find.ById(SqliteDb.TableName, "twenty two"); + Expect.isNull(doc, "There should not have been a document returned"); + }) + }), + Runner.TestList("ByField", new[] + { + Runner.TestCase("succeeds when documents are found", async () => + { + await using var db = await SqliteDb.BuildDb(); + await LoadDocs(); + + var docs = await Find.ByField(SqliteDb.TableName, "NumValue", Op.GT, 15); + Expect.equal(docs.Count, 2, "There should have been two documents returned"); + }), + Runner.TestCase("succeeds when documents are not found", async () => + { + await using var db = await SqliteDb.BuildDb(); + await LoadDocs(); + + var docs = await Find.ByField(SqliteDb.TableName, "Value", Op.EQ, "mauve"); + Expect.equal(docs.Count, 0, "There should have been no documents returned"); + }) + }), + Runner.TestList("FirstByField", new[] + { + Runner.TestCase("succeeds when a document is found", async () => + { + await using var db = await SqliteDb.BuildDb(); + await LoadDocs(); + + var doc = await Find.FirstByField(SqliteDb.TableName, "Value", Op.EQ, "another"); + if (doc is null) Expect.isTrue(false, "There should have been a document returned"); + Expect.equal(doc!.Id, "two", "The incorrect document was returned"); + }), + Runner.TestCase("succeeds when multiple documents are found", async () => + { + await using var db = await SqliteDb.BuildDb(); + await LoadDocs(); + + var doc = await Find.FirstByField(SqliteDb.TableName, "Sub.Foo", Op.EQ, "green"); + if (doc is null) Expect.isTrue(false, "There should have been a document returned"); + Expect.contains(new[] { "two", "four" }, doc!.Id, "An incorrect document was returned"); + }), + Runner.TestCase("succeeds when a document is not found", async () => + { + await using var db = await SqliteDb.BuildDb(); + await LoadDocs(); + + var doc = await Find.FirstByField(SqliteDb.TableName, "Value", Op.EQ, "absent"); + Expect.isNull(doc, "There should not have been a document returned"); + }) + }) + }), + Runner.TestList("Update", new[] + { + Runner.TestList("Full", new[] + { + Runner.TestCase("succeeds when a document is updated", async () => + { + await using var db = await SqliteDb.BuildDb(); + await LoadDocs(); + + var testDoc = new JsonDocument { Id = "one", Sub = new() { Foo = "blue", Bar = "red" } }; + await Update.Full(SqliteDb.TableName, "one", testDoc); + var after = await Find.ById(SqliteDb.TableName, "one"); + if (after is null) + Expect.isTrue(false, "There should have been a document returned post-update"); + Expect.equal(after!.Id, "one", "The updated document is not correct"); + Expect.isNotNull(after.Sub, "The updated document should have had a sub-document"); + Expect.equal(after.Sub!.Foo, "blue", "The updated sub-document is not correct"); + Expect.equal(after.Sub.Bar, "red", "The updated sub-document is not correct"); + }), + Runner.TestCase("succeeds when no document is updated", async () => + { + await using var db = await SqliteDb.BuildDb(); + + var before = await Find.All(SqliteDb.TableName); + Expect.equal(before.Count, 0, "There should have been no documents returned"); + + // This not raising an exception is the test + await Update.Full(SqliteDb.TableName, "test", + new JsonDocument { Id = "x", Sub = new() { Foo = "blue", Bar = "red" } }); + }) + }), + Runner.TestList("FullFunc", new[] + { + Runner.TestCase("succeeds when a document is updated", async () => + { + await using var db = await SqliteDb.BuildDb(); + await LoadDocs(); + + await Update.FullFunc(SqliteDb.TableName, doc => doc.Id, + new JsonDocument { Id = "one", Value = "le un", NumValue = 1 }); + var after = await Find.ById(SqliteDb.TableName, "one"); + if (after is null) + Expect.isTrue(false, "There should have been a document returned post-update"); + Expect.equal(after!.Id, "one", "The updated document is incorrect"); + Expect.equal(after.Value, "le un", "The updated document is incorrect"); + Expect.equal(after.NumValue, 1, "The updated document is incorrect"); + Expect.isNull(after.Sub, "The updated document should not have a sub-document"); + }), + Runner.TestCase("succeeds when no document is updated", async () => + { + await using var db = await SqliteDb.BuildDb(); + + var before = await Find.All(SqliteDb.TableName); + Expect.equal(before.Count, 0, "There should have been no documents returned"); + + // This not raising an exception is the test + await Update.FullFunc(SqliteDb.TableName, doc => doc.Id, + new JsonDocument { Id = "one", Value = "le un", NumValue = 1 }); + }) + }), + Runner.TestList("PartialById", new[] + { + Runner.TestCase("succeeds when a document is updated", async () => + { + await using var db = await SqliteDb.BuildDb(); + await LoadDocs(); + + await Update.PartialById(SqliteDb.TableName, "one", new { NumValue = 44 }); + var after = await Find.ById(SqliteDb.TableName, "one"); + if (after is null) + Expect.isTrue(false, "There should have been a document returned post-update"); + Expect.equal(after!.Id, "one", "The updated document is not correct"); + Expect.equal(after.NumValue, 44, "The updated document is not correct"); + }), + Runner.TestCase("succeeds when no document is updated", async () => + { + await using var db = await SqliteDb.BuildDb(); + + var before = await Find.All(SqliteDb.TableName); + Expect.equal(before.Count, 0, "There should have been no documents returned"); + + // This not raising an exception is the test + await Update.PartialById(SqliteDb.TableName, "test", new { Foo = "green" }); + }) + }), + Runner.TestList("PartialByField", new[] + { + Runner.TestCase("succeeds when a document is updated", async () => + { + await using var db = await SqliteDb.BuildDb(); + await LoadDocs(); + + await Update.PartialByField(SqliteDb.TableName, "Value", Op.EQ, "purple", + new { NumValue = 77 }); + var after = await Count.ByField(SqliteDb.TableName, "NumValue", Op.EQ, 77); + Expect.equal(after, 2L, "There should have been 2 documents returned"); + }), + Runner.TestCase("succeeds when no document is updated", async () => + { + await using var db = await SqliteDb.BuildDb(); + + var before = await Find.All(SqliteDb.TableName); + Expect.equal(before.Count, 0, "There should have been no documents returned"); + + // This not raising an exception is the test + await Update.PartialByField(SqliteDb.TableName, "Value", Op.EQ, "burgundy", + new { Foo = "green" }); + }) + }) + }), + Runner.TestList("Delete", new[] + { + Runner.TestList("ById", new[] + { + Runner.TestCase("succeeds when a document is deleted", async () => + { + await using var db = await SqliteDb.BuildDb(); + await LoadDocs(); + + await Delete.ById(SqliteDb.TableName, "four"); + var remaining = await Count.All(SqliteDb.TableName); + Expect.equal(remaining, 4L, "There should have been 4 documents remaining"); + }), + Runner.TestCase("succeeds when a document is not deleted", async () => + { + await using var db = await SqliteDb.BuildDb(); + await LoadDocs(); + + await Delete.ById(SqliteDb.TableName, "thirty"); + var remaining = await Count.All(SqliteDb.TableName); + Expect.equal(remaining, 5L, "There should have been 5 documents remaining"); + }) + }), + Runner.TestList("ByField", new[] + { + Runner.TestCase("succeeds when documents are deleted", async () => + { + await using var db = await SqliteDb.BuildDb(); + await LoadDocs(); + + await Delete.ByField(SqliteDb.TableName, "Value", Op.NE, "purple"); + var remaining = await Count.All(SqliteDb.TableName); + Expect.equal(remaining, 2L, "There should have been 2 documents remaining"); + }), + Runner.TestCase("succeeds when documents are not deleted", async () => + { + await using var db = await SqliteDb.BuildDb(); + await LoadDocs(); + + await Delete.ByField(SqliteDb.TableName, "Value", Op.EQ, "crimson"); + var remaining = await Count.All(SqliteDb.TableName); + Expect.equal(remaining, 5L, "There should have been 5 documents remaining"); + }) + }) + }), + // Runner.TestList("Extensions" [ + // Runner.TestCase("EnsureTable succeeds" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() // let itExists (name: string) = task { @@ -502,57 +539,57 @@ public static class SqliteCSharpTests // Expect.isFalse exists "The table should not exist already" // Expect.isFalse alsoExists "The key index should not exist already" // - // do! Definition.EnsureTable "ensured" + // await Definition.EnsureTable "ensured" // let! exists' = itExists "ensured" // let! alsoExists' = itExists "idx_ensured_key" // Expect.isTrue exists' "The table should now exist" // Expect.isTrue alsoExists' "The key index should now exist" // } - // testList "Insert" [ - // testTask "succeeds" { + // Runner.TestList("Insert" [ + // Runner.TestCase("succeeds" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // let! before = conn.FindAll Db.tableName + // let! before = conn.FindAll SqliteDb.TableName // Expect.hasCountOf before 0u isTrue "There should be no documents in the table" - // do! conn.Insert( - // Db.tableName, + // await conn.Insert( + // SqliteDb.TableName , // JsonDocument(Id = "turkey", Sub = Some (SubDocument(Foo = "gobble", Bar = "gobble")))) - // let! after = conn.FindAll Db.tableName + // let! after = conn.FindAll SqliteDb.TableName // Expect.hasCountOf after 1u isTrue "There should have been one document inserted" // } - // testTask "fails for duplicate key" { + // Runner.TestCase("fails for duplicate key" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! conn.Insert(Db.tableName, JsonDocument(Id = "test")) + // await conn.Insert(SqliteDb.TableName , JsonDocument(Id = "test")) // Expect.throws // (fun () -> - // conn.Insert(Db.tableName, JsonDocument(Id = "test")) + // conn.Insert(SqliteDb.TableName , JsonDocument(Id = "test")) // |> Async.AwaitTask // |> Async.RunSynchronously) // "An exception should have been raised for duplicate document ID insert" // } // ] - // testList "Save" [ - // testTask "succeeds when a document is inserted" { + // Runner.TestList("Save" [ + // Runner.TestCase("succeeds when a document is inserted" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // let! before = conn.FindAll Db.tableName + // let! before = conn.FindAll SqliteDb.TableName // Expect.hasCountOf before 0u isTrue "There should be no documents in the table" // - // do! conn.Save( - // Db.tableName, + // await conn.Save( + // SqliteDb.TableName , // JsonDocument(Id = "test", Sub = Some (SubDocument(Foo = "a", Bar = "b")))) - // let! after = conn.FindAll Db.tableName + // let! after = conn.FindAll SqliteDb.TableName // Expect.hasCountOf after 1u isTrue "There should have been one document inserted" // } - // testTask "succeeds when a document is updated" { + // Runner.TestCase("succeeds when a document is updated" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! conn.Insert( - // Db.tableName, + // await conn.Insert( + // SqliteDb.TableName , // JsonDocument(Id = "test", Sub = Some (SubDocument(Foo = "a", Bar = "b")))) // - // let! before = conn.FindById(Db.tableName, "test") + // let! before = conn.FindById(SqliteDb.TableName , "test") // if isNull before then Expect.isTrue false "There should have been a document returned" // let before = before :> JsonDocument // Expect.equal before.Id "test" "The document is not correct" @@ -560,159 +597,159 @@ public static class SqliteCSharpTests // Expect.equal before.Sub.Value.Foo "a" "The document is not correct" // Expect.equal before.Sub.Value.Bar "b" "The document is not correct" // - // do! Save(Db.tableName, JsonDocument(Id = "test")) - // let! after = conn.FindById(Db.tableName, "test") + // await Save(SqliteDb.TableName , JsonDocument(Id = "test")) + // let! after = conn.FindById(SqliteDb.TableName , "test") // if isNull after then Expect.isTrue false "There should have been a document returned post-update" // let after = after :> JsonDocument // Expect.equal after.Id "test" "The updated document is not correct" // Expect.isNone after.Sub "There should not have been a sub-document in the updated document" // } // ] - // testTask "CountAll succeeds" { + // Runner.TestCase("CountAll succeeds" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // let! theCount = conn.CountAll Db.tableName + // let! theCount = conn.CountAll SqliteDb.TableName // Expect.equal theCount 5L "There should have been 5 matching documents" // } - // testTask "CountByField succeeds" { + // Runner.TestCase("CountByField succeeds" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // let! theCount = conn.CountByField(Db.tableName, "Value", Op.EQ, "purple") + // let! theCount = conn.CountByField(SqliteDb.TableName , "Value", Op.EQ, "purple") // Expect.equal theCount 2L "There should have been 2 matching documents" // } - // testList "ExistsById" [ - // testTask "succeeds when a document exists" { + // Runner.TestList("ExistsById" [ + // Runner.TestCase("succeeds when a document exists" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // let! exists = conn.ExistsById(Db.tableName, "three") + // let! exists = conn.ExistsById(SqliteDb.TableName , "three") // Expect.isTrue exists "There should have been an existing document" // } - // testTask "succeeds when a document does not exist" { + // Runner.TestCase("succeeds when a document does not exist" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // let! exists = conn.ExistsById(Db.tableName, "seven") + // let! exists = conn.ExistsById(SqliteDb.TableName , "seven") // Expect.isFalse exists "There should not have been an existing document" // } // ] - // testList "ExistsByField" [ - // testTask "succeeds when documents exist" { + // Runner.TestList("ExistsByField" [ + // Runner.TestCase("succeeds when documents exist" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // let! exists = conn.ExistsByField(Db.tableName, "NumValue", Op.GE, 10) + // let! exists = conn.ExistsByField(SqliteDb.TableName , "NumValue", Op.GE, 10) // Expect.isTrue exists "There should have been existing documents" // } - // testTask "succeeds when no matching documents exist" { + // Runner.TestCase("succeeds when no matching documents exist" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // let! exists = conn.ExistsByField(Db.tableName, "Nothing", Op.EQ, "none") + // let! exists = conn.ExistsByField(SqliteDb.TableName , "Nothing", Op.EQ, "none") // Expect.isFalse exists "There should not have been any existing documents" // } // ] - // testList "FindAll" [ - // testTask "succeeds when there is data" { + // Runner.TestList("FindAll" [ + // Runner.TestCase("succeeds when there is data" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() // - // do! conn.Insert(Db.tableName, JsonDocument(Id = "one", Value = "two")) - // do! conn.Insert(Db.tableName, JsonDocument(Id = "three", Value = "four")) - // do! conn.Insert(Db.tableName, JsonDocument(Id = "five", Value = "six")) + // await conn.Insert(SqliteDb.TableName , JsonDocument(Id = "one", Value = "two")) + // await conn.Insert(SqliteDb.TableName , JsonDocument(Id = "three", Value = "four")) + // await conn.Insert(SqliteDb.TableName , JsonDocument(Id = "five", Value = "six")) // - // let! results = conn.FindAll Db.tableName + // let! results = conn.FindAll SqliteDb.TableName // Expect.hasCountOf results 3u isTrue "There should have been 3 documents returned" // } - // testTask "succeeds when there is no data" { + // Runner.TestCase("succeeds when there is no data" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // let! results = conn.FindAll Db.tableName + // let! results = conn.FindAll SqliteDb.TableName // Expect.hasCountOf results 0u isTrue "There should have been no documents returned" // } // ] - // testList "FindById" [ - // testTask "succeeds when a document is found" { + // Runner.TestList("FindById" [ + // Runner.TestCase("succeeds when a document is found" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // let! doc = conn.FindById(Db.tableName, "two") + // let! doc = conn.FindById(SqliteDb.TableName , "two") // if isNull doc then Expect.isTrue false "There should have been a document returned" // Expect.equal (doc :> JsonDocument).Id "two" "The incorrect document was returned" // } - // testTask "succeeds when a document is not found" { + // Runner.TestCase("succeeds when a document is not found" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // let! doc = conn.FindById(Db.tableName, "three hundred eighty-seven") + // let! doc = conn.FindById(SqliteDb.TableName , "three hundred eighty-seven") // Expect.isNull doc "There should not have been a document returned" // } // ] - // testList "FindByField" [ - // testTask "succeeds when documents are found" { + // Runner.TestList("FindByField" [ + // Runner.TestCase("succeeds when documents are found" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // let! docs = conn.FindByField(Db.tableName, "NumValue", Op.GT, 15) + // let! docs = conn.FindByField(SqliteDb.TableName , "NumValue", Op.GT, 15) // Expect.hasCountOf docs 2u isTrue "There should have been two documents returned" // } - // testTask "succeeds when documents are not found" { + // Runner.TestCase("succeeds when documents are not found" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // let! docs = conn.FindByField(Db.tableName, "Value", Op.EQ, "mauve") + // let! docs = conn.FindByField(SqliteDb.TableName , "Value", Op.EQ, "mauve") // Expect.hasCountOf docs 0u isTrue "There should have been no documents returned" // } // ] - // testList "FindFirstByField" [ - // testTask "succeeds when a document is found" { + // Runner.TestList("FindFirstByField" [ + // Runner.TestCase("succeeds when a document is found" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // let! doc = conn.FindFirstByField(Db.tableName, "Value", Op.EQ, "another") + // let! doc = conn.FindFirstByField(SqliteDb.TableName , "Value", Op.EQ, "another") // if isNull doc then Expect.isTrue false "There should have been a document returned" // Expect.equal (doc :> JsonDocument).Id "two" "The incorrect document was returned" // } - // testTask "succeeds when multiple documents are found" { + // Runner.TestCase("succeeds when multiple documents are found" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // let! doc = conn.FindFirstByField(Db.tableName, "Sub.Foo", Op.EQ, "green") + // let! doc = conn.FindFirstByField(SqliteDb.TableName , "Sub.Foo", Op.EQ, "green") // if isNull doc then Expect.isTrue false "There should have been a document returned" // Expect.contains [ "two"; "four" ] (doc :> JsonDocument).Id "An incorrect document was returned" // } - // testTask "succeeds when a document is not found" { + // Runner.TestCase("succeeds when a document is not found" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // let! doc = conn.FindFirstByField(Db.tableName, "Value", Op.EQ, "absent") + // let! doc = conn.FindFirstByField(SqliteDb.TableName , "Value", Op.EQ, "absent") // Expect.isNull doc "There should not have been a document returned" // } // ] - // testList "UpdateFull" [ - // testTask "succeeds when a document is updated" { + // Runner.TestList("UpdateFull" [ + // Runner.TestCase("succeeds when a document is updated" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // // let testDoc = JsonDocument(Id = "one", Sub = Some (SubDocument(Foo = "blue", Bar = "red"))) - // do! conn.UpdateFull(Db.tableName, "one", testDoc) - // let! after = conn.FindById(Db.tableName, "one") + // await conn.UpdateFull(SqliteDb.TableName , "one", testDoc) + // let! after = conn.FindById(SqliteDb.TableName , "one") // if isNull after then Expect.isTrue false "There should have been a document returned post-update" // let after = after :> JsonDocument // Expect.equal after.Id "one" "The updated document is not correct" @@ -720,30 +757,30 @@ public static class SqliteCSharpTests // Expect.equal after.Sub.Value.Foo "blue" "The updated sub-document is not correct" // Expect.equal after.Sub.Value.Bar "red" "The updated sub-document is not correct" // } - // testTask "succeeds when no document is updated" { + // Runner.TestCase("succeeds when no document is updated" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // let! before = conn.FindAll Db.tableName + // let! before = conn.FindAll SqliteDb.TableName // Expect.hasCountOf before 0u isTrue "There should have been no documents returned" // // // This not raising an exception is the test - // do! conn.UpdateFull( - // Db.tableName, + // await conn.UpdateFull( + // SqliteDb.TableName , // "test", // JsonDocument(Id = "x", Sub = Some (SubDocument(Foo = "blue", Bar = "red")))) // } // ] - // testList "UpdateFullFunc" [ - // testTask "succeeds when a document is updated" { + // Runner.TestList("UpdateFullFunc" [ + // Runner.TestCase("succeeds when a document is updated" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // do! conn.UpdateFullFunc( - // Db.tableName, + // await conn.UpdateFullFunc( + // SqliteDb.TableName , // System.Func _.Id, // JsonDocument(Id = "one", Value = "le un", NumValue = 1, Sub = None)) - // let! after = conn.FindById(Db.tableName, "one") + // let! after = conn.FindById(SqliteDb.TableName , "one") // if isNull after then Expect.isTrue false "There should have been a document returned post-update" // let after = after :> JsonDocument // Expect.equal after.Id "one" "The updated document is incorrect" @@ -751,176 +788,176 @@ public static class SqliteCSharpTests // Expect.equal after.NumValue 1 "The updated document is incorrect" // Expect.isNone after.Sub "The updated document should not have a sub-document" // } - // testTask "succeeds when no document is updated" { + // Runner.TestCase("succeeds when no document is updated" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // let! before = conn.FindAll Db.tableName + // let! before = conn.FindAll SqliteDb.TableName // Expect.hasCountOf before 0u isTrue "There should have been no documents returned" // // // This not raising an exception is the test - // do! conn.UpdateFullFunc( - // Db.tableName, + // await conn.UpdateFullFunc( + // SqliteDb.TableName , // System.Func _.Id, // JsonDocument(Id = "one", Value = "le un", NumValue = 1, Sub = None)) // } // ] - // testList "UpdatePartialById" [ - // testTask "succeeds when a document is updated" { + // Runner.TestList("UpdatePartialById" [ + // Runner.TestCase("succeeds when a document is updated" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // do! conn.UpdatePartialById(Db.tableName, "one", {| NumValue = 44 |}) - // let! after = conn.FindById(Db.tableName, "one") + // await conn.UpdatePartialById(SqliteDb.TableName , "one", {| NumValue = 44 |}) + // let! after = conn.FindById(SqliteDb.TableName , "one") // if isNull after then Expect.isTrue false "There should have been a document returned post-update" // let after = after :> JsonDocument // Expect.equal after.Id "one" "The updated document is not correct" // Expect.equal after.NumValue 44 "The updated document is not correct" // } - // testTask "succeeds when no document is updated" { + // Runner.TestCase("succeeds when no document is updated" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // let! before = conn.FindAll Db.tableName + // let! before = conn.FindAll SqliteDb.TableName // Expect.hasCountOf before 0u isTrue "There should have been no documents returned" // // // This not raising an exception is the test - // do! conn.UpdatePartialById(Db.tableName, "test", {| Foo = "green" |}) + // await conn.UpdatePartialById(SqliteDb.TableName , "test", {| Foo = "green" |}) // } // ] - // testList "UpdatePartialByField" [ - // testTask "succeeds when a document is updated" { + // Runner.TestList("UpdatePartialByField" [ + // Runner.TestCase("succeeds when a document is updated" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // do! conn.UpdatePartialByField(Db.tableName, "Value", Op.EQ, "purple", {| NumValue = 77 |}) - // let! after = conn.CountByField(Db.tableName, "NumValue", Op.EQ, 77) + // await conn.UpdatePartialByField(SqliteDb.TableName , "Value", Op.EQ, "purple", {| NumValue = 77 |}) + // let! after = conn.CountByField(SqliteDb.TableName , "NumValue", Op.EQ, 77) // Expect.equal after 2L "There should have been 2 documents returned" // } - // testTask "succeeds when no document is updated" { + // Runner.TestCase("succeeds when no document is updated" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // let! before = conn.FindAll Db.tableName + // let! before = conn.FindAll SqliteDb.TableName // Expect.hasCountOf before 0u isTrue "There should have been no documents returned" // // // This not raising an exception is the test - // do! conn.UpdatePartialByField(Db.tableName, "Value", Op.EQ, "burgundy", {| Foo = "green" |}) + // await conn.UpdatePartialByField(SqliteDb.TableName , "Value", Op.EQ, "burgundy", {| Foo = "green" |}) // } // ] - // testList "DeleteById" [ - // testTask "succeeds when a document is deleted" { + // Runner.TestList("DeleteById" [ + // Runner.TestCase("succeeds when a document is deleted" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // do! conn.DeleteById(Db.tableName, "four") - // let! remaining = conn.CountAll Db.tableName + // await conn.DeleteById(SqliteDb.TableName , "four") + // let! remaining = conn.CountAll SqliteDb.TableName // Expect.equal remaining 4L "There should have been 4 documents remaining" // } - // testTask "succeeds when a document is not deleted" { + // Runner.TestCase("succeeds when a document is not deleted" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // do! conn.DeleteById(Db.tableName, "thirty") - // let! remaining = conn.CountAll Db.tableName + // await conn.DeleteById(SqliteDb.TableName , "thirty") + // let! remaining = conn.CountAll SqliteDb.TableName // Expect.equal remaining 5L "There should have been 5 documents remaining" // } // ] - // testList "DeleteByField" [ - // testTask "succeeds when documents are deleted" { + // Runner.TestList("DeleteByField" [ + // Runner.TestCase("succeeds when documents are deleted" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // do! conn.DeleteByField(Db.tableName, "Value", Op.NE, "purple") - // let! remaining = conn.CountAll Db.tableName + // await conn.DeleteByField(SqliteDb.TableName , "Value", Op.NE, "purple") + // let! remaining = conn.CountAll SqliteDb.TableName // Expect.equal remaining 2L "There should have been 2 documents remaining" // } - // testTask "succeeds when documents are not deleted" { + // Runner.TestCase("succeeds when documents are not deleted" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // do! conn.DeleteByField(Db.tableName, "Value", Op.EQ, "crimson") - // let! remaining = Count.All Db.tableName + // await conn.DeleteByField(SqliteDb.TableName , "Value", Op.EQ, "crimson") + // let! remaining = Count.All SqliteDb.TableName // Expect.equal remaining 5L "There should have been 5 documents remaining" // } // ] - // testList "CustomSingle" [ - // testTask "succeeds when a row is found" { + // Runner.TestList("CustomSingle" [ + // Runner.TestCase("succeeds when a row is found" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // // let! doc = // conn.CustomSingle( - // $"SELECT data FROM {Db.tableName} WHERE data ->> 'Id' = @id", + // $"SELECT data FROM {SqliteDb.TableName } WHERE data ->> 'Id' = @id", // [ SqliteParameter("@id", "one") ], // FromData) // if isNull doc then Expect.isTrue false "There should have been a document returned" // Expect.equal (doc :> JsonDocument).Id "one" "The incorrect document was returned" // } - // testTask "succeeds when a row is not found" { + // Runner.TestCase("succeeds when a row is not found" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // // let! doc = // conn.CustomSingle( - // $"SELECT data FROM {Db.tableName} WHERE data ->> 'Id' = @id", + // $"SELECT data FROM {SqliteDb.TableName } WHERE data ->> 'Id' = @id", // [ SqliteParameter("@id", "eighty") ], // FromData) // Expect.isNull doc "There should not have been a document returned" // } // ] - // testList "CustomList" [ - // testTask "succeeds when data is found" { + // Runner.TestList("CustomList" [ + // Runner.TestCase("succeeds when data is found" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // let! docs = conn.CustomList(Query.SelectFromTable Db.tableName, [], FromData) + // let! docs = conn.CustomList(Query.SelectFromTable SqliteDb.TableName , [], FromData) // Expect.hasCountOf docs 5u isTrue "There should have been 5 documents returned" // } - // testTask "succeeds when data is not found" { + // Runner.TestCase("succeeds when data is not found" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // // let! docs = // conn.CustomList( - // $"SELECT data FROM {Db.tableName} WHERE data ->> 'NumValue' > @value", + // $"SELECT data FROM {SqliteDb.TableName } WHERE data ->> 'NumValue' > @value", // [ SqliteParameter("@value", 100) ], // FromData) // Expect.isEmpty docs "There should have been no documents returned" // } // ] - // testList "CustomNonQuery" [ - // testTask "succeeds when operating on data" { + // Runner.TestList("CustomNonQuery" [ + // Runner.TestCase("succeeds when operating on data" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // do! conn.CustomNonQuery($"DELETE FROM {Db.tableName}", []) + // await conn.CustomNonQuery($"DELETE FROM {SqliteDb.TableName }", []) // - // let! remaining = conn.CountAll Db.tableName + // let! remaining = conn.CountAll SqliteDb.TableName // Expect.equal remaining 0L "There should be no documents remaining in the table" // } - // testTask "succeeds when no data matches where clause" { + // Runner.TestCase("succeeds when no data matches where clause" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() - // do! loadDocs () + // await LoadDocs(); // - // do! conn.CustomNonQuery( - // $"DELETE FROM {Db.tableName} WHERE data ->> 'NumValue' > @value", + // await conn.CustomNonQuery( + // $"DELETE FROM {SqliteDb.TableName } WHERE data ->> 'NumValue' > @value", // [ SqliteParameter("@value", 100) ]) // - // let! remaining = conn.CountAll Db.tableName + // let! remaining = conn.CountAll SqliteDb.TableName // Expect.equal remaining 5L "There should be 5 documents remaining in the table" // } // ] - // testTask "CustomScalar succeeds" { + // Runner.TestCase("CustomScalar succeeds" { // use! db = Db.buildDb () // use conn = Configuration.DbConn() //