From a266c38310d1c7edfcfcd1d0e17df4e537966548 Mon Sep 17 00:00:00 2001 From: rekhoff Date: Fri, 21 Mar 2025 10:37:12 -0700 Subject: [PATCH 1/2] Added Unit Test that checks the BTreeIndexBase Column implements IComparable --- sdks/csharp/tests~/Tests.cs | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/sdks/csharp/tests~/Tests.cs b/sdks/csharp/tests~/Tests.cs index 7bc6590054d..2369ee21fb7 100644 --- a/sdks/csharp/tests~/Tests.cs +++ b/sdks/csharp/tests~/Tests.cs @@ -81,4 +81,56 @@ public static void GenericEqualityComparerCheck() Assert.False(GenericEqualityComparer.Instance.Equals(statusFailed, statusFailedUnequalValue)); Assert.False(GenericEqualityComparer.Instance.Equals(statusCommitted, statusOutOfEnergy)); } + + public class BTreeIndexBaseColumnImplementsIComparableTest + { + + public sealed class UserHandle : RemoteTableHandle + { + protected override string RemoteTableName => "user"; + + public sealed class IdentityIndex : BTreeIndexBase + { + protected override SpacetimeDB.Identity GetKey(User row) => row.Identity; + + public IdentityIndex(UserHandle table) : base(table) { } + } + + public readonly IdentityIndex Identity; + + internal UserHandle(DbConnection conn) : base(conn) + { + Identity = new(this); + } + } + + [Fact] + public void Identity_ShouldImplementIComparable() + { + // Arrange + var identityType = typeof(SpacetimeDB.Identity); + + // Act + bool implementsIComparable = + typeof(IComparable<>).MakeGenericType(identityType).IsAssignableFrom(identityType); + + // Assert + Assert.True(implementsIComparable, $"{identityType} does not implement IComparable<{identityType}>"); + } + + [Fact] + public void IdentityIndex_ShouldInheritFrom_BTreeIndexBase() + { + // Arrange + var identityIndexType = typeof(UserHandle.IdentityIndex); + var expectedBaseType = typeof(RemoteTableHandle.BTreeIndexBase); + + // Act + bool isCorrectBaseType = expectedBaseType.IsAssignableFrom(identityIndexType.BaseType); + + // Assert + Assert.True(isCorrectBaseType, + "IdentityIndex does not correctly inherit from BTreeIndexBase"); + } + } } \ No newline at end of file From a0fcd3cefd5c92aae1f8c12a593da258a760b378 Mon Sep 17 00:00:00 2001 From: rekhoff Date: Fri, 21 Mar 2025 13:57:03 -0700 Subject: [PATCH 2/2] Removed whitespace --- sdks/csharp/tests~/Tests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdks/csharp/tests~/Tests.cs b/sdks/csharp/tests~/Tests.cs index 2369ee21fb7..b43264f92df 100644 --- a/sdks/csharp/tests~/Tests.cs +++ b/sdks/csharp/tests~/Tests.cs @@ -81,7 +81,7 @@ public static void GenericEqualityComparerCheck() Assert.False(GenericEqualityComparer.Instance.Equals(statusFailed, statusFailedUnequalValue)); Assert.False(GenericEqualityComparer.Instance.Equals(statusCommitted, statusOutOfEnergy)); } - + public class BTreeIndexBaseColumnImplementsIComparableTest { @@ -103,7 +103,7 @@ internal UserHandle(DbConnection conn) : base(conn) Identity = new(this); } } - + [Fact] public void Identity_ShouldImplementIComparable() {