Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArcInvestigation writer fix #230

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ISA/ISA.Spreadsheet/ArcInvestigation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ module ArcInvestigation =
yield SparseRow.fromValues [contactsLabel]
yield! Contacts.toRows (Some contactsLabelPrefix) (List.ofArray investigation.Contacts)

for study in (List.ofSeq investigation.Studies) do
for study in investigation.RegisteredStudies do
yield SparseRow.fromValues [studyLabel]
yield! Studies.toRows study None
}
Expand Down
14 changes: 14 additions & 0 deletions tests/ISA/ISA.Json.Tests/Json.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,20 @@ let testInvestigationFile =

Expect.equal i.Remarks List.empty "Remark list should be an empty list."
)
testCase "OnlyConsiderRegisteredStudies" (fun () ->
let isa = ArcInvestigation("MyInvestigation")
let registeredStudyIdentifier = "RegisteredStudy"
let registeredStudy = ArcStudy(registeredStudyIdentifier)
let unregisteredStudyIdentifier = "UnregisteredStudy"
let unregisteredStudy = ArcStudy(unregisteredStudyIdentifier)

isa.AddStudy(unregisteredStudy)
isa.AddRegisteredStudy(registeredStudy)

let result = ArcInvestigation.toJsonString isa |> ArcInvestigation.fromJsonString

Expect.sequenceEqual result.RegisteredStudyIdentifiers [registeredStudyIdentifier] "Only the registered study should be written and read"
)
testCase "FullInvestigation" (fun () ->

let comment =
Expand Down
14 changes: 14 additions & 0 deletions tests/ISA/ISA.Spreadsheet.Tests/InvestigationFileTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ let private testInvestigationWriterComponents =
wb.AddWorksheet(sheet)
Expect.isSome (wb.TryGetWorksheetByName "Investigation") "Worksheet should be added to workbook"
)
testCase "OnlyConsiderRegisteredStudies" (fun () ->
let isa = ArcInvestigation("MyInvestigation")
let registeredStudyIdentifier = "RegisteredStudy"
let registeredStudy = ArcStudy(registeredStudyIdentifier)
let unregisteredStudyIdentifier = "UnregisteredStudy"
let unregisteredStudy = ArcStudy(unregisteredStudyIdentifier)

isa.AddStudy(unregisteredStudy)
isa.AddRegisteredStudy(registeredStudy)

let result = ArcInvestigation.toFsWorkbook isa |> ArcInvestigation.fromFsWorkbook

Expect.sequenceEqual result.RegisteredStudyIdentifiers [registeredStudyIdentifier] "Only the registered study should be written and read"
)



Expand Down