@@ -65,6 +65,70 @@ let private simpleTable =
6565 )
6666 ]
6767
68+ let private commentTable =
69+ testList " commentTable" [
70+ let wsName = " isa_datamap"
71+ let ws =
72+ initWorksheet wsName
73+ [
74+ Data.appendDataColumn 1
75+ Explication.appendMeanColumn 1
76+ Unit.appendPPMColumn 1
77+ ObjectType.appendFloatColumn 1
78+ Description.appendDescriptionColumn 1
79+ GeneratedBy.appendGeneratedByColumn 1
80+ Label.appendLabelColumn 1
81+ Comment.appendCommentColumn 1
82+ ]
83+ testCase " Read" ( fun () ->
84+
85+ let table = DataMapTable.tryFromFsWorksheet ws
86+
87+ Expect.isSome table " Table was not created"
88+ let table = table.Value
89+
90+ Expect.equal table.DataContexts.Count 1 " Wrong number of rows"
91+
92+ let dc = table.GetDataContext( 0 )
93+
94+ let expectedComment = Comment( Comment.commentHeader, Comment.commentValue)
95+ let expectedData = Data.dataValue.Copy()
96+ expectedData.Comments <- ResizeArray [| expectedComment |]
97+
98+ Expect.equal ( dc.AsData()) expectedData " Data did not match"
99+
100+ let explication = Expect.wantSome dc.Explication " Explication was not set"
101+ Expect.equal explication Explication.meanValue " Explication did not match"
102+
103+ let unit = Expect.wantSome dc.Unit " Unit was not set"
104+ Expect.equal unit Unit.ppmValue " Unit did not match"
105+
106+ let objectType = Expect.wantSome dc.ObjectType " ObjectType was not set"
107+ Expect.equal objectType ObjectType.floatValue " ObjectType did not match"
108+
109+ let description = Expect.wantSome dc.Description " Description was not set"
110+ Expect.equal description Description.descriptionValue " Description did not match"
111+
112+ let generatedBy = Expect.wantSome dc.GeneratedBy " GeneratedBy was not set"
113+ Expect.equal generatedBy GeneratedBy.generatedByValue " GeneratedBy did not match"
114+
115+ let label = Expect.wantSome dc.Label " Label was not set"
116+ Expect.equal label Label.labelValue " Label did not match"
117+
118+ Expect.hasLength dc.Comments 1 " Comments should have one entry"
119+ let comment = dc.Comments.[ 0 ]
120+ Expect.equal comment.Name ( Some Comment.commentHeader) " Comment key did not match"
121+ Expect.equal comment.Value ( Some Comment.commentValue) " Comment value did not match"
122+ )
123+ testCase " Write" ( fun () ->
124+ let table = DataMapTable.tryFromFsWorksheet ws
125+ Expect.isSome table " Table was not created"
126+ let out = DataMapTable.toFsWorksheet table.Value
127+ Expect.workSheetEqual out ws " Worksheet was not correctly written"
128+
129+ )
130+ ]
131+
68132let private valuelessTable =
69133 testList " valuelessTable" [
70134 let wsName = " isa_datamap"
@@ -188,6 +252,7 @@ let private emptyDatamap =
188252let main =
189253 testList " DataMapTableTests" [
190254 simpleTable
255+ commentTable
191256 valuelessTable
192257 emptyTable
193258 simpleFile
0 commit comments