From 0e1e7fb83b8e43923be4aad37bff54f6420ca865 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Fri, 12 Jan 2024 09:25:07 +0100 Subject: [PATCH] Rework Validate API --- arc-validate.sln | 18 +- .../invenio_prototype_v0.2.0.fsx | 13 +- .../TestGeneration/Critical/ARCFileSystem.fs | 2 +- .../TestGeneration/Critical/ARCISA.fs | 4 +- src/ARCExpect/ValidationFunctions.fs | 242 +++++++++--------- tests/ARCExpect.Tests/ARCExpectTests.fs | 130 +++++----- 6 files changed, 217 insertions(+), 192 deletions(-) diff --git a/arc-validate.sln b/arc-validate.sln index f5584ba..e2d8ca7 100644 --- a/arc-validate.sln +++ b/arc-validate.sln @@ -12,9 +12,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{B3F07465-210 Dockerfile = Dockerfile ErrorClassOntology.obo = ErrorClassOntology.obo global.json = global.json - playground.fsx = playground.fsx README.md = README.md TestOntology.obo = TestOntology.obo + playgrounds\workingGraph.md = playgrounds\workingGraph.md EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{6275F297-567B-421B-B055-4F88B2785765}" @@ -44,6 +44,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".ci", ".ci", "{66A8015E-565 EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "playgrounds", "playgrounds", "{7994D526-5B21-4EBD-9CCB-EFA04EE303CF}" + ProjectSection(SolutionItems) = preProject + playgrounds\arc-validation-packages.fsx = playgrounds\arc-validation-packages.fsx + playgrounds\argu.fsx = playgrounds\argu.fsx + playgrounds\codeGeneratorScripting.fsx = playgrounds\codeGeneratorScripting.fsx + playgrounds\errorClassesStatic.fsx = playgrounds\errorClassesStatic.fsx + playgrounds\expectoPlayground.fsx = playgrounds\expectoPlayground.fsx + playgrounds\getAnnotationTableCvPs.fsx = playgrounds\getAnnotationTableCvPs.fsx + playgrounds\github-api.fsx = playgrounds\github-api.fsx + playgrounds\graphModelIOTest.fsx = playgrounds\graphModelIOTest.fsx + playgrounds\graphoscopePlayground.fsx = playgrounds\graphoscopePlayground.fsx + playgrounds\playground.fsx = playgrounds\playground.fsx + EndProjectSection EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ARCValidationPackages", "src\ARCValidationPackages\ARCValidationPackages.fsproj", "{CF14C74E-20D2-4EC9-B11E-357BFD1244CB}" EndProject @@ -57,6 +69,7 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ARCExpect.Tests", "tests\AR EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "arcGraph_prototypes", "arcGraph_prototypes", "{02699157-EFC4-4E1A-94CC-B9825E2D1CB8}" ProjectSection(SolutionItems) = preProject + carepaket.fsx = carepaket.fsx playgrounds\arcGraph_playgrounds\prototype_v0.1.0.fsx = playgrounds\arcGraph_playgrounds\prototype_v0.1.0.fsx playgrounds\arcGraph_playgrounds\prototype_v0.1.1.fsx = playgrounds\arcGraph_playgrounds\prototype_v0.1.1.fsx playgrounds\arcGraph_playgrounds\prototype_v0.2.0.fsx = playgrounds\arcGraph_playgrounds\prototype_v0.2.0.fsx @@ -64,9 +77,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "arcGraph_prototypes", "arcG EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo_notebooks", "demo_notebooks", "{A83F65C9-925E-437C-A457-EF8B9C6B154D}" - ProjectSection(SolutionItems) = preProject - playgrounds\demo_notebooks\demo_ARCGraph.ipynb = playgrounds\demo_notebooks\demo_ARCGraph.ipynb - EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "qcPackage_prototypes", "qcPackage_prototypes", "{9B3B6E39-DB2F-4A91-944B-EFAAD961FCE7}" ProjectSection(SolutionItems) = preProject diff --git a/playgrounds/qcPackage_prototypes/invenio_prototype_v0.2.0.fsx b/playgrounds/qcPackage_prototypes/invenio_prototype_v0.2.0.fsx index 4684e5d..c84cbb1 100644 --- a/playgrounds/qcPackage_prototypes/invenio_prototype_v0.2.0.fsx +++ b/playgrounds/qcPackage_prototypes/invenio_prototype_v0.2.0.fsx @@ -39,6 +39,7 @@ let outDir = arcDir let absoluteDirectoryPaths = FileSystem.parseRelativeDirectoryPaths arcDir let absoluteFilePaths = FileSystem.parseRelativeFilePaths arcDir + let invFileTokens = Investigation.parseMetadataSheetsFromTokens() absoluteFilePaths |> List.concat @@ -51,13 +52,15 @@ let invFileTokens = let cases = [ testList INVMSO.``Investigation Metadata``.INVESTIGATION.key.Name [ - ARCExpect.validate (TestID.Name INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Title``.Name) { + ARCExpect.validationCase (TestID.Name INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Title``.Name) { invFileTokens - |> Validate.ByTerm.contains INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Title`` + |> Validate.ParamCollection.ContainsParamWithTerm + INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Title`` } - ARCExpect.validate (TestID.Name INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Description``.Name) { - cvParams - |> Validate.ByTerm.contains INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Description`` + ARCExpect.validationCase (TestID.Name INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Description``.Name) { + invFileTokens + |> Validate.ParamCollection.ContainsParamWithTerm + INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Description`` } ] ] \ No newline at end of file diff --git a/src/ARCExpect/TestGeneration/Critical/ARCFileSystem.fs b/src/ARCExpect/TestGeneration/Critical/ARCFileSystem.fs index f3d710f..997ff8b 100644 --- a/src/ARCExpect/TestGeneration/Critical/ARCFileSystem.fs +++ b/src/ARCExpect/TestGeneration/Critical/ARCFileSystem.fs @@ -25,7 +25,7 @@ module FileSystem = testList "FileSystem" [ testList "Investigation" [ validationCase (TestID.Name "Investigation File") { - relativeFilePaths |> Validate.ByValue.containsValue "isa.investigation.xlsx" + relativeFilePaths |> Validate.ParamCollection.ContainsParamWithValue "isa.investigation.xlsx" } ] ] \ No newline at end of file diff --git a/src/ARCExpect/TestGeneration/Critical/ARCISA.fs b/src/ARCExpect/TestGeneration/Critical/ARCISA.fs index 4243c22..2ca9c28 100644 --- a/src/ARCExpect/TestGeneration/Critical/ARCISA.fs +++ b/src/ARCExpect/TestGeneration/Critical/ARCISA.fs @@ -24,11 +24,11 @@ module ISA = testList INVMSO.``Investigation Metadata``.INVESTIGATION.key.Name [ validationCase (TestID.Name INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Title``.Name) { cvParams - |> Validate.ByTerm.contains INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Title`` + |> Validate.ParamCollection.ContainsParamWithTerm INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Title`` } validationCase (TestID.Name INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Description``.Name) { cvParams - |> Validate.ByTerm.contains INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Description`` + |> Validate.ParamCollection.ContainsParamWithTerm INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Description`` } ] ] \ No newline at end of file diff --git a/src/ARCExpect/ValidationFunctions.fs b/src/ARCExpect/ValidationFunctions.fs index c1f745d..641702e 100644 --- a/src/ARCExpect/ValidationFunctions.fs +++ b/src/ARCExpect/ValidationFunctions.fs @@ -1,165 +1,163 @@ -namespace ARCExpect.Validate +namespace ARCExpect open ControlledVocabulary open ARCExpect open ARCTokenization.StructuralOntology - /// -/// Validation functions to perform value-based validation on IParams +/// Top level API for performing validation. /// -type ByValue = - static member notEmpty (cvp:CvParam) = - match CvParam.isEmpty cvp with - | false -> () - | true -> - cvp - |> ErrorMessage.ofCvParam "is empty." - |> Expecto.Tests.failtestNoStackf "%s" - - static member notEmpty (ip : #IParam) = - match Param.isEmpty ip with - | false -> () - | true -> - ip - |> ErrorMessage.ofIParam "is empty." - |> Expecto.Tests.failtestNoStackf "%s" - - static member equals (targetValue : System.IConvertible) (ip : #IParam) = - let act = Param.getValue ip - match targetValue = act with - | true -> () - | false -> - ip - |> ErrorMessage.ofIParam $"should equal {targetValue}." - |> Expecto.Tests.failtestNoStackf "%s" - +module Validate = + /// - /// tests wether any of the CvParams in the given collection has the expectedValue + /// Validation functions to perform on any type implementing the `IParam` interface. /// - /// the value expected to occur in at least 1 CvParam in the given collection - static member containsValue (expectedValue : #System.IConvertible) (set : #seq<#IParam>) = - match Seq.exists (fun (ip : #IParam)-> (ip.Value |> ParamValue.getValue) = (expectedValue :> System.IConvertible)) set with - | true -> () - | false -> - expectedValue - |> ErrorMessage.ofValue $"does not exist" - |> Expecto.Tests.failtestNoStackf "%s" + type Param = + + /// + /// Validates that the value of the given Param is not empty (meaning it is not an empty string: ""). + /// + /// The param to validate + static member ValueIsNotEmpty (param : #IParam) = + match Param.isEmpty param with + | false -> () + | true -> + param + |> ErrorMessage.ofIParam "is empty." + |> Expecto.Tests.failtestNoStackf "%s" - /// - /// tests wether any of the CvParams equal the expectedParam by value - /// - /// the Cvparam for which it is expected to share it's value with at least one Cvparam in the collection - static member containsParam (expectedParam : #IParam) (set : #seq<#IParam>) = - let tmp = - Param.getParamValue expectedParam - |> ParamValue.getValue - match Seq.exists (fun (ip : #IParam)-> (ip.Value |> ParamValue.getValue) = tmp) set with - | true -> () - | false -> - expectedParam - |> ErrorMessage.ofIParam $"does not exist" - |> Expecto.Tests.failtestNoStackf "%s" - - - static member isMatch (pattern:string) = - fun (ip : #IParam) -> + /// + /// Validates if the value of the given Param is equal to the expected value. + /// + /// The expected value to validate against + /// The param to validate + static member ValueIsEqualTo (targetValue : System.IConvertible) (param : #IParam) = + let act = Param.getValue param + match targetValue = act with + | true -> () + | false -> + param + |> ErrorMessage.ofIParam $"should equal {targetValue}." + |> Expecto.Tests.failtestNoStackf "%s" + + /// + /// Validates if the term of the given Param is equal to the expected term. + /// + /// The expected term to validate against + /// The param to validate + static member TermIsEqualTo (expectedTerm:CvTerm) (param : #IParam) = + match (Param.getTerm param) = expectedTerm with + | true -> () + | false -> + param + |> ErrorMessage.ofIParam $"should equal {expectedTerm}." + |> Expecto.Tests.failtestNoStackf "%s" + + /// + /// Validates if the value of the given Param matches a regex pattern. + /// + /// The regex pattern that the value should match + /// The param to validate + static member ValueMatchesPattern (pattern:string) (param : #IParam) = let tmp = - Param.getParamValue ip + Param.getParamValue param |> ParamValue.getValue |> string match System.Text.RegularExpressions.Regex.IsMatch(tmp,pattern) with | true -> () | false -> - ip + param |> ErrorMessage.ofIParam "is invalid." |> Expecto.Tests.failtestNoStackf "%s" - - static member isMatch (regex:System.Text.RegularExpressions.Regex) = - fun (ip : #IParam) -> + /// + /// Validates if the value of the given Param matches a regex. + /// + /// The regex that the value should match + /// The param to validate + static member ValueMatchesRegex (regex:System.Text.RegularExpressions.Regex) (param : #IParam) = let tmp = - Param.getParamValue ip + Param.getParamValue param |> ParamValue.getValue |> string match regex.IsMatch(tmp) with | true -> () | false -> - ip + param |> ErrorMessage.ofIParam "is invalid." |> Expecto.Tests.failtestNoStackf "%s" - - - static member isMatchBy (validator:string -> bool) = - fun (ip : #IParam) -> + + /// + /// Validates if the value of the given Param satisfies a predicate (meaning a function that for a given Param returns either true or false) + /// + /// The predicate that the Param should satisfy + /// The param to validate + static member ValueSatisfiesPredicate (predicate: System.IConvertible -> bool) (param : #IParam) = let tmp = - Param.getParamValue ip + Param.getParamValue param |> ParamValue.getValue - |> string - match validator tmp with - | true -> () - | false -> - ip - |> ErrorMessage.ofIParam "is invalid." - |> Expecto.Tests.failtestNoStackf "%s" -/// -/// Validation functions to perform term-based validation on IParams -/// -type ByTerm = - - /// Compares by Term - static member equals (target:CvTerm) = - fun (ip : #IParam) -> - match (Param.getTerm ip) = target with - | true -> () - | false -> - ip - |> ErrorMessage.ofIParam $"should equal {target}." - |> Expecto.Tests.failtestNoStackf "%s" + if not (predicate tmp) then + param + |> ErrorMessage.ofIParam "is invalid." + |> Expecto.Tests.failtestNoStackf "%s" - /// Compares by Term - static member equals (target:CvParam) = - fun (ip : #IParam) -> - match (Param.getTerm ip) = (CvParam.getTerm target) with - | true -> () - | false -> - ip - |> ErrorMessage.ofIParam $"should equal {target}." - |> Expecto.Tests.failtestNoStackf "%s" - /// - /// tests wether any of the CvParams in the given collection is annotated with the expectedTerm + /// Validation functions to perform on a collection containing any type implementing the `IParam` interface. /// - /// the term expected to occur in at least 1 CvParam in the given collection - static member contains (expectedTerm:CvTerm) = - fun (set : #seq<#IParam>) -> - match Seq.exists (fun e -> Param.getTerm e = expectedTerm) set with + type ParamCollection = + + /// + /// Validates if at least one Param with the expected value in the given collection exists. + /// + /// the value expected to occur in at least 1 Param in the given collection + /// The param collection to validate + static member ContainsParamWithValue (expectedValue : #System.IConvertible) (paramCollection : #seq<#IParam>) = + match Seq.exists (fun (param : #IParam)-> (param.Value |> ParamValue.getValue) = (expectedValue :> System.IConvertible)) paramCollection with | true -> () | false -> - expectedTerm - |> ErrorMessage.ofCvTerm "is missing." + expectedValue + |> ErrorMessage.ofValue $"does not exist" |> Expecto.Tests.failtestNoStackf "%s" - /// - /// tests wether any of the CvParams equal the expectedParam by term - /// - /// the Cvparam for which it is expected to share it's term with at least one Cvparam in the collection - static member contains (expectedParam : IParam) = - fun (set: #seq<#IParam>) -> - match Seq.exists (fun e -> Param.getTerm e = Param.getTerm expectedParam) set with + /// + /// Validates if at least one Param with the expected term in the given collection exists. + /// + /// the term expected to occur in at least 1 Param in the given collection + /// The param collection to validate + static member ContainsParamWithTerm (expectedTerm : CvTerm) (paramCollection: #seq<#IParam>) = + match Seq.exists (fun e -> Param.getTerm e = expectedTerm) paramCollection with | true -> () | false -> - expectedParam - |> ErrorMessage.ofIParam "is missing." + expectedTerm + |> ErrorMessage.ofCvTerm $"does not exist" |> Expecto.Tests.failtestNoStackf "%s" + /// + /// Validates if the given Param is contained in the given collection át least once. + /// + /// the param expected to occur at least once in the given collection + /// The param collection to validate + static member ContainsParam (expectedParam : #IParam) (paramCollection : #seq<#IParam>) = + + let tmp = + Param.getParamValue expectedParam + |> ParamValue.getValue + // this is incomplete and does not exactly perform what the name advertises + // (e.g., it only checks value but not term, or even if the Params are Cv or User) + match Seq.exists (fun (param : #IParam)-> (param.Value |> ParamValue.getValue) = tmp) paramCollection with + | true -> () + | false -> + expectedParam + |> ErrorMessage.ofIParam $"does not exist" + |> Expecto.Tests.failtestNoStackf "%s" -/// -/// Validation functions to perform context-dependent tests on CvParams representing a special kind of object (e.g. multiple properties of a Person, an Email, etc.) -/// -type ByObject = - static member email (ip : #IParam) = - ip |> ByValue.isMatch StringValidationPattern.email - ip |> ByTerm.equals INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Email`` \ No newline at end of file + /// + /// Validates wether the given Param's value is an email that matches a pre-defined regex pattern ("^[^@\s]+@[^@\s]+\.[^@\s]+$") + /// and wether the param is annotated with the term `Investigation Person Email` + /// + /// + let email (param : #IParam) = + param |> Param.ValueMatchesRegex StringValidationPattern.email + param |> Param.TermIsEqualTo INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Email`` \ No newline at end of file diff --git a/tests/ARCExpect.Tests/ARCExpectTests.fs b/tests/ARCExpect.Tests/ARCExpectTests.fs index 928acac..6a9a1fb 100644 --- a/tests/ARCExpect.Tests/ARCExpectTests.fs +++ b/tests/ARCExpect.Tests/ARCExpectTests.fs @@ -4,74 +4,88 @@ open Expecto open ARCExpect [] -let ``ByValue tests`` = - testList "ArcExpect.ByValue" [ - test "equal values are equal" {Validate.ByValue.equals "Kevin" ReferenceObjects.CvParams.``Investigation Person First Name``} - test "inequal values are inequal" { - Expect.throws - (fun () -> Validate.ByValue.equals "Kevin2" ReferenceObjects.CvParams.``Investigation Person First Name``) - "inequal values were not correctly detected as inequal" - } +let ``Validate.Param API tests`` = + testList "Validate API tests" [ + testList "Param" [ - test "contained value is detected" {Validate.ByValue.containsValue "Kevin" [ReferenceObjects.CvParams.``Investigation Person First Name``]} - test "non-contained value is detected" { - Expect.throws - (fun () -> Validate.ByValue.containsValue "Kevin2" [ReferenceObjects.CvParams.``Investigation Person First Name``]) - "non-contained value was not correctly detected as not contained" - } + test "ValueIsNotEmpty passes if valid" {Validate.Param.ValueIsNotEmpty ReferenceObjects.CvParams.``Investigation Person First Name``} + test "ValueIsNotEmpty fails if invalid" { + Expect.throws + (fun () -> Validate.Param.ValueIsNotEmpty ReferenceObjects.CvParams.``Empty Value``) + "empty cvparam was not correctly detected as empty" + } - test "correct email is matched via regex" {Validate.ByValue.isMatch StringValidationPattern.email ReferenceObjects.CvParams.``Investigation Person Email (valid)``} - test "incorrect email is not matched via regex" { - Expect.throws - (fun () -> Validate.ByValue.isMatch StringValidationPattern.email ReferenceObjects.CvParams.``Investigation Person Email (invalid)``) - "incorrect email was not correctly detected as incorrect" - } + test "ValueIsEqualTo passes if valid" {Validate.Param.ValueIsEqualTo "Kevin" ReferenceObjects.CvParams.``Investigation Person First Name``} + test "ValueIsEqualTo fails if invalid" { + Expect.throws + (fun () -> Validate.Param.ValueIsEqualTo "Kevin2" ReferenceObjects.CvParams.``Investigation Person First Name``) + "inequal values were not correctly detected as inequal" + } - test "isMatchBy detects substring" {Validate.ByValue.isMatchBy (fun x -> x.Contains("Kev")) ReferenceObjects.CvParams.``Investigation Person First Name``} - test "isMatchBy fails on no match" { - Expect.throws - (fun () -> Validate.ByValue.isMatchBy (fun x -> x.Contains("XYZ")) ReferenceObjects.CvParams.``Investigation Person First Name``) - "no match expected, but matched." - } + test "TermIsEqualTo passes if valid" { + Validate.Param.TermIsEqualTo + ReferenceObjects.CvTerms.``Investigation Person First Name`` + ReferenceObjects.CvParams.``Investigation Person First Name`` + } + test "TermIsEqualTo fails if invalid" { + Expect.throws + (fun () -> Validate.Param.TermIsEqualTo ReferenceObjects.CvTerms.``Investigation Person Email`` ReferenceObjects.CvParams.``Investigation Person First Name``) + "inequal cvterms were not correctly detected as inequal" + } - test "non-empty cvparam is not empty" {Validate.ByValue.notEmpty ReferenceObjects.CvParams.``Investigation Person First Name``} - test "empty cvparam is empty" { - Expect.throws - (fun () -> Validate.ByValue.notEmpty ReferenceObjects.CvParams.``Empty Value``) - "empty cvparam was not correctly detected as empty" - } + test "ValueMatchesPattern passes if valid" {Validate.Param.ValueMatchesPattern @"^[^@\s]+@[^@\s]+\.[^@\s]+$" ReferenceObjects.CvParams.``Investigation Person Email (valid)``} + test "ValueMatchesPattern fails if invalid" { + Expect.throws + (fun () ->Validate.Param.ValueMatchesPattern @"^[^@\s]+@[^@\s]+\.[^@\s]+$" ReferenceObjects.CvParams.``Investigation Person Email (invalid)``) + "incorrect email was not correctly detected as incorrect" + } + + test "ValueMatchesRegex passes if valid" {Validate.Param.ValueMatchesRegex StringValidationPattern.email ReferenceObjects.CvParams.``Investigation Person Email (valid)``} + test "ValueMatchesRegex fails if invalid" { + Expect.throws + (fun () ->Validate.Param.ValueMatchesRegex StringValidationPattern.email ReferenceObjects.CvParams.``Investigation Person Email (invalid)``) + "incorrect email was not correctly detected as incorrect" + } + + test "ValueSatisfiesPredicate passes if valid" {Validate.Param.ValueSatisfiesPredicate (fun x -> (string x).Contains("Kev")) ReferenceObjects.CvParams.``Investigation Person First Name``} + test "ValueSatisfiesPredicate fails if invalid" { + Expect.throws + (fun () -> Validate.Param.ValueSatisfiesPredicate (fun x -> (string x).Contains("XYZ")) ReferenceObjects.CvParams.``Investigation Person First Name``) + "no match expected, but matched." + } + ] ] [] -let ``ByTerm tests`` = - testList "ArcExpect.ByTerm" [ - test "equal cvterms are equal" { - Validate.ByTerm.equals - ReferenceObjects.CvTerms.``Investigation Person First Name`` - ReferenceObjects.CvParams.``Investigation Person First Name`` - } - - test "inequal cvterms are inequal" { - Expect.throws - (fun () -> Validate.ByTerm.equals ReferenceObjects.CvTerms.``Investigation Person Email`` ReferenceObjects.CvParams.``Investigation Person First Name``) - "inequal cvterms were not correctly detected as inequal" - } +let ``Validate.ParamCollection API tests`` = + testList "Validate API tests" [ + testList "ParamCollection" [ - test "contained cvparam is detected" {Validate.ByTerm.contains ReferenceObjects.CvParams.``Investigation Person First Name`` [ReferenceObjects.CvParams.``Investigation Person First Name``] } - test "non-contained cvparam is detected" { - Expect.throws - (fun () -> Validate.ByTerm.contains ReferenceObjects.CvParams.``Investigation Person First Name`` [ReferenceObjects.CvParams.``Investigation Person Email (valid)``] ) - "non-contained cvparam was not correctly detected as not contained" - } + test "ContainsParamWithValue passes if valid" {Validate.ParamCollection.ContainsParamWithValue "Kevin" [ReferenceObjects.CvParams.``Investigation Person First Name``]} + test "ContainsParamWithValue fails if invalid" { + Expect.throws + (fun () -> Validate.ParamCollection.ContainsParamWithValue "Kevin2" [ReferenceObjects.CvParams.``Investigation Person First Name``]) + "non-contained value was not correctly detected as not contained" + } + + test "ContainsParamWithTerm passes if valid" {Validate.ParamCollection.ContainsParamWithTerm ReferenceObjects.CvTerms.``Investigation Person First Name`` [ReferenceObjects.CvParams.``Investigation Person First Name``] } + test "ContainsParamWithTerm fails if invalid" { + Expect.throws + (fun () -> Validate.ParamCollection.ContainsParamWithTerm ReferenceObjects.CvTerms.``Investigation Person First Name`` [ReferenceObjects.CvParams.``Investigation Person Email (valid)``] ) + "non-contained cvparam was not correctly detected as not contained" + } + ] ] [] -let ``Valid tests`` = - testList "ArcExpect.Valid" [ - test "valid email is valid" {Validate.ByObject.email ReferenceObjects.CvParams.``Investigation Person Email (valid)``} - test "invalid email is invalid" { - Expect.throws - (fun () -> Validate.ByObject.email ReferenceObjects.CvParams.``Investigation Person Email (invalid)``) - "invalid email was not correctly detected as invalid"} +let ``Validate composite/top level API tests`` = + testList "Validate API tests" [ + testList "composite validation cases" [ + test "email passes if valid" {Validate.email ReferenceObjects.CvParams.``Investigation Person Email (valid)``} + test "email fails if invalid" { + Expect.throws + (fun () -> Validate.email ReferenceObjects.CvParams.``Investigation Person Email (invalid)``) + "invalid email was not correctly detected as invalid"} + ] ] \ No newline at end of file