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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
| using System;
| using System.Collections.Generic;
| using System.Net.NetworkInformation;
| using Xunit;
| using System.Linq;
|
| public abstract class BaseModifyTimestampArrayFsharpTests : PlDotNetTest
| {
| protected abstract string FunctionBody { get; }
|
| protected abstract LanguageType Language { get; }
|
| public BaseModifyTimestampArrayFsharpTests()
| {
| FunctionInfo = new SqlFunctionInfo { Name = "ModifyTimestampArrayFsharp", Arguments = new List<FunctionArgument> { new FunctionArgument("a", "TIMESTAMP[]"), new FunctionArgument("b", "TIMESTAMP") }, ReturnType = "TIMESTAMP[]", Body = FunctionBody, Language = Language, IsStrict = false, };
| }
|
| public static object[][] TestCases()
| {
| return new object[][] { new object[] { "f#-timestamp-1array-null", "modifyTimestampArrayFSharp1", "ARRAY['2004-12-19 10:23:54 PM'::TIMESTAMP, '2020-10-19 10:23:54 PM'::TIMESTAMP, NULL::TIMESTAMP, '2022-12-25 10:23:54 PM'::TIMESTAMP], NULL::TIMESTAMP", "= ARRAY['2022-11-15 13:23:45'::TIMESTAMP, '2020-10-19 10:23:54 PM'::TIMESTAMP, NULL::TIMESTAMP, '2022-12-25 10:23:54 PM'::TIMESTAMP]" }, new object[] { "f#-timestamp-1array-null", "modifyTimestampArrayFSharp2", "ARRAY['2004-12-19 10:23:54 PM'::TIMESTAMP, '2020-10-19 10:23:54 PM'::TIMESTAMP, NULL::TIMESTAMP, '2022-12-25 10:23:54 PM'::TIMESTAMP], '2023-01-01 12:12:12 PM'::TIMESTAMP", "= ARRAY['2023-01-01 12:12:12 PM'::TIMESTAMP, '2020-10-19 10:23:54 PM'::TIMESTAMP, NULL::TIMESTAMP, '2022-12-25 10:23:54 PM'::TIMESTAMP]" }, new object[] { "f#-timestamp-2array-null", "modifyTimestampArrayFSharp3", "ARRAY[['2004-12-19 10:23:54 PM'::TIMESTAMP, '2020-10-19 10:23:54 PM'::TIMESTAMP], [NULL::TIMESTAMP, '2022-12-25 10:23:54 PM'::TIMESTAMP]], '2023-01-01 12:12:12 PM'::TIMESTAMP", "= ARRAY[['2023-01-01 12:12:12 PM'::TIMESTAMP, '2020-10-19 10:23:54 PM'::TIMESTAMP], [NULL::TIMESTAMP, '2022-12-25 10:23:54 PM'::TIMESTAMP]]" }, new object[] { "f#-timestamp-2array-null", "modifyTimestampArrayFSharp4", "ARRAY[[NULL::TIMESTAMP, NULL::TIMESTAMP], [NULL::TIMESTAMP, NULL::TIMESTAMP]], '2023-01-01 12:12:12 PM'::TIMESTAMP", "= ARRAY[['2023-01-01 12:12:12 PM'::TIMESTAMP, NULL::TIMESTAMP], [NULL::TIMESTAMP, NULL::TIMESTAMP]]" }, };
| }
|
| [Theory]
| [MemberData(nameof(TestCases))]
| public void TestModifyTimestampArrayFsharp(string featureName, string testName, string input, string expectedResult)
| {
| RunGenericTest(featureName, testName, input, expectedResult);
| }
| }
|
| [Trait("Language", "FSharp")]
| [Trait("Category", "Date")]
| public class ModifyTimestampArrayFsharpTestsFSharp : BaseModifyTimestampArrayFsharpTests
| {
| protected override string FunctionBody => @"
| #line 1
| let dim = a.Rank
| let newValue =
| match b.HasValue with
| | true -> b.Value
| | false -> new DateTime(2022, 11, 15, 13, 23, 45)
| match dim with
| | 1 ->
| a.SetValue(newValue, 0) |> ignore
| a
| | 2 ->
| a.SetValue(newValue, 0, 0) |> ignore
| a
| | 3 ->
| a.SetValue(newValue, 0, 0, 0) |> ignore
| a
| | _ -> a
| ";
| protected override LanguageType Language => LanguageType.PlfSharp;
| }
|
|