@@ -170,33 +170,87 @@ await QuerySql.InsertPostgresTypes(new QuerySql.InsertPostgresTypesArgs
170170 [ KnownTestType . PostgresArrayDataTypes ] = new TestImpl
171171 {
172172 Impl = $$ """
173+ public static IEnumerable<TestCaseData> PostgresArrayTypesTestCases
174+ {
175+ get
176+ {
177+ yield return new TestCaseData(
178+ new byte[] { 0x45, 0x42 },
179+ new bool[] { true, false },
180+ new string[] { "Makeshift", "Swahili" },
181+ new int[] { 543, -4234 },
182+ new decimal[] { 1.2345678m, 2.3456789m },
183+ new DateTime[] { new DateTime(2021, 1, 1), new DateTime(2022, 2, 2) },
184+ new DateTime[] { new DateTime(2023, 3, 3), new DateTime(2024, 4, 4) }
185+ ).SetName("Arrays with values");
186+
187+ yield return new TestCaseData(
188+ new byte[] { },
189+ new bool[] { },
190+ new string[] { },
191+ new int[] { },
192+ new decimal[] { },
193+ new DateTime[] { },
194+ new DateTime[] { }
195+ ).SetName("Arrays with null values");
196+
197+ yield return new TestCaseData(
198+ null,
199+ null,
200+ null,
201+ null,
202+ null,
203+ null,
204+ null
205+ ).SetName("Null Array Types");
206+ }
207+ }
208+
173209 [Test]
174- [TestCase(new byte[] { 0x45, 0x42 }, new string[] { "Party", "Fight" }, new int[] { 543, -4234 })]
175- [TestCase(new byte[] { }, new string[] { }, new int[] { })]
176- [TestCase(null, null, null)]
210+ [TestCaseSource(nameof(PostgresArrayTypesTestCases))]
177211 public async Task TestPostgresArrayTypes(
178212 byte[] cBytea,
213+ bool[] cBooleanArray,
179214 string[] cTextArray,
180- int[] cIntegerArray)
215+ int[] cIntegerArray,
216+ decimal[] cDecimalArray,
217+ DateTime[] cDateArray,
218+ DateTime[] cTimestampArray)
181219 {
182220 await QuerySql.InsertPostgresTypes(new QuerySql.InsertPostgresTypesArgs
183221 {
184222 CBytea = cBytea,
223+ CBooleanArray = cBooleanArray,
185224 CTextArray = cTextArray,
186- CIntegerArray = cIntegerArray
225+ CIntegerArray = cIntegerArray,
226+ CDecimalArray = cDecimalArray,
227+ CDateArray = cDateArray,
228+ CTimestampArray = cTimestampArray
187229 });
188230
189231 var expected = new QuerySql.GetPostgresTypesRow
190232 {
191- CBytea = cBytea,
233+ CBytea = cBytea,
234+ CBooleanArray = cBooleanArray,
192235 CTextArray = cTextArray,
193- CIntegerArray = cIntegerArray
236+ CIntegerArray = cIntegerArray,
237+ CDecimalArray = cDecimalArray,
238+ CDateArray = cDateArray,
239+ CTimestampArray = cTimestampArray
194240 };
195241 var actual = await QuerySql.GetPostgresTypes();
196-
197- Assert.That(actual{{ Consts . UnknownRecordValuePlaceholder }} .CBytea, Is.EqualTo(expected.CBytea));
198- Assert.That(actual{{ Consts . UnknownRecordValuePlaceholder }} .CTextArray, Is.EqualTo(expected.CTextArray));
199- Assert.That(actual{{ Consts . UnknownRecordValuePlaceholder }} .CIntegerArray, Is.EqualTo(expected.CIntegerArray));
242+ AssertSingularEquals(expected, actual{{ Consts . UnknownRecordValuePlaceholder }} );
243+
244+ void AssertSingularEquals(QuerySql.GetPostgresTypesRow x, QuerySql.GetPostgresTypesRow y)
245+ {
246+ Assert.That(x.CBytea, Is.EqualTo(y.CBytea));
247+ Assert.That(x.CTextArray, Is.EqualTo(y.CTextArray));
248+ Assert.That(x.CIntegerArray, Is.EqualTo(y.CIntegerArray));
249+ Assert.That(x.CBooleanArray, Is.EqualTo(y.CBooleanArray));
250+ Assert.That(x.CDecimalArray, Is.EqualTo(y.CDecimalArray));
251+ Assert.That(x.CDateArray, Is.EqualTo(y.CDateArray));
252+ Assert.That(x.CTimestampArray, Is.EqualTo(y.CTimestampArray));
253+ }
200254 }
201255 """
202256 } ,
@@ -329,13 +383,17 @@ public async Task TestFloatingPointCopyFrom(
329383 CMoney = cMoney
330384 };
331385 var actual = await QuerySql.GetPostgresTypesCnt();
332-
333- Assert.That(actual{{ Consts . UnknownRecordValuePlaceholder }} .Cnt, Is.EqualTo(expected.Cnt));
334- Assert.That(actual{{ Consts . UnknownRecordValuePlaceholder }} .CReal, Is.EqualTo(expected.CReal));
335- Assert.That(actual{{ Consts . UnknownRecordValuePlaceholder }} .CDecimal, Is.EqualTo(expected.CDecimal));
336- Assert.That(actual{{ Consts . UnknownRecordValuePlaceholder }} .CNumeric, Is.EqualTo(expected.CNumeric));
337- Assert.That(actual{{ Consts . UnknownRecordValuePlaceholder }} .CDoublePrecision, Is.EqualTo(expected.CDoublePrecision));
338- Assert.That(actual{{ Consts . UnknownRecordValuePlaceholder }} .CMoney, Is.EqualTo(expected.CMoney));
386+ AssertSingularEquals(expected, actual{{ Consts . UnknownRecordValuePlaceholder }} );
387+
388+ void AssertSingularEquals(QuerySql.GetPostgresTypesCntRow x, QuerySql.GetPostgresTypesCntRow y)
389+ {
390+ Assert.That(x.Cnt, Is.EqualTo(y.Cnt));
391+ Assert.That(x.CReal, Is.EqualTo(y.CReal));
392+ Assert.That(x.CDecimal, Is.EqualTo(y.CDecimal));
393+ Assert.That(x.CNumeric, Is.EqualTo(y.CNumeric));
394+ Assert.That(x.CDoublePrecision, Is.EqualTo(y.CDoublePrecision));
395+ Assert.That(x.CMoney, Is.EqualTo(y.CMoney));
396+ }
339397 }
340398 """
341399 } ,
@@ -375,12 +433,16 @@ public async Task TestDateTimeCopyFrom(
375433 CTimestampWithTz = cTimestampWithTz,
376434 };
377435 var actual = await QuerySql.GetPostgresTypesCnt();
378-
379- Assert.That(actual{{ Consts . UnknownRecordValuePlaceholder }} .Cnt, Is.EqualTo(expected.Cnt));
380- Assert.That(actual{{ Consts . UnknownRecordValuePlaceholder }} .CDate, Is.EqualTo(expected.CDate));
381- Assert.That(actual{{ Consts . UnknownRecordValuePlaceholder }} .CTime, Is.EqualTo(expected.CTime));
382- Assert.That(actual{{ Consts . UnknownRecordValuePlaceholder }} .CTimestamp, Is.EqualTo(expected.CTimestamp));
383- Assert.That(actual{{ Consts . UnknownRecordValuePlaceholder }} .CTimestampWithTz, Is.EqualTo(expected.CTimestampWithTz));
436+ AssertSingularEquals(expected, actual{{ Consts . UnknownRecordValuePlaceholder }} );
437+
438+ void AssertSingularEquals(QuerySql.GetPostgresTypesCntRow x, QuerySql.GetPostgresTypesCntRow y)
439+ {
440+ Assert.That(x.Cnt, Is.EqualTo(y.Cnt));
441+ Assert.That(x.CDate, Is.EqualTo(y.CDate));
442+ Assert.That(x.CTime, Is.EqualTo(y.CTime));
443+ Assert.That(x.CTimestamp, Is.EqualTo(y.CTimestamp));
444+ Assert.That(x.CTimestampWithTz, Is.EqualTo(y.CTimestampWithTz));
445+ }
384446 }
385447 """
386448 } ,
0 commit comments