From ac7e6d28bd037573f4b7d1ef78e82893aa704f34 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Fri, 6 Sep 2024 15:25:04 +0200 Subject: [PATCH] Add '@context' support: - instance methods and static methods for set/tryGet/remove - tests for all classes --- src/ROCrate/ROCrateObject.fs | 18 ++++++++- tests/ROCrate/ISAProfile/Assay.Tests.fs | 38 +++++++++++++++++++ tests/ROCrate/ISAProfile/Data.Tests.fs | 38 +++++++++++++++++++ tests/ROCrate/ISAProfile/Dataset.Tests.fs | 38 +++++++++++++++++++ .../ROCrate/ISAProfile/Investigation.Tests.fs | 38 +++++++++++++++++++ tests/ROCrate/ISAProfile/LabProcess.tests.fs | 38 +++++++++++++++++++ tests/ROCrate/ISAProfile/LabProtocol.Tests.fs | 38 +++++++++++++++++++ tests/ROCrate/ISAProfile/Person.Tests.fs | 38 +++++++++++++++++++ .../ROCrate/ISAProfile/PropertyValue.Tests.fs | 38 +++++++++++++++++++ tests/ROCrate/ISAProfile/Sample.tests.fs | 38 +++++++++++++++++++ .../ISAProfile/ScholarlyArticle.Tests.fs | 38 +++++++++++++++++++ tests/ROCrate/ISAProfile/Study.Tests.fs | 38 +++++++++++++++++++ tests/ROCrate/ROCrateObject.Tests.fs | 38 +++++++++++++++++++ 13 files changed, 473 insertions(+), 1 deletion(-) diff --git a/src/ROCrate/ROCrateObject.fs b/src/ROCrate/ROCrateObject.fs index 30b30108..6f1acc95 100644 --- a/src/ROCrate/ROCrateObject.fs +++ b/src/ROCrate/ROCrateObject.fs @@ -37,4 +37,20 @@ type ROCrateObject(id:string, schemaType: string, ?additionalType) = member this.AdditionalType with get() = _additionalType - and set(value) = _additionalType <- value \ No newline at end of file + and set(value) = _additionalType <- value + + member this.SetContext (context: #DynamicObj) = + this.SetValue("@context", context) + + static member setContext (context: #DynamicObj) = + fun (roc: #ROCrateObject) -> roc.SetContext(context) + + member this.TryGetContext() = + DynObj.tryGetTypedValue("@context") this + + static member tryGetContext (roc: #ROCrateObject) = roc.TryGetContext() + + member this.RemoveContext() = + this.Remove("@context") + + static member removeContext (roc: #ROCrateObject) = roc.RemoveContext() \ No newline at end of file diff --git a/tests/ROCrate/ISAProfile/Assay.Tests.fs b/tests/ROCrate/ISAProfile/Assay.Tests.fs index d32fafd8..717b6f72 100644 --- a/tests/ROCrate/ISAProfile/Assay.Tests.fs +++ b/tests/ROCrate/ISAProfile/Assay.Tests.fs @@ -64,8 +64,46 @@ let tests_dynamic_members = testSequenced ( ] ) +let tests_instance_methods = testSequenced ( + testList "instance methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + mandatory_properties.SetContext context + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = mandatory_properties.TryGetContext() + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + mandatory_properties.RemoveContext() + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + +let tests_static_methods = testSequenced ( + testList "static methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + ROCrateObject.setContext context mandatory_properties + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = ROCrateObject.tryGetContext mandatory_properties + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + ROCrateObject.removeContext mandatory_properties + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + let main = testList "Assay" [ tests_profile_object_is_valid tests_interface_members tests_dynamic_members + tests_instance_methods + tests_static_methods ] \ No newline at end of file diff --git a/tests/ROCrate/ISAProfile/Data.Tests.fs b/tests/ROCrate/ISAProfile/Data.Tests.fs index 79d12cdb..ad8f058e 100644 --- a/tests/ROCrate/ISAProfile/Data.Tests.fs +++ b/tests/ROCrate/ISAProfile/Data.Tests.fs @@ -54,8 +54,46 @@ let tests_dynamic_members = testSequenced ( ] ) +let tests_instance_methods = testSequenced ( + testList "instance methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + mandatory_properties.SetContext context + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = mandatory_properties.TryGetContext() + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + mandatory_properties.RemoveContext() + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + +let tests_static_methods = testSequenced ( + testList "static methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + ROCrateObject.setContext context mandatory_properties + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = ROCrateObject.tryGetContext mandatory_properties + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + ROCrateObject.removeContext mandatory_properties + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + let main = testList "Data" [ tests_profile_object_is_valid tests_interface_members tests_dynamic_members + tests_instance_methods + tests_static_methods ] \ No newline at end of file diff --git a/tests/ROCrate/ISAProfile/Dataset.Tests.fs b/tests/ROCrate/ISAProfile/Dataset.Tests.fs index a6619d0a..0bd1a513 100644 --- a/tests/ROCrate/ISAProfile/Dataset.Tests.fs +++ b/tests/ROCrate/ISAProfile/Dataset.Tests.fs @@ -38,8 +38,46 @@ let tests_dynamic_members = testSequenced ( ] ) +let tests_instance_methods = testSequenced ( + testList "instance methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + mandatory_properties.SetContext context + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = mandatory_properties.TryGetContext() + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + mandatory_properties.RemoveContext() + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + +let tests_static_methods = testSequenced ( + testList "static methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + ROCrateObject.setContext context mandatory_properties + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = ROCrateObject.tryGetContext mandatory_properties + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + ROCrateObject.removeContext mandatory_properties + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + let main = testList "Dataset" [ tests_profile_object_is_valid tests_interface_members tests_dynamic_members + tests_instance_methods + tests_static_methods ] \ No newline at end of file diff --git a/tests/ROCrate/ISAProfile/Investigation.Tests.fs b/tests/ROCrate/ISAProfile/Investigation.Tests.fs index 1e0d15de..68a09d4c 100644 --- a/tests/ROCrate/ISAProfile/Investigation.Tests.fs +++ b/tests/ROCrate/ISAProfile/Investigation.Tests.fs @@ -70,8 +70,46 @@ let tests_dynamic_members = testSequenced ( ] ) +let tests_instance_methods = testSequenced ( + testList "instance methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + mandatory_properties.SetContext context + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = mandatory_properties.TryGetContext() + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + mandatory_properties.RemoveContext() + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + +let tests_static_methods = testSequenced ( + testList "static methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + ROCrateObject.setContext context mandatory_properties + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = ROCrateObject.tryGetContext mandatory_properties + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + ROCrateObject.removeContext mandatory_properties + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + let main = testList "Investigation" [ tests_profile_object_is_valid tests_interface_members tests_dynamic_members + tests_instance_methods + tests_static_methods ] \ No newline at end of file diff --git a/tests/ROCrate/ISAProfile/LabProcess.tests.fs b/tests/ROCrate/ISAProfile/LabProcess.tests.fs index a713a077..e68b2410 100644 --- a/tests/ROCrate/ISAProfile/LabProcess.tests.fs +++ b/tests/ROCrate/ISAProfile/LabProcess.tests.fs @@ -69,8 +69,46 @@ let tests_dynamic_members = testSequenced ( ] ) +let tests_instance_methods = testSequenced ( + testList "instance methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + mandatory_properties.SetContext context + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = mandatory_properties.TryGetContext() + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + mandatory_properties.RemoveContext() + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + +let tests_static_methods = testSequenced ( + testList "static methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + ROCrateObject.setContext context mandatory_properties + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = ROCrateObject.tryGetContext mandatory_properties + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + ROCrateObject.removeContext mandatory_properties + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + let main = testList "LabProcess" [ tests_profile_object_is_valid tests_interface_members tests_dynamic_members + tests_instance_methods + tests_static_methods ] \ No newline at end of file diff --git a/tests/ROCrate/ISAProfile/LabProtocol.Tests.fs b/tests/ROCrate/ISAProfile/LabProtocol.Tests.fs index 3e88ea43..2829c9e4 100644 --- a/tests/ROCrate/ISAProfile/LabProtocol.Tests.fs +++ b/tests/ROCrate/ISAProfile/LabProtocol.Tests.fs @@ -62,8 +62,46 @@ let tests_dynamic_members = testSequenced ( ] ) +let tests_instance_methods = testSequenced ( + testList "instance methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + mandatory_properties.SetContext context + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = mandatory_properties.TryGetContext() + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + mandatory_properties.RemoveContext() + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + +let tests_static_methods = testSequenced ( + testList "static methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + ROCrateObject.setContext context mandatory_properties + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = ROCrateObject.tryGetContext mandatory_properties + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + ROCrateObject.removeContext mandatory_properties + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + let main = testList "LabProtocol" [ tests_profile_object_is_valid tests_interface_members tests_dynamic_members + tests_instance_methods + tests_static_methods ] \ No newline at end of file diff --git a/tests/ROCrate/ISAProfile/Person.Tests.fs b/tests/ROCrate/ISAProfile/Person.Tests.fs index cf72916c..28c16389 100644 --- a/tests/ROCrate/ISAProfile/Person.Tests.fs +++ b/tests/ROCrate/ISAProfile/Person.Tests.fs @@ -68,8 +68,46 @@ let tests_dynamic_members = testSequenced ( ] ) +let tests_instance_methods = testSequenced ( + testList "instance methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + mandatory_properties.SetContext context + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = mandatory_properties.TryGetContext() + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + mandatory_properties.RemoveContext() + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + +let tests_static_methods = testSequenced ( + testList "static methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + ROCrateObject.setContext context mandatory_properties + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = ROCrateObject.tryGetContext mandatory_properties + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + ROCrateObject.removeContext mandatory_properties + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + let main = testList "Person" [ tests_profile_object_is_valid tests_interface_members tests_dynamic_members + tests_instance_methods + tests_static_methods ] \ No newline at end of file diff --git a/tests/ROCrate/ISAProfile/PropertyValue.Tests.fs b/tests/ROCrate/ISAProfile/PropertyValue.Tests.fs index 6ca0eebe..bbed3900 100644 --- a/tests/ROCrate/ISAProfile/PropertyValue.Tests.fs +++ b/tests/ROCrate/ISAProfile/PropertyValue.Tests.fs @@ -60,8 +60,46 @@ let tests_dynamic_members = testSequenced ( ] ) +let tests_instance_methods = testSequenced ( + testList "instance methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + mandatory_properties.SetContext context + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = mandatory_properties.TryGetContext() + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + mandatory_properties.RemoveContext() + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + +let tests_static_methods = testSequenced ( + testList "static methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + ROCrateObject.setContext context mandatory_properties + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = ROCrateObject.tryGetContext mandatory_properties + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + ROCrateObject.removeContext mandatory_properties + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + let main = testList "PropertyValue" [ tests_profile_object_is_valid tests_interface_members tests_dynamic_members + tests_instance_methods + tests_static_methods ] \ No newline at end of file diff --git a/tests/ROCrate/ISAProfile/Sample.tests.fs b/tests/ROCrate/ISAProfile/Sample.tests.fs index bcc5b025..ad62735e 100644 --- a/tests/ROCrate/ISAProfile/Sample.tests.fs +++ b/tests/ROCrate/ISAProfile/Sample.tests.fs @@ -52,8 +52,46 @@ let tests_dynamic_members = testSequenced ( ] ) +let tests_instance_methods = testSequenced ( + testList "instance methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + mandatory_properties.SetContext context + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = mandatory_properties.TryGetContext() + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + mandatory_properties.RemoveContext() + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + +let tests_static_methods = testSequenced ( + testList "static methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + ROCrateObject.setContext context mandatory_properties + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = ROCrateObject.tryGetContext mandatory_properties + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + ROCrateObject.removeContext mandatory_properties + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + let main = testList "Sample" [ tests_profile_object_is_valid tests_interface_members tests_dynamic_members + tests_instance_methods + tests_static_methods ] \ No newline at end of file diff --git a/tests/ROCrate/ISAProfile/ScholarlyArticle.Tests.fs b/tests/ROCrate/ISAProfile/ScholarlyArticle.Tests.fs index ba498f3d..5c8e6bdd 100644 --- a/tests/ROCrate/ISAProfile/ScholarlyArticle.Tests.fs +++ b/tests/ROCrate/ISAProfile/ScholarlyArticle.Tests.fs @@ -60,8 +60,46 @@ let tests_dynamic_members = testSequenced ( ] ) +let tests_instance_methods = testSequenced ( + testList "instance methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + mandatory_properties.SetContext context + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = mandatory_properties.TryGetContext() + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + mandatory_properties.RemoveContext() + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + +let tests_static_methods = testSequenced ( + testList "static methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + ROCrateObject.setContext context mandatory_properties + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = ROCrateObject.tryGetContext mandatory_properties + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + ROCrateObject.removeContext mandatory_properties + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + let main = testList "ScholarlyArticle" [ tests_profile_object_is_valid tests_interface_members tests_dynamic_members + tests_instance_methods + tests_static_methods ] \ No newline at end of file diff --git a/tests/ROCrate/ISAProfile/Study.Tests.fs b/tests/ROCrate/ISAProfile/Study.Tests.fs index 05151e08..a2e8515e 100644 --- a/tests/ROCrate/ISAProfile/Study.Tests.fs +++ b/tests/ROCrate/ISAProfile/Study.Tests.fs @@ -70,8 +70,46 @@ let tests_dynamic_members = testSequenced ( ] ) +let tests_instance_methods = testSequenced ( + testList "instance methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + mandatory_properties.SetContext context + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = mandatory_properties.TryGetContext() + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + mandatory_properties.RemoveContext() + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + +let tests_static_methods = testSequenced ( + testList "static methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + ROCrateObject.setContext context mandatory_properties + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = ROCrateObject.tryGetContext mandatory_properties + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + ROCrateObject.removeContext mandatory_properties + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + let main = testList "Study" [ tests_profile_object_is_valid tests_interface_members tests_dynamic_members + tests_instance_methods + tests_static_methods ] \ No newline at end of file diff --git a/tests/ROCrate/ROCrateObject.Tests.fs b/tests/ROCrate/ROCrateObject.Tests.fs index 6d2b0e5f..b85e8514 100644 --- a/tests/ROCrate/ROCrateObject.Tests.fs +++ b/tests/ROCrate/ROCrateObject.Tests.fs @@ -38,8 +38,46 @@ let tests_dynamic_members = testSequenced ( ] ) +let tests_instance_methods = testSequenced ( + testList "instance methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + mandatory_properties.SetContext context + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = mandatory_properties.TryGetContext() + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + mandatory_properties.RemoveContext() + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + +let tests_static_methods = testSequenced ( + testList "static methods" [ + + let context = new DynamicObj() + context.SetValue("more", "context") + + testCase "can set context" <| fun _ -> + ROCrateObject.setContext context mandatory_properties + Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties + testCase "can get context" <| fun _ -> + let ctx = ROCrateObject.tryGetContext mandatory_properties + Expect.equal ctx (Some context) "context was not set correctly" + testCase "can remove context" <| fun _ -> + ROCrateObject.removeContext mandatory_properties + Expect.isNone (DynObj.tryGetTypedValue "@context" mandatory_properties) "context was not removed correctly" + ] +) + let main = testList "ROCrateObject" [ tests_profile_object_is_valid tests_interface_members tests_dynamic_members + tests_instance_methods + tests_static_methods ] \ No newline at end of file