diff --git a/docs/examples/record_api_dotnet/Create.cs b/docs/examples/record_api_dotnet/Create.cs index a34343c7..6d6a2a91 100644 --- a/docs/examples/record_api_dotnet/Create.cs +++ b/docs/examples/record_api_dotnet/Create.cs @@ -2,7 +2,7 @@ using TrailBase; using System.Text.Json.Nodes; public partial class Examples { - public static async Task Create(Client client) { - return await client.Records("simple_strict_table").Create(JsonNode.Parse("""{"text_not_null": "test"}""")); - } + public static async Task Create(Client client) => + await client.Records("simple_strict_table").Create( + new JsonObject { ["text_not_null"] = "test" }); } diff --git a/docs/examples/record_api_dotnet/Delete.cs b/docs/examples/record_api_dotnet/Delete.cs index 7bed4ade..19d264a9 100644 --- a/docs/examples/record_api_dotnet/Delete.cs +++ b/docs/examples/record_api_dotnet/Delete.cs @@ -1,7 +1,6 @@ using TrailBase; public partial class Examples { - public static async Task Delete(Client client, RecordId id) { + public static async Task Delete(Client client, RecordId id) => await client.Records("simple_strict_table").Delete(id); - } } diff --git a/docs/examples/record_api_dotnet/ExamplesTest.cs b/docs/examples/record_api_dotnet/ExamplesTest.cs index 735750be..ee6e6094 100644 --- a/docs/examples/record_api_dotnet/ExamplesTest.cs +++ b/docs/examples/record_api_dotnet/ExamplesTest.cs @@ -24,8 +24,12 @@ public class ExamplesTest : IClassFixture { public async Task BasicTest() { var client = await Connect(); + var tableStream = await Examples.SubscribeAll(client); + var id = await Examples.Create(client); + var recordStream = await Examples.Subscribe(client, id); + Console.WriteLine($"ID: {id}"); { @@ -41,5 +45,20 @@ public class ExamplesTest : IClassFixture { } await Examples.Delete(client, id); + + List events = []; + await foreach (Event ev in recordStream) { + events.Add(ev); + } + Assert.Equal(2, events.Count); + + List tableEvents = []; + await foreach (Event ev in tableStream) { + tableEvents.Add(ev); + + if (tableEvents.Count >= 3) { + break; + } + } } } diff --git a/docs/examples/record_api_dotnet/Read.cs b/docs/examples/record_api_dotnet/Read.cs index e666d21d..b64b611d 100644 --- a/docs/examples/record_api_dotnet/Read.cs +++ b/docs/examples/record_api_dotnet/Read.cs @@ -2,7 +2,6 @@ using TrailBase; using System.Text.Json.Nodes; public partial class Examples { - public static async Task Read(Client client, RecordId id) { - return await client.Records("simple_strict_table").Read(id); - } + public static async Task Read(Client client, RecordId id) => + await client.Records("simple_strict_table").Read(id); } diff --git a/docs/examples/record_api_dotnet/Subscribe.cs b/docs/examples/record_api_dotnet/Subscribe.cs new file mode 100644 index 00000000..fb14fb93 --- /dev/null +++ b/docs/examples/record_api_dotnet/Subscribe.cs @@ -0,0 +1,9 @@ +using TrailBase; + +public partial class Examples { + public static async Task> Subscribe(Client client, RecordId id) => + await client.Records("simple_strict_table").Subscribe(id); + + public static async Task> SubscribeAll(Client client) => + await client.Records("simple_strict_table").SubscribeAll(); +} diff --git a/docs/examples/record_api_dotnet/Update.cs b/docs/examples/record_api_dotnet/Update.cs index 1a7512be..1725a463 100644 --- a/docs/examples/record_api_dotnet/Update.cs +++ b/docs/examples/record_api_dotnet/Update.cs @@ -2,7 +2,7 @@ using TrailBase; using System.Text.Json.Nodes; public partial class Examples { - public static async Task Update(Client client, RecordId id) { - await client.Records("simple_strict_table").Update(id, JsonNode.Parse("""{"text_not_null": "updated"}""")); - } + public static async Task Update(Client client, RecordId id) => + await client.Records("simple_strict_table").Update( + id, new JsonObject { ["text_not_null"] = "updated" }); } diff --git a/docs/src/content/docs/documentation/APIs/record_apis.mdx b/docs/src/content/docs/documentation/APIs/record_apis.mdx index 3c7fbaf0..88503ecb 100644 --- a/docs/src/content/docs/documentation/APIs/record_apis.mdx +++ b/docs/src/content/docs/documentation/APIs/record_apis.mdx @@ -291,6 +291,7 @@ updates, and deletions. import subscribeDartCode from "@examples/record_api_dart/lib/src/subscribe.dart?raw"; import subscribeTsCode from "@examples/record_api_ts/src/subscribe.ts?raw"; +import subscribeDotnetCode from "@examples/record_api_dotnet/Subscribe.cs?raw"; @@ -300,6 +301,10 @@ import subscribeTsCode from "@examples/record_api_ts/src/subscribe.ts?raw"; + + + + ### Schema