From 2b322f0f4a37001a1b2f32ae29956be2d69118e1 Mon Sep 17 00:00:00 2001 From: Chet Bortz Date: Wed, 18 Mar 2026 11:05:26 -0400 Subject: [PATCH 1/2] test `apple_user_id` mapping in `AccessPassEvent` --- AccessGridTest/AccessPassEventTests.cs | 80 ++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 AccessGridTest/AccessPassEventTests.cs diff --git a/AccessGridTest/AccessPassEventTests.cs b/AccessGridTest/AccessPassEventTests.cs new file mode 100644 index 0000000..01860cf --- /dev/null +++ b/AccessGridTest/AccessPassEventTests.cs @@ -0,0 +1,80 @@ +namespace AccessGridTest; + +using System.Text.Json; +using System.Text.Json.Serialization; +using AccessGrid; +using NUnit.Framework; + +[TestFixture] +public class AccessPassEventTests +{ + private JsonSerializerOptions _jsonOptions; + + [SetUp] + public void SetUp() + { + _jsonOptions = new JsonSerializerOptions + { + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + Converters = { new JsonStringEnumConverter() } + }; + } + + [Test] + public void Deserialize_ShouldIncludeAppleUserId_WhenPresent() + { + var json = """ + { + "id": "ap_123", + "card_template_id": "ct_456", + "state": "active", + "full_name": "Jane Doe", + "apple_user_id": "001234.abc567def890.1234", + "card_templates": [], + "devices": [] + } + """; + + var evt = JsonSerializer.Deserialize(json, _jsonOptions); + + Assert.That(evt.AppleUserId, Is.EqualTo("001234.abc567def890.1234")); + } + + [Test] + public void Deserialize_ShouldHaveNullAppleUserId_WhenAbsent() + { + var json = """ + { + "id": "ap_123", + "card_template_id": "ct_456", + "state": "active", + "card_templates": [], + "devices": [] + } + """; + + var evt = JsonSerializer.Deserialize(json, _jsonOptions); + + Assert.That(evt.AppleUserId, Is.Null); + } + + [Test] + public void Deserialize_ShouldHaveNullAppleUserId_WhenExplicitlyNull() + { + var json = """ + { + "id": "ap_123", + "card_template_id": "ct_456", + "state": "active", + "apple_user_id": null, + "card_templates": [], + "devices": [] + } + """; + + var evt = JsonSerializer.Deserialize(json, _jsonOptions); + + Assert.That(evt.AppleUserId, Is.Null); + } +} From 3b3f8c0036fb98ceb42e30cbf8edb67fac027b8e Mon Sep 17 00:00:00 2001 From: Chet Bortz Date: Wed, 18 Mar 2026 11:29:57 -0400 Subject: [PATCH 2/2] update README and ensure versions match via test --- AccessGridTest/VersionConsistencyTests.cs | 26 +++++++++++++++++++++++ README.md | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 AccessGridTest/VersionConsistencyTests.cs diff --git a/AccessGridTest/VersionConsistencyTests.cs b/AccessGridTest/VersionConsistencyTests.cs new file mode 100644 index 0000000..7089269 --- /dev/null +++ b/AccessGridTest/VersionConsistencyTests.cs @@ -0,0 +1,26 @@ +namespace AccessGridTest; + +using System.IO; +using System.Text.RegularExpressions; +using NUnit.Framework; + +[TestFixture] +public class VersionConsistencyTests +{ + [Test] + public void ReadmeVersion_ShouldMatchCsprojVersion() + { + var repoRoot = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, "..", "..", "..", "..")); + + var csproj = File.ReadAllText(Path.Combine(repoRoot, "src", "AccessGrid.csproj")); + var csprojMatch = Regex.Match(csproj, @"(.+?)"); + Assert.That(csprojMatch.Success, Is.True, "Could not find in csproj"); + + var readme = File.ReadAllText(Path.Combine(repoRoot, "README.md")); + var readmeMatch = Regex.Match(readme, @"-Version\s+(\S+)"); + Assert.That(readmeMatch.Success, Is.True, "Could not find version in README"); + + Assert.That(readmeMatch.Groups[1].Value, Is.EqualTo(csprojMatch.Groups[1].Value), + "README version does not match csproj version"); + } +} diff --git a/README.md b/README.md index d8fe4d2..6a7d1f8 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Official C# SDK for interacting with the AccessGrid API. ## Installation ``` -Install-Package accessgrid -Version 1.2.1 +Install-Package accessgrid -Version 1.2.2 ``` ## Authentication