Skip to content

Commit

Permalink
finish basic property tests for isa profile types
Browse files Browse the repository at this point in the history
  • Loading branch information
kMutagene committed Sep 4, 2024
1 parent 9d526b8 commit 4e91e9d
Show file tree
Hide file tree
Showing 14 changed files with 422 additions and 44 deletions.
1 change: 1 addition & 0 deletions tests/ROCrate/ARCtrl.ROCrate.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="Common.fs" />
<Compile Include="ROCrateObject.Tests.fs" />
<Compile Include="ISAProfile\Dataset.Tests.fs" />
<Compile Include="ISAProfile\Investigation.Tests.fs" />
<Compile Include="ISAProfile\Study.Tests.fs" />
Expand Down
13 changes: 12 additions & 1 deletion tests/ROCrate/ISAProfile/Assay.Tests.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Tests.Assay

open ARCtrl.ROCrate
open DynamicObj

open TestingUtils
open Common
Expand Down Expand Up @@ -51,7 +52,17 @@ let tests_interface_members = testList "interface members" [
testCase "allProperties" <| fun _ -> Expect.ROCrateObjectHasExpectedInterfaceMembers "schema.org/Dataset" "assay_all_properties_id" (Some "Assay") all_properties
]

let tests_dynamic_members = testList "dynamic members" []
let tests_dynamic_members = testSequenced (
testList "dynamic members" [
testCase "property not present before setting" <| fun _ -> Expect.isNone (DynObj.tryGetTypedValue<int> "yes" mandatory_properties) "dynamic property 'yes' was set although it was expected not to be set"
testCase "Set dynamic property" <| fun _ ->
mandatory_properties.SetValue("yes",42)
Expect.ROCrateObjectHasDynamicProperty "yes" 42 mandatory_properties
testCase "Remove dynamic property" <| fun _ ->
mandatory_properties.Remove("yes")
Expect.isNone (DynObj.tryGetTypedValue<int> "yes" mandatory_properties) "dynamic property 'yes' was set although it was expected not to be removed"
]
)

let main = testList "Assay" [
tests_profile_object_is_valid
Expand Down
58 changes: 49 additions & 9 deletions tests/ROCrate/ISAProfile/Data.Tests.fs
Original file line number Diff line number Diff line change
@@ -1,21 +1,61 @@
module Tests.Data

open ARCtrl.ROCrate
open DynamicObj

open TestingUtils
open Common

let mandatory_properties = Data(
id = "data_mandatory_properties_id",
name = "name"
)

let all_properties = Data(
id = "data_all_properties_id",
name = "name",
additionalType = "additionalType",
comment = "comment",
encodingFormat = "encodingFormat",
disambiguatingDescription = "disambiguatingDescription"
)

let tests_profile_object_is_valid = testList "constructed properties" [
testList "mandatory properties" [
testCase "Id" <| fun _ -> Expect.ROCrateObjectHasId "data_mandatory_properties_id" mandatory_properties
testCase "SchemaType" <| fun _ -> Expect.ROCrateObjectHasType "schema.org/MediaObject" mandatory_properties
testCase "name" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "name" "name" all_properties
]
testList "all properties" [
testCase "Id" <| fun _ -> Expect.ROCrateObjectHasId "data_all_properties_id" all_properties
testCase "SchemaType" <| fun _ -> Expect.ROCrateObjectHasType "schema.org/MediaObject" all_properties
testCase "AdditionalType" <| fun _ -> Expect.ROCrateObjectHasAdditionalType "additionalType" all_properties
testCase "name" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "name" "name" all_properties
testCase "comment" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "comment" "comment" all_properties
testCase "encodingFormat" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "encodingFormat" "encodingFormat" all_properties
testCase "disambiguatingDescription" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "disambiguatingDescription" "disambiguatingDescription" all_properties
]
]

let tests_profile_object_is_valid = testList "profile object is valid" []

let tests_static_methods = testList "static methods" []

let tests_interface_members = testList "interface members" []
let tests_interface_members = testList "interface members" [
testCase "mandatoryProperties" <| fun _ -> Expect.ROCrateObjectHasExpectedInterfaceMembers "schema.org/MediaObject" "data_mandatory_properties_id" None mandatory_properties
testCase "allProperties" <| fun _ -> Expect.ROCrateObjectHasExpectedInterfaceMembers "schema.org/MediaObject" "data_all_properties_id" (Some "additionalType") all_properties
]

let tests_dynamic_members = testList "dynamic members" []
let tests_dynamic_members = testSequenced (
testList "dynamic members" [
testCase "property not present before setting" <| fun _ -> Expect.isNone (DynObj.tryGetTypedValue<int> "yes" mandatory_properties) "dynamic property 'yes' was set although it was expected not to be set"
testCase "Set dynamic property" <| fun _ ->
mandatory_properties.SetValue("yes",42)
Expect.ROCrateObjectHasDynamicProperty "yes" 42 mandatory_properties
testCase "Remove dynamic property" <| fun _ ->
mandatory_properties.Remove("yes")
Expect.isNone (DynObj.tryGetTypedValue<int> "yes" mandatory_properties) "dynamic property 'yes' was set although it was expected not to be removed"
]
)

let main = testList "Data" [
tests_profile_object_is_valid
tests_static_methods
tests_interface_members
tests_dynamic_members
]

]
13 changes: 12 additions & 1 deletion tests/ROCrate/ISAProfile/Dataset.Tests.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Tests.Dataset

open ARCtrl.ROCrate
open DynamicObj

open TestingUtils
open Common
Expand All @@ -25,7 +26,17 @@ let tests_interface_members = testList "interface members" [
testCase "allProperties" <| fun _ -> Expect.ROCrateObjectHasExpectedInterfaceMembers "schema.org/Dataset" "dataset_all_properties_id" (Some "additionalType") all_properties
]

let tests_dynamic_members = testList "dynamic members" []
let tests_dynamic_members = testSequenced (
testList "dynamic members" [
testCase "property not present before setting" <| fun _ -> Expect.isNone (DynObj.tryGetTypedValue<int> "yes" mandatory_properties) "dynamic property 'yes' was set although it was expected not to be set"
testCase "Set dynamic property" <| fun _ ->
mandatory_properties.SetValue("yes",42)
Expect.ROCrateObjectHasDynamicProperty "yes" 42 mandatory_properties
testCase "Remove dynamic property" <| fun _ ->
mandatory_properties.Remove("yes")
Expect.isNone (DynObj.tryGetTypedValue<int> "yes" mandatory_properties) "dynamic property 'yes' was set although it was expected not to be removed"
]
)

let main = testList "Dataset" [
tests_profile_object_is_valid
Expand Down
13 changes: 12 additions & 1 deletion tests/ROCrate/ISAProfile/Investigation.Tests.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Tests.Investigation

open ARCtrl.ROCrate
open DynamicObj

open TestingUtils
open Common
Expand Down Expand Up @@ -57,7 +58,17 @@ let tests_interface_members = testList "interface members" [
testCase "allProperties" <| fun _ -> Expect.ROCrateObjectHasExpectedInterfaceMembers "schema.org/Dataset" "investigation_all_properties_id" (Some "Investigation") all_properties
]

let tests_dynamic_members = testList "dynamic members" []
let tests_dynamic_members = testSequenced (
testList "dynamic members" [
testCase "property not present before setting" <| fun _ -> Expect.isNone (DynObj.tryGetTypedValue<int> "yes" mandatory_properties) "dynamic property 'yes' was set although it was expected not to be set"
testCase "Set dynamic property" <| fun _ ->
mandatory_properties.SetValue("yes",42)
Expect.ROCrateObjectHasDynamicProperty "yes" 42 mandatory_properties
testCase "Remove dynamic property" <| fun _ ->
mandatory_properties.Remove("yes")
Expect.isNone (DynObj.tryGetTypedValue<int> "yes" mandatory_properties) "dynamic property 'yes' was set although it was expected not to be removed"
]
)

let main = testList "Investigation" [
tests_profile_object_is_valid
Expand Down
13 changes: 12 additions & 1 deletion tests/ROCrate/ISAProfile/LabProcess.tests.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Tests.LabProcess

open ARCtrl.ROCrate
open DynamicObj

open TestingUtils
open Common
Expand Down Expand Up @@ -56,7 +57,17 @@ let tests_interface_members = testList "interface members" [
testCase "allProperties" <| fun _ -> Expect.ROCrateObjectHasExpectedInterfaceMembers "bioschemas.org/LabProcess" "labprocess_all_properties_id" (Some "additionalType") all_properties
]

let tests_dynamic_members = testList "dynamic members" []
let tests_dynamic_members = testSequenced (
testList "dynamic members" [
testCase "property not present before setting" <| fun _ -> Expect.isNone (DynObj.tryGetTypedValue<int> "yes" mandatory_properties) "dynamic property 'yes' was set although it was expected not to be set"
testCase "Set dynamic property" <| fun _ ->
mandatory_properties.SetValue("yes",42)
Expect.ROCrateObjectHasDynamicProperty "yes" 42 mandatory_properties
testCase "Remove dynamic property" <| fun _ ->
mandatory_properties.Remove("yes")
Expect.isNone (DynObj.tryGetTypedValue<int> "yes" mandatory_properties) "dynamic property 'yes' was set although it was expected not to be removed"
]
)

let main = testList "LabProcess" [
tests_profile_object_is_valid
Expand Down
59 changes: 54 additions & 5 deletions tests/ROCrate/ISAProfile/LabProtocol.Tests.fs
Original file line number Diff line number Diff line change
@@ -1,20 +1,69 @@
module Tests.LabProtocol

open ARCtrl.ROCrate
open DynamicObj

open TestingUtils
open Common

let tests_profile_object_is_valid = testList "profile object is valid" []
let mandatory_properties = LabProtocol(
id = "labprotocol_mandatory_properties_id"
)

let tests_static_methods = testList "static methods" []
let all_properties = LabProtocol(
id = "labprotocol_all_properties_id",
additionalType = "additionalType",
name = "name",
intendedUse = "intendedUse",
description = "description",
url = "url",
comment = "comment",
version = "version",
labEquipment = "labEquipment",
reagent = "reagent",
computationalTool = "computationalTool"
)

let tests_interface_members = testList "interface members" []
let tests_profile_object_is_valid = testList "constructed properties" [
testList "mandatory properties" [
testCase "Id" <| fun _ -> Expect.ROCrateObjectHasId "labprotocol_mandatory_properties_id" mandatory_properties
testCase "SchemaType" <| fun _ -> Expect.ROCrateObjectHasType "bioschemas.org/LabProtocol" mandatory_properties
]
testList "all properties" [
testCase "Id" <| fun _ -> Expect.ROCrateObjectHasId "labprotocol_all_properties_id" all_properties
testCase "SchemaType" <| fun _ -> Expect.ROCrateObjectHasType "bioschemas.org/LabProtocol" all_properties
testCase "AdditionalType" <| fun _ -> Expect.ROCrateObjectHasAdditionalType "additionalType" all_properties
testCase "name" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "name" "name" all_properties
testCase "intendedUse" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "intendedUse" "intendedUse" all_properties
testCase "description" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "description" "description" all_properties
testCase "url" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "url" "url" all_properties
testCase "comment" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "comment" "comment" all_properties
testCase "version" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "version" "version" all_properties
testCase "labEquipment" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "labEquipment" "labEquipment" all_properties
testCase "reagent" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "reagent" "reagent" all_properties
testCase "computationalTool" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "computationalTool" "computationalTool" all_properties
]
]

let tests_dynamic_members = testList "dynamic members" []
let tests_interface_members = testList "interface members" [
testCase "mandatoryProperties" <| fun _ -> Expect.ROCrateObjectHasExpectedInterfaceMembers "bioschemas.org/LabProtocol" "labprotocol_mandatory_properties_id" None mandatory_properties
testCase "allProperties" <| fun _ -> Expect.ROCrateObjectHasExpectedInterfaceMembers "bioschemas.org/LabProtocol" "labprotocol_all_properties_id" (Some "additionalType") all_properties
]

let tests_dynamic_members = testSequenced (
testList "dynamic members" [
testCase "property not present before setting" <| fun _ -> Expect.isNone (DynObj.tryGetTypedValue<int> "yes" mandatory_properties) "dynamic property 'yes' was set although it was expected not to be set"
testCase "Set dynamic property" <| fun _ ->
mandatory_properties.SetValue("yes",42)
Expect.ROCrateObjectHasDynamicProperty "yes" 42 mandatory_properties
testCase "Remove dynamic property" <| fun _ ->
mandatory_properties.Remove("yes")
Expect.isNone (DynObj.tryGetTypedValue<int> "yes" mandatory_properties) "dynamic property 'yes' was set although it was expected not to be removed"
]
)

let main = testList "LabProtocol" [
tests_profile_object_is_valid
tests_static_methods
tests_interface_members
tests_dynamic_members
]
67 changes: 61 additions & 6 deletions tests/ROCrate/ISAProfile/Person.Tests.fs
Original file line number Diff line number Diff line change
@@ -1,20 +1,75 @@
module Tests.Person

open ARCtrl.ROCrate
open DynamicObj

open TestingUtils
open Common

let tests_profile_object_is_valid = testList "profile object is valid" []
let mandatory_properties = Person(
id = "person_mandatory_properties_id",
givenName = "givenName"
)

let tests_static_methods = testList "static methods" []
let all_properties = Person(
id = "person_all_properties_id",
givenName = "givenName",
additionalType = "additionalType",
familyName = "familyName",
email = "email",
identifier = "identifier",
affiliation = "affiliation",
jobTitle = "jobTitle",
additionalName = "additionalName",
address = "address",
telephone = "telephone",
faxNumber = "faxNumber",
disambiguatingDescription = "disambiguatingDescription"
)

let tests_interface_members = testList "interface members" []
let tests_profile_object_is_valid = testList "constructed properties" [
testList "mandatory properties" [
testCase "Id" <| fun _ -> Expect.ROCrateObjectHasId "person_mandatory_properties_id" mandatory_properties
testCase "SchemaType" <| fun _ -> Expect.ROCrateObjectHasType "schema.org/Person" mandatory_properties
testCase "givenName" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "givenName" "givenName" all_properties
]
testList "all properties" [
testCase "Id" <| fun _ -> Expect.ROCrateObjectHasId "person_mandatory_properties_id" mandatory_properties
testCase "SchemaType" <| fun _ -> Expect.ROCrateObjectHasType "schema.org/Person" mandatory_properties
testCase "AdditionalType" <| fun _ -> Expect.ROCrateObjectHasAdditionalType "additionalType" all_properties
testCase "givenName" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "givenName" "givenName" all_properties
testCase "familyName" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "familyName" "familyName" all_properties
testCase "email" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "email" "email" all_properties
testCase "identifier" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "identifier" "identifier" all_properties
testCase "affiliation" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "affiliation" "affiliation" all_properties
testCase "jobTitle" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "jobTitle" "jobTitle" all_properties
testCase "additionalName" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "additionalName" "additionalName" all_properties
testCase "address" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "address" "address" all_properties
testCase "telephone" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "telephone" "telephone" all_properties
testCase "faxNumber" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "faxNumber" "faxNumber" all_properties
testCase "disambiguatingDescription" <| fun _ -> Expect.ROCrateObjectHasDynamicProperty "disambiguatingDescription" "disambiguatingDescription" all_properties
]
]

let tests_interface_members = testList "interface members" [
testCase "mandatoryProperties" <| fun _ -> Expect.ROCrateObjectHasExpectedInterfaceMembers "schema.org/Person" "person_mandatory_properties_id" None mandatory_properties
testCase "allProperties" <| fun _ -> Expect.ROCrateObjectHasExpectedInterfaceMembers "schema.org/Person" "person_all_properties_id" (Some "additionalType") all_properties
]

let tests_dynamic_members = testList "dynamic members" []
let tests_dynamic_members = testSequenced (
testList "dynamic members" [
testCase "property not present before setting" <| fun _ -> Expect.isNone (DynObj.tryGetTypedValue<int> "yes" mandatory_properties) "dynamic property 'yes' was set although it was expected not to be set"
testCase "Set dynamic property" <| fun _ ->
mandatory_properties.SetValue("yes",42)
Expect.ROCrateObjectHasDynamicProperty "yes" 42 mandatory_properties
testCase "Remove dynamic property" <| fun _ ->
mandatory_properties.Remove("yes")
Expect.isNone (DynObj.tryGetTypedValue<int> "yes" mandatory_properties) "dynamic property 'yes' was set although it was expected not to be removed"
]
)

let main = testList "Person" [
tests_profile_object_is_valid
tests_static_methods
tests_interface_members
tests_dynamic_members
]
]
Loading

0 comments on commit 4e91e9d

Please sign in to comment.