1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
| using System;
| using System.Collections.Generic;
| using System.Net.NetworkInformation;
| using Xunit;
| using System.Linq;
|
| public abstract class BaseUpdateArrayTimestampIndexTests : PlDotNetTest
| {
| protected abstract string FunctionBody { get; }
|
| protected abstract LanguageType Language { get; }
|
| public BaseUpdateArrayTimestampIndexTests()
| {
| FunctionInfo = new SqlFunctionInfo { Name = "UpdateArrayTimestampIndex", Arguments = new List<FunctionArgument> { new FunctionArgument("values_array", "TIMESTAMP[]"), new FunctionArgument("desired", "TIMESTAMP"), new FunctionArgument("index", "integer[]") }, ReturnType = "TIMESTAMP[]", Body = FunctionBody, Language = Language, IsStrict = true, };
| }
|
| public static object[][] TestCases()
| {
| return new object[][] { new object[] { "c#-timestamp-1array", "updateArrayTimestampIndex1", "ARRAY[TIMESTAMP '2004-10-19 10:23:54 PM', TIMESTAMP '2020-10-19 10:23:54 PM', null::timestamp, TIMESTAMP '2022-12-25 10:23:54 PM'], TIMESTAMP '2025-10-19 10:23:54 PM', ARRAY[2]", "= ARRAY[TIMESTAMP '2004-10-19 10:23:54 PM', TIMESTAMP '2020-10-19 10:23:54 PM', TIMESTAMP '2025-10-19 10:23:54 PM', TIMESTAMP '2022-12-25 10:23:54 PM']" }, new object[] { "c#-timestamp-null-2array-arraynull", "updateArrayTimestampIndex2", "ARRAY[[null::timestamp, null::timestamp], [null::timestamp, TIMESTAMP '2022-12-25 10:23:54 PM']], TIMESTAMP '2025-10-19 10:23:54 PM', ARRAY[1,0]", "= ARRAY[[null::timestamp, null::timestamp], [TIMESTAMP '2025-10-19 10:23:54 PM', TIMESTAMP '2022-12-25 10:23:54 PM']]" }, };
| }
|
| [Theory]
| [MemberData(nameof(TestCases))]
| public void TestUpdateArrayTimestampIndex(string featureName, string testName, string input, string expectedResult)
| {
| RunGenericTest(featureName, testName, input, expectedResult);
| }
| }
|
| [Trait("Language", "CSharp")]
| [Trait("Category", "DateTime")]
| public class UpdateArrayTimestampIndexTestsCSharp : BaseUpdateArrayTimestampIndexTests
| {
| protected override string FunctionBody => @"
| int[] arrayInteger = index.Cast<int>().ToArray();
| values_array.SetValue(desired, arrayInteger);
| return values_array;
| ";
| protected override LanguageType Language => LanguageType.PlcSharp;
| }
|
|