-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNodeUtils.Tests.fs
More file actions
64 lines (55 loc) · 1.55 KB
/
NodeUtils.Tests.fs
File metadata and controls
64 lines (55 loc) · 1.55 KB
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
56
57
58
59
60
61
62
63
64
module OpenDiffix.Core.NodeUtilsTests
open Xunit
open FsUnit.Xunit
open AnalyzerTypes
let testTable: Table =
{
Name = "table"
Columns =
[
{ Name = "str_col"; Type = StringType }
{ Name = "int_col"; Type = IntegerType }
{ Name = "float_col"; Type = RealType }
{ Name = "bool_col"; Type = BooleanType }
]
}
let expression = Boolean true |> Constant
let negativeExpression = Boolean false |> Constant
let anonContext =
{
BucketSeed = 0UL
BaseLabels = []
AnonymizationParams = AnonymizationParams.Default
}
let selectQuery =
{
TargetList = [ { Expression = expression; Alias = "col"; Tag = RegularTargetEntry } ]
Where = expression
From = RangeTable(testTable, testTable.Name)
GroupBy = [ expression ]
Having = expression
OrderBy = [ OrderBy(expression, Ascending, NullsFirst) ]
Limit = None
AnonymizationContext = Some anonContext
}
let selectQueryNegative =
{
TargetList = [ { Expression = negativeExpression; Alias = "col"; Tag = RegularTargetEntry } ]
Where = negativeExpression
From = RangeTable(testTable, testTable.Name)
GroupBy = [ negativeExpression ]
Having = negativeExpression
OrderBy = [ OrderBy(negativeExpression, Ascending, NullsFirst) ]
Limit = None
AnonymizationContext = Some anonContext
}
[<Fact>]
let ``Map expressions`` () =
let data =
selectQuery
|> NodeUtils.map (
function
| Constant(Boolean true) -> Constant(Boolean false)
| other -> other
)
should equal selectQueryNegative data