Skip to content

Commit 869d6e0

Browse files
committed
Add unit tests
1 parent a6adeb9 commit 869d6e0

6 files changed

Lines changed: 45 additions & 48 deletions

File tree

src/ARCtrl/ARCtrl.Javascript.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<Compile Include="JsonIO\OntologySourceReference.fs" />
1919
<Compile Include="JsonIO\DataFile.fs" />
2020
<Compile Include="JsonIO\Data.fs" />
21+
<Compile Include="JsonIO\Datamap.fs" />
2122
<Compile Include="JsonIO\Person.fs" />
2223
<Compile Include="JsonIO\Publication.fs" />
2324
<Compile Include="JsonIO\Process\Value.fs" />

src/ARCtrl/ARCtrl.Python.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<Compile Include="JsonIO\OntologySourceReference.fs" />
2121
<Compile Include="JsonIO\DataFile.fs" />
2222
<Compile Include="JsonIO\Data.fs" />
23+
<Compile Include="JsonIO\Datamap.fs" />
2324
<Compile Include="JsonIO\Person.fs" />
2425
<Compile Include="JsonIO\Publication.fs" />
2526
<Compile Include="JsonIO\Process\Value.fs" />

src/ARCtrl/ARCtrl.fsproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
<Compile Include="JsonIO\Table\CompositeHeader.fs" />
4545
<Compile Include="JsonIO\Table\ArcTable.fs" />
4646
<Compile Include="JsonIO\Table\Templates.fs" />
47-
<Compile Include="JsonIO\DataMap\DataMap.fs" />
4847
<Compile Include="JsonIO\Assay.fs" />
4948
<Compile Include="JsonIO\Study.fs" />
5049
<Compile Include="JsonIO\Investigation.fs" />

src/ARCtrl/JsonIO/DataMap/DataMap.fs

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/ARCtrl/JsonIO/Datamap.fs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ module DatamapExtensions =
1919
member this.ToJsonString(?spaces) =
2020
DataMap.toJsonString(?spaces=spaces) this
2121

22-
static member fromCompressedJsonString (s: string) =
23-
try Decode.fromJsonString (Compression.decode DataMap.decoderCompressed) s with
24-
| e -> failwithf "Error. Unable to parse json string to Datamap: %s" e.Message
22+
//static member fromCompressedJsonString (s: string) =
23+
// try Decode.fromJsonString (Compression.decode DataMap.decoderCompressed) s with
24+
// | e -> failwithf "Error. Unable to parse json string to Datamap: %s" e.Message
2525

26-
static member toCompressedJsonString(?spaces) =
27-
fun (obj:DataMap) ->
28-
let spaces = defaultArg spaces 0
29-
Encode.toJsonString spaces (Compression.encode DataMap.encoderCompressed obj)
26+
//static member toCompressedJsonString(?spaces) =
27+
// fun (obj:DataMap) ->
28+
// let spaces = defaultArg spaces 0
29+
// Encode.toJsonString spaces (Compression.encode DataMap.encoderCompressed obj)
3030

31-
member this.ToCompressedJsonString(?spaces) =
32-
DataMap.toCompressedJsonString(?spaces=spaces) this
31+
//member this.ToCompressedJsonString(?spaces) =
32+
// DataMap.toCompressedJsonString(?spaces=spaces) this

tests/Json/DataMap.Tests.fs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,42 @@ module Helper =
2121
"Kevin F",
2222
(ResizeArray [Comment.create("Hello", "World")])
2323
)
24+
2425
let create_filled() =
2526
DataMap(ResizeArray [
2627
for i in 1 .. 3 do
2728
create_Datacontext i
2829
])
30+
31+
let compare =
32+
fun (d1: DataMap) (d2: DataMap) ->
33+
let d1DataContexts =
34+
d1.DataContexts
35+
|> Array.ofSeq
36+
let d2DataContexts =
37+
d2.DataContexts
38+
|> Array.ofSeq
39+
40+
Expect.equal d1DataContexts.Length d2DataContexts.Length "Datamap Länge"
41+
42+
for i in 0..d1DataContexts.Length - 1 do
43+
44+
Expect.equal d1DataContexts.[i] d2DataContexts.[i] $"Datamap is not equal on {i}"
45+
46+
Expect.sequenceEqual d1.DataContexts d2.DataContexts "DataContexts"
47+
|> Some
48+
49+
open Helper
50+
51+
let private test_datamapJsonTesting =
52+
createBaseJsonTests
53+
"datamap-json"
54+
create_filled
55+
DataMap.toJsonString
56+
DataMap.fromJsonString
57+
None
58+
compare
59+
60+
let main = testList "Datamap" [
61+
test_datamapJsonTesting
62+
]

0 commit comments

Comments
 (0)