From d1190b957e313b8090168c519be7f8bdc0730d99 Mon Sep 17 00:00:00 2001 From: Timmy Lind Date: Wed, 3 Jun 2026 12:46:26 +0200 Subject: [PATCH 1/2] add arrays in complex type this introduces failures in tests --- Moq.Dapper.Test/DapperQueryAsyncTest.cs | 7 +++++++ Moq.Dapper.Test/DapperQueryTest.cs | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/Moq.Dapper.Test/DapperQueryAsyncTest.cs b/Moq.Dapper.Test/DapperQueryAsyncTest.cs index f175cfa..cefaa7a 100644 --- a/Moq.Dapper.Test/DapperQueryAsyncTest.cs +++ b/Moq.Dapper.Test/DapperQueryAsyncTest.cs @@ -206,6 +206,7 @@ public void QueryAsyncGenericComplexType() new ComplexType { StringProperty = "String1", + StringArrayProperty = ["StringArray1"], IntegerProperty = 7, LongProperty = 70, BigIntegerProperty = 700, @@ -219,6 +220,7 @@ public void QueryAsyncGenericComplexType() new ComplexType { StringProperty = "String2", + StringArrayProperty = ["StringArray1", "StringArray2"], IntegerProperty = 77, LongProperty = 770, BigIntegerProperty = 7700, @@ -232,6 +234,7 @@ public void QueryAsyncGenericComplexType() new ComplexType { StringProperty = "String3", + StringArrayProperty = ["StringArray1", "StringArray2", "StringArray3"], IntegerProperty = 777, LongProperty = 7770, BigIntegerProperty = 77700, @@ -258,6 +261,7 @@ public void QueryAsyncGenericComplexType() foreach (var complexObject in expected) { var match = actual.Where(co => co.StringProperty == complexObject.StringProperty && + co.StringArrayProperty == complexObject.StringArrayProperty && co.IntegerProperty == complexObject.IntegerProperty && co.LongProperty == complexObject.LongProperty && co.BigIntegerProperty == complexObject.BigIntegerProperty && @@ -279,6 +283,7 @@ public void QuerySingleOrDefaultAsyncWithComplexType() var expected = new ComplexType { StringProperty = "String1", + StringArrayProperty = ["StringArray1", "StringArray2"], IntegerProperty = 7, LongProperty = 70, BigIntegerProperty = 700, @@ -323,6 +328,7 @@ public void QueryFirstOrDefaultAsyncWithComplexType() var expected = new ComplexType { StringProperty = "String1", + StringArrayProperty = ["StringArray1", "StringArray2", "StringArray3"], IntegerProperty = 7, LongProperty = 70, BigIntegerProperty = 700, @@ -416,6 +422,7 @@ public enum EnumType public BigInteger BigIntegerProperty { get; set; } public long LongProperty { get; set; } public int IntegerProperty { get; set; } + public string[] StringArrayProperty { get; set; } public string StringProperty { get; set; } public Guid GuidProperty { get; set; } public DateTime DateTimeProperty { get; set; } diff --git a/Moq.Dapper.Test/DapperQueryTest.cs b/Moq.Dapper.Test/DapperQueryTest.cs index 666b7a0..7a22d5e 100644 --- a/Moq.Dapper.Test/DapperQueryTest.cs +++ b/Moq.Dapper.Test/DapperQueryTest.cs @@ -115,6 +115,7 @@ public void QueryGenericComplexType() new ComplexType { StringProperty = "String1", + StringArrayProperty = ["StringArray1"], IntegerProperty = 7, LongProperty = 70, BigIntegerProperty = 700, @@ -128,6 +129,7 @@ public void QueryGenericComplexType() new ComplexType { StringProperty = "String2", + StringArrayProperty = ["StringArray1", "StringArray2"], IntegerProperty = 77, LongProperty = 770, BigIntegerProperty = 7700, @@ -141,6 +143,7 @@ public void QueryGenericComplexType() new ComplexType { StringProperty = "String3", + StringArrayProperty = ["StringArray1", "StringArray2", "StringArray3"], IntegerProperty = 777, LongProperty = 7770, BigIntegerProperty = 77700, @@ -162,6 +165,7 @@ public void QueryGenericComplexType() foreach (var complexObject in expected) { var match = actual.Where(co => co.StringProperty == complexObject.StringProperty && + co.StringArrayProperty == complexObject.StringArrayProperty && co.IntegerProperty == complexObject.IntegerProperty && co.LongProperty == complexObject.LongProperty && co.BigIntegerProperty == complexObject.BigIntegerProperty && @@ -184,6 +188,7 @@ public void QuerySingleOrDefaultWithComplexType() var expected = new ComplexType { StringProperty = "String1", + StringArrayProperty = ["StringArray1"], IntegerProperty = 7, LongProperty = 70, BigIntegerProperty = 700, @@ -224,6 +229,7 @@ public void QueryFirstOrDefaultWithComplexType() var expected = new ComplexType { StringProperty = "String1", + StringArrayProperty = ["StringArray1"], IntegerProperty = 7, LongProperty = 70, BigIntegerProperty = 700, @@ -293,6 +299,7 @@ public enum EnumType public int IntegerProperty { get; set; } public long LongProperty { get; set; } public BigInteger BigIntegerProperty { get; set; } + public string[] StringArrayProperty { get; set; } public string StringProperty { get; set; } public Guid GuidProperty { get; set; } public DateTime DateTimeProperty { get; set; } From 42875e860d5a5392b7e6664b0c8b8c623aaa1484 Mon Sep 17 00:00:00 2001 From: Timmy Lind Date: Wed, 3 Jun 2026 12:46:59 +0200 Subject: [PATCH 2/2] include .IsArray when matching types --- Moq.Dapper/EnumerableExtensions.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Moq.Dapper/EnumerableExtensions.cs b/Moq.Dapper/EnumerableExtensions.cs index 88e4571..9476c19 100644 --- a/Moq.Dapper/EnumerableExtensions.cs +++ b/Moq.Dapper/EnumerableExtensions.cs @@ -54,6 +54,7 @@ Type GetDataColumnType(Type source) => bool IsMatchingType(Type t) => t.IsPrimitive || t.IsEnum || + t.IsArray || t == typeof(DateTime) || t == typeof(DateTimeOffset) || t == typeof(decimal) ||