From 91b3f018ed8f445bffc6bf5bf37b361923197e8e Mon Sep 17 00:00:00 2001 From: Heinrich Lukas Weil Date: Wed, 20 Sep 2023 12:38:56 +0200 Subject: [PATCH 1/2] restructure testing environment --- ARCtrl.sln | 7 + tests/ARCtrl/ARCtrl.Tests.fs | 27 +- tests/ARCtrl/ARCtrl.Tests.fsproj | 7 +- tests/ARCtrl/Templates.Tests.fs | 5 +- tests/FileSystem/FileSystem.Tests.fsproj | 2 +- tests/FileSystem/FileSystemTree.Tests.fs | 9 +- tests/FileSystem/Utils.fs | 48 ---- .../ISA/ISA.Json.Tests/ISA.Json.Tests.fsproj | 11 +- tests/ISA/ISA.Json.Tests/Json.Tests.fs | 248 +++++++++--------- tests/ISA/ISA.Json.Tests/JsonSchema.Tests.fs | 20 +- tests/ISA/ISA.Json.Tests/Utils.fs | 52 ---- .../ISA.Spreadsheet.Tests/ArcTableTests.fs | 24 +- .../ISA.Spreadsheet.Tests/AssayFileTests.fs | 93 +++---- .../CompositeColumnTests.fs | 2 +- .../ISA.Spreadsheet.Tests.fsproj | 6 +- .../InvestigationFileTests.fs | 46 ++-- .../ISA.Spreadsheet.Tests/SparseTableTests.fs | 2 +- .../StringConversionTests.fs | 18 +- .../ISA.Spreadsheet.Tests/StudyFileTests.fs | 22 +- tests/ISA/ISA.Spreadsheet.Tests/Utils.fs | 47 ---- tests/ISA/ISA.Tests/ArcAssay.Tests.fs | 10 +- tests/ISA/ISA.Tests/ArcInvestigation.Tests.fs | 10 +- tests/ISA/ISA.Tests/ArcJsonConversionTests.fs | 14 +- tests/ISA/ISA.Tests/ArcStudy.Tests.fs | 12 +- tests/ISA/ISA.Tests/ArcTable.Tests.fs | 20 +- tests/ISA/ISA.Tests/ArcTables.Tests.fs | 20 +- tests/ISA/ISA.Tests/ISA.Tests.fsproj | 2 +- tests/ISA/ISA.Tests/Update.Tests.fs | 20 +- tests/ISA/ISA.Tests/Utils.fs | 45 ---- tests/TestingUtils/Library.fs | 100 +++++++ .../TestObjects.Contract/ISA.fs} | 8 +- .../TestObjects.Json}/Assay.fs | 2 +- .../TestObjects.Json}/Investigation.fs | 2 +- .../TestObjects.Json}/OntologyAnnotation.fs | 2 +- .../TestObjects.Json}/Person.fs | 2 +- .../TestObjects.Json}/Process.fs | 2 +- .../TestObjects.Json}/ProcessInput.fs | 2 +- .../TestObjects.Json}/Protocol.fs | 2 +- .../TestObjects.Json}/Publication.fs | 2 +- .../TestObjects.Json}/Validation.fs | 2 +- .../Spreadsheet.ArcTable.fs} | 2 +- .../Spreadsheet.Assay.fs} | 2 +- .../Spreadsheet.InvestigationFile.fs} | 2 +- .../Spreadsheet.Study.fs} | 2 +- tests/TestingUtils/TestingUtils.fsproj | 30 +++ tests/TestingUtils/paket.references | 4 + 46 files changed, 480 insertions(+), 537 deletions(-) delete mode 100644 tests/FileSystem/Utils.fs delete mode 100644 tests/ISA/ISA.Json.Tests/Utils.fs delete mode 100644 tests/ISA/ISA.Spreadsheet.Tests/Utils.fs delete mode 100644 tests/ISA/ISA.Tests/Utils.fs create mode 100644 tests/TestingUtils/Library.fs rename tests/{ARCtrl/TestObjects/ISAContracts.fs => TestingUtils/TestObjects.Contract/ISA.fs} (96%) rename tests/{ISA/ISA.Json.Tests/TestObjects => TestingUtils/TestObjects.Json}/Assay.fs (99%) rename tests/{ISA/ISA.Json.Tests/TestObjects => TestingUtils/TestObjects.Json}/Investigation.fs (99%) rename tests/{ISA/ISA.Json.Tests/TestObjects => TestingUtils/TestObjects.Json}/OntologyAnnotation.fs (97%) rename tests/{ISA/ISA.Json.Tests/TestObjects => TestingUtils/TestObjects.Json}/Person.fs (98%) rename tests/{ISA/ISA.Json.Tests/TestObjects => TestingUtils/TestObjects.Json}/Process.fs (99%) rename tests/{ISA/ISA.Json.Tests/TestObjects => TestingUtils/TestObjects.Json}/ProcessInput.fs (99%) rename tests/{ISA/ISA.Json.Tests/TestObjects => TestingUtils/TestObjects.Json}/Protocol.fs (99%) rename tests/{ISA/ISA.Json.Tests/TestObjects => TestingUtils/TestObjects.Json}/Publication.fs (96%) rename tests/{ISA/ISA.Json.Tests/TestObjects => TestingUtils/TestObjects.Json}/Validation.fs (99%) rename tests/{ISA/ISA.Spreadsheet.Tests/TestObjects/ArcTable.fs => TestingUtils/TestObjects.Spreadsheet/Spreadsheet.ArcTable.fs} (99%) rename tests/{ISA/ISA.Spreadsheet.Tests/TestObjects/Assay.fs => TestingUtils/TestObjects.Spreadsheet/Spreadsheet.Assay.fs} (99%) rename tests/{ISA/ISA.Spreadsheet.Tests/TestObjects/InvestigationFile.fs => TestingUtils/TestObjects.Spreadsheet/Spreadsheet.InvestigationFile.fs} (99%) rename tests/{ISA/ISA.Spreadsheet.Tests/TestObjects/Study.fs => TestingUtils/TestObjects.Spreadsheet/Spreadsheet.Study.fs} (99%) create mode 100644 tests/TestingUtils/TestingUtils.fsproj create mode 100644 tests/TestingUtils/paket.references diff --git a/ARCtrl.sln b/ARCtrl.sln index 8ceaef60..cd2ec611 100644 --- a/ARCtrl.sln +++ b/ARCtrl.sln @@ -67,6 +67,8 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ARCtrl.Contract", "src\Cont EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FileSystem.Tests", "tests\FileSystem\FileSystem.Tests.fsproj", "{D9FE196B-AC21-4C3E-B9AE-DDDEC2158BC3}" EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "TestingUtils", "tests\TestingUtils\TestingUtils.fsproj", "{AA011593-6603-4E16-A7B0-0ED3862511DE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -125,6 +127,10 @@ Global {D9FE196B-AC21-4C3E-B9AE-DDDEC2158BC3}.Debug|Any CPU.Build.0 = Debug|Any CPU {D9FE196B-AC21-4C3E-B9AE-DDDEC2158BC3}.Release|Any CPU.ActiveCfg = Release|Any CPU {D9FE196B-AC21-4C3E-B9AE-DDDEC2158BC3}.Release|Any CPU.Build.0 = Release|Any CPU + {AA011593-6603-4E16-A7B0-0ED3862511DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AA011593-6603-4E16-A7B0-0ED3862511DE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AA011593-6603-4E16-A7B0-0ED3862511DE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AA011593-6603-4E16-A7B0-0ED3862511DE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -145,6 +151,7 @@ Global {801247D5-7EE5-49C8-AB26-F822A415BA49} = {64B34A6E-318D-4E6E-9262-CE52C9B85A38} {1945EE8A-F105-43A9-91C9-8C4422B9873E} = {6DA2330B-D407-4FB1-AF05-B0184034EC44} {D9FE196B-AC21-4C3E-B9AE-DDDEC2158BC3} = {64B34A6E-318D-4E6E-9262-CE52C9B85A38} + {AA011593-6603-4E16-A7B0-0ED3862511DE} = {64B34A6E-318D-4E6E-9262-CE52C9B85A38} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1E354DE6-99BA-421E-9EF8-E808B855A85F} diff --git a/tests/ARCtrl/ARCtrl.Tests.fs b/tests/ARCtrl/ARCtrl.Tests.fs index a5c76946..0a4a124e 100644 --- a/tests/ARCtrl/ARCtrl.Tests.fs +++ b/tests/ARCtrl/ARCtrl.Tests.fs @@ -8,8 +8,9 @@ open Expecto open ARCtrl open ARCtrl.ISA -open TestObjects.ISAContracts - +open TestObjects.Contract.ISA +open TestObjects.Spreadsheet +open TestingUtils let private test_model = testList "model" [ testCase "create" <| fun _ -> @@ -53,19 +54,19 @@ let private test_model = testList "model" [ let private test_isaFromContracts = testList "read_contracts" [ testCase "simpleISA" (fun () -> - let iContract = TestObjects.ISAContracts.SimpleISA.investigationReadContract - let sContract = TestObjects.ISAContracts.SimpleISA.studyReadContract - let aContract = TestObjects.ISAContracts.SimpleISA.assayReadContract + let iContract = SimpleISA.investigationReadContract + let sContract = SimpleISA.studyReadContract + let aContract = SimpleISA.assayReadContract let arc = ARC() arc.SetISAFromContracts([|iContract; sContract; aContract|]) Expect.isSome arc.ISA "isa should be filled out" let inv = arc.ISA.Value - Expect.equal inv.Identifier TestObjects.Investigation.investigationIdentifier "investigation identifier should have been read from investigation contract" + Expect.equal inv.Identifier Investigation.investigationIdentifier "investigation identifier should have been read from investigation contract" Expect.equal inv.Studies.Count 2 "should have read two studies" let study1 = inv.Studies.[0] let study2 = inv.Studies.[1] - Expect.equal study1.Identifier TestObjects.Study.studyIdentifier "study 1 identifier should have been read from study contract" + Expect.equal study1.Identifier Study.studyIdentifier "study 1 identifier should have been read from study contract" Expect.equal study1.TableCount 8 "study 1 should have the 7 tables from investigation plus one extra. One table should be overwritten." Expect.equal study2.TableCount 4 "study 2 should have exactly as many tables as stated in investigation file" @@ -73,7 +74,7 @@ let private test_isaFromContracts = testList "read_contracts" [ let assay1 = study1.RegisteredAssays.[0] let assay2 = study1.RegisteredAssays.[1] let assay3 = study1.RegisteredAssays.[2] - Expect.equal assay1.Identifier TestObjects.Assay.assayIdentifier "assay 1 identifier should have been read from assay contract" + Expect.equal assay1.Identifier Assay.assayIdentifier "assay 1 identifier should have been read from assay contract" Expect.equal assay1.TableCount 1 "assay 1 should have read one table" Expect.equal assay2.TableCount 0 "assay 2 should have read no tables" Expect.equal assay3.TableCount 0 "assay 3 should have read no tables" @@ -95,11 +96,11 @@ let private test_isaFromContracts = testList "read_contracts" [ Expect.equal study.TableCount 1 "study should have read one table" let studyTable = study.Tables.[0] Expect.equal studyTable.ColumnCount 2 "study column number should be unchanged" - TestingUtils.mySequenceEqual + Expect.mySequenceEqual (studyTable.GetProtocolDescriptionColumn()).Cells [CompositeCell.createFreeText UpdateAssayWithStudyProtocol.description] "Description value was not kept correctly" - TestingUtils.mySequenceEqual + Expect.mySequenceEqual (studyTable.GetProtocolNameColumn()).Cells [CompositeCell.createFreeText UpdateAssayWithStudyProtocol.protocolName] "Protocol ref value was not kept correctly" @@ -109,15 +110,15 @@ let private test_isaFromContracts = testList "read_contracts" [ Expect.equal assay.TableCount 1 "assay should have read one table" let assayTable = assay.Tables.[0] Expect.equal assayTable.ColumnCount 3 "assay column number should be updated" - TestingUtils.mySequenceEqual + Expect.mySequenceEqual (assayTable.GetProtocolNameColumn()).Cells (Array.create 2 (CompositeCell.createFreeText UpdateAssayWithStudyProtocol.protocolName)) "Protocol ref value was not kept correctly" - TestingUtils.mySequenceEqual + Expect.mySequenceEqual (assayTable.GetColumnByHeader(UpdateAssayWithStudyProtocol.inputHeader)).Cells (Array.create 2 UpdateAssayWithStudyProtocol.inputCell) "Protocol ref value was not kept correctly" - TestingUtils.mySequenceEqual + Expect.mySequenceEqual (assayTable.GetProtocolDescriptionColumn()).Cells (Array.create 2 (CompositeCell.createFreeText UpdateAssayWithStudyProtocol.description)) "Description value was not taken correctly" diff --git a/tests/ARCtrl/ARCtrl.Tests.fsproj b/tests/ARCtrl/ARCtrl.Tests.fsproj index 5ce0d737..dd23366a 100644 --- a/tests/ARCtrl/ARCtrl.Tests.fsproj +++ b/tests/ARCtrl/ARCtrl.Tests.fsproj @@ -6,14 +6,8 @@ false - - - - - - @@ -21,6 +15,7 @@ + \ No newline at end of file diff --git a/tests/ARCtrl/Templates.Tests.fs b/tests/ARCtrl/Templates.Tests.fs index 2895d789..7e580307 100644 --- a/tests/ARCtrl/Templates.Tests.fs +++ b/tests/ARCtrl/Templates.Tests.fs @@ -13,6 +13,7 @@ open ARCtrl.ISA open System open System.Text +open TestingUtils let private fableReplaceLineEndings(str: string) = str.Replace("\r\n","\n").Replace("\n\r","\n") @@ -143,8 +144,8 @@ let tests_Template = testList "Template" [ //printfn "EXPECTED: %A" expected.Table Expect.equal actualValue.Table.Name expected.Table.Name "Name should be equal" - TestingUtils.mySequenceEqual actualValue.Table.Headers expected.Table.Headers "Headers should be equal" - TestingUtils.mySequenceEqual actualValue.Table.Values expected.Table.Values "Headers should be equal" + Expect.mySequenceEqual actualValue.Table.Headers expected.Table.Headers "Headers should be equal" + Expect.mySequenceEqual actualValue.Table.Values expected.Table.Values "Headers should be equal" Expect.equal actualValue.Table.RowCount expected.Table.RowCount "RowCount should be equal" Expect.equal actualValue.Table.ColumnCount expected.Table.ColumnCount "ColumnCount should be equal" diff --git a/tests/FileSystem/FileSystem.Tests.fsproj b/tests/FileSystem/FileSystem.Tests.fsproj index 013ed572..45c814d1 100644 --- a/tests/FileSystem/FileSystem.Tests.fsproj +++ b/tests/FileSystem/FileSystem.Tests.fsproj @@ -7,12 +7,12 @@ - + \ No newline at end of file diff --git a/tests/FileSystem/FileSystemTree.Tests.fs b/tests/FileSystem/FileSystemTree.Tests.fs index ac55f734..6e8a715f 100644 --- a/tests/FileSystem/FileSystemTree.Tests.fs +++ b/tests/FileSystem/FileSystemTree.Tests.fs @@ -7,6 +7,7 @@ open Expecto #endif open ARCtrl.FileSystem +open TestingUtils let private newArcRelativePaths = [| @"isa.investigation.xlsx"; @".arc\.gitkeep"; @".git\config"; @@ -97,7 +98,7 @@ let private tests_fromFilePaths = let filest = FileSystemTree.fromFilePaths newArcRelativePaths // damn... i made this, because i thought equal would somehow not work. But i missed adding "@" in front of paths. // i'll leave it for improved error message. - TestingUtils.testFileSystemTree filest newArcFST + Expect.testFileSystemTree filest newArcFST Expect.equal filest newArcFST "isEqual" ] @@ -373,7 +374,7 @@ let private tests_AddFile = |]) let newPath = @"studies\TestAssay1\resources\MyAwesomeRessource.pdf" let actual = newArcFST.AddFile newPath - TestingUtils.testFileSystemTree actual expected // use this instead of equal to ensure order of Folder children does not matter + Expect.testFileSystemTree actual expected // use this instead of equal to ensure order of Folder children does not matter testCase "new arc, add root file" <| fun _ -> let expected = Folder("root",[| File "isa.investigation.xlsx"; File "Test.md"; @@ -428,7 +429,7 @@ let private tests_AddFile = |]) let newPath = @"Test.md" let actual = newArcFST.AddFile newPath - TestingUtils.testFileSystemTree actual expected // use this instead of equal to ensure order of Folder children does not matter + Expect.testFileSystemTree actual expected // use this instead of equal to ensure order of Folder children does not matter testCase "new arc, add new folder" <| fun _ -> let expected = Folder("root",[| File "isa.investigation.xlsx"; @@ -484,7 +485,7 @@ let private tests_AddFile = |]) let newPath = @"MyNewFolder/README.md" let actual = newArcFST.AddFile newPath - TestingUtils.testFileSystemTree actual expected // use this instead of equal to ensure order of Folder children does not matter + Expect.testFileSystemTree actual expected // use this instead of equal to ensure order of Folder children does not matter ] let main = testList "FileSystemTree" [ diff --git a/tests/FileSystem/Utils.fs b/tests/FileSystem/Utils.fs deleted file mode 100644 index a345837e..00000000 --- a/tests/FileSystem/Utils.fs +++ /dev/null @@ -1,48 +0,0 @@ -module TestingUtils - -module Result = - - let getMessage (r : Result<'T,string>) = - match r with - | Ok _ -> "" - | Error msg -> msg - -let private firstDiff s1 s2 = - let s1 = Seq.append (Seq.map Some s1) (Seq.initInfinite (fun _ -> None)) - let s2 = Seq.append (Seq.map Some s2) (Seq.initInfinite (fun _ -> None)) - Seq.mapi2 (fun i s p -> i,s,p) s1 s2 - |> Seq.find (function |_,Some s,Some p when s=p -> false |_-> true) - -/// Expects the `actual` sequence to equal the `expected` one. -let mySequenceEqual actual expected message = - match firstDiff actual expected with - | _,None,None -> () - | i,Some a, Some e -> - failwithf "%s. Sequence does not match at position %i. Expected item: %A, but got %A." message i e a - | i,None,Some e -> - failwithf "%s. Sequence actual shorter than expected, at pos %i for expected item %A." message i e - | i,Some a,None -> - failwithf "%s. Sequence actual longer than expected, at pos %i found item %A." message i a - -open ARCtrl.FileSystem - -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif - -let rec testFileSystemTree (actual:FileSystemTree) (expected:FileSystemTree) = - match actual, expected with - | File n1, File n2 -> Expect.equal n1 n2 $"Expects file names to be equal: {n1} = {n2}" - | Folder (n1, children1), Folder (n2, children2) -> - Expect.equal n1 n2 $"Expects folder names to be equal: {n1} = {n2}" - let sortByName (children: FileSystemTree []) = children |> Array.sortBy (fun c -> c.Name) - Array.iter2 testFileSystemTree (sortByName children1) (sortByName children2) - | anyActual, anyExpected -> - failwith $"Testing FileSystemTree found an issue with unequal states: -Actual: -{anyActual} - -Expected: -{anyExpected}" \ No newline at end of file diff --git a/tests/ISA/ISA.Json.Tests/ISA.Json.Tests.fsproj b/tests/ISA/ISA.Json.Tests/ISA.Json.Tests.fsproj index 78e9bcd5..96b0fbc6 100644 --- a/tests/ISA/ISA.Json.Tests/ISA.Json.Tests.fsproj +++ b/tests/ISA/ISA.Json.Tests/ISA.Json.Tests.fsproj @@ -7,22 +7,13 @@ - - - - - - - - - - + \ No newline at end of file diff --git a/tests/ISA/ISA.Json.Tests/Json.Tests.fs b/tests/ISA/ISA.Json.Tests/Json.Tests.fs index 086405f4..93584f32 100644 --- a/tests/ISA/ISA.Json.Tests/Json.Tests.fs +++ b/tests/ISA/ISA.Json.Tests/Json.Tests.fs @@ -16,6 +16,8 @@ open Expecto open TestingUtils +open TestObjects.Json + module JsonExtensions = let private f2 i = @@ -101,7 +103,7 @@ let testEncode = let expected = comments - mySequenceEqual result' expected "Retrieved value did not match" + Expect.mySequenceEqual result' expected "Retrieved value did not match" ) ] @@ -129,7 +131,7 @@ let testDecode = let expected = ["@id";"characteristics";"name";"type"] - mySequenceEqual result expected "Field names did not match" + Expect.mySequenceEqual result expected "Field names did not match" ) ] @@ -138,7 +140,7 @@ let testOntoloyAnnotation = testCase "ReaderSuccess" (fun () -> - let result = OntologyAnnotation.fromString TestObjects.OntologyAnnotation.peptidase + let result = OntologyAnnotation.fromString OntologyAnnotation.peptidase let comment = Comment.create(Name = "comment",Value = "This is a comment") @@ -149,18 +151,18 @@ let testOntoloyAnnotation = ) testCase "WriterOutputMatchesInput" (fun () -> - let o_read_in = OntologyAnnotation.fromString TestObjects.OntologyAnnotation.peptidase + let o_read_in = OntologyAnnotation.fromString OntologyAnnotation.peptidase let o_out = OntologyAnnotation.toString o_read_in let expected = - TestObjects.OntologyAnnotation.peptidase + OntologyAnnotation.peptidase |> Utils.wordFrequency let actual = o_out |> Utils.wordFrequency - mySequenceEqual actual expected "Written processInput does not match read process input" + Expect.mySequenceEqual actual expected "Written processInput does not match read process input" ) ] @@ -169,7 +171,7 @@ let testOntoloyAnnotationLD = testCase "ReaderSuccess" (fun () -> - let result = OntologyAnnotation.fromString TestObjects.OntologyAnnotation.peptidaseLD + let result = OntologyAnnotation.fromString OntologyAnnotation.peptidaseLD let comment = Comment.create(Name = "comment",Value = "This is a comment") @@ -180,33 +182,33 @@ let testOntoloyAnnotationLD = ) testCase "WriterOutputMatchesInputGivenIDs" (fun () -> - let o_read_in = OntologyAnnotation.fromString TestObjects.OntologyAnnotation.peptidase + let o_read_in = OntologyAnnotation.fromString OntologyAnnotation.peptidase let o_out = OntologyAnnotation.toStringLD o_read_in let expected = - TestObjects.OntologyAnnotation.peptidaseLD + OntologyAnnotation.peptidaseLD |> Utils.wordFrequency let actual = o_out |> Utils.wordFrequency - mySequenceEqual actual expected "Written processInput does not match read process input" + Expect.mySequenceEqual actual expected "Written processInput does not match read process input" ) testCase "WriterOutputMatchesInputDefaultIDs" (fun () -> - let o_read_in = OntologyAnnotation.fromString TestObjects.OntologyAnnotation.peptidaseWithoutIds + let o_read_in = OntologyAnnotation.fromString OntologyAnnotation.peptidaseWithoutIds let o_out = OntologyAnnotation.toStringLD o_read_in let expected = - TestObjects.OntologyAnnotation.peptidaseWithDefaultLD + OntologyAnnotation.peptidaseWithDefaultLD |> Utils.wordFrequency let actual = o_out |> Utils.wordFrequency - mySequenceEqual actual expected "Written processInput does not match read process input" + Expect.mySequenceEqual actual expected "Written processInput does not match read process input" ) ] @@ -217,7 +219,7 @@ let testProcessInput = testList "Source" [ testCase "ReaderSuccess" (fun () -> - let result = ProcessInput.fromString TestObjects.ProcessInput.source + let result = ProcessInput.fromString ProcessInput.source let expected = Source.create("#source/source-culture8","source-culture8") @@ -228,24 +230,24 @@ let testProcessInput = ) testCase "WriterOutputMatchesInput" (fun () -> - let o_read_in = ProcessInput.fromString TestObjects.ProcessInput.source + let o_read_in = ProcessInput.fromString ProcessInput.source let o_out = ProcessInput.toString o_read_in let expected = - TestObjects.ProcessInput.source + ProcessInput.source |> Utils.wordFrequency let actual = o_out |> Utils.wordFrequency - mySequenceEqual actual expected "Written processInput does not match read process input" + Expect.mySequenceEqual actual expected "Written processInput does not match read process input" ) ] testList "Material" [ testCase "ReaderSuccess" (fun () -> - let result = ProcessInput.fromString TestObjects.ProcessInput.material + let result = ProcessInput.fromString ProcessInput.material let expected = Material.create("#material/extract-G-0.1-aliquot1","extract-G-0.1-aliquot1",MaterialType.ExtractName,Characteristics = []) @@ -257,11 +259,11 @@ let testProcessInput = ) testCase "WriterOutputMatchesInput" (fun () -> - let o_read_in = ProcessInput.fromString TestObjects.ProcessInput.material + let o_read_in = ProcessInput.fromString ProcessInput.material let o_out = ProcessInput.toString o_read_in let expected = - TestObjects.ProcessInput.material + ProcessInput.material |> Utils.wordFrequency let actual = @@ -274,7 +276,7 @@ let testProcessInput = testList "Data" [ testCase "ReaderSuccess" (fun () -> - let result = ProcessInput.fromString TestObjects.ProcessInput.data + let result = ProcessInput.fromString ProcessInput.data let expected = Data.create("#data/rawspectraldatafile-JIC64_Nitrogen_0.07_External_1_3.txt","JIC64_Nitrogen_0.07_External_1_3.txt",DataFile.RawDataFile,Comments = []) Expect.isTrue (ProcessInput.isData result) "Result is not a data" @@ -282,11 +284,11 @@ let testProcessInput = ) testCase "WriterOutputMatchesInput" (fun () -> - let o_read_in = ProcessInput.fromString TestObjects.ProcessInput.data + let o_read_in = ProcessInput.fromString ProcessInput.data let o_out = ProcessInput.toString o_read_in let expected = - TestObjects.ProcessInput.data + ProcessInput.data |> Utils.wordFrequency let actual = @@ -299,7 +301,7 @@ let testProcessInput = testList "Sample" [ testCase "ReaderSuccessSimple" (fun () -> - let result = ProcessInput.fromString TestObjects.ProcessInput.sampleSimple + let result = ProcessInput.fromString ProcessInput.sampleSimple let expectedDerivesFrom = [Source.create("#source/source-culture8")] @@ -312,11 +314,11 @@ let testProcessInput = ) testCase "WriterOutputMatchesInputSimple" (fun () -> - let o_read_in = ProcessInput.fromString TestObjects.ProcessInput.sampleSimple + let o_read_in = ProcessInput.fromString ProcessInput.sampleSimple let o_out = ProcessInput.toString o_read_in let expected = - TestObjects.ProcessInput.sampleSimple + ProcessInput.sampleSimple |> Utils.wordFrequency let actual = @@ -334,7 +336,7 @@ let testProcessInputLD = testList "Source" [ testCase "ReaderSuccess" (fun () -> - let result = ProcessInput.fromString TestObjects.ProcessInput.sourceLD + let result = ProcessInput.fromString ProcessInput.sourceLD let expected = Source.create("#source/source-culture8","source-culture8") @@ -345,11 +347,11 @@ let testProcessInputLD = ) testCase "WriterOutputMatchesInputGivenID" (fun () -> - let o_read_in = ProcessInput.fromString TestObjects.ProcessInput.source + let o_read_in = ProcessInput.fromString ProcessInput.source let o_out = ProcessInput.toStringLD o_read_in let expected = - TestObjects.ProcessInput.sourceLD + ProcessInput.sourceLD |> Utils.wordFrequency let actual = @@ -360,11 +362,11 @@ let testProcessInputLD = ) testCase "WriterOutputMatchesInputDefaultID" (fun () -> - let o_read_in = ProcessInput.fromString TestObjects.ProcessInput.sourceWithoutID + let o_read_in = ProcessInput.fromString ProcessInput.sourceWithoutID let o_out = ProcessInput.toStringLD o_read_in let expected = - TestObjects.ProcessInput.sourceWithDefaultLD + ProcessInput.sourceWithDefaultLD |> Utils.wordFrequency let actual = @@ -377,7 +379,7 @@ let testProcessInputLD = testList "Material" [ testCase "ReaderSuccess" (fun () -> - let result = ProcessInput.fromString TestObjects.ProcessInput.materialLD + let result = ProcessInput.fromString ProcessInput.materialLD let expected = Material.create("#material/extract-G-0.1-aliquot1","extract-G-0.1-aliquot1",MaterialType.ExtractName,Characteristics = []) @@ -389,11 +391,11 @@ let testProcessInputLD = ) testCase "WriterOutputMatchesInputGivenID" (fun () -> - let o_read_in = ProcessInput.fromString TestObjects.ProcessInput.material + let o_read_in = ProcessInput.fromString ProcessInput.material let o_out = ProcessInput.toStringLD o_read_in let expected = - TestObjects.ProcessInput.materialLD + ProcessInput.materialLD |> Utils.wordFrequency let actual = @@ -404,11 +406,11 @@ let testProcessInputLD = ) testCase "WriterOutputMatchesInputDefaultID" (fun () -> - let o_read_in = ProcessInput.fromString TestObjects.ProcessInput.materialWithoutID + let o_read_in = ProcessInput.fromString ProcessInput.materialWithoutID let o_out = ProcessInput.toStringLD o_read_in let expected = - TestObjects.ProcessInput.materialWithDefaultLD + ProcessInput.materialWithDefaultLD |> Utils.wordFrequency let actual = @@ -421,7 +423,7 @@ let testProcessInputLD = testList "Data" [ testCase "ReaderSuccess" (fun () -> - let result = ProcessInput.fromString TestObjects.ProcessInput.dataLD + let result = ProcessInput.fromString ProcessInput.dataLD let expected = Data.create("#data/rawspectraldatafile-JIC64_Nitrogen_0.07_External_1_3.txt","JIC64_Nitrogen_0.07_External_1_3.txt",DataFile.RawDataFile,Comments = []) Expect.isTrue (ProcessInput.isData result) "Result is not a data" @@ -429,11 +431,11 @@ let testProcessInputLD = ) testCase "WriterOutputMatchesInputGivenID" (fun () -> - let o_read_in = ProcessInput.fromString TestObjects.ProcessInput.data + let o_read_in = ProcessInput.fromString ProcessInput.data let o_out = ProcessInput.toStringLD o_read_in let expected = - TestObjects.ProcessInput.dataLD + ProcessInput.dataLD |> Utils.wordFrequency let actual = @@ -444,11 +446,11 @@ let testProcessInputLD = ) testCase "WriterOutputMatchesInputDefaultID" (fun () -> - let o_read_in = ProcessInput.fromString TestObjects.ProcessInput.dataWithoutID + let o_read_in = ProcessInput.fromString ProcessInput.dataWithoutID let o_out = ProcessInput.toStringLD o_read_in let expected = - TestObjects.ProcessInput.dataWithDefaultLD + ProcessInput.dataWithDefaultLD |> Utils.wordFrequency let actual = @@ -461,7 +463,7 @@ let testProcessInputLD = testList "Sample" [ testCase "ReaderSuccessSimple" (fun () -> - let result = ProcessInput.fromString TestObjects.ProcessInput.sampleSimpleLD + let result = ProcessInput.fromString ProcessInput.sampleSimpleLD let expectedDerivesFrom = [Source.create("#source/source-culture8")] @@ -474,11 +476,11 @@ let testProcessInputLD = ) testCase "WriterOutputMatchesInputSimpleGivenID" (fun () -> - let o_read_in = ProcessInput.fromString TestObjects.ProcessInput.sampleSimple + let o_read_in = ProcessInput.fromString ProcessInput.sampleSimple let o_out = ProcessInput.toStringLD o_read_in let expected = - TestObjects.ProcessInput.sampleSimpleLD + ProcessInput.sampleSimpleLD |> Utils.wordFrequency let actual = @@ -489,11 +491,11 @@ let testProcessInputLD = ) testCase "WriterOutputMatchesInputSimpleDefaultID" (fun () -> - let o_read_in = ProcessInput.fromString TestObjects.ProcessInput.sampleSimpleWithoutID + let o_read_in = ProcessInput.fromString ProcessInput.sampleSimpleWithoutID let o_out = ProcessInput.toStringLD o_read_in let expected = - TestObjects.ProcessInput.sampleSimpleWithDefaultLD + ProcessInput.sampleSimpleWithDefaultLD |> Utils.wordFrequency let actual = @@ -519,7 +521,7 @@ let testProtocolFile = ) testCase "ReaderSuccess" (fun () -> - let protocol = Protocol.fromString TestObjects.Protocol.protocol + let protocol = Protocol.fromString Protocol.protocol let exptected_name = "peptide_digestion" let actual = protocol.Name Expect.isSome actual "Should be some" @@ -528,7 +530,7 @@ let testProtocolFile = testCase "WriterRunning" (fun () -> - let p = Protocol.fromString TestObjects.Protocol.protocol + let p = Protocol.fromString Protocol.protocol let writingSuccess = try @@ -542,7 +544,7 @@ let testProtocolFile = testAsync "WriterSchemaCorrectness" { - let p = Protocol.fromString TestObjects.Protocol.protocol + let p = Protocol.fromString Protocol.protocol let s = Protocol.toString p @@ -553,7 +555,7 @@ let testProtocolFile = testCase "OutputMatchesInput" (fun () -> - let o_read_in = Protocol.fromString TestObjects.Protocol.protocol + let o_read_in = Protocol.fromString Protocol.protocol let exptected_name = "peptide_digestion" let actual_name = o_read_in.Name Expect.isSome actual_name "Should be some" @@ -562,7 +564,7 @@ let testProtocolFile = let o = o_read_in |> Protocol.toString let expected = - TestObjects.Protocol.protocol + Protocol.protocol |> Utils.extractWords |> Array.countBy id |> Array.sortBy fst @@ -591,7 +593,7 @@ let testProtocolFileLD = ) testCase "ReaderSuccess" (fun () -> - let protocol = Protocol.fromString TestObjects.Protocol.protocolLD + let protocol = Protocol.fromString Protocol.protocolLD let exptected_name = "peptide_digestion" let actual = protocol.Name Expect.isSome actual "Should be some" @@ -600,7 +602,7 @@ let testProtocolFileLD = testCase "WriterRunning" (fun () -> - let p = Protocol.fromString TestObjects.Protocol.protocol + let p = Protocol.fromString Protocol.protocol let writingSuccess = try @@ -614,7 +616,7 @@ let testProtocolFileLD = // testAsync "WriterSchemaCorrectness" { - // let p = Protocol.fromString TestObjects.Protocol.protocol + // let p = Protocol.fromString Protocol.protocol // let s = Protocol.toString p @@ -625,7 +627,7 @@ let testProtocolFileLD = testCase "OutputMatchesInputGivenIDs" (fun () -> - let o_read_in = Protocol.fromString TestObjects.Protocol.protocol + let o_read_in = Protocol.fromString Protocol.protocol let exptected_name = "peptide_digestion" let actual_name = o_read_in.Name Expect.isSome actual_name "Should be some" @@ -634,7 +636,7 @@ let testProtocolFileLD = let o = o_read_in |> Protocol.toStringLD let expected = - TestObjects.Protocol.protocolLD + Protocol.protocolLD |> Utils.extractWords |> Array.countBy id |> Array.sortBy fst @@ -650,7 +652,7 @@ let testProtocolFileLD = testCase "OutputMatchesInputDefaultIDs" (fun () -> - let o_read_in = Protocol.fromString TestObjects.Protocol.protocolWithoutIds + let o_read_in = Protocol.fromString Protocol.protocolWithoutIds let exptected_name = "peptide_digestion" let actual_name = o_read_in.Name Expect.isSome actual_name "Should be some" @@ -659,7 +661,7 @@ let testProtocolFileLD = let o = o_read_in |> Protocol.toStringLD let expected = - TestObjects.Protocol.protocolWithDefaultLD + Protocol.protocolWithDefaultLD |> Utils.extractWords |> Array.countBy id |> Array.sortBy fst @@ -681,7 +683,7 @@ let testProcessFile = let readingSuccess = try - Process.fromString TestObjects.Process.process' |> ignore + Process.fromString Process.process' |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -692,7 +694,7 @@ let testProcessFile = testCase "WriterSuccess" (fun () -> - let p = Process.fromString TestObjects.Process.process' + let p = Process.fromString Process.process' let writingSuccess = try @@ -706,7 +708,7 @@ let testProcessFile = testAsync "WriterSchemaCorrectness" { - let p = Process.fromString TestObjects.Process.process' + let p = Process.fromString Process.process' let s = Process.toString p @@ -718,11 +720,11 @@ let testProcessFile = testCase "OutputMatchesInput" (fun () -> let o = - Process.fromString TestObjects.Process.process' + Process.fromString Process.process' |> Process.toString let expected = - TestObjects.Process.process' + Process.process' |> Utils.extractWords |> Array.countBy id |> Array.sortBy fst @@ -733,7 +735,7 @@ let testProcessFile = |> Array.countBy id |> Array.sortBy fst - mySequenceEqual actual expected "Written process file does not match read process file" + Expect.mySequenceEqual actual expected "Written process file does not match read process file" ) ] @@ -744,7 +746,7 @@ let testProcessFileLD = let readingSuccess = try - Process.fromString TestObjects.Process.processLD |> ignore + Process.fromString Process.processLD |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -755,7 +757,7 @@ let testProcessFileLD = testCase "WriterSuccess" (fun () -> - let p = Process.fromString TestObjects.Process.processLD + let p = Process.fromString Process.processLD let writingSuccess = try @@ -769,7 +771,7 @@ let testProcessFileLD = // testAsync "WriterSchemaCorrectness" { - // let p = Process.fromString TestObjects.Process.process' + // let p = Process.fromString Process.process' // let s = Process.toString p @@ -781,11 +783,11 @@ let testProcessFileLD = testCase "OutputMatchesInputGivenIDs" (fun () -> let o = - Process.fromString TestObjects.Process.process' + Process.fromString Process.process' |> Process.toStringLD let expected = - TestObjects.Process.processLD + Process.processLD |> Utils.extractWords |> Array.countBy id |> Array.sortBy fst @@ -796,17 +798,17 @@ let testProcessFileLD = |> Array.countBy id |> Array.sortBy fst - mySequenceEqual actual expected "Written process file does not match read process file" + Expect.mySequenceEqual actual expected "Written process file does not match read process file" ) testCase "OutputMatchesInputDefaultLD" (fun () -> let o = - Process.fromString TestObjects.Process.processWithoutIDs + Process.fromString Process.processWithoutIDs |> Process.toStringLD let expected = - TestObjects.Process.processWithDefaultLD + Process.processWithDefaultLD |> Utils.extractWords |> Array.countBy id |> Array.sortBy fst @@ -816,7 +818,7 @@ let testProcessFileLD = |> Utils.extractWords |> Array.countBy id |> Array.sortBy fst - mySequenceEqual actual expected "Written process file does not match read process file" + Expect.mySequenceEqual actual expected "Written process file does not match read process file" ) ] @@ -827,7 +829,7 @@ let testPersonFile = let readingSuccess = try - Person.fromString TestObjects.Person.person |> ignore + Person.fromString Person.person |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -838,7 +840,7 @@ let testPersonFile = testCase "WriterSuccess" (fun () -> - let a = Person.fromString TestObjects.Person.person + let a = Person.fromString Person.person let writingSuccess = try @@ -852,7 +854,7 @@ let testPersonFile = testAsync "WriterSchemaCorrectness" { - let a = Person.fromString TestObjects.Person.person + let a = Person.fromString Person.person let s = Person.toString a @@ -864,11 +866,11 @@ let testPersonFile = testCase "OutputMatchesInput" (fun () -> let o = - Person.fromString TestObjects.Person.person + Person.fromString Person.person |> Person.toString let expected = - TestObjects.Person.person + Person.person |> Utils.extractWords |> Array.countBy id |> Array.sortBy fst @@ -879,13 +881,13 @@ let testPersonFile = |> Array.countBy id |> Array.sortBy fst - mySequenceEqual actual expected "Written person file does not match read person file" + Expect.mySequenceEqual actual expected "Written person file does not match read person file" ) testCase "WithORCID ReaderCorrectness" (fun () -> - let p = Person.fromString TestObjects.Person.personWithORCID + let p = Person.fromString Person.personWithORCID Expect.isNone p.Comments "Comments should be None" Expect.isSome p.ORCID "ORCID should be Some" Expect.equal p.ORCID.Value "0000-0002-1825-0097" "ORCID not as expected" @@ -894,7 +896,7 @@ let testPersonFile = testAsync "WithORCID WriterSchemaCorrectness" { - let a = Person.fromString TestObjects.Person.personWithORCID + let a = Person.fromString Person.personWithORCID let s = Person.toString a @@ -906,11 +908,11 @@ let testPersonFile = testCase "WithORCID OutputMatchesInput" (fun () -> let o = - Person.fromString TestObjects.Person.personWithORCID + Person.fromString Person.personWithORCID |> Person.toString let expected = - TestObjects.Person.personWithORCID + Person.personWithORCID |> Utils.extractWords |> Array.countBy id |> Array.sortBy fst @@ -921,7 +923,7 @@ let testPersonFile = |> Array.countBy id |> Array.sortBy fst - mySequenceEqual actual expected "Written person file does not match read person file" + Expect.mySequenceEqual actual expected "Written person file does not match read person file" ) ] @@ -932,7 +934,7 @@ let testPersonFileLD = let readingSuccess = try - Person.fromString TestObjects.Person.personLD |> ignore + Person.fromString Person.personLD |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -943,7 +945,7 @@ let testPersonFileLD = testCase "WriterSuccess" (fun () -> - let a = Person.fromString TestObjects.Person.person + let a = Person.fromString Person.person let writingSuccess = try @@ -957,7 +959,7 @@ let testPersonFileLD = // testAsync "WriterSchemaCorrectness" { - // let a = Person.fromString TestObjects.Person.person + // let a = Person.fromString Person.person // let s = Person.toString a @@ -969,11 +971,11 @@ let testPersonFileLD = testCase "OutputMatchesInputGivenID" (fun () -> let o = - Person.fromString TestObjects.Person.person + Person.fromString Person.person |> Person.toStringLD let expected = - TestObjects.Person.personLD + Person.personLD |> Utils.extractWords |> Array.countBy id |> Array.sortBy fst @@ -984,17 +986,17 @@ let testPersonFileLD = |> Array.countBy id |> Array.sortBy fst - mySequenceEqual actual expected "Written person file does not match read person file" + Expect.mySequenceEqual actual expected "Written person file does not match read person file" ) testCase "OutputMatchesInputDefaultLD" (fun () -> let o = - Person.fromString TestObjects.Person.personWithoutID + Person.fromString Person.personWithoutID |> Person.toStringLD let expected = - TestObjects.Person.personWithDefaultLD + Person.personWithDefaultLD |> Utils.extractWords |> Array.countBy id |> Array.sortBy fst @@ -1005,7 +1007,7 @@ let testPersonFileLD = |> Array.countBy id |> Array.sortBy fst - mySequenceEqual actual expected "Written person file does not match read person file" + Expect.mySequenceEqual actual expected "Written person file does not match read person file" ) ] @@ -1016,7 +1018,7 @@ let testPublicationFile = let readingSuccess = try - Publication.fromString TestObjects.Publication.publication |> ignore + Publication.fromString Publication.publication |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -1027,7 +1029,7 @@ let testPublicationFile = testCase "WriterSuccess" (fun () -> - let a = Publication.fromString TestObjects.Publication.publication + let a = Publication.fromString Publication.publication let writingSuccess = try @@ -1041,7 +1043,7 @@ let testPublicationFile = testAsync "WriterSchemaCorrectness" { - let a = Publication.fromString TestObjects.Publication.publication + let a = Publication.fromString Publication.publication let s = Publication.toString a @@ -1053,11 +1055,11 @@ let testPublicationFile = testCase "OutputMatchesInput" (fun () -> let o = - Publication.fromString TestObjects.Publication.publication + Publication.fromString Publication.publication |> Publication.toString let expected = - TestObjects.Publication.publication + Publication.publication |> Utils.extractWords |> Array.countBy id |> Array.sortBy fst @@ -1068,7 +1070,7 @@ let testPublicationFile = |> Array.countBy id |> Array.sortBy fst - mySequenceEqual actual expected "Written Publication file does not match read publication file" + Expect.mySequenceEqual actual expected "Written Publication file does not match read publication file" ) ] @@ -1079,7 +1081,7 @@ let testPublicationFileLD = let readingSuccess = try - Publication.fromString TestObjects.Publication.publicationLD |> ignore + Publication.fromString Publication.publicationLD |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -1090,7 +1092,7 @@ let testPublicationFileLD = testCase "WriterSuccess" (fun () -> - let a = Publication.fromString TestObjects.Publication.publication + let a = Publication.fromString Publication.publication let writingSuccess = try @@ -1104,7 +1106,7 @@ let testPublicationFileLD = // testAsync "WriterSchemaCorrectness" { - // let a = Publication.fromString TestObjects.Publication.publication + // let a = Publication.fromString Publication.publication // let s = Publication.toString a @@ -1116,11 +1118,11 @@ let testPublicationFileLD = testCase "OutputMatchesInput" (fun () -> let o = - Publication.fromString TestObjects.Publication.publication + Publication.fromString Publication.publication |> Publication.toStringLD let expected = - TestObjects.Publication.publicationLD + Publication.publicationLD |> Utils.extractWords |> Array.countBy id |> Array.sortBy fst @@ -1131,7 +1133,7 @@ let testPublicationFileLD = |> Array.countBy id |> Array.sortBy fst - mySequenceEqual actual expected "Written Publication file does not match read publication file" + Expect.mySequenceEqual actual expected "Written Publication file does not match read publication file" ) ] @@ -1142,7 +1144,7 @@ let testAssayFile = let readingSuccess = try - Assay.fromString TestObjects.Assay.assay |> ignore + Assay.fromString Assay.assay |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -1153,7 +1155,7 @@ let testAssayFile = testCase "WriterSuccess" (fun () -> - let a = Assay.fromString TestObjects.Assay.assay + let a = Assay.fromString Assay.assay let writingSuccess = try @@ -1167,7 +1169,7 @@ let testAssayFile = testAsync "WriterSchemaCorrectness" { - let a = Assay.fromString TestObjects.Assay.assay + let a = Assay.fromString Assay.assay let s = Assay.toString a @@ -1179,11 +1181,11 @@ let testAssayFile = testCase "OutputMatchesInput" (fun () -> let o = - Assay.fromString TestObjects.Assay.assay + Assay.fromString Assay.assay |> Assay.toString let expected = - TestObjects.Assay.assay + Assay.assay |> Utils.extractWords |> Array.countBy id |> Array.sortBy fst @@ -1194,7 +1196,7 @@ let testAssayFile = |> Array.countBy id |> Array.sortBy fst - mySequenceEqual actual expected "Written assay file does not match read assay file" + Expect.mySequenceEqual actual expected "Written assay file does not match read assay file" ) ] @@ -1205,7 +1207,7 @@ let testInvestigationFile = let readingSuccess = try - Investigation.fromString TestObjects.Investigation.investigation |> ignore + Investigation.fromString Investigation.investigation |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -1215,7 +1217,7 @@ let testInvestigationFile = testCase "WriterSuccess" (fun () -> - let i = Investigation.fromString TestObjects.Investigation.investigation + let i = Investigation.fromString Investigation.investigation let writingSuccess = try @@ -1229,7 +1231,7 @@ let testInvestigationFile = testAsync "WriterSchemaCorrectness" { - let i = Investigation.fromString TestObjects.Investigation.investigation + let i = Investigation.fromString Investigation.investigation let s = Investigation.toString i @@ -1241,11 +1243,11 @@ let testInvestigationFile = testCase "OutputMatchesInput" (fun () -> let o = - Investigation.fromString TestObjects.Investigation.investigation + Investigation.fromString Investigation.investigation |> Investigation.toString let expected = - TestObjects.Investigation.investigation + Investigation.investigation |> Utils.extractWords |> Array.countBy id |> Array.sortBy fst @@ -1256,7 +1258,7 @@ let testInvestigationFile = |> Array.countBy id |> Array.sortBy fst - mySequenceEqual actual expected "Written investigation file does not match read investigation file" + Expect.mySequenceEqual actual expected "Written investigation file does not match read investigation file" ) testCase "HandleEmptyRemarks" (fun () -> @@ -1615,7 +1617,7 @@ let testInvestigationFile = |> Array.countBy id |> Array.sortBy fst - mySequenceEqual o i "Written investigation file does not match read investigation file" + Expect.mySequenceEqual o i "Written investigation file does not match read investigation file" ) ] @@ -1627,7 +1629,7 @@ let testInvestigationFileLD = let readingSuccess = try - Investigation.fromString TestObjects.Investigation.investigationLD |> ignore + Investigation.fromString Investigation.investigationLD |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -1637,7 +1639,7 @@ let testInvestigationFileLD = testCase "WriterSuccess" (fun () -> - let i = Investigation.fromString TestObjects.Investigation.investigation + let i = Investigation.fromString Investigation.investigation let writingSuccess = try @@ -1678,7 +1680,7 @@ let testInvestigationFileLD = // |> Array.countBy id // |> Array.sortBy fst - // mySequenceEqual actual expected "Written investigation file does not match read investigation file" + // Expect.mySequenceEqual actual expected "Written investigation file does not match read investigation file" // ) // testCase "HandleEmptyRemarks" (fun () -> @@ -2033,8 +2035,8 @@ let testInvestigationFileLD = // |> Array.countBy id // |> Array.sortBy fst - // mySequenceEqual actual expected "Written investigation file does not match read investigation file" - mySequenceEqual [1;2] [1;2] "bla" + // Expect.mySequenceEqual actual expected "Written investigation file does not match read investigation file" + Expect.mySequenceEqual [1;2] [1;2] "bla" ) ] diff --git a/tests/ISA/ISA.Json.Tests/JsonSchema.Tests.fs b/tests/ISA/ISA.Json.Tests/JsonSchema.Tests.fs index 353bceaf..ae5e457c 100644 --- a/tests/ISA/ISA.Json.Tests/JsonSchema.Tests.fs +++ b/tests/ISA/ISA.Json.Tests/JsonSchema.Tests.fs @@ -46,7 +46,7 @@ let tests_Process = testAsync "ProcessDateCorrect" { - let! vr = Validation.validateProcess TestObjects.Validation.processDate + let! vr = Validation.validateProcess TestObjects.Json.Validation.processDate Expect.isTrue vr.Success (sprintf "Process schema validation should have succeded but did not: %A" (vr.GetErrors())) @@ -54,7 +54,7 @@ let tests_Process = testAsync "ProcessDateTimeCorrect" { - let! vr = Validation.validateProcess TestObjects.Validation.processDateTime + let! vr = Validation.validateProcess TestObjects.Json.Validation.processDateTime Expect.isTrue vr.Success (sprintf "Process schema validation should have succeded but did not: %A" (vr.GetErrors())) @@ -62,7 +62,7 @@ let tests_Process = testAsync "ProcessDateWrong" { - let! vr = Validation.validateProcess TestObjects.Validation.processDateWrong + let! vr = Validation.validateProcess TestObjects.Json.Validation.processDateWrong Expect.isFalse vr.Success "Process schema validation should have failed but did not" @@ -70,7 +70,7 @@ let tests_Process = testAsync "ProcessAdditionalField" { - let! vr = Validation.validateProcess TestObjects.Validation.processAdditionalField + let! vr = Validation.validateProcess TestObjects.Json.Validation.processAdditionalField Expect.isFalse vr.Success "Process schema validation should have failed but did not" @@ -78,7 +78,7 @@ let tests_Process = testAsync "ProcessBroken" { - let! vr = Validation.validateProcess TestObjects.Validation.processBroken + let! vr = Validation.validateProcess TestObjects.Json.Validation.processBroken Expect.isFalse vr.Success "Process schema validation should have failed but did not" @@ -91,7 +91,7 @@ let tests_ProcessParameterValue = testAsync "PPVUnit" { - let! vr = Validation.validateProcessParameterValue TestObjects.Validation.ppvUnit + let! vr = Validation.validateProcessParameterValue TestObjects.Json.Validation.ppvUnit Expect.isTrue vr.Success (sprintf "Process parameter value schema validation should have succeded but did not: %A" (vr.GetErrors())) @@ -99,7 +99,7 @@ let tests_ProcessParameterValue = testAsync "PPVOntology" { - let! vr = Validation.validateProcessParameterValue TestObjects.Validation.ppvOntology + let! vr = Validation.validateProcessParameterValue TestObjects.Json.Validation.ppvOntology Expect.isTrue vr.Success (sprintf "Process parameter value schema validation should have succeded but did not: %A" (vr.GetErrors())) @@ -107,7 +107,7 @@ let tests_ProcessParameterValue = testAsync "PPVUriWrong" { - let! vr = Validation.validateProcessParameterValue TestObjects.Validation.ppvUriWrong + let! vr = Validation.validateProcessParameterValue TestObjects.Json.Validation.ppvUriWrong Expect.isFalse vr.Success "Process schema validation should have failed but did not" @@ -115,7 +115,7 @@ let tests_ProcessParameterValue = testAsync "PPVAdditionalField" { - let! vr = Validation.validateProcessParameterValue TestObjects.Validation.ppvAdditionalField + let! vr = Validation.validateProcessParameterValue TestObjects.Json.Validation.ppvAdditionalField Expect.isFalse vr.Success "Process schema validation should have failed but did not" @@ -123,7 +123,7 @@ let tests_ProcessParameterValue = testAsync "PPVBroken" { - let! vr = Validation.validateProcessParameterValue TestObjects.Validation.ppvBroken + let! vr = Validation.validateProcessParameterValue TestObjects.Json.Validation.ppvBroken Expect.isFalse vr.Success "Process schema validation should have failed but did not" diff --git a/tests/ISA/ISA.Json.Tests/Utils.fs b/tests/ISA/ISA.Json.Tests/Utils.fs deleted file mode 100644 index 3911092c..00000000 --- a/tests/ISA/ISA.Json.Tests/Utils.fs +++ /dev/null @@ -1,52 +0,0 @@ -module TestingUtils - -open Expecto -open ARCtrl.ISA.Json - -module Async = - - let map (f : 'U -> 'T) (a : Async<'U>) = - async { - let! a' = a - return f a' - } - -module Utils = - - let extractWords (json:string) = - json.Split([|'{';'}';'[';']';',';':'|]) - |> Array.map (fun s -> s.Trim()) - |> Array.filter ((<>) "") - - let wordFrequency (json:string) = - json - |> extractWords - |> Array.countBy id - |> Array.sortBy fst - -module Result = - - let getMessage res = - match res with - | Ok m -> m - | Error m -> m - -let firstDiff s1 s2 = - let s1 = Seq.append (Seq.map Some s1) (Seq.initInfinite (fun _ -> None)) - let s2 = Seq.append (Seq.map Some s2) (Seq.initInfinite (fun _ -> None)) - Seq.mapi2 (fun i s p -> i,s,p) s1 s2 - |> Seq.find (function |_,Some s,Some p when s=p -> false |_-> true) - -/// Expects the `actual` sequence to equal the `expected` one. -let inline mySequenceEqual actual expected message = - match firstDiff actual expected with - | _,None,None -> () - | i,Some a, Some e -> - failwithf "%s. Sequence does not match at position %i. Expected item: %A, but got %A." - message i e a - | i,None,Some e -> - failwithf "%s. Sequence actual shorter than expected, at pos %i for expected item %A." - message i e - | i,Some a,None -> - failwithf "%s. Sequence actual longer than expected, at pos %i found item %A." - message i a \ No newline at end of file diff --git a/tests/ISA/ISA.Spreadsheet.Tests/ArcTableTests.fs b/tests/ISA/ISA.Spreadsheet.Tests/ArcTableTests.fs index eb3bbf53..7436d9a0 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/ArcTableTests.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/ArcTableTests.fs @@ -11,7 +11,7 @@ open ARCtrl.ISA open ARCtrl.ISA.Spreadsheet open TestingUtils -open TestObjects.ArcTable +open TestObjects.Spreadsheet.ArcTable let private ensureCorrectTestHeaders = testList "ensureCorrectTestHeaders" [ @@ -34,7 +34,7 @@ let private ensureCorrectTestHeaders = Parameter.instrumentHeaderV3 + " " ] - mySequenceEqual (ws.Row(1).Cells |> Seq.map (fun c -> c.Value)) expectedHeaders "Headers did not match" + Expect.mySequenceEqual (ws.Row(1).Cells |> Seq.map (fun c -> c.Value)) expectedHeaders "Headers did not match" let expectedValues = [ @@ -46,7 +46,7 @@ let private ensureCorrectTestHeaders = Parameter.instrumentValueV3 ] - mySequenceEqual (ws.Row(2).Cells |> Seq.map (fun c -> c.Value)) expectedValues "Values did not match" + Expect.mySequenceEqual (ws.Row(2).Cells |> Seq.map (fun c -> c.Value)) expectedValues "Values did not match" ) ] @@ -77,7 +77,7 @@ let private groupCols = let actualHeaderGroups = grouped |> List.map (fun cols -> cols |> List.map (fun c -> c.[1].Value) |> List.reduce (fun a b -> a + ";" + b)) - mySequenceEqual actualHeaderGroups expectedHeaderGroups "Header groups did not match" + Expect.mySequenceEqual actualHeaderGroups expectedHeaderGroups "Header groups did not match" ) ] @@ -116,7 +116,7 @@ let private simpleTable = Characteristic.organismHeader Factor.timeHeader ] - mySequenceEqual table.Headers expectedHeaders "Headers did not match" + Expect.mySequenceEqual table.Headers expectedHeaders "Headers did not match" let expectedCells = [ @@ -128,7 +128,7 @@ let private simpleTable = Characteristic.organismValue Factor.timeValue ] - mySequenceEqual (table.GetRow(0)) expectedCells "Cells did not match" + Expect.mySequenceEqual (table.GetRow(0)) expectedCells "Cells did not match" ) testCase "Write" (fun () -> @@ -173,7 +173,7 @@ let private emptyTable = Characteristic.organismHeader Factor.timeHeader ] - mySequenceEqual table.Headers expectedHeaders "Headers did not match" + Expect.mySequenceEqual table.Headers expectedHeaders "Headers did not match" ) // TODO: What should we do with units of empty columns? //testCase "Write" (fun () -> @@ -219,7 +219,7 @@ let private mixedTable = Characteristic.organismHeader Factor.timeHeader ] - mySequenceEqual table.Headers expectedHeaders "Headers did not match" + Expect.mySequenceEqual table.Headers expectedHeaders "Headers did not match" ) testCase "Write" (fun () -> @@ -265,7 +265,7 @@ let private ioTable = Factor.timeHeader Output.rawDataHeader ] - mySequenceEqual table.Headers expectedHeaders "Headers did not match" + Expect.mySequenceEqual table.Headers expectedHeaders "Headers did not match" let expectedCells = [ Input.sampleValue @@ -275,7 +275,7 @@ let private ioTable = Factor.timeValue Output.rawDataValue ] - mySequenceEqual (table.GetRow(0)) expectedCells "Cells did not match" + Expect.mySequenceEqual (table.GetRow(0)) expectedCells "Cells did not match" ) testCase "Write" (fun () -> @@ -320,7 +320,7 @@ let private deprecatedColumnTable = Parameter.temperatureHeader Output.deprecatedSampleHeader ] - mySequenceEqual table.Headers expectedHeaders "Headers did not match" + Expect.mySequenceEqual table.Headers expectedHeaders "Headers did not match" let expectedCells = [ @@ -330,7 +330,7 @@ let private deprecatedColumnTable = Parameter.temperatureValue Output.rawDataValue ] - mySequenceEqual (table.GetRow(0)) expectedCells "Cells did not match" + Expect.mySequenceEqual (table.GetRow(0)) expectedCells "Cells did not match" ) ] diff --git a/tests/ISA/ISA.Spreadsheet.Tests/AssayFileTests.fs b/tests/ISA/ISA.Spreadsheet.Tests/AssayFileTests.fs index 8a1c53fc..5f3554c8 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/AssayFileTests.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/AssayFileTests.fs @@ -11,6 +11,7 @@ open ARCtrl.ISA open TestingUtils open ARCtrl.ISA.Spreadsheet +open TestObjects.Spreadsheet let testMetaDataFunctions = @@ -20,7 +21,7 @@ let testMetaDataFunctions = let readingSuccess = try - ArcAssay.fromMetadataSheet TestObjects.Assay.assayMetadata |> ignore + ArcAssay.fromMetadataSheet Assay.assayMetadata |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -31,7 +32,7 @@ let testMetaDataFunctions = testCase "ReaderReadsORCID" (fun () -> - let assay = ArcAssay.fromMetadataSheet TestObjects.Assay.assayMetadata + let assay = ArcAssay.fromMetadataSheet Assay.assayMetadata Expect.equal assay.Performers.Length 3 "Assay should have 3 performers" Expect.isSome assay.Performers.[0].ORCID "ORCID should be set" Expect.equal assay.Performers.[0].ORCID.Value "0000-0002-1825-0097" "ORCID not read correctly" @@ -45,7 +46,7 @@ let testMetaDataFunctions = let readingSuccess = try - ArcAssay.fromMetadataSheet TestObjects.Assay.assayMetadataObsoleteSheetName |> ignore + ArcAssay.fromMetadataSheet Assay.assayMetadataObsoleteSheetName |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -56,7 +57,7 @@ let testMetaDataFunctions = testCase "WriterSuccess" (fun () -> - let a = ArcAssay.fromMetadataSheet TestObjects.Assay.assayMetadata + let a = ArcAssay.fromMetadataSheet Assay.assayMetadata let writingSuccess = try @@ -71,7 +72,7 @@ let testMetaDataFunctions = testCase "WriterCreatesNoEmptyCells" (fun () -> let o = - ArcAssay.fromMetadataSheet TestObjects.Assay.assayMetadata + ArcAssay.fromMetadataSheet Assay.assayMetadata |> ArcAssay.toMetadataSheet o.CellCollection.GetCells() @@ -80,7 +81,7 @@ let testMetaDataFunctions = testCase "WriterSuccessObsoleteSheetName" (fun () -> - let a = ArcAssay.fromMetadataSheet TestObjects.Assay.assayMetadataObsoleteSheetName + let a = ArcAssay.fromMetadataSheet Assay.assayMetadataObsoleteSheetName let writingSuccess = try @@ -95,28 +96,28 @@ let testMetaDataFunctions = testCase "OutputMatchesInput" (fun () -> let o = - TestObjects.Assay.assayMetadata + Assay.assayMetadata |> ArcAssay.fromMetadataSheet |> ArcAssay.toMetadataSheet - Expect.workSheetEqual o TestObjects.Assay.assayMetadata "Written assay metadata does not match read assay metadata" + Expect.workSheetEqual o Assay.assayMetadata "Written assay metadata does not match read assay metadata" ) testCase "OutputSheetNamesDifferentObsoleteSheetName" (fun () -> let o = - TestObjects.Assay.assayMetadataObsoleteSheetName + Assay.assayMetadataObsoleteSheetName |> ArcAssay.fromMetadataSheet |> ArcAssay.toMetadataSheet - Expect.isTrue (o.Name <> TestObjects.Assay.assayMetadataObsoleteSheetName.Name) "sheet names were expected to be different (obsolete replaced by new)" + Expect.isTrue (o.Name <> Assay.assayMetadataObsoleteSheetName.Name) "sheet names were expected to be different (obsolete replaced by new)" ) testCase "ReaderSuccessEmpty" (fun () -> let readingSuccess = try - ArcAssay.fromMetadataSheet TestObjects.Assay.assayMetadataEmpty |> ignore + ArcAssay.fromMetadataSheet Assay.assayMetadataEmpty |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the empty test file failed: %s" err.Message) @@ -126,7 +127,7 @@ let testMetaDataFunctions = testCase "ReaderCorrectnessEmpty" (fun () -> - let assay = ArcAssay.fromMetadataSheet TestObjects.Assay.assayMetadataEmpty + let assay = ArcAssay.fromMetadataSheet Assay.assayMetadataEmpty Expect.isNone assay.MeasurementType "MeasurementType should not be set" Expect.isNone assay.TechnologyPlatform "TechnologyPlatform should not be set" Expect.isNone assay.TechnologyType "TechnologyType should not be set" @@ -134,7 +135,7 @@ let testMetaDataFunctions = testCase "ReaderCorrectnessEmptyStrings" (fun () -> - let assay = ArcAssay.fromMetadataSheet TestObjects.Assay.assayMetadataEmptyStrings + let assay = ArcAssay.fromMetadataSheet Assay.assayMetadataEmptyStrings Expect.isNone assay.MeasurementType "MeasurementType should not be set" Expect.isNone assay.TechnologyPlatform "TechnologyPlatform should not be set" Expect.isNone assay.TechnologyType "TechnologyType should not be set" @@ -145,7 +146,7 @@ let testMetaDataFunctions = let readingSuccess = try - ArcAssay.fromMetadataSheet TestObjects.Assay.assayMetadataEmptyObsoleteSheetName |> ignore + ArcAssay.fromMetadataSheet Assay.assayMetadataEmptyObsoleteSheetName |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the empty test file failed: %s" err.Message) @@ -154,7 +155,7 @@ let testMetaDataFunctions = testCase "WriterSuccessEmpty" (fun () -> - let a = ArcAssay.fromMetadataSheet TestObjects.Assay.assayMetadataEmpty + let a = ArcAssay.fromMetadataSheet Assay.assayMetadataEmpty let writingSuccess = try @@ -168,7 +169,7 @@ let testMetaDataFunctions = testCase "WriterSuccessEmptyObsoleteSheetName" (fun () -> - let a = ArcAssay.fromMetadataSheet TestObjects.Assay.assayMetadataEmptyObsoleteSheetName + let a = ArcAssay.fromMetadataSheet Assay.assayMetadataEmptyObsoleteSheetName let writingSuccess = try @@ -183,27 +184,27 @@ let testMetaDataFunctions = testCase "OutputMatchesInputEmpty" (fun () -> let o = - TestObjects.Assay.assayMetadataEmpty + Assay.assayMetadataEmpty |> ArcAssay.fromMetadataSheet |> ArcAssay.toMetadataSheet - Expect.workSheetEqual o TestObjects.Assay.assayMetadataEmpty "Written Empty assay metadata does not match read assay metadata" + Expect.workSheetEqual o Assay.assayMetadataEmpty "Written Empty assay metadata does not match read assay metadata" ) testCase "OutputSheetNamesDifferentEmptyObsoleteSheetName" (fun () -> let o = - TestObjects.Assay.assayMetadataEmptyObsoleteSheetName + Assay.assayMetadataEmptyObsoleteSheetName |> ArcAssay.fromMetadataSheet |> ArcAssay.toMetadataSheet - Expect.isTrue (o.Name <> TestObjects.Assay.assayMetadataEmptyObsoleteSheetName.Name) "sheet names were expected to be different (obsolete replaced by new)" + Expect.isTrue (o.Name <> Assay.assayMetadataEmptyObsoleteSheetName.Name) "sheet names were expected to be different (obsolete replaced by new)" ) testCase "ReaderSuccessFromWorkbook" (fun () -> let readingSuccess = try - ArcAssay.fromFsWorkbook TestObjects.Assay.assayMetadataWorkbook |> ignore + ArcAssay.fromFsWorkbook Assay.assayMetadataWorkbook |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -214,7 +215,7 @@ let testMetaDataFunctions = testCase "ReaderSuccessFromWorkbookObsoleteSheetName" (fun () -> let readingSuccess = try - ArcAssay.fromFsWorkbook TestObjects.Assay.assayMetadataWorkbookObsoleteSheetName |> ignore + ArcAssay.fromFsWorkbook Assay.assayMetadataWorkbookObsoleteSheetName |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -225,7 +226,7 @@ let testMetaDataFunctions = testCase "ReaderSuccessFromWorkbookEmpty" (fun () -> let readingSuccess = try - ArcAssay.fromFsWorkbook TestObjects.Assay.assayMetadataWorkbookEmpty |> ignore + ArcAssay.fromFsWorkbook Assay.assayMetadataWorkbookEmpty |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -236,7 +237,7 @@ let testMetaDataFunctions = testCase "ReaderSuccessFromWorkbookEmptyObsoleteSheetName" (fun () -> let readingSuccess = try - ArcAssay.fromFsWorkbook TestObjects.Assay.assayMetadataWorkbookEmptyObsoleteSheetName |> ignore + ArcAssay.fromFsWorkbook Assay.assayMetadataWorkbookEmptyObsoleteSheetName |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -246,7 +247,7 @@ let testMetaDataFunctions = testCase "WriterSuccessFromWorkbook" (fun () -> - let a = ArcAssay.fromFsWorkbook TestObjects.Assay.assayMetadataWorkbook + let a = ArcAssay.fromFsWorkbook Assay.assayMetadataWorkbook let writingSuccess = try @@ -260,7 +261,7 @@ let testMetaDataFunctions = testCase "WriterSuccessFromWorkbookObsoleteSheetName" (fun () -> - let a = ArcAssay.fromFsWorkbook TestObjects.Assay.assayMetadataWorkbookObsoleteSheetName + let a = ArcAssay.fromFsWorkbook Assay.assayMetadataWorkbookObsoleteSheetName let writingSuccess = try @@ -274,7 +275,7 @@ let testMetaDataFunctions = testCase "WriterSuccessFromWorkbookEmpty" (fun () -> - let a = ArcAssay.fromFsWorkbook TestObjects.Assay.assayMetadataWorkbookEmpty + let a = ArcAssay.fromFsWorkbook Assay.assayMetadataWorkbookEmpty let writingSuccess = try @@ -288,7 +289,7 @@ let testMetaDataFunctions = testCase "WriterSuccessFromWorkbookEmptyObsoleteSheetName" (fun () -> - let a = ArcAssay.fromFsWorkbook TestObjects.Assay.assayMetadataWorkbookEmptyObsoleteSheetName + let a = ArcAssay.fromFsWorkbook Assay.assayMetadataWorkbookEmptyObsoleteSheetName let writingSuccess = try @@ -303,48 +304,48 @@ let testMetaDataFunctions = testCase "OutputMatchesInputFromWorkbook" (fun () -> let o = - TestObjects.Assay.assayMetadataWorkbook + Assay.assayMetadataWorkbook |> ArcAssay.fromFsWorkbook |> ArcAssay.toMetadataSheet - Expect.workSheetEqual o TestObjects.Assay.assayMetadata "Written Empty assay metadata does not match read assay metadata" + Expect.workSheetEqual o Assay.assayMetadata "Written Empty assay metadata does not match read assay metadata" ) testCase "OutputSheetNamesDifferentFromWorkbookObsoleteSheetName" (fun () -> let o = - TestObjects.Assay.assayMetadataWorkbookEmptyObsoleteSheetName + Assay.assayMetadataWorkbookEmptyObsoleteSheetName |> ArcAssay.fromFsWorkbook |> ArcAssay.toMetadataSheet - Expect.isTrue (o.Name <> TestObjects.Assay.assayMetadataEmptyObsoleteSheetName.Name) "sheet names were expected to be different (obsolete replaced by new)" + Expect.isTrue (o.Name <> Assay.assayMetadataEmptyObsoleteSheetName.Name) "sheet names were expected to be different (obsolete replaced by new)" ) testCase "OutputMatchesInputFromWorkbookEmpty" (fun () -> let o = - TestObjects.Assay.assayMetadataWorkbookEmpty + Assay.assayMetadataWorkbookEmpty |> ArcAssay.fromFsWorkbook |> ArcAssay.toMetadataSheet - Expect.workSheetEqual o TestObjects.Assay.assayMetadataEmpty "Written Empty assay metadata does not match read assay metadata" + Expect.workSheetEqual o Assay.assayMetadataEmpty "Written Empty assay metadata does not match read assay metadata" ) testCase "OutputSheetNamesDifferentFromWorkbookEmptyObsoleteSheetName" (fun () -> let o = - TestObjects.Assay.assayMetadataWorkbookEmptyObsoleteSheetName + Assay.assayMetadataWorkbookEmptyObsoleteSheetName |> ArcAssay.fromFsWorkbook |> ArcAssay.toMetadataSheet - Expect.isTrue (o.Name <> TestObjects.Assay.assayMetadataEmptyObsoleteSheetName.Name) "sheet names were expected to be different (obsolete replaced by new)" + Expect.isTrue (o.Name <> Assay.assayMetadataEmptyObsoleteSheetName.Name) "sheet names were expected to be different (obsolete replaced by new)" ) testCase "ReaderSuccessDeprecatedKeys" (fun () -> let readingSuccess = try - ArcAssay.fromMetadataSheet TestObjects.Assay.assayMetadataDeprecatedKeys |> ignore + ArcAssay.fromMetadataSheet Assay.assayMetadataDeprecatedKeys |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -355,7 +356,7 @@ let testMetaDataFunctions = testCase "WriterSuccessDeprecatedKeys" (fun () -> - let a = ArcAssay.fromMetadataSheet TestObjects.Assay.assayMetadataDeprecatedKeys + let a = ArcAssay.fromMetadataSheet Assay.assayMetadataDeprecatedKeys let writingSuccess = try @@ -370,11 +371,11 @@ let testMetaDataFunctions = testCase "OutputMatchesInputDeprecatedKeys" (fun () -> let o = - TestObjects.Assay.assayMetadataDeprecatedKeys + Assay.assayMetadataDeprecatedKeys |> ArcAssay.fromMetadataSheet |> ArcAssay.toMetadataSheet - Expect.workSheetEqual o TestObjects.Assay.assayMetadata "Written assay metadata does not match read assay metadata" + Expect.workSheetEqual o Assay.assayMetadata "Written assay metadata does not match read assay metadata" ) @@ -411,9 +412,9 @@ let testAssayFileReader = // let factors = API.Assay.getFactors assay // let protocols = API.Assay.getProtocols assay - // mySequenceEqual factors expectedFactors "Factors were read incorrectly" - // mySequenceEqual protocols expectedProtocols "Protocols were read incorrectly" - // mySequenceEqual persons expectedPersons "Persons were read incorrectly from metadata sheet" + // Expect.mySequenceEqual factors expectedFactors "Factors were read incorrectly" + // Expect.mySequenceEqual protocols expectedProtocols "Protocols were read incorrectly" + // Expect.mySequenceEqual persons expectedPersons "Persons were read incorrectly from metadata sheet" // Expect.isSome assay.FileName "FileName was not read" // Expect.equal assay.FileName.Value fileName "FileName was not read correctly" @@ -427,7 +428,7 @@ let testAssayFileReader = // Expect.isSome assay.ProcessSequence "Processes were not read" // assay.ProcessSequence.Value // |> Seq.map (fun p -> Option.defaultValue "" p.Name) - // |> fun names -> mySequenceEqual names ["GreatAssay_0";"GreatAssay_1";"SecondAssay_0"] "Process names do not match" + // |> fun names -> Expect.mySequenceEqual names ["GreatAssay_0";"GreatAssay_1";"SecondAssay_0"] "Process names do not match" //) //testCase "AroundTheWorldComponents" (fun () -> @@ -459,7 +460,7 @@ let testAssayFileReader = // Expect.equal p.ExecutesProtocol.Value refP.ExecutesProtocol.Value "Assay written to xlsx and read in again does no longer match json. Protocol does not match" // Expect.equal p refP "Assay written to xlsx and read in again does no longer match json. Process does not match" // ) - // mySequenceEqual a'.ProcessSequence.Value ref.ProcessSequence.Value "" + // Expect.mySequenceEqual a'.ProcessSequence.Value ref.ProcessSequence.Value "" //) //testCase "AroundTheWorldProtocolType" (fun () -> @@ -492,7 +493,7 @@ let testAssayFileReader = // Expect.equal p.ExecutesProtocol.Value refP.ExecutesProtocol.Value "Assay written to xlsx and read in again does no longer match json. Protocol does not match" // Expect.equal p refP "Assay written to xlsx and read in again does no longer match json. Process does not match" // ) - // mySequenceEqual a'.ProcessSequence.Value ref.ProcessSequence.Value "" + // Expect.mySequenceEqual a'.ProcessSequence.Value ref.ProcessSequence.Value "" //) ] diff --git a/tests/ISA/ISA.Spreadsheet.Tests/CompositeColumnTests.fs b/tests/ISA/ISA.Spreadsheet.Tests/CompositeColumnTests.fs index 10f32876..62b51f55 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/CompositeColumnTests.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/CompositeColumnTests.fs @@ -10,7 +10,7 @@ open ARCtrl.ISA open TestingUtils open ARCtrl.ISA.Spreadsheet -open TestObjects.ArcTable +open TestObjects.Spreadsheet.ArcTable let private parameterTests = testList "Parameter" [ diff --git a/tests/ISA/ISA.Spreadsheet.Tests/ISA.Spreadsheet.Tests.fsproj b/tests/ISA/ISA.Spreadsheet.Tests/ISA.Spreadsheet.Tests.fsproj index fc91acb1..ec5630fd 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/ISA.Spreadsheet.Tests.fsproj +++ b/tests/ISA/ISA.Spreadsheet.Tests/ISA.Spreadsheet.Tests.fsproj @@ -7,11 +7,6 @@ - - - - - @@ -27,6 +22,7 @@ + \ No newline at end of file diff --git a/tests/ISA/ISA.Spreadsheet.Tests/InvestigationFileTests.fs b/tests/ISA/ISA.Spreadsheet.Tests/InvestigationFileTests.fs index 4cebfe04..2ea42146 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/InvestigationFileTests.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/InvestigationFileTests.fs @@ -11,6 +11,8 @@ open FsSpreadsheet open TestingUtils open ARCtrl.ISA.Spreadsheet +open TestObjects.Spreadsheet + let private testInvestigationWriterComponents = // Test the single components of invesigation file writing testList "InvestigationWriterPartTests" [ @@ -62,7 +64,7 @@ let private testInvestigationFile = let readingSuccess = try - ArcInvestigation.fromFsWorkbook TestObjects.Investigation.fullInvestigation |> ignore + ArcInvestigation.fromFsWorkbook Investigation.fullInvestigation |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -74,7 +76,7 @@ let private testInvestigationFile = let readingSuccess = try - ArcInvestigation.fromFsWorkbook TestObjects.Investigation.fullInvestigationObsoleteSheetName |> ignore + ArcInvestigation.fromFsWorkbook Investigation.fullInvestigationObsoleteSheetName |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -86,7 +88,7 @@ let private testInvestigationFile = let readingSuccess = try - ArcInvestigation.fromFsWorkbook TestObjects.Investigation.fullInvestigationWrongSheetName |> ignore + ArcInvestigation.fromFsWorkbook Investigation.fullInvestigationWrongSheetName |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the test file failed: %s" err.Message) @@ -95,7 +97,7 @@ let private testInvestigationFile = ) testCase "WriterSuccess" (fun () -> - let i = ArcInvestigation.fromFsWorkbook TestObjects.Investigation.fullInvestigation + let i = ArcInvestigation.fromFsWorkbook Investigation.fullInvestigation let writingSuccess = try @@ -110,10 +112,10 @@ let private testInvestigationFile = testCase "OutputMatchesInput" (fun () -> let i = - TestObjects.Investigation.fullInvestigation.GetWorksheetByName "isa_investigation" + Investigation.fullInvestigation.GetWorksheetByName "isa_investigation" let o = - TestObjects.Investigation.fullInvestigation + Investigation.fullInvestigation |> ArcInvestigation.fromFsWorkbook |> ArcInvestigation.toFsWorkbook |> fun wb -> wb.GetWorksheetByName "isa_investigation" @@ -132,7 +134,7 @@ let private testInvestigationFile = let readingSuccess = try - ArcInvestigation.fromFsWorkbook TestObjects.Investigation.emptyInvestigation |> ignore + ArcInvestigation.fromFsWorkbook Investigation.emptyInvestigation |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the empty test file failed: %s" err.Message) @@ -141,7 +143,7 @@ let private testInvestigationFile = testCase "WriterSuccessEmpty" (fun () -> - let i = ArcInvestigation.fromFsWorkbook TestObjects.Investigation.emptyInvestigation + let i = ArcInvestigation.fromFsWorkbook Investigation.emptyInvestigation let writingSuccess = try @@ -156,11 +158,11 @@ let private testInvestigationFile = //testCase "OutputMatchesInputEmpty" (fun () -> // let i = - // TestObjects.Investigation.emptyInvestigation.GetWorksheetByName "isa_investigation" + // Investigation.emptyInvestigation.GetWorksheetByName "isa_investigation" // |> fun ws -> ws.Rows // |> Seq.map (fun r -> r.Cells |> Seq.map (fun c -> c.Value) |> Seq.reduce (fun a b -> a + b)) // let o = - // TestObjects.Investigation.emptyInvestigation + // Investigation.emptyInvestigation // |> ArcInvestigation.fromFsWorkbook // |> ArcInvestigation.toFsWorkbook // |> fun wb -> wb.GetWorksheetByName "isa_investigation" @@ -168,7 +170,7 @@ let private testInvestigationFile = // |> Seq.map (fun r -> r.Cells |> Seq.map (fun c -> c.Value) |> Seq.reduce (fun a b -> a + b)) - // mySequenceEqual o i "Written empty investigation file does not match read empty investigation file" + // Expect.mySequenceEqual o i "Written empty investigation file does not match read empty investigation file" //) ] |> testSequenced @@ -223,7 +225,7 @@ let private testInvestigationFile = // Expect.isSome retrievedInvestigation "Could not retrieve investigation" -// mySequenceEqual +// Expect.mySequenceEqual // (retrievedInvestigation.Value |> getKeyValues) // (testInvestigation |> getKeyValues) // "Could not retrieve the correct investigation from investigation file" @@ -249,7 +251,7 @@ let private testInvestigationFile = // Expect.isSome retrievedItem "Could not retrieve item from investigation file" -// mySequenceEqual +// Expect.mySequenceEqual // (retrievedItem.Value |> getKeyValues) // (testItem |> getKeyValues) // "Could not retrieve the correct item from investigation file" @@ -277,7 +279,7 @@ let private testInvestigationFile = // Expect.isSome retrievedItem "Could not retrieve item from investigation file" -// mySequenceEqual +// Expect.mySequenceEqual // (retrievedItem.Value |> getKeyValues) // (testItem |> getKeyValues) // "Could not retrieve the correct item from investigation file" @@ -292,7 +294,7 @@ let private testInvestigationFile = // let retrievedStudies = ISA_Investigation.getStudies doc |> Seq.map getIdentificationKeyValues -// mySequenceEqual +// Expect.mySequenceEqual // retrievedStudies // testStudies // "Could not retrieve the correct studies from the investigation file" @@ -328,7 +330,7 @@ let private testInvestigationFile = // Expect.isSome retrievedInvestigation "Investigation file was not filled out" -// mySequenceEqual +// Expect.mySequenceEqual // (retrievedInvestigation.Value |> getKeyValues) // (investigation |> getKeyValues) // "Investigation file was not filled out correctly" @@ -353,7 +355,7 @@ let private testInvestigationFile = // Expect.isSome retrievedStudy "Study could not be found" -// mySequenceEqual +// Expect.mySequenceEqual // (retrievedStudy.Value |> getKeyValues) // (study |> getKeyValues) // "Study was not inserted correctly correctly" @@ -396,7 +398,7 @@ let private testInvestigationFile = // (ISA_Investigation.tryAddStudy study2 doc) // "Could not add study" -// mySequenceEqual +// Expect.mySequenceEqual // (ISA_Investigation.getStudies doc |> Seq.map getKeyValues) // ([study1;study2] |> Seq.map getKeyValues) // "The Sequences do not match the expected seqs" @@ -424,7 +426,7 @@ let private testInvestigationFile = // Expect.isSome retrievedAssay "Assay could not be found" -// mySequenceEqual +// Expect.mySequenceEqual // (retrievedAssay.Value |> getKeyValues) // (assay |> getKeyValues) // "Study was not inserted correctly correctly" @@ -452,7 +454,7 @@ let private testInvestigationFile = // Expect.isSome retrievedAssay "Assay could not be found" -// mySequenceEqual +// Expect.mySequenceEqual // (retrievedAssay.Value |> getKeyValues) // (assay |> getKeyValues) // "Assay was not inserted correctly correctly" @@ -481,7 +483,7 @@ let private testInvestigationFile = // Expect.isSome retrievedAssay "Assay could not be found" -// mySequenceEqual +// Expect.mySequenceEqual // (retrievedAssay.Value |> getKeyValues) // (updatedAssay |> getKeyValues) // "Assay was not updated correctly" @@ -509,7 +511,7 @@ let private testInvestigationFile = // (ISA_Investigation.tryRemoveItemFromStudy assayToRemove study doc) // "Could not remove assay" -// mySequenceEqual +// Expect.mySequenceEqual // (ISA_Investigation.getItemsInStudy (Assay()) study doc |> Seq.map getKeyValues) // ([remainingAssay] |> Seq.map getKeyValues) // "The Sequences do not match the expected seqs" diff --git a/tests/ISA/ISA.Spreadsheet.Tests/SparseTableTests.fs b/tests/ISA/ISA.Spreadsheet.Tests/SparseTableTests.fs index 3dbe0dc0..0ef3a98d 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/SparseTableTests.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/SparseTableTests.fs @@ -130,7 +130,7 @@ let main = |> SparseTable.ToRows |> Seq.iteri (fun i r -> let testSeq = Seq.item i testRows - mySequenceEqual (SparseRow.getValues r) testSeq "" + Expect.mySequenceEqual (SparseRow.getValues r) testSeq "" ) diff --git a/tests/ISA/ISA.Spreadsheet.Tests/StringConversionTests.fs b/tests/ISA/ISA.Spreadsheet.Tests/StringConversionTests.fs index c00e432b..ddc81aaf 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/StringConversionTests.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/StringConversionTests.fs @@ -80,7 +80,7 @@ let aggregated = // ] // let ontologies = OntologyAnnotation.fromAggregatedStrings ';' terms accessions sources - // mySequenceEqual ontologies testOntologies "Ontology Annotations were not created correctly from aggregated strings" + // Expect.mySequenceEqual ontologies testOntologies "Ontology Annotations were not created correctly from aggregated strings" // Expect.equal (OntologyAnnotation.toAggregatedStrings ';' ontologies) (terms,accessions,sources) "Ontology Annotations were not parsed correctly to aggregated strings" // let testComponents = @@ -90,7 +90,7 @@ let aggregated = // ] // let components = Component.fromAggregatedStrings ';' names terms accessions sources - // mySequenceEqual components testComponents "Components were not created correctly from aggregated strings" + // Expect.mySequenceEqual components testComponents "Components were not created correctly from aggregated strings" // Expect.equal (Component.toAggregatedStrings ';' components) (names,terms,accessions,sources) "Components were not parsed correctly to aggregated strings" // let testPParams = @@ -100,7 +100,7 @@ let aggregated = // ] // let pParams = ProtocolParameter.fromAggregatedStrings ';' terms accessions sources - // mySequenceEqual pParams testPParams "Protocol Parameters were not created correctly from aggregated strings" + // Expect.mySequenceEqual pParams testPParams "Protocol Parameters were not created correctly from aggregated strings" // Expect.equal (ProtocolParameter.toAggregatedStrings ';' pParams) (terms,accessions,sources) "Protocol Parameters were not parsed correctly to aggregated strings" //) @@ -113,19 +113,19 @@ let aggregated = // let testOntologies = [ ] // let ontologies = OntologyAnnotation.fromAggregatedStrings ';' terms accessions sources - // mySequenceEqual ontologies testOntologies "Ontology Annotations were not created correctly from empty aggregated strings. Empty strings should results in an empty list" + // Expect.mySequenceEqual ontologies testOntologies "Ontology Annotations were not created correctly from empty aggregated strings. Empty strings should results in an empty list" // Expect.equal (OntologyAnnotation.toAggregatedStrings ';' ontologies) (terms,accessions,sources) "Ontology Annotations were not parsed correctly to empty aggregated strings" // let testComponents = [] // let components = Component.fromAggregatedStrings ';' names terms accessions sources - // mySequenceEqual components testComponents "Components were not created correctly from empty aggregated strings. Empty strings should results in an empty list" + // Expect.mySequenceEqual components testComponents "Components were not created correctly from empty aggregated strings. Empty strings should results in an empty list" // Expect.equal (Component.toAggregatedStrings ';' components) (names,terms,accessions,sources) "Components were not parsed correctly to empty aggregated strings" // let testPParams = [] // let pParams = ProtocolParameter.fromAggregatedStrings ';' terms accessions sources - // mySequenceEqual pParams testPParams "Protocol Parameters were not created correctly from aggregated strings. Empty strings should results in an empty list" + // Expect.mySequenceEqual pParams testPParams "Protocol Parameters were not created correctly from aggregated strings. Empty strings should results in an empty list" // Expect.equal (ProtocolParameter.toAggregatedStrings ';' pParams) (terms,accessions,sources) "Protocol Parameters were not parsed correctly to aggregated strings" //) //testCase "PartlyEmptyStrings" (fun () -> @@ -141,7 +141,7 @@ let aggregated = // ] // let ontologies = OntologyAnnotation.fromAggregatedStrings ';' terms accessions sources - // mySequenceEqual ontologies testOntologies "Ontology Annotations were not created correctly from partly empty aggregated strings" + // Expect.mySequenceEqual ontologies testOntologies "Ontology Annotations were not created correctly from partly empty aggregated strings" // Expect.equal (OntologyAnnotation.toAggregatedStrings ';' ontologies) (terms,accessions,";") "Ontology Annotations were not parsed correctly to partly empty aggregated strings" // let testComponents = @@ -151,7 +151,7 @@ let aggregated = // ] // let components = Component.fromAggregatedStrings ';' names terms accessions sources - // mySequenceEqual components testComponents "Components were not created correctly from partly empty aggregated strings" + // Expect.mySequenceEqual components testComponents "Components were not created correctly from partly empty aggregated strings" // Expect.equal (Component.toAggregatedStrings ';' components) (";",terms,accessions,";") "Components were not parsed correctly to partly empty aggregated strings" // let testPParams = @@ -161,7 +161,7 @@ let aggregated = // ] // let pParams = ProtocolParameter.fromAggregatedStrings ';' terms accessions sources - // mySequenceEqual pParams testPParams "Protocol Parameters were not created correctly from partly empty aggregated strings" + // Expect.mySequenceEqual pParams testPParams "Protocol Parameters were not created correctly from partly empty aggregated strings" // Expect.equal (ProtocolParameter.toAggregatedStrings ';' pParams) (terms,accessions,";") "Protocol Parameters were not parsed correctly to partly empty aggregated strings" //) diff --git a/tests/ISA/ISA.Spreadsheet.Tests/StudyFileTests.fs b/tests/ISA/ISA.Spreadsheet.Tests/StudyFileTests.fs index 46140e1d..a13fe306 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/StudyFileTests.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/StudyFileTests.fs @@ -10,6 +10,8 @@ open ARCtrl.ISA open TestingUtils open ARCtrl.ISA.Spreadsheet +open TestObjects.Spreadsheet + let testMetaDataFunctions = testList "StudyMetadataTests" [ @@ -17,7 +19,7 @@ let testMetaDataFunctions = let readingSuccess = try - ArcStudy.fromMetadataSheet TestObjects.Study.studyMetadataEmpty |> ignore + ArcStudy.fromMetadataSheet Study.studyMetadataEmpty |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the empty test file failed: %s" err.Message) @@ -28,7 +30,7 @@ let testMetaDataFunctions = let readingSuccess = try - ArcStudy.fromMetadataSheet TestObjects.Study.studyMetadataEmptyObsoleteSheetName |> ignore + ArcStudy.fromMetadataSheet Study.studyMetadataEmptyObsoleteSheetName |> ignore Result.Ok "DidRun" with | err -> Result.Error(sprintf "Reading the empty test file failed: %s" err.Message) @@ -37,7 +39,7 @@ let testMetaDataFunctions = testCase "WriterSuccessEmpty" (fun () -> - let study,assays = ArcStudy.fromMetadataSheet TestObjects.Study.studyMetadataEmpty + let study,assays = ArcStudy.fromMetadataSheet Study.studyMetadataEmpty let writingSuccess = try @@ -52,7 +54,7 @@ let testMetaDataFunctions = testCase "WriterSuccessEmptyObsoleteSheetName" (fun () -> let study,assays = - ArcStudy.fromMetadataSheet TestObjects.Study.studyMetadataEmptyObsoleteSheetName + ArcStudy.fromMetadataSheet Study.studyMetadataEmptyObsoleteSheetName let writingSuccess = try ArcStudy.toMetadataSheet study (Some assays) |> ignore @@ -66,30 +68,30 @@ let testMetaDataFunctions = testCase "OutputMatchesInputEmpty" (fun () -> let o = - TestObjects.Study.studyMetadataEmpty + Study.studyMetadataEmpty |> ArcStudy.fromMetadataSheet |> fun (s,a) -> ArcStudy.toMetadataSheet s (Some a) - Expect.workSheetEqual o TestObjects.Study.studyMetadataEmpty "Written Empty study metadata does not match read study metadata" + Expect.workSheetEqual o Study.studyMetadataEmpty "Written Empty study metadata does not match read study metadata" ) testCase "OutputMatchesInput" (fun () -> let o = - TestObjects.Study.studyMetadata + Study.studyMetadata |> ArcStudy.fromMetadataSheet |> fun (s,a) -> ArcStudy.toMetadataSheet s (Some a) - Expect.workSheetEqual o TestObjects.Study.studyMetadata "Written Empty study metadata does not match read study metadata" + Expect.workSheetEqual o Study.studyMetadata "Written Empty study metadata does not match read study metadata" ) testCase "OutputSheetNamesDifferentEmptyObsoleteSheetName" (fun () -> let o = - TestObjects.Study.studyMetadataEmptyObsoleteSheetName + Study.studyMetadataEmptyObsoleteSheetName |> ArcStudy.fromMetadataSheet |> fun (s,a) -> ArcStudy.toMetadataSheet s (Some a) - Expect.isTrue (o.Name <> TestObjects.Study.studyMetadataEmptyObsoleteSheetName.Name) "sheet names were expected to be different (obsolete replaced by new)" + Expect.isTrue (o.Name <> Study.studyMetadataEmptyObsoleteSheetName.Name) "sheet names were expected to be different (obsolete replaced by new)" ) ] diff --git a/tests/ISA/ISA.Spreadsheet.Tests/Utils.fs b/tests/ISA/ISA.Spreadsheet.Tests/Utils.fs deleted file mode 100644 index ab0151fc..00000000 --- a/tests/ISA/ISA.Spreadsheet.Tests/Utils.fs +++ /dev/null @@ -1,47 +0,0 @@ -module TestingUtils - -open FsSpreadsheet - -module Result = - - let getMessage (r : Result<'T,string>) = - match r with - | Ok _ -> "" - | Error msg -> msg - -let private firstDiff s1 s2 = - let s1 = Seq.append (Seq.map Some s1) (Seq.initInfinite (fun _ -> None)) - let s2 = Seq.append (Seq.map Some s2) (Seq.initInfinite (fun _ -> None)) - Seq.mapi2 (fun i s p -> i,s,p) s1 s2 - |> Seq.find (function |_,Some s,Some p when s=p -> false |_-> true) - -/// Expects the `actual` sequence to equal the `expected` one. -let mySequenceEqual actual expected message = - match firstDiff actual expected with - | _,None,None -> () - | i,Some a, Some e -> - failwithf "%s. Sequence does not match at position %i. Expected item: %A, but got %A." - message i e a - | i,None,Some e -> - failwithf "%s. Sequence actual shorter than expected, at pos %i for expected item %A." - message i e - | i,Some a,None -> - failwithf "%s. Sequence actual longer than expected, at pos %i found item %A." - message i a - -module Expect = - - let workSheetEqual (actual : FsWorksheet) (expected : FsWorksheet) message = - let f (ws : FsWorksheet) = - ws.RescanRows() - ws.Rows - |> Seq.map (fun r -> r.Cells |> Seq.map (fun c -> c.Value) |> Seq.reduce (fun a b -> a + b)) - if actual.Name <> expected.Name then - failwithf $"{message}. Worksheet names do not match. Expected {expected.Name} but got {actual.Name}" - mySequenceEqual (f actual) (f expected) $"{message}. Worksheet does not match" - - let columnsEqual (actual : FsCell seq seq) (expected : FsCell seq seq) message = - let f (cols : FsCell seq seq) = - cols - |> Seq.map (fun r -> r |> Seq.map (fun c -> c.Value) |> Seq.reduce (fun a b -> a + b)) - mySequenceEqual (f actual) (f expected) $"{message}. Columns do not match" \ No newline at end of file diff --git a/tests/ISA/ISA.Tests/ArcAssay.Tests.fs b/tests/ISA/ISA.Tests/ArcAssay.Tests.fs index 3bd3ebe6..a66a1273 100644 --- a/tests/ISA/ISA.Tests/ArcAssay.Tests.fs +++ b/tests/ISA/ISA.Tests/ArcAssay.Tests.fs @@ -529,7 +529,7 @@ let private test_UpdateBy = testList "UpdateBy" [ Expect.equal actual.MeasurementType next.MeasurementType "MeasurementType" Expect.equal actual.TechnologyType next.TechnologyType "TechnologyType" Expect.equal actual.TechnologyPlatform next.TechnologyPlatform "TechnologyPlatform" - TestingUtils.mySequenceEqual actual.Tables next.Tables "Tables" + TestingUtils.Expect.mySequenceEqual actual.Tables next.Tables "Tables" Expect.equal actual.Performers next.Performers "Performers" Expect.equal actual.Comments next.Comments "Comments" testCase "UpdateBy, replace existing" <| fun _ -> @@ -548,7 +548,7 @@ let private test_UpdateBy = testList "UpdateBy" [ Expect.equal actual.MeasurementType next.MeasurementType "MeasurementType" Expect.equal actual.TechnologyType next.TechnologyType "TechnologyType" Expect.equal actual.TechnologyPlatform expected.TechnologyPlatform "TechnologyPlatform" - TestingUtils.mySequenceEqual actual.Tables next.Tables "Tables" + TestingUtils.Expect.mySequenceEqual actual.Tables next.Tables "Tables" Expect.equal actual.Performers next.Performers "Performers" Expect.equal actual.Comments expected.Comments "Comments" testCase "UpdateBy, replace existing, empty tables" <| fun _ -> @@ -562,7 +562,7 @@ let private test_UpdateBy = testList "UpdateBy" [ ) let expected = create_testAssay() actual.UpdateBy(next, true) - TestingUtils.mySequenceEqual actual.Tables expected.Tables "Tables" + TestingUtils.Expect.mySequenceEqual actual.Tables expected.Tables "Tables" testCase "UpdateBy, replace existing, append" <| fun _ -> let actual = create_testAssay() let next = @@ -579,7 +579,7 @@ let private test_UpdateBy = testList "UpdateBy" [ Expect.equal actual.MeasurementType next.MeasurementType "MeasurementType" Expect.equal actual.TechnologyType next.TechnologyType "TechnologyType" Expect.equal actual.TechnologyPlatform expected.TechnologyPlatform "TechnologyPlatform" - TestingUtils.mySequenceEqual actual.Tables (ResizeArray([yield! expected.Tables; yield! next.Tables])) "Tables" + TestingUtils.Expect.mySequenceEqual actual.Tables (ResizeArray([yield! expected.Tables; yield! next.Tables])) "Tables" Expect.equal actual.Performers [|yield! expected.Performers; yield! next.Performers|] "Performers" Expect.equal actual.Comments [|yield! expected.Comments; yield! next.Comments|] "Comments" testCase "UpdateBy, replace all, append" <| fun _ -> @@ -598,7 +598,7 @@ let private test_UpdateBy = testList "UpdateBy" [ Expect.equal actual.MeasurementType next.MeasurementType "MeasurementType" Expect.equal actual.TechnologyType next.TechnologyType "TechnologyType" Expect.equal actual.TechnologyPlatform next.TechnologyPlatform "TechnologyPlatform" - TestingUtils.mySequenceEqual actual.Tables (ResizeArray([yield! expected.Tables; yield! next.Tables])) "Tables" + TestingUtils.Expect.mySequenceEqual actual.Tables (ResizeArray([yield! expected.Tables; yield! next.Tables])) "Tables" Expect.equal actual.Performers [|yield! expected.Performers; yield! next.Performers|] "Performers" Expect.equal actual.Comments [|yield! expected.Comments; yield! next.Comments|] "Comments" ] diff --git a/tests/ISA/ISA.Tests/ArcInvestigation.Tests.fs b/tests/ISA/ISA.Tests/ArcInvestigation.Tests.fs index 02b04026..b939a009 100644 --- a/tests/ISA/ISA.Tests/ArcInvestigation.Tests.fs +++ b/tests/ISA/ISA.Tests/ArcInvestigation.Tests.fs @@ -365,7 +365,7 @@ let tests_Study = testList "CRUD Study" [ testCase "add multiple" <| fun _ -> let i = createExampleInvestigation() Expect.equal i.StudyCount 2 "StudyCount" - TestingUtils.mySequenceEqual i.StudyIdentifiers (seq {"Study 1"; "Study 2"}) "StudyIdentifiers" + TestingUtils.Expect.mySequenceEqual i.StudyIdentifiers (seq {"Study 1"; "Study 2"}) "StudyIdentifiers" let s2 = i.Studies.Item 1 Expect.equal s2.Title (Some "Study 2 Title") "Study 2 Title" testCase "add with same name, throws" <| fun _ -> @@ -445,8 +445,8 @@ let tests_Assay = testList "CRUD Assay" [ let i = createExampleInvestigation() Expect.equal i.StudyCount 2 "StudyCount" Expect.equal i.AssayCount 2 "AssayCount" - TestingUtils.mySequenceEqual i.StudyIdentifiers (seq {"Study 1"; "Study 2"}) "StudyIdentifiers" - TestingUtils.mySequenceEqual i.AssayIdentifiers (seq {"Assay 1"; "Assay 2"}) "AssayIdentifiers" + TestingUtils.Expect.mySequenceEqual i.StudyIdentifiers (seq {"Study 1"; "Study 2"}) "StudyIdentifiers" + TestingUtils.Expect.mySequenceEqual i.AssayIdentifiers (seq {"Assay 1"; "Assay 2"}) "AssayIdentifiers" let s = i.Studies.Item 0 Expect.equal s.RegisteredAssayCount 2 "Registered AssayCount" let s2 = i.Studies.Item 1 @@ -652,8 +652,8 @@ let tests_Assay = testList "CRUD Assay" [ // Expect.equal actual.Contacts expected.Contacts "Contacts" // Expect.equal actual.Assays.Count 1 "Count 1" // Expect.equal expected.Assays.Count 1 "Count 2" -// TestingUtils.mySequenceEqual actual.Assays expected.Assays "Assays" -// TestingUtils.mySequenceEqual actual.Studies expected.Studies "Studies" +// TestingUtils.Expect.mySequenceEqual actual.Assays expected.Assays "Assays" +// TestingUtils.Expect.mySequenceEqual actual.Studies expected.Studies "Studies" // Expect.equal actual.RegisteredStudyIdentifiers expected.RegisteredStudyIdentifiers "RegisteredStudyIdentifiers" // Expect.equal actual.Comments expected.Comments "Comments" // Expect.equal actual.Remarks expected.Remarks "Remarks" diff --git a/tests/ISA/ISA.Tests/ArcJsonConversionTests.fs b/tests/ISA/ISA.Tests/ArcJsonConversionTests.fs index 990d6fd1..1c2bdf3c 100644 --- a/tests/ISA/ISA.Tests/ArcJsonConversionTests.fs +++ b/tests/ISA/ISA.Tests/ArcJsonConversionTests.fs @@ -397,8 +397,8 @@ let private tests_arcAssay = Expect.equal resultingArcAssay.TechnologyPlatform arcAssay.TechnologyPlatform "ArcAssay technologyPlatform should match" let expectedTables = [t1;t2] - mySequenceEqual resultingArcAssay.Tables expectedTables "ArcAssay tables should match" - mySequenceEqual resultingArcAssay.Comments arcAssay.Comments "ArcAssay comments should match" + Expect.mySequenceEqual resultingArcAssay.Tables expectedTables "ArcAssay tables should match" + Expect.mySequenceEqual resultingArcAssay.Comments arcAssay.Comments "ArcAssay comments should match" ) ] @@ -522,7 +522,7 @@ let private tests_protocolTransformation = let t = ArcTable.init "TestTable" let expected = [Protocol.create(Name = "TestTable")] - TestingUtils.mySequenceEqual (t.GetProtocols()) expected "Protocol Name should be ArcTable name." + TestingUtils.Expect.mySequenceEqual (t.GetProtocols()) expected "Protocol Name should be ArcTable name." ) testCase "GetProtocols SingleName" (fun () -> let t = ArcTable.init "TestTable" @@ -530,7 +530,7 @@ let private tests_protocolTransformation = t.AddProtocolNameColumn([|name|]) let expected = [Protocol.create(Name = name)] - TestingUtils.mySequenceEqual (t.GetProtocols()) expected "Protocols do not match" + TestingUtils.Expect.mySequenceEqual (t.GetProtocols()) expected "Protocols do not match" ) testCase "GetProtocols SameNames" (fun () -> let t = ArcTable.init "TestTable" @@ -538,7 +538,7 @@ let private tests_protocolTransformation = t.AddProtocolNameColumn([|name;name|]) let expected = [Protocol.create(Name = name)] - TestingUtils.mySequenceEqual (t.GetProtocols()) expected "Protocols do not match" + TestingUtils.Expect.mySequenceEqual (t.GetProtocols()) expected "Protocols do not match" ) testCase "GetProtocols DifferentNames" (fun () -> let t = ArcTable.init "TestTable" @@ -547,7 +547,7 @@ let private tests_protocolTransformation = t.AddProtocolNameColumn([|name1;name2|]) let expected = [Protocol.create(Name = name1);Protocol.create(Name = name2)] - TestingUtils.mySequenceEqual (t.GetProtocols()) expected "Protocols do not match" + TestingUtils.Expect.mySequenceEqual (t.GetProtocols()) expected "Protocols do not match" ) //testCase "GetProtocols Parameters" (fun () -> // let t = ArcTable.init "TestTable" @@ -556,7 +556,7 @@ let private tests_protocolTransformation = // t.AddProtocolNameColumn([|name1;name2|]) // t.addpara([|pParam1;pParam1|]) // let expected = [Protocol.create(Name = name1;Parameters = [pParam1]);Protocol.create(Name = name2;Parameters = [pParam1])] - // TestingUtils.mySequenceEqual (t.GetProtocols()) expected "Protocols do not match" + // TestingUtils.Expect.mySequenceEqual (t.GetProtocols()) expected "Protocols do not match" //) diff --git a/tests/ISA/ISA.Tests/ArcStudy.Tests.fs b/tests/ISA/ISA.Tests/ArcStudy.Tests.fs index 5cf2ec20..7e2b23c6 100644 --- a/tests/ISA/ISA.Tests/ArcStudy.Tests.fs +++ b/tests/ISA/ISA.Tests/ArcStudy.Tests.fs @@ -379,11 +379,11 @@ let tests_UpdateBy = testList "UpdateReferenceByStudyFile" [ let expectedDescription = Array.create 2 (CompositeCell.createFreeText ArcTables.Tests.TestObjects.descriptionValue2) |> Array.append (Array.create 2 (CompositeCell.createFreeText ArcTables.Tests.TestObjects.descriptionValue1)) - TestingUtils.mySequenceEqual + TestingUtils.Expect.mySequenceEqual (resultTable.GetColumnByHeader CompositeHeader.ProtocolDescription).Cells (expectedDescription) "Description value was not taken correctly" - TestingUtils.mySequenceEqual + TestingUtils.Expect.mySequenceEqual (resultTable.GetColumnByHeader (CompositeHeader.Parameter ArcTables.Tests.TestObjects.oa_species)).Cells (Array.create 4 (CompositeCell.createTerm ArcTables.Tests.TestObjects.oa_chlamy)) "Check for previous param correctness" @@ -402,8 +402,8 @@ let tests_UpdateBy = testList "UpdateReferenceByStudyFile" [ Expect.equal actual.Publications expected.Publications "Publications" Expect.equal actual.Contacts expected.Contacts "Contacts" Expect.equal actual.StudyDesignDescriptors expected.StudyDesignDescriptors "StudyDesignDescriptors" - TestingUtils.mySequenceEqual actual.Tables expected.Tables "Tables" - TestingUtils.mySequenceEqual actual.RegisteredAssayIdentifiers expected.RegisteredAssayIdentifiers "RegisteredAssayIdentifiers" + TestingUtils.Expect.mySequenceEqual actual.Tables expected.Tables "Tables" + TestingUtils.Expect.mySequenceEqual actual.RegisteredAssayIdentifiers expected.RegisteredAssayIdentifiers "RegisteredAssayIdentifiers" Expect.equal actual.Factors expected.Factors "Factors" Expect.equal actual.Comments expected.Comments "Comments" testCase "replace existing, all replaced" <| fun _ -> @@ -433,8 +433,8 @@ let tests_UpdateBy = testList "UpdateReferenceByStudyFile" [ Expect.equal actual.Publications next.Publications "Publications" Expect.equal actual.Contacts next.Contacts "Contacts" Expect.equal actual.StudyDesignDescriptors next.StudyDesignDescriptors "StudyDesignDescriptors" - TestingUtils.mySequenceEqual actual.Tables next.Tables "Tables" - TestingUtils.mySequenceEqual actual.RegisteredAssayIdentifiers next.RegisteredAssayIdentifiers "RegisteredAssayIdentifiers" + TestingUtils.Expect.mySequenceEqual actual.Tables next.Tables "Tables" + TestingUtils.Expect.mySequenceEqual actual.RegisteredAssayIdentifiers next.RegisteredAssayIdentifiers "RegisteredAssayIdentifiers" Expect.equal actual.Factors next.Factors "Factors" Expect.equal actual.Comments next.Comments "Comments" testCase "full replace, empty" <| fun _ -> diff --git a/tests/ISA/ISA.Tests/ArcTable.Tests.fs b/tests/ISA/ISA.Tests/ArcTable.Tests.fs index a903d9c8..a1d64722 100644 --- a/tests/ISA/ISA.Tests/ArcTable.Tests.fs +++ b/tests/ISA/ISA.Tests/ArcTable.Tests.fs @@ -376,8 +376,8 @@ let private tests_UpdateHeader = Expect.equal table.Values.[3,4] (CompositeCell.createTerm oa_SCIEXInstrumentModel) "cell 3,4" Expect.equal table.Headers.[4] column_param.Header "header4" Expect.equal table.Values.[4,4] (CompositeCell.createUnitized (string 4,OntologyAnnotation.empty)) "cell 4,4" - TestingUtils.mySequenceEqual table.Headers table2.Headers "equal table headers" - TestingUtils.mySequenceEqual table.Values table2.Values "equal table values" + TestingUtils.Expect.mySequenceEqual table.Headers table2.Headers "equal table headers" + TestingUtils.Expect.mySequenceEqual table.Values table2.Values "equal table values" ) ] @@ -566,7 +566,7 @@ let private tests_AddColumn = let expected = let m = [ for rowIndex, cell in Array.indexed cells do yield (0, rowIndex), cell] |> Map.ofList System.Collections.Generic.Dictionary(m) - TestingUtils.mySequenceEqual table.Values expected "values" + TestingUtils.Expect.mySequenceEqual table.Values expected "values" ) testCase "term column, with cells" (fun () -> let table = create_table() @@ -579,7 +579,7 @@ let private tests_AddColumn = let expected = let m = [ for rowIndex, cell in Array.indexed cells do yield (0, rowIndex), cell] |> Map.ofList System.Collections.Generic.Dictionary(m) - TestingUtils.mySequenceEqual table.Values expected "values" + TestingUtils.Expect.mySequenceEqual table.Values expected "values" ) testCase "IO column, with wrong cells" (fun () -> let table = create_table() @@ -803,7 +803,7 @@ let private tests_addColumn = let expected = let m = [ for rowIndex, cell in Array.indexed cells do yield (0, rowIndex), cell] |> Map.ofList System.Collections.Generic.Dictionary(m) - TestingUtils.mySequenceEqual updatedTable.Values expected "values" + TestingUtils.Expect.mySequenceEqual updatedTable.Values expected "values" ) testCase "term column, with cells" (fun () -> let table = create_table() @@ -819,7 +819,7 @@ let private tests_addColumn = let expected = let m = [ for rowIndex, cell in Array.indexed cells do yield (0, rowIndex), cell] |> Map.ofList System.Collections.Generic.Dictionary(m) - TestingUtils.mySequenceEqual updatedTable.Values expected "values" + TestingUtils.Expect.mySequenceEqual updatedTable.Values expected "values" ) testCase "IO column, with cells at index" (fun () -> let table = create_table() @@ -1971,11 +1971,11 @@ let private tests_UpdateRefWithSheet = Expect.equal refTable.RowCount expectedRowCount "RowCount of reference table should be the same as value table after update" Expect.equal refTable.ColumnCount expectedColumnCount "ColumnCount of reference table should be the sum of value table and protocol table after update" - TestingUtils.mySequenceEqual + TestingUtils.Expect.mySequenceEqual (refTable.GetProtocolDescriptionColumn().Cells) (Array.create 5 (CompositeCell.createFreeText protocolDescription)) "ProtocolDescriptionColumn should be filled with protocol description" - TestingUtils.mySequenceEqual + TestingUtils.Expect.mySequenceEqual (refTable.GetColumnByHeader column_component.Header).Cells column_component.Cells "Component column should have been taken as is" @@ -2004,11 +2004,11 @@ let private tests_UpdateRefWithSheet = Expect.equal refTable.RowCount expectedRowCount "RowCount of reference table should be the same as value table after update" Expect.equal refTable.ColumnCount expectedColumnCount "ColumnCount of reference table should be the sum of value table and protocol table after update" - TestingUtils.mySequenceEqual + TestingUtils.Expect.mySequenceEqual (refTable.GetProtocolDescriptionColumn().Cells) (Array.create 5 (CompositeCell.createFreeText newProtocolDescription)) "ProtocolDescriptionColumn should be filled with protocol description" - TestingUtils.mySequenceEqual + TestingUtils.Expect.mySequenceEqual (refTable.GetColumnByHeader column_component.Header).Cells column_component.Cells "Component column should have been taken as is" diff --git a/tests/ISA/ISA.Tests/ArcTables.Tests.fs b/tests/ISA/ISA.Tests/ArcTables.Tests.fs index abb7a640..3ecb074a 100644 --- a/tests/ISA/ISA.Tests/ArcTables.Tests.fs +++ b/tests/ISA/ISA.Tests/ArcTables.Tests.fs @@ -182,7 +182,7 @@ let updateReferenceWithSheet = Expect.equal resultTable.Name tableOfInterest.Name "Should be same table name" Expect.equal resultTable.ColumnCount (tableOfInterest.ColumnCount + 1) "Should be same number of columns" Expect.equal resultTable.RowCount tableOfInterest.RowCount "Should be same number of rows" - mySequenceEqual + Expect.mySequenceEqual (resultTable.GetColumnByHeader CompositeHeader.ProtocolDescription).Cells (Array.create 2 (CompositeCell.createFreeText descriptionValue1)) "Description value was not taken correctly" @@ -198,7 +198,7 @@ let updateReferenceWithSheet = Expect.equal resultTable.Name tableOfInterest.Name "Should be same table name" Expect.equal resultTable.ColumnCount (tableOfInterest.ColumnCount + 2) "Should be same number of columns" Expect.equal resultTable.RowCount tableOfInterest.RowCount "Should be same number of rows" - mySequenceEqual + Expect.mySequenceEqual (resultTable.GetColumnByHeader CompositeHeader.ProtocolDescription).Cells (Array.create 2 (CompositeCell.createFreeText descriptionValue1)) "Description value was not taken correctly" @@ -229,11 +229,11 @@ let updateReferenceWithSheet = Expect.equal resultTable1.Name tableOfInterest1.Name "Should be same table name" Expect.equal resultTable1.ColumnCount (tableOfInterest1.ColumnCount + 1) "Should be same number of columns" Expect.equal tableOfInterest1.RowCount tableOfInterest1.RowCount "Should be same number of rows" - mySequenceEqual + Expect.mySequenceEqual (resultTable1.GetColumnByHeader CompositeHeader.ProtocolDescription).Cells (Array.create 2 (CompositeCell.createFreeText descriptionValue1)) "Description value was not taken correctly" - mySequenceEqual + Expect.mySequenceEqual (resultTable1.GetColumnByHeader (CompositeHeader.Parameter oa_species)).Cells (Array.create 2 (CompositeCell.createTerm oa_chlamy)) "Check for previous param correctness" @@ -242,11 +242,11 @@ let updateReferenceWithSheet = Expect.equal resultTable2.Name tableOfInterest2.Name "Should be same table name" Expect.equal resultTable2.ColumnCount (tableOfInterest2.ColumnCount + 1) "Should be same number of columns" Expect.equal tableOfInterest2.RowCount tableOfInterest2.RowCount "Should be same number of rows" - mySequenceEqual + Expect.mySequenceEqual (resultTable2.GetProtocolDescriptionColumn()).Cells (Array.create 3 (CompositeCell.createFreeText descriptionValue1)) "Description value was not taken correctly" - mySequenceEqual + Expect.mySequenceEqual (resultTable2.GetColumnByHeader (CompositeHeader.Factor oa_instrumentModel)).Cells (Array.create 3 (CompositeCell.createTerm oa_SCIEXInstrumentModel)) "Check for previous param correctness" @@ -267,11 +267,11 @@ let updateReferenceWithSheet = let expectedDescription = Array.create 2 (CompositeCell.emptyFreeText) |> Array.append (Array.create 2 (CompositeCell.createFreeText descriptionValue1)) - mySequenceEqual + Expect.mySequenceEqual (resultTable.GetColumnByHeader CompositeHeader.ProtocolDescription).Cells (expectedDescription) "Description value was not taken correctly" - mySequenceEqual + Expect.mySequenceEqual (resultTable.GetColumnByHeader (CompositeHeader.Parameter oa_species)).Cells (Array.create 4 (CompositeCell.createTerm oa_chlamy)) "Check for previous param correctness" @@ -292,11 +292,11 @@ let updateReferenceWithSheet = let expectedDescription = Array.create 2 (CompositeCell.createFreeText descriptionValue2) |> Array.append (Array.create 2 (CompositeCell.createFreeText descriptionValue1)) - mySequenceEqual + Expect.mySequenceEqual (resultTable.GetColumnByHeader CompositeHeader.ProtocolDescription).Cells (expectedDescription) "Description value was not taken correctly" - mySequenceEqual + Expect.mySequenceEqual (resultTable.GetColumnByHeader (CompositeHeader.Parameter oa_species)).Cells (Array.create 4 (CompositeCell.createTerm oa_chlamy)) "Check for previous param correctness" diff --git a/tests/ISA/ISA.Tests/ISA.Tests.fsproj b/tests/ISA/ISA.Tests/ISA.Tests.fsproj index 11e33496..fce7c7cc 100644 --- a/tests/ISA/ISA.Tests/ISA.Tests.fsproj +++ b/tests/ISA/ISA.Tests/ISA.Tests.fsproj @@ -7,7 +7,6 @@ - @@ -28,6 +27,7 @@ + \ No newline at end of file diff --git a/tests/ISA/ISA.Tests/Update.Tests.fs b/tests/ISA/ISA.Tests/Update.Tests.fs index aeb47e5a..7545a2d2 100644 --- a/tests/ISA/ISA.Tests/Update.Tests.fs +++ b/tests/ISA/ISA.Tests/Update.Tests.fs @@ -351,8 +351,8 @@ let updateTests = let update = UpdateAllAppendLists.updateRecordType eOld eNew // new IntList is empty and should not update - TestingUtils.mySequenceEqual update.IntList (List.append eOld.IntList eNew.IntList) "ListType UpdateAllAppendLists; failed by not correctly appending IntList" - TestingUtils.mySequenceEqual update.StringList (List.append eOld.StringList eNew.StringList) "ListType UpdateAllAppendLists; failed by not correctly appending StringList" + TestingUtils.Expect.mySequenceEqual update.IntList (List.append eOld.IntList eNew.IntList) "ListType UpdateAllAppendLists; failed by not correctly appending IntList" + TestingUtils.Expect.mySequenceEqual update.StringList (List.append eOld.StringList eNew.StringList) "ListType UpdateAllAppendLists; failed by not correctly appending StringList" ) testCase "ArrayType UpdateByExisting" (fun () -> @@ -385,8 +385,8 @@ let updateTests = let update = UpdateAllAppendLists.updateRecordType eOld eNew // new IntList is empty and should not update - TestingUtils.mySequenceEqual update.FloatArray (Array.append eOld.FloatArray eNew.FloatArray) "ArrayType UpdateAllAppendLists; failed by not correctly appending IntList" - TestingUtils.mySequenceEqual update.StringArray (Array.append eOld.StringArray eNew.StringArray) "ArrayType UpdateAllAppendLists; failed by not correctly appending StringList" + TestingUtils.Expect.mySequenceEqual update.FloatArray (Array.append eOld.FloatArray eNew.FloatArray) "ArrayType UpdateAllAppendLists; failed by not correctly appending IntList" + TestingUtils.Expect.mySequenceEqual update.StringArray (Array.append eOld.StringArray eNew.StringArray) "ArrayType UpdateAllAppendLists; failed by not correctly appending StringList" ) testCase "SeqType UpdateByExisting" (fun () -> @@ -419,8 +419,8 @@ let updateTests = let update = UpdateAllAppendLists.updateRecordType eOld eNew // Here the values are passed hard coded as Expect seems to interact strangely when comparing seqs. - TestingUtils.mySequenceEqual update.StringSeq (Seq.append eOld.StringSeq eNew.StringSeq) "ArrayType UpdateAllAppendLists; failed by not correctly appending list1" - TestingUtils.mySequenceEqual update.StringOptSeq (Seq.append eOld.StringOptSeq eNew.StringOptSeq) "ArrayType UpdateAllAppendLists; failed by not correctly appending list2" + TestingUtils.Expect.mySequenceEqual update.StringSeq (Seq.append eOld.StringSeq eNew.StringSeq) "ArrayType UpdateAllAppendLists; failed by not correctly appending list1" + TestingUtils.Expect.mySequenceEqual update.StringOptSeq (Seq.append eOld.StringOptSeq eNew.StringOptSeq) "ArrayType UpdateAllAppendLists; failed by not correctly appending list2" ) testCase "SeqType UpdateByExistingAppendLists" (fun () -> @@ -436,8 +436,8 @@ let updateTests = let update = UpdateByExistingAppendLists.updateRecordType eOld eNew // Here the values are passed hard coded as Expect seems to interact strangely when comparing seqs. - TestingUtils.mySequenceEqual update.StringSeq (Seq.append eOld.StringSeq eNew.StringSeq) "ArrayType UpdateAllAppendLists; failed by not correctly appending list1" - TestingUtils.mySequenceEqual update.StringOptSeq (Seq.append eOld.StringOptSeq eNew.StringOptSeq) "ArrayType UpdateAllAppendLists; failed by not correctly appending list2" + TestingUtils.Expect.mySequenceEqual update.StringSeq (Seq.append eOld.StringSeq eNew.StringSeq) "ArrayType UpdateAllAppendLists; failed by not correctly appending list1" + TestingUtils.Expect.mySequenceEqual update.StringOptSeq (Seq.append eOld.StringOptSeq eNew.StringOptSeq) "ArrayType UpdateAllAppendLists; failed by not correctly appending list2" ) testCase "RecordTypeType UpdateByExisting" (fun () -> @@ -584,7 +584,7 @@ let updateTests = let appendedList = List.append eOld.OptionalList.Value eNew.OptionalList.Value // map types will never be checked if they are empty or not, so they will always be replaced - TestingUtils.mySequenceEqual update.OptionalList.Value appendedList "Optional Lists were not appended correctly" + TestingUtils.Expect.mySequenceEqual update.OptionalList.Value appendedList "Optional Lists were not appended correctly" ) testCase "OptionalListType UpdateAllAppendListsEmpty" (fun () -> @@ -615,7 +615,7 @@ let updateTests = let appendedList = List.append eOld.OptionalList.Value eNew.OptionalList.Value // map types will never be checked if they are empty or not, so they will always be replaced - TestingUtils.mySequenceEqual update.OptionalList.Value appendedList "Optional Lists were not appended correctly" + TestingUtils.Expect.mySequenceEqual update.OptionalList.Value appendedList "Optional Lists were not appended correctly" ) testCase "OptionalListType UpdateByExistingAppendListsEmpty" (fun () -> diff --git a/tests/ISA/ISA.Tests/Utils.fs b/tests/ISA/ISA.Tests/Utils.fs deleted file mode 100644 index c05f61ac..00000000 --- a/tests/ISA/ISA.Tests/Utils.fs +++ /dev/null @@ -1,45 +0,0 @@ -module TestingUtils - -open ARCtrl.ISA - -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif - -module Result = - - let getMessage (r : Result<'T,string>) = - match r with - | Ok _ -> "" - | Error msg -> msg - -let private firstDiff s1 s2 = - let s1 = Seq.append (Seq.map Some s1) (Seq.initInfinite (fun _ -> None)) - let s2 = Seq.append (Seq.map Some s2) (Seq.initInfinite (fun _ -> None)) - Seq.mapi2 (fun i s p -> i,s,p) s1 s2 - |> Seq.find (function |_,Some s,Some p when s=p -> false |_-> true) - -/// Expects the `actual` sequence to equal the `expected` one. -let mySequenceEqual actual expected message = - match firstDiff actual expected with - | _,None,None -> () - | i,Some a, Some e -> - failwithf "%s. Sequence does not match at position %i. Expected item: %A, but got %A." - message i e a - | i,None,Some e -> - failwithf "%s. Sequence actual shorter than expected, at pos %i for expected item %A." - message i e - | i,Some a,None -> - failwithf "%s. Sequence actual longer than expected, at pos %i found item %A." - message i a - -module Expect = - - let arcTableEqual (t1 : ArcTable) (t2 : ArcTable) (message : string) = - let sortVals (dict : System.Collections.Generic.Dictionary) = - dict |> Seq.sortBy (fun kv -> kv.Key) - Expect.equal t1.Name t2.Name (sprintf "%s: Name" message) - mySequenceEqual t1.Headers t2.Headers (sprintf "%s: Headers" message) - mySequenceEqual (t1.Values |> sortVals) (t2.Values |> sortVals) (sprintf "%s: Values" message) \ No newline at end of file diff --git a/tests/TestingUtils/Library.fs b/tests/TestingUtils/Library.fs new file mode 100644 index 00000000..97bd5757 --- /dev/null +++ b/tests/TestingUtils/Library.fs @@ -0,0 +1,100 @@ +namespace TestingUtils + +open FsSpreadsheet +open ARCtrl.ISA +open ARCtrl.FileSystem + +#if FABLE_COMPILER +open Fable.Mocha +#else +open Expecto +#endif + +module Async = + + let map (f : 'U -> 'T) (a : Async<'U>) = + async { + let! a' = a + return f a' + } + +module Utils = + + let extractWords (json:string) = + json.Split([|'{';'}';'[';']';',';':'|]) + |> Array.map (fun s -> s.Trim()) + |> Array.filter ((<>) "") + + let wordFrequency (json:string) = + json + |> extractWords + |> Array.countBy id + |> Array.sortBy fst + + let firstDiff s1 s2 = + let s1 = Seq.append (Seq.map Some s1) (Seq.initInfinite (fun _ -> None)) + let s2 = Seq.append (Seq.map Some s2) (Seq.initInfinite (fun _ -> None)) + Seq.mapi2 (fun i s p -> i,s,p) s1 s2 + |> Seq.find (function |_,Some s,Some p when s=p -> false |_-> true) + + +module Result = + + let getMessage res = + match res with + | Ok m -> m + | Error m -> m + +module Expect = + open Utils + /// Expects the `actual` sequence to equal the `expected` one. + let inline mySequenceEqual actual expected message = + match firstDiff actual expected with + | _,None,None -> () + | i,Some a, Some e -> + failwithf "%s. Sequence does not match at position %i. Expected item: %A, but got %A." + message i e a + | i,None,Some e -> + failwithf "%s. Sequence actual shorter than expected, at pos %i for expected item %A." + message i e + | i,Some a,None -> + failwithf "%s. Sequence actual longer than expected, at pos %i found item %A." + message i a + + + let workSheetEqual (actual : FsWorksheet) (expected : FsWorksheet) message = + let f (ws : FsWorksheet) = + ws.RescanRows() + ws.Rows + |> Seq.map (fun r -> r.Cells |> Seq.map (fun c -> c.Value) |> Seq.reduce (fun a b -> a + b)) + if actual.Name <> expected.Name then + failwithf $"{message}. Worksheet names do not match. Expected {expected.Name} but got {actual.Name}" + mySequenceEqual (f actual) (f expected) $"{message}. Worksheet does not match" + + let columnsEqual (actual : FsCell seq seq) (expected : FsCell seq seq) message = + let f (cols : FsCell seq seq) = + cols + |> Seq.map (fun r -> r |> Seq.map (fun c -> c.Value) |> Seq.reduce (fun a b -> a + b)) + mySequenceEqual (f actual) (f expected) $"{message}. Columns do not match" + + let arcTableEqual (t1 : ArcTable) (t2 : ArcTable) (message : string) = + let sortVals (dict : System.Collections.Generic.Dictionary) = + dict |> Seq.sortBy (fun kv -> kv.Key) + Expect.equal t1.Name t2.Name (sprintf "%s: Name" message) + mySequenceEqual t1.Headers t2.Headers (sprintf "%s: Headers" message) + mySequenceEqual (t1.Values |> sortVals) (t2.Values |> sortVals) (sprintf "%s: Values" message) + + let rec testFileSystemTree (actual:FileSystemTree) (expected:FileSystemTree) = + match actual, expected with + | File n1, File n2 -> Expect.equal n1 n2 $"Expects file names to be equal: {n1} = {n2}" + | Folder (n1, children1), Folder (n2, children2) -> + Expect.equal n1 n2 $"Expects folder names to be equal: {n1} = {n2}" + let sortByName (children: FileSystemTree []) = children |> Array.sortBy (fun c -> c.Name) + Array.iter2 testFileSystemTree (sortByName children1) (sortByName children2) + | anyActual, anyExpected -> + failwith $"Testing FileSystemTree found an issue with unequal states: + Actual: + {anyActual} + + Expected: + {anyExpected}" \ No newline at end of file diff --git a/tests/ARCtrl/TestObjects/ISAContracts.fs b/tests/TestingUtils/TestObjects.Contract/ISA.fs similarity index 96% rename from tests/ARCtrl/TestObjects/ISAContracts.fs rename to tests/TestingUtils/TestObjects.Contract/ISA.fs index 21f7c487..7c6d6ddc 100644 --- a/tests/ARCtrl/TestObjects/ISAContracts.fs +++ b/tests/TestingUtils/TestObjects.Contract/ISA.fs @@ -1,4 +1,4 @@ -module TestObjects.ISAContracts +module TestObjects.Contract.ISA open FsSpreadsheet open ARCtrl.Contract @@ -6,8 +6,10 @@ open ARCtrl open ARCtrl.ISA open ARCtrl.ISA.Spreadsheet +open TestObjects.Spreadsheet + module SimpleISA = - let assayMetadataWorksheet = TestObjects.Assay.assayMetadata + let assayMetadataWorksheet = Assay.assayMetadata let assayWsName = "Measurement" let assayTable = ArcTable.initWorksheet assayWsName @@ -32,7 +34,7 @@ module SimpleISA = dto = DTO.Spreadsheet assayWB) - let studyMetadataWorksheet = TestObjects.Study.studyMetadata + let studyMetadataWorksheet = Study.studyMetadata let studyNewWsName = "preparation" let studyNewTable = ArcTable.initWorksheet studyNewWsName diff --git a/tests/ISA/ISA.Json.Tests/TestObjects/Assay.fs b/tests/TestingUtils/TestObjects.Json/Assay.fs similarity index 99% rename from tests/ISA/ISA.Json.Tests/TestObjects/Assay.fs rename to tests/TestingUtils/TestObjects.Json/Assay.fs index 222085d1..e97b7ebf 100644 --- a/tests/ISA/ISA.Json.Tests/TestObjects/Assay.fs +++ b/tests/TestingUtils/TestObjects.Json/Assay.fs @@ -1,4 +1,4 @@ -module TestObjects.Assay +module TestObjects.Json.Assay let assay = """ diff --git a/tests/ISA/ISA.Json.Tests/TestObjects/Investigation.fs b/tests/TestingUtils/TestObjects.Json/Investigation.fs similarity index 99% rename from tests/ISA/ISA.Json.Tests/TestObjects/Investigation.fs rename to tests/TestingUtils/TestObjects.Json/Investigation.fs index 59fd5e3a..18f20da8 100644 --- a/tests/ISA/ISA.Json.Tests/TestObjects/Investigation.fs +++ b/tests/TestingUtils/TestObjects.Json/Investigation.fs @@ -1,4 +1,4 @@ -module TestObjects.Investigation +module TestObjects.Json.Investigation let investigationLD = """ diff --git a/tests/ISA/ISA.Json.Tests/TestObjects/OntologyAnnotation.fs b/tests/TestingUtils/TestObjects.Json/OntologyAnnotation.fs similarity index 97% rename from tests/ISA/ISA.Json.Tests/TestObjects/OntologyAnnotation.fs rename to tests/TestingUtils/TestObjects.Json/OntologyAnnotation.fs index d3ddd477..ab0a8f43 100644 --- a/tests/ISA/ISA.Json.Tests/TestObjects/OntologyAnnotation.fs +++ b/tests/TestingUtils/TestObjects.Json/OntologyAnnotation.fs @@ -1,4 +1,4 @@ -module TestObjects.OntologyAnnotation +module TestObjects.Json.OntologyAnnotation let peptidase = """{ diff --git a/tests/ISA/ISA.Json.Tests/TestObjects/Person.fs b/tests/TestingUtils/TestObjects.Json/Person.fs similarity index 98% rename from tests/ISA/ISA.Json.Tests/TestObjects/Person.fs rename to tests/TestingUtils/TestObjects.Json/Person.fs index 53cacd1e..12803a77 100644 --- a/tests/ISA/ISA.Json.Tests/TestObjects/Person.fs +++ b/tests/TestingUtils/TestObjects.Json/Person.fs @@ -1,4 +1,4 @@ -module TestObjects.Person +module TestObjects.Json.Person let person = """ diff --git a/tests/ISA/ISA.Json.Tests/TestObjects/Process.fs b/tests/TestingUtils/TestObjects.Json/Process.fs similarity index 99% rename from tests/ISA/ISA.Json.Tests/TestObjects/Process.fs rename to tests/TestingUtils/TestObjects.Json/Process.fs index 66f652c8..c9f755dd 100644 --- a/tests/ISA/ISA.Json.Tests/TestObjects/Process.fs +++ b/tests/TestingUtils/TestObjects.Json/Process.fs @@ -1,4 +1,4 @@ -module TestObjects.Process +module TestObjects.Json.Process let process' = diff --git a/tests/ISA/ISA.Json.Tests/TestObjects/ProcessInput.fs b/tests/TestingUtils/TestObjects.Json/ProcessInput.fs similarity index 99% rename from tests/ISA/ISA.Json.Tests/TestObjects/ProcessInput.fs rename to tests/TestingUtils/TestObjects.Json/ProcessInput.fs index 30b33506..a568496d 100644 --- a/tests/ISA/ISA.Json.Tests/TestObjects/ProcessInput.fs +++ b/tests/TestingUtils/TestObjects.Json/ProcessInput.fs @@ -1,4 +1,4 @@ -module TestObjects.ProcessInput +module TestObjects.Json.ProcessInput let sampleSimple = """ diff --git a/tests/ISA/ISA.Json.Tests/TestObjects/Protocol.fs b/tests/TestingUtils/TestObjects.Json/Protocol.fs similarity index 99% rename from tests/ISA/ISA.Json.Tests/TestObjects/Protocol.fs rename to tests/TestingUtils/TestObjects.Json/Protocol.fs index b06eae72..b668fc00 100644 --- a/tests/ISA/ISA.Json.Tests/TestObjects/Protocol.fs +++ b/tests/TestingUtils/TestObjects.Json/Protocol.fs @@ -1,4 +1,4 @@ -module TestObjects.Protocol +module TestObjects.Json.Protocol let protocol = diff --git a/tests/ISA/ISA.Json.Tests/TestObjects/Publication.fs b/tests/TestingUtils/TestObjects.Json/Publication.fs similarity index 96% rename from tests/ISA/ISA.Json.Tests/TestObjects/Publication.fs rename to tests/TestingUtils/TestObjects.Json/Publication.fs index fda5f33e..60594ada 100644 --- a/tests/ISA/ISA.Json.Tests/TestObjects/Publication.fs +++ b/tests/TestingUtils/TestObjects.Json/Publication.fs @@ -1,4 +1,4 @@ -module TestObjects.Publication +module TestObjects.Json.Publication let publication = diff --git a/tests/ISA/ISA.Json.Tests/TestObjects/Validation.fs b/tests/TestingUtils/TestObjects.Json/Validation.fs similarity index 99% rename from tests/ISA/ISA.Json.Tests/TestObjects/Validation.fs rename to tests/TestingUtils/TestObjects.Json/Validation.fs index 3782cc5b..97987813 100644 --- a/tests/ISA/ISA.Json.Tests/TestObjects/Validation.fs +++ b/tests/TestingUtils/TestObjects.Json/Validation.fs @@ -1,4 +1,4 @@ -module TestObjects.Validation +module TestObjects.Json.Validation let processDateWrong = """ diff --git a/tests/ISA/ISA.Spreadsheet.Tests/TestObjects/ArcTable.fs b/tests/TestingUtils/TestObjects.Spreadsheet/Spreadsheet.ArcTable.fs similarity index 99% rename from tests/ISA/ISA.Spreadsheet.Tests/TestObjects/ArcTable.fs rename to tests/TestingUtils/TestObjects.Spreadsheet/Spreadsheet.ArcTable.fs index 7040af62..edb98dd1 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/TestObjects/ArcTable.fs +++ b/tests/TestingUtils/TestObjects.Spreadsheet/Spreadsheet.ArcTable.fs @@ -1,4 +1,4 @@ -module TestObjects.ArcTable +module TestObjects.Spreadsheet.ArcTable open FsSpreadsheet open ARCtrl.ISA diff --git a/tests/ISA/ISA.Spreadsheet.Tests/TestObjects/Assay.fs b/tests/TestingUtils/TestObjects.Spreadsheet/Spreadsheet.Assay.fs similarity index 99% rename from tests/ISA/ISA.Spreadsheet.Tests/TestObjects/Assay.fs rename to tests/TestingUtils/TestObjects.Spreadsheet/Spreadsheet.Assay.fs index 10251139..7ad35395 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/TestObjects/Assay.fs +++ b/tests/TestingUtils/TestObjects.Spreadsheet/Spreadsheet.Assay.fs @@ -1,4 +1,4 @@ -module TestObjects.Assay +module TestObjects.Spreadsheet.Assay open FsSpreadsheet diff --git a/tests/ISA/ISA.Spreadsheet.Tests/TestObjects/InvestigationFile.fs b/tests/TestingUtils/TestObjects.Spreadsheet/Spreadsheet.InvestigationFile.fs similarity index 99% rename from tests/ISA/ISA.Spreadsheet.Tests/TestObjects/InvestigationFile.fs rename to tests/TestingUtils/TestObjects.Spreadsheet/Spreadsheet.InvestigationFile.fs index 0e4ab9d8..bfb2861b 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/TestObjects/InvestigationFile.fs +++ b/tests/TestingUtils/TestObjects.Spreadsheet/Spreadsheet.InvestigationFile.fs @@ -1,4 +1,4 @@ -module TestObjects.Investigation +module TestObjects.Spreadsheet.Investigation open FsSpreadsheet.DSL open FsSpreadsheet diff --git a/tests/ISA/ISA.Spreadsheet.Tests/TestObjects/Study.fs b/tests/TestingUtils/TestObjects.Spreadsheet/Spreadsheet.Study.fs similarity index 99% rename from tests/ISA/ISA.Spreadsheet.Tests/TestObjects/Study.fs rename to tests/TestingUtils/TestObjects.Spreadsheet/Spreadsheet.Study.fs index b4a6dad8..8908361a 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/TestObjects/Study.fs +++ b/tests/TestingUtils/TestObjects.Spreadsheet/Spreadsheet.Study.fs @@ -1,4 +1,4 @@ -module TestObjects.Study +module TestObjects.Spreadsheet.Study open FsSpreadsheet diff --git a/tests/TestingUtils/TestingUtils.fsproj b/tests/TestingUtils/TestingUtils.fsproj new file mode 100644 index 00000000..1cf1a0b8 --- /dev/null +++ b/tests/TestingUtils/TestingUtils.fsproj @@ -0,0 +1,30 @@ + + + + net6.0 + true + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/TestingUtils/paket.references b/tests/TestingUtils/paket.references new file mode 100644 index 00000000..5c28c4e4 --- /dev/null +++ b/tests/TestingUtils/paket.references @@ -0,0 +1,4 @@ +FSharp.Core +Fable.Core +Expecto +Fable.Mocha \ No newline at end of file From 70f288bfa95fb98c0258f8eab8ae8f1a225e67e7 Mon Sep 17 00:00:00 2001 From: Heinrich Lukas Weil Date: Wed, 20 Sep 2023 13:51:29 +0200 Subject: [PATCH 2/2] unified mocha and expecto functionality into TestingUtils project --- tests/ARCtrl/ARCtrl.Contracts.Tests.fs | 6 +- tests/ARCtrl/ARCtrl.Tests.fs | 15 ++--- tests/ARCtrl/ARCtrl.Tests.fsproj | 2 +- tests/ARCtrl/SemVer.Tests.fs | 6 +- tests/ARCtrl/Templates.Tests.fs | 8 +-- tests/ARCtrl/paket.references | 3 - tests/FileSystem/FileSystemTree.Tests.fs | 6 +- tests/FileSystem/paket.references | 3 - tests/ISA/ISA.Json.Tests/Json.Tests.fs | 44 +++++++------ tests/ISA/ISA.Json.Tests/JsonSchema.Tests.fs | 6 +- tests/ISA/ISA.Json.Tests/paket.references | 3 - .../ISA.Spreadsheet.Tests/ArcTableTests.fs | 29 ++++----- .../ISA.Spreadsheet.Tests/AssayFileTests.fs | 18 ++---- .../CompositeCellTests.fs | 6 +- .../CompositeColumnTests.fs | 7 +-- .../CompositeHeaderTests.fs | 6 +- tests/ISA/ISA.Spreadsheet.Tests/FableTests.fs | 7 +-- .../ISA.Spreadsheet.Tests/Identifier.Tests.fs | 6 +- .../InvestigationFileTests.fs | 29 ++++----- .../ISA.Spreadsheet.Tests/SparseTableTests.fs | 8 +-- .../StringConversionTests.fs | 24 +++----- .../ISA.Spreadsheet.Tests/StudyFileTests.fs | 6 -- .../ISA.Spreadsheet.Tests/paket.references | 3 - tests/ISA/ISA.Tests/ArcAssay.Tests.fs | 16 ++--- tests/ISA/ISA.Tests/ArcInvestigation.Tests.fs | 16 ++--- tests/ISA/ISA.Tests/ArcJsonConversionTests.fs | 19 +++--- tests/ISA/ISA.Tests/ArcStudy.Tests.fs | 18 +++--- tests/ISA/ISA.Tests/ArcTable.Tests.fs | 26 ++++---- tests/ISA/ISA.Tests/ArcTables.Tests.fs | 20 +++--- tests/ISA/ISA.Tests/CompositeCell.Tests.fs | 6 +- tests/ISA/ISA.Tests/CompositeColumn.Tests.fs | 6 +- tests/ISA/ISA.Tests/CompositeHeader.Tests.fs | 6 +- tests/ISA/ISA.Tests/DataModel.Tests.fs | 6 +- tests/ISA/ISA.Tests/Fable.Tests.fs | 6 +- tests/ISA/ISA.Tests/Identifier.Tests.fs | 6 +- tests/ISA/ISA.Tests/Person.Tests.fs | 6 +- tests/ISA/ISA.Tests/Regex.Tests.fs | 6 +- tests/ISA/ISA.Tests/Update.Tests.fs | 26 ++++---- tests/ISA/ISA.Tests/paket.references | 3 - tests/TestingUtils/Library.fs | 61 +++++++++++++++++-- 40 files changed, 199 insertions(+), 305 deletions(-) diff --git a/tests/ARCtrl/ARCtrl.Contracts.Tests.fs b/tests/ARCtrl/ARCtrl.Contracts.Tests.fs index 4a0f8d0f..bd10b401 100644 --- a/tests/ARCtrl/ARCtrl.Contracts.Tests.fs +++ b/tests/ARCtrl/ARCtrl.Contracts.Tests.fs @@ -1,10 +1,6 @@ module ARCtrl.Contracts.Tests -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif +open TestingUtils open ARCtrl open ARCtrl.Contract diff --git a/tests/ARCtrl/ARCtrl.Tests.fs b/tests/ARCtrl/ARCtrl.Tests.fs index 0a4a124e..3c570e4c 100644 --- a/tests/ARCtrl/ARCtrl.Tests.fs +++ b/tests/ARCtrl/ARCtrl.Tests.fs @@ -1,10 +1,5 @@ module ARCtrl.Tests -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif open ARCtrl open ARCtrl.ISA @@ -96,11 +91,11 @@ let private test_isaFromContracts = testList "read_contracts" [ Expect.equal study.TableCount 1 "study should have read one table" let studyTable = study.Tables.[0] Expect.equal studyTable.ColumnCount 2 "study column number should be unchanged" - Expect.mySequenceEqual + Expect.sequenceEqual (studyTable.GetProtocolDescriptionColumn()).Cells [CompositeCell.createFreeText UpdateAssayWithStudyProtocol.description] "Description value was not kept correctly" - Expect.mySequenceEqual + Expect.sequenceEqual (studyTable.GetProtocolNameColumn()).Cells [CompositeCell.createFreeText UpdateAssayWithStudyProtocol.protocolName] "Protocol ref value was not kept correctly" @@ -110,15 +105,15 @@ let private test_isaFromContracts = testList "read_contracts" [ Expect.equal assay.TableCount 1 "assay should have read one table" let assayTable = assay.Tables.[0] Expect.equal assayTable.ColumnCount 3 "assay column number should be updated" - Expect.mySequenceEqual + Expect.sequenceEqual (assayTable.GetProtocolNameColumn()).Cells (Array.create 2 (CompositeCell.createFreeText UpdateAssayWithStudyProtocol.protocolName)) "Protocol ref value was not kept correctly" - Expect.mySequenceEqual + Expect.sequenceEqual (assayTable.GetColumnByHeader(UpdateAssayWithStudyProtocol.inputHeader)).Cells (Array.create 2 UpdateAssayWithStudyProtocol.inputCell) "Protocol ref value was not kept correctly" - Expect.mySequenceEqual + Expect.sequenceEqual (assayTable.GetProtocolDescriptionColumn()).Cells (Array.create 2 (CompositeCell.createFreeText UpdateAssayWithStudyProtocol.description)) "Description value was not taken correctly" diff --git a/tests/ARCtrl/ARCtrl.Tests.fsproj b/tests/ARCtrl/ARCtrl.Tests.fsproj index dd23366a..b769a27c 100644 --- a/tests/ARCtrl/ARCtrl.Tests.fsproj +++ b/tests/ARCtrl/ARCtrl.Tests.fsproj @@ -6,9 +6,9 @@ false + - diff --git a/tests/ARCtrl/SemVer.Tests.fs b/tests/ARCtrl/SemVer.Tests.fs index fc8cb85b..626025f3 100644 --- a/tests/ARCtrl/SemVer.Tests.fs +++ b/tests/ARCtrl/SemVer.Tests.fs @@ -1,10 +1,6 @@ module ARCtrl.SemVer.Tests -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif +open TestingUtils open ARCtrl diff --git a/tests/ARCtrl/Templates.Tests.fs b/tests/ARCtrl/Templates.Tests.fs index 7e580307..5b111af5 100644 --- a/tests/ARCtrl/Templates.Tests.fs +++ b/tests/ARCtrl/Templates.Tests.fs @@ -1,18 +1,14 @@ module ARCtrl.Templates.Tests #if FABLE_COMPILER -open Fable.Mocha open Thoth.Json #else -open Expecto open Thoth.Json.Net #endif open ARCtrl.Templates.Json open ARCtrl.ISA -open System -open System.Text open TestingUtils let private fableReplaceLineEndings(str: string) = @@ -144,8 +140,8 @@ let tests_Template = testList "Template" [ //printfn "EXPECTED: %A" expected.Table Expect.equal actualValue.Table.Name expected.Table.Name "Name should be equal" - Expect.mySequenceEqual actualValue.Table.Headers expected.Table.Headers "Headers should be equal" - Expect.mySequenceEqual actualValue.Table.Values expected.Table.Values "Headers should be equal" + Expect.sequenceEqual actualValue.Table.Headers expected.Table.Headers "Headers should be equal" + Expect.sequenceEqual actualValue.Table.Values expected.Table.Values "Headers should be equal" Expect.equal actualValue.Table.RowCount expected.Table.RowCount "RowCount should be equal" Expect.equal actualValue.Table.ColumnCount expected.Table.ColumnCount "ColumnCount should be equal" diff --git a/tests/ARCtrl/paket.references b/tests/ARCtrl/paket.references index 2561dfaa..47cc4278 100644 --- a/tests/ARCtrl/paket.references +++ b/tests/ARCtrl/paket.references @@ -1,6 +1,3 @@ FSharp.Core -Fable.Core -Expecto -Fable.Mocha Microsoft.NET.Test.Sdk YoloDev.Expecto.TestSdk \ No newline at end of file diff --git a/tests/FileSystem/FileSystemTree.Tests.fs b/tests/FileSystem/FileSystemTree.Tests.fs index 6e8a715f..fe846d94 100644 --- a/tests/FileSystem/FileSystemTree.Tests.fs +++ b/tests/FileSystem/FileSystemTree.Tests.fs @@ -1,10 +1,6 @@ module ARCtrl.FileSystemTree.Tests -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif +open TestingUtils open ARCtrl.FileSystem open TestingUtils diff --git a/tests/FileSystem/paket.references b/tests/FileSystem/paket.references index 2561dfaa..47cc4278 100644 --- a/tests/FileSystem/paket.references +++ b/tests/FileSystem/paket.references @@ -1,6 +1,3 @@ FSharp.Core -Fable.Core -Expecto -Fable.Mocha Microsoft.NET.Test.Sdk YoloDev.Expecto.TestSdk \ No newline at end of file diff --git a/tests/ISA/ISA.Json.Tests/Json.Tests.fs b/tests/ISA/ISA.Json.Tests/Json.Tests.fs index 93584f32..d9d25b67 100644 --- a/tests/ISA/ISA.Json.Tests/Json.Tests.fs +++ b/tests/ISA/ISA.Json.Tests/Json.Tests.fs @@ -8,10 +8,8 @@ open ARCtrl.ISA open Fable.Core open Fable.Core.JsInterop open Thoth.Json -open Fable.Mocha #else open Thoth.Json.Net -open Expecto #endif open TestingUtils @@ -103,7 +101,7 @@ let testEncode = let expected = comments - Expect.mySequenceEqual result' expected "Retrieved value did not match" + Expect.sequenceEqual result' expected "Retrieved value did not match" ) ] @@ -131,7 +129,7 @@ let testDecode = let expected = ["@id";"characteristics";"name";"type"] - Expect.mySequenceEqual result expected "Field names did not match" + Expect.sequenceEqual result expected "Field names did not match" ) ] @@ -162,7 +160,7 @@ let testOntoloyAnnotation = o_out |> Utils.wordFrequency - Expect.mySequenceEqual actual expected "Written processInput does not match read process input" + Expect.sequenceEqual actual expected "Written processInput does not match read process input" ) ] @@ -193,7 +191,7 @@ let testOntoloyAnnotationLD = o_out |> Utils.wordFrequency - Expect.mySequenceEqual actual expected "Written processInput does not match read process input" + Expect.sequenceEqual actual expected "Written processInput does not match read process input" ) testCase "WriterOutputMatchesInputDefaultIDs" (fun () -> @@ -208,7 +206,7 @@ let testOntoloyAnnotationLD = o_out |> Utils.wordFrequency - Expect.mySequenceEqual actual expected "Written processInput does not match read process input" + Expect.sequenceEqual actual expected "Written processInput does not match read process input" ) ] @@ -241,7 +239,7 @@ let testProcessInput = o_out |> Utils.wordFrequency - Expect.mySequenceEqual actual expected "Written processInput does not match read process input" + Expect.sequenceEqual actual expected "Written processInput does not match read process input" ) ] testList "Material" [ @@ -735,7 +733,7 @@ let testProcessFile = |> Array.countBy id |> Array.sortBy fst - Expect.mySequenceEqual actual expected "Written process file does not match read process file" + Expect.sequenceEqual actual expected "Written process file does not match read process file" ) ] @@ -798,7 +796,7 @@ let testProcessFileLD = |> Array.countBy id |> Array.sortBy fst - Expect.mySequenceEqual actual expected "Written process file does not match read process file" + Expect.sequenceEqual actual expected "Written process file does not match read process file" ) testCase "OutputMatchesInputDefaultLD" (fun () -> @@ -818,7 +816,7 @@ let testProcessFileLD = |> Utils.extractWords |> Array.countBy id |> Array.sortBy fst - Expect.mySequenceEqual actual expected "Written process file does not match read process file" + Expect.sequenceEqual actual expected "Written process file does not match read process file" ) ] @@ -881,7 +879,7 @@ let testPersonFile = |> Array.countBy id |> Array.sortBy fst - Expect.mySequenceEqual actual expected "Written person file does not match read person file" + Expect.sequenceEqual actual expected "Written person file does not match read person file" ) @@ -923,7 +921,7 @@ let testPersonFile = |> Array.countBy id |> Array.sortBy fst - Expect.mySequenceEqual actual expected "Written person file does not match read person file" + Expect.sequenceEqual actual expected "Written person file does not match read person file" ) ] @@ -986,7 +984,7 @@ let testPersonFileLD = |> Array.countBy id |> Array.sortBy fst - Expect.mySequenceEqual actual expected "Written person file does not match read person file" + Expect.sequenceEqual actual expected "Written person file does not match read person file" ) testCase "OutputMatchesInputDefaultLD" (fun () -> @@ -1007,7 +1005,7 @@ let testPersonFileLD = |> Array.countBy id |> Array.sortBy fst - Expect.mySequenceEqual actual expected "Written person file does not match read person file" + Expect.sequenceEqual actual expected "Written person file does not match read person file" ) ] @@ -1070,7 +1068,7 @@ let testPublicationFile = |> Array.countBy id |> Array.sortBy fst - Expect.mySequenceEqual actual expected "Written Publication file does not match read publication file" + Expect.sequenceEqual actual expected "Written Publication file does not match read publication file" ) ] @@ -1133,7 +1131,7 @@ let testPublicationFileLD = |> Array.countBy id |> Array.sortBy fst - Expect.mySequenceEqual actual expected "Written Publication file does not match read publication file" + Expect.sequenceEqual actual expected "Written Publication file does not match read publication file" ) ] @@ -1196,7 +1194,7 @@ let testAssayFile = |> Array.countBy id |> Array.sortBy fst - Expect.mySequenceEqual actual expected "Written assay file does not match read assay file" + Expect.sequenceEqual actual expected "Written assay file does not match read assay file" ) ] @@ -1258,7 +1256,7 @@ let testInvestigationFile = |> Array.countBy id |> Array.sortBy fst - Expect.mySequenceEqual actual expected "Written investigation file does not match read investigation file" + Expect.sequenceEqual actual expected "Written investigation file does not match read investigation file" ) testCase "HandleEmptyRemarks" (fun () -> @@ -1617,7 +1615,7 @@ let testInvestigationFile = |> Array.countBy id |> Array.sortBy fst - Expect.mySequenceEqual o i "Written investigation file does not match read investigation file" + Expect.sequenceEqual o i "Written investigation file does not match read investigation file" ) ] @@ -1680,7 +1678,7 @@ let testInvestigationFileLD = // |> Array.countBy id // |> Array.sortBy fst - // Expect.mySequenceEqual actual expected "Written investigation file does not match read investigation file" + // Expect.sequenceEqual actual expected "Written investigation file does not match read investigation file" // ) // testCase "HandleEmptyRemarks" (fun () -> @@ -2035,8 +2033,8 @@ let testInvestigationFileLD = // |> Array.countBy id // |> Array.sortBy fst - // Expect.mySequenceEqual actual expected "Written investigation file does not match read investigation file" - Expect.mySequenceEqual [1;2] [1;2] "bla" + // Expect.sequenceEqual actual expected "Written investigation file does not match read investigation file" + Expect.sequenceEqual [1;2] [1;2] "bla" ) ] diff --git a/tests/ISA/ISA.Json.Tests/JsonSchema.Tests.fs b/tests/ISA/ISA.Json.Tests/JsonSchema.Tests.fs index ae5e457c..526caf4c 100644 --- a/tests/ISA/ISA.Json.Tests/JsonSchema.Tests.fs +++ b/tests/ISA/ISA.Json.Tests/JsonSchema.Tests.fs @@ -1,10 +1,6 @@ module JsonSchema.Tests -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif +open TestingUtils open ARCtrl.ISA.Json diff --git a/tests/ISA/ISA.Json.Tests/paket.references b/tests/ISA/ISA.Json.Tests/paket.references index 2561dfaa..47cc4278 100644 --- a/tests/ISA/ISA.Json.Tests/paket.references +++ b/tests/ISA/ISA.Json.Tests/paket.references @@ -1,6 +1,3 @@ FSharp.Core -Fable.Core -Expecto -Fable.Mocha Microsoft.NET.Test.Sdk YoloDev.Expecto.TestSdk \ No newline at end of file diff --git a/tests/ISA/ISA.Spreadsheet.Tests/ArcTableTests.fs b/tests/ISA/ISA.Spreadsheet.Tests/ArcTableTests.fs index 7436d9a0..a84c3970 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/ArcTableTests.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/ArcTableTests.fs @@ -1,12 +1,5 @@ module ArcTableTests -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif - - open ARCtrl.ISA open ARCtrl.ISA.Spreadsheet @@ -34,7 +27,7 @@ let private ensureCorrectTestHeaders = Parameter.instrumentHeaderV3 + " " ] - Expect.mySequenceEqual (ws.Row(1).Cells |> Seq.map (fun c -> c.Value)) expectedHeaders "Headers did not match" + Expect.sequenceEqual (ws.Row(1).Cells |> Seq.map (fun c -> c.Value)) expectedHeaders "Headers did not match" let expectedValues = [ @@ -46,7 +39,7 @@ let private ensureCorrectTestHeaders = Parameter.instrumentValueV3 ] - Expect.mySequenceEqual (ws.Row(2).Cells |> Seq.map (fun c -> c.Value)) expectedValues "Values did not match" + Expect.sequenceEqual (ws.Row(2).Cells |> Seq.map (fun c -> c.Value)) expectedValues "Values did not match" ) ] @@ -77,7 +70,7 @@ let private groupCols = let actualHeaderGroups = grouped |> List.map (fun cols -> cols |> List.map (fun c -> c.[1].Value) |> List.reduce (fun a b -> a + ";" + b)) - Expect.mySequenceEqual actualHeaderGroups expectedHeaderGroups "Header groups did not match" + Expect.sequenceEqual actualHeaderGroups expectedHeaderGroups "Header groups did not match" ) ] @@ -116,7 +109,7 @@ let private simpleTable = Characteristic.organismHeader Factor.timeHeader ] - Expect.mySequenceEqual table.Headers expectedHeaders "Headers did not match" + Expect.sequenceEqual table.Headers expectedHeaders "Headers did not match" let expectedCells = [ @@ -128,7 +121,7 @@ let private simpleTable = Characteristic.organismValue Factor.timeValue ] - Expect.mySequenceEqual (table.GetRow(0)) expectedCells "Cells did not match" + Expect.sequenceEqual (table.GetRow(0)) expectedCells "Cells did not match" ) testCase "Write" (fun () -> @@ -173,7 +166,7 @@ let private emptyTable = Characteristic.organismHeader Factor.timeHeader ] - Expect.mySequenceEqual table.Headers expectedHeaders "Headers did not match" + Expect.sequenceEqual table.Headers expectedHeaders "Headers did not match" ) // TODO: What should we do with units of empty columns? //testCase "Write" (fun () -> @@ -219,7 +212,7 @@ let private mixedTable = Characteristic.organismHeader Factor.timeHeader ] - Expect.mySequenceEqual table.Headers expectedHeaders "Headers did not match" + Expect.sequenceEqual table.Headers expectedHeaders "Headers did not match" ) testCase "Write" (fun () -> @@ -265,7 +258,7 @@ let private ioTable = Factor.timeHeader Output.rawDataHeader ] - Expect.mySequenceEqual table.Headers expectedHeaders "Headers did not match" + Expect.sequenceEqual table.Headers expectedHeaders "Headers did not match" let expectedCells = [ Input.sampleValue @@ -275,7 +268,7 @@ let private ioTable = Factor.timeValue Output.rawDataValue ] - Expect.mySequenceEqual (table.GetRow(0)) expectedCells "Cells did not match" + Expect.sequenceEqual (table.GetRow(0)) expectedCells "Cells did not match" ) testCase "Write" (fun () -> @@ -320,7 +313,7 @@ let private deprecatedColumnTable = Parameter.temperatureHeader Output.deprecatedSampleHeader ] - Expect.mySequenceEqual table.Headers expectedHeaders "Headers did not match" + Expect.sequenceEqual table.Headers expectedHeaders "Headers did not match" let expectedCells = [ @@ -330,7 +323,7 @@ let private deprecatedColumnTable = Parameter.temperatureValue Output.rawDataValue ] - Expect.mySequenceEqual (table.GetRow(0)) expectedCells "Cells did not match" + Expect.sequenceEqual (table.GetRow(0)) expectedCells "Cells did not match" ) ] diff --git a/tests/ISA/ISA.Spreadsheet.Tests/AssayFileTests.fs b/tests/ISA/ISA.Spreadsheet.Tests/AssayFileTests.fs index 5f3554c8..c004fbb8 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/AssayFileTests.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/AssayFileTests.fs @@ -1,12 +1,6 @@ module ArcAssayTests -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif - open ARCtrl.ISA open TestingUtils open ARCtrl.ISA.Spreadsheet @@ -412,9 +406,9 @@ let testAssayFileReader = // let factors = API.Assay.getFactors assay // let protocols = API.Assay.getProtocols assay - // Expect.mySequenceEqual factors expectedFactors "Factors were read incorrectly" - // Expect.mySequenceEqual protocols expectedProtocols "Protocols were read incorrectly" - // Expect.mySequenceEqual persons expectedPersons "Persons were read incorrectly from metadata sheet" + // Expect.sequenceEqual factors expectedFactors "Factors were read incorrectly" + // Expect.sequenceEqual protocols expectedProtocols "Protocols were read incorrectly" + // Expect.sequenceEqual persons expectedPersons "Persons were read incorrectly from metadata sheet" // Expect.isSome assay.FileName "FileName was not read" // Expect.equal assay.FileName.Value fileName "FileName was not read correctly" @@ -428,7 +422,7 @@ let testAssayFileReader = // Expect.isSome assay.ProcessSequence "Processes were not read" // assay.ProcessSequence.Value // |> Seq.map (fun p -> Option.defaultValue "" p.Name) - // |> fun names -> Expect.mySequenceEqual names ["GreatAssay_0";"GreatAssay_1";"SecondAssay_0"] "Process names do not match" + // |> fun names -> Expect.sequenceEqual names ["GreatAssay_0";"GreatAssay_1";"SecondAssay_0"] "Process names do not match" //) //testCase "AroundTheWorldComponents" (fun () -> @@ -460,7 +454,7 @@ let testAssayFileReader = // Expect.equal p.ExecutesProtocol.Value refP.ExecutesProtocol.Value "Assay written to xlsx and read in again does no longer match json. Protocol does not match" // Expect.equal p refP "Assay written to xlsx and read in again does no longer match json. Process does not match" // ) - // Expect.mySequenceEqual a'.ProcessSequence.Value ref.ProcessSequence.Value "" + // Expect.sequenceEqual a'.ProcessSequence.Value ref.ProcessSequence.Value "" //) //testCase "AroundTheWorldProtocolType" (fun () -> @@ -493,7 +487,7 @@ let testAssayFileReader = // Expect.equal p.ExecutesProtocol.Value refP.ExecutesProtocol.Value "Assay written to xlsx and read in again does no longer match json. Protocol does not match" // Expect.equal p refP "Assay written to xlsx and read in again does no longer match json. Process does not match" // ) - // Expect.mySequenceEqual a'.ProcessSequence.Value ref.ProcessSequence.Value "" + // Expect.sequenceEqual a'.ProcessSequence.Value ref.ProcessSequence.Value "" //) ] diff --git a/tests/ISA/ISA.Spreadsheet.Tests/CompositeCellTests.fs b/tests/ISA/ISA.Spreadsheet.Tests/CompositeCellTests.fs index 72e0ec66..0bb66461 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/CompositeCellTests.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/CompositeCellTests.fs @@ -1,10 +1,6 @@ module CompositeCellTests -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif +open TestingUtils let main = testList "CompositeCell" [ diff --git a/tests/ISA/ISA.Spreadsheet.Tests/CompositeColumnTests.fs b/tests/ISA/ISA.Spreadsheet.Tests/CompositeColumnTests.fs index 62b51f55..12140ff8 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/CompositeColumnTests.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/CompositeColumnTests.fs @@ -1,13 +1,8 @@ module CompositeColumnTests -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif +open TestingUtils open ARCtrl.ISA -open TestingUtils open ARCtrl.ISA.Spreadsheet open TestObjects.Spreadsheet.ArcTable diff --git a/tests/ISA/ISA.Spreadsheet.Tests/CompositeHeaderTests.fs b/tests/ISA/ISA.Spreadsheet.Tests/CompositeHeaderTests.fs index 671a4fce..21cc62ad 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/CompositeHeaderTests.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/CompositeHeaderTests.fs @@ -1,10 +1,6 @@ module CompositeHeaderTests -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif +open TestingUtils let main = testList "CompositeHeader" [ diff --git a/tests/ISA/ISA.Spreadsheet.Tests/FableTests.fs b/tests/ISA/ISA.Spreadsheet.Tests/FableTests.fs index 0c251a30..784199f5 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/FableTests.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/FableTests.fs @@ -3,12 +3,7 @@ open ARCtrl.ISA.Spreadsheet open FsSpreadsheet -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif - +open TestingUtils let tests_typeTranspilation = testList "type transpilation" [ testCase "FsWorkbook" <| fun _ -> diff --git a/tests/ISA/ISA.Spreadsheet.Tests/Identifier.Tests.fs b/tests/ISA/ISA.Spreadsheet.Tests/Identifier.Tests.fs index 9d51a129..36f920f9 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/Identifier.Tests.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/Identifier.Tests.fs @@ -1,10 +1,6 @@ module IdentifierTests -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif +open TestingUtils open ARCtrl.ISA.Identifier diff --git a/tests/ISA/ISA.Spreadsheet.Tests/InvestigationFileTests.fs b/tests/ISA/ISA.Spreadsheet.Tests/InvestigationFileTests.fs index 2ea42146..176cb5cf 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/InvestigationFileTests.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/InvestigationFileTests.fs @@ -1,10 +1,5 @@ module ArcInvestigationTests -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif open ARCtrl.ISA open FsSpreadsheet @@ -170,7 +165,7 @@ let private testInvestigationFile = // |> Seq.map (fun r -> r.Cells |> Seq.map (fun c -> c.Value) |> Seq.reduce (fun a b -> a + b)) - // Expect.mySequenceEqual o i "Written empty investigation file does not match read empty investigation file" + // Expect.sequenceEqual o i "Written empty investigation file does not match read empty investigation file" //) ] |> testSequenced @@ -225,7 +220,7 @@ let private testInvestigationFile = // Expect.isSome retrievedInvestigation "Could not retrieve investigation" -// Expect.mySequenceEqual +// Expect.sequenceEqual // (retrievedInvestigation.Value |> getKeyValues) // (testInvestigation |> getKeyValues) // "Could not retrieve the correct investigation from investigation file" @@ -251,7 +246,7 @@ let private testInvestigationFile = // Expect.isSome retrievedItem "Could not retrieve item from investigation file" -// Expect.mySequenceEqual +// Expect.sequenceEqual // (retrievedItem.Value |> getKeyValues) // (testItem |> getKeyValues) // "Could not retrieve the correct item from investigation file" @@ -279,7 +274,7 @@ let private testInvestigationFile = // Expect.isSome retrievedItem "Could not retrieve item from investigation file" -// Expect.mySequenceEqual +// Expect.sequenceEqual // (retrievedItem.Value |> getKeyValues) // (testItem |> getKeyValues) // "Could not retrieve the correct item from investigation file" @@ -294,7 +289,7 @@ let private testInvestigationFile = // let retrievedStudies = ISA_Investigation.getStudies doc |> Seq.map getIdentificationKeyValues -// Expect.mySequenceEqual +// Expect.sequenceEqual // retrievedStudies // testStudies // "Could not retrieve the correct studies from the investigation file" @@ -330,7 +325,7 @@ let private testInvestigationFile = // Expect.isSome retrievedInvestigation "Investigation file was not filled out" -// Expect.mySequenceEqual +// Expect.sequenceEqual // (retrievedInvestigation.Value |> getKeyValues) // (investigation |> getKeyValues) // "Investigation file was not filled out correctly" @@ -355,7 +350,7 @@ let private testInvestigationFile = // Expect.isSome retrievedStudy "Study could not be found" -// Expect.mySequenceEqual +// Expect.sequenceEqual // (retrievedStudy.Value |> getKeyValues) // (study |> getKeyValues) // "Study was not inserted correctly correctly" @@ -398,7 +393,7 @@ let private testInvestigationFile = // (ISA_Investigation.tryAddStudy study2 doc) // "Could not add study" -// Expect.mySequenceEqual +// Expect.sequenceEqual // (ISA_Investigation.getStudies doc |> Seq.map getKeyValues) // ([study1;study2] |> Seq.map getKeyValues) // "The Sequences do not match the expected seqs" @@ -426,7 +421,7 @@ let private testInvestigationFile = // Expect.isSome retrievedAssay "Assay could not be found" -// Expect.mySequenceEqual +// Expect.sequenceEqual // (retrievedAssay.Value |> getKeyValues) // (assay |> getKeyValues) // "Study was not inserted correctly correctly" @@ -454,7 +449,7 @@ let private testInvestigationFile = // Expect.isSome retrievedAssay "Assay could not be found" -// Expect.mySequenceEqual +// Expect.sequenceEqual // (retrievedAssay.Value |> getKeyValues) // (assay |> getKeyValues) // "Assay was not inserted correctly correctly" @@ -483,7 +478,7 @@ let private testInvestigationFile = // Expect.isSome retrievedAssay "Assay could not be found" -// Expect.mySequenceEqual +// Expect.sequenceEqual // (retrievedAssay.Value |> getKeyValues) // (updatedAssay |> getKeyValues) // "Assay was not updated correctly" @@ -511,7 +506,7 @@ let private testInvestigationFile = // (ISA_Investigation.tryRemoveItemFromStudy assayToRemove study doc) // "Could not remove assay" -// Expect.mySequenceEqual +// Expect.sequenceEqual // (ISA_Investigation.getItemsInStudy (Assay()) study doc |> Seq.map getKeyValues) // ([remainingAssay] |> Seq.map getKeyValues) // "The Sequences do not match the expected seqs" diff --git a/tests/ISA/ISA.Spreadsheet.Tests/SparseTableTests.fs b/tests/ISA/ISA.Spreadsheet.Tests/SparseTableTests.fs index 0ef3a98d..412be520 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/SparseTableTests.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/SparseTableTests.fs @@ -2,12 +2,6 @@ open ARCtrl.ISA.Spreadsheet -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif - open TestingUtils let main = @@ -130,7 +124,7 @@ let main = |> SparseTable.ToRows |> Seq.iteri (fun i r -> let testSeq = Seq.item i testRows - Expect.mySequenceEqual (SparseRow.getValues r) testSeq "" + Expect.sequenceEqual (SparseRow.getValues r) testSeq "" ) diff --git a/tests/ISA/ISA.Spreadsheet.Tests/StringConversionTests.fs b/tests/ISA/ISA.Spreadsheet.Tests/StringConversionTests.fs index ddc81aaf..6d740bf2 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/StringConversionTests.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/StringConversionTests.fs @@ -2,11 +2,7 @@ open ARCtrl.ISA -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif +open TestingUtils let singleItems = @@ -80,7 +76,7 @@ let aggregated = // ] // let ontologies = OntologyAnnotation.fromAggregatedStrings ';' terms accessions sources - // Expect.mySequenceEqual ontologies testOntologies "Ontology Annotations were not created correctly from aggregated strings" + // Expect.sequenceEqual ontologies testOntologies "Ontology Annotations were not created correctly from aggregated strings" // Expect.equal (OntologyAnnotation.toAggregatedStrings ';' ontologies) (terms,accessions,sources) "Ontology Annotations were not parsed correctly to aggregated strings" // let testComponents = @@ -90,7 +86,7 @@ let aggregated = // ] // let components = Component.fromAggregatedStrings ';' names terms accessions sources - // Expect.mySequenceEqual components testComponents "Components were not created correctly from aggregated strings" + // Expect.sequenceEqual components testComponents "Components were not created correctly from aggregated strings" // Expect.equal (Component.toAggregatedStrings ';' components) (names,terms,accessions,sources) "Components were not parsed correctly to aggregated strings" // let testPParams = @@ -100,7 +96,7 @@ let aggregated = // ] // let pParams = ProtocolParameter.fromAggregatedStrings ';' terms accessions sources - // Expect.mySequenceEqual pParams testPParams "Protocol Parameters were not created correctly from aggregated strings" + // Expect.sequenceEqual pParams testPParams "Protocol Parameters were not created correctly from aggregated strings" // Expect.equal (ProtocolParameter.toAggregatedStrings ';' pParams) (terms,accessions,sources) "Protocol Parameters were not parsed correctly to aggregated strings" //) @@ -113,19 +109,19 @@ let aggregated = // let testOntologies = [ ] // let ontologies = OntologyAnnotation.fromAggregatedStrings ';' terms accessions sources - // Expect.mySequenceEqual ontologies testOntologies "Ontology Annotations were not created correctly from empty aggregated strings. Empty strings should results in an empty list" + // Expect.sequenceEqual ontologies testOntologies "Ontology Annotations were not created correctly from empty aggregated strings. Empty strings should results in an empty list" // Expect.equal (OntologyAnnotation.toAggregatedStrings ';' ontologies) (terms,accessions,sources) "Ontology Annotations were not parsed correctly to empty aggregated strings" // let testComponents = [] // let components = Component.fromAggregatedStrings ';' names terms accessions sources - // Expect.mySequenceEqual components testComponents "Components were not created correctly from empty aggregated strings. Empty strings should results in an empty list" + // Expect.sequenceEqual components testComponents "Components were not created correctly from empty aggregated strings. Empty strings should results in an empty list" // Expect.equal (Component.toAggregatedStrings ';' components) (names,terms,accessions,sources) "Components were not parsed correctly to empty aggregated strings" // let testPParams = [] // let pParams = ProtocolParameter.fromAggregatedStrings ';' terms accessions sources - // Expect.mySequenceEqual pParams testPParams "Protocol Parameters were not created correctly from aggregated strings. Empty strings should results in an empty list" + // Expect.sequenceEqual pParams testPParams "Protocol Parameters were not created correctly from aggregated strings. Empty strings should results in an empty list" // Expect.equal (ProtocolParameter.toAggregatedStrings ';' pParams) (terms,accessions,sources) "Protocol Parameters were not parsed correctly to aggregated strings" //) //testCase "PartlyEmptyStrings" (fun () -> @@ -141,7 +137,7 @@ let aggregated = // ] // let ontologies = OntologyAnnotation.fromAggregatedStrings ';' terms accessions sources - // Expect.mySequenceEqual ontologies testOntologies "Ontology Annotations were not created correctly from partly empty aggregated strings" + // Expect.sequenceEqual ontologies testOntologies "Ontology Annotations were not created correctly from partly empty aggregated strings" // Expect.equal (OntologyAnnotation.toAggregatedStrings ';' ontologies) (terms,accessions,";") "Ontology Annotations were not parsed correctly to partly empty aggregated strings" // let testComponents = @@ -151,7 +147,7 @@ let aggregated = // ] // let components = Component.fromAggregatedStrings ';' names terms accessions sources - // Expect.mySequenceEqual components testComponents "Components were not created correctly from partly empty aggregated strings" + // Expect.sequenceEqual components testComponents "Components were not created correctly from partly empty aggregated strings" // Expect.equal (Component.toAggregatedStrings ';' components) (";",terms,accessions,";") "Components were not parsed correctly to partly empty aggregated strings" // let testPParams = @@ -161,7 +157,7 @@ let aggregated = // ] // let pParams = ProtocolParameter.fromAggregatedStrings ';' terms accessions sources - // Expect.mySequenceEqual pParams testPParams "Protocol Parameters were not created correctly from partly empty aggregated strings" + // Expect.sequenceEqual pParams testPParams "Protocol Parameters were not created correctly from partly empty aggregated strings" // Expect.equal (ProtocolParameter.toAggregatedStrings ';' pParams) (terms,accessions,";") "Protocol Parameters were not parsed correctly to partly empty aggregated strings" //) diff --git a/tests/ISA/ISA.Spreadsheet.Tests/StudyFileTests.fs b/tests/ISA/ISA.Spreadsheet.Tests/StudyFileTests.fs index a13fe306..21719e0c 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/StudyFileTests.fs +++ b/tests/ISA/ISA.Spreadsheet.Tests/StudyFileTests.fs @@ -1,12 +1,6 @@ module ArcStudyTests -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif -open ARCtrl.ISA open TestingUtils open ARCtrl.ISA.Spreadsheet diff --git a/tests/ISA/ISA.Spreadsheet.Tests/paket.references b/tests/ISA/ISA.Spreadsheet.Tests/paket.references index 2561dfaa..47cc4278 100644 --- a/tests/ISA/ISA.Spreadsheet.Tests/paket.references +++ b/tests/ISA/ISA.Spreadsheet.Tests/paket.references @@ -1,6 +1,3 @@ FSharp.Core -Fable.Core -Expecto -Fable.Mocha Microsoft.NET.Test.Sdk YoloDev.Expecto.TestSdk \ No newline at end of file diff --git a/tests/ISA/ISA.Tests/ArcAssay.Tests.fs b/tests/ISA/ISA.Tests/ArcAssay.Tests.fs index a66a1273..4ba48861 100644 --- a/tests/ISA/ISA.Tests/ArcAssay.Tests.fs +++ b/tests/ISA/ISA.Tests/ArcAssay.Tests.fs @@ -2,11 +2,7 @@ open ARCtrl.ISA -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif +open TestingUtils module Helper = let TableName = "Test" @@ -529,7 +525,7 @@ let private test_UpdateBy = testList "UpdateBy" [ Expect.equal actual.MeasurementType next.MeasurementType "MeasurementType" Expect.equal actual.TechnologyType next.TechnologyType "TechnologyType" Expect.equal actual.TechnologyPlatform next.TechnologyPlatform "TechnologyPlatform" - TestingUtils.Expect.mySequenceEqual actual.Tables next.Tables "Tables" + TestingUtils.Expect.sequenceEqual actual.Tables next.Tables "Tables" Expect.equal actual.Performers next.Performers "Performers" Expect.equal actual.Comments next.Comments "Comments" testCase "UpdateBy, replace existing" <| fun _ -> @@ -548,7 +544,7 @@ let private test_UpdateBy = testList "UpdateBy" [ Expect.equal actual.MeasurementType next.MeasurementType "MeasurementType" Expect.equal actual.TechnologyType next.TechnologyType "TechnologyType" Expect.equal actual.TechnologyPlatform expected.TechnologyPlatform "TechnologyPlatform" - TestingUtils.Expect.mySequenceEqual actual.Tables next.Tables "Tables" + TestingUtils.Expect.sequenceEqual actual.Tables next.Tables "Tables" Expect.equal actual.Performers next.Performers "Performers" Expect.equal actual.Comments expected.Comments "Comments" testCase "UpdateBy, replace existing, empty tables" <| fun _ -> @@ -562,7 +558,7 @@ let private test_UpdateBy = testList "UpdateBy" [ ) let expected = create_testAssay() actual.UpdateBy(next, true) - TestingUtils.Expect.mySequenceEqual actual.Tables expected.Tables "Tables" + TestingUtils.Expect.sequenceEqual actual.Tables expected.Tables "Tables" testCase "UpdateBy, replace existing, append" <| fun _ -> let actual = create_testAssay() let next = @@ -579,7 +575,7 @@ let private test_UpdateBy = testList "UpdateBy" [ Expect.equal actual.MeasurementType next.MeasurementType "MeasurementType" Expect.equal actual.TechnologyType next.TechnologyType "TechnologyType" Expect.equal actual.TechnologyPlatform expected.TechnologyPlatform "TechnologyPlatform" - TestingUtils.Expect.mySequenceEqual actual.Tables (ResizeArray([yield! expected.Tables; yield! next.Tables])) "Tables" + TestingUtils.Expect.sequenceEqual actual.Tables (ResizeArray([yield! expected.Tables; yield! next.Tables])) "Tables" Expect.equal actual.Performers [|yield! expected.Performers; yield! next.Performers|] "Performers" Expect.equal actual.Comments [|yield! expected.Comments; yield! next.Comments|] "Comments" testCase "UpdateBy, replace all, append" <| fun _ -> @@ -598,7 +594,7 @@ let private test_UpdateBy = testList "UpdateBy" [ Expect.equal actual.MeasurementType next.MeasurementType "MeasurementType" Expect.equal actual.TechnologyType next.TechnologyType "TechnologyType" Expect.equal actual.TechnologyPlatform next.TechnologyPlatform "TechnologyPlatform" - TestingUtils.Expect.mySequenceEqual actual.Tables (ResizeArray([yield! expected.Tables; yield! next.Tables])) "Tables" + TestingUtils.Expect.sequenceEqual actual.Tables (ResizeArray([yield! expected.Tables; yield! next.Tables])) "Tables" Expect.equal actual.Performers [|yield! expected.Performers; yield! next.Performers|] "Performers" Expect.equal actual.Comments [|yield! expected.Comments; yield! next.Comments|] "Comments" ] diff --git a/tests/ISA/ISA.Tests/ArcInvestigation.Tests.fs b/tests/ISA/ISA.Tests/ArcInvestigation.Tests.fs index b939a009..2e347846 100644 --- a/tests/ISA/ISA.Tests/ArcInvestigation.Tests.fs +++ b/tests/ISA/ISA.Tests/ArcInvestigation.Tests.fs @@ -2,11 +2,7 @@ open ARCtrl.ISA -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif +open TestingUtils let private assay_Identifier = "MyAssay" let private assay_MeasurementType = OntologyAnnotation.fromString("My Measurement Type", "MST", "MST:42424242") @@ -365,7 +361,7 @@ let tests_Study = testList "CRUD Study" [ testCase "add multiple" <| fun _ -> let i = createExampleInvestigation() Expect.equal i.StudyCount 2 "StudyCount" - TestingUtils.Expect.mySequenceEqual i.StudyIdentifiers (seq {"Study 1"; "Study 2"}) "StudyIdentifiers" + TestingUtils.Expect.sequenceEqual i.StudyIdentifiers (seq {"Study 1"; "Study 2"}) "StudyIdentifiers" let s2 = i.Studies.Item 1 Expect.equal s2.Title (Some "Study 2 Title") "Study 2 Title" testCase "add with same name, throws" <| fun _ -> @@ -445,8 +441,8 @@ let tests_Assay = testList "CRUD Assay" [ let i = createExampleInvestigation() Expect.equal i.StudyCount 2 "StudyCount" Expect.equal i.AssayCount 2 "AssayCount" - TestingUtils.Expect.mySequenceEqual i.StudyIdentifiers (seq {"Study 1"; "Study 2"}) "StudyIdentifiers" - TestingUtils.Expect.mySequenceEqual i.AssayIdentifiers (seq {"Assay 1"; "Assay 2"}) "AssayIdentifiers" + TestingUtils.Expect.sequenceEqual i.StudyIdentifiers (seq {"Study 1"; "Study 2"}) "StudyIdentifiers" + TestingUtils.Expect.sequenceEqual i.AssayIdentifiers (seq {"Assay 1"; "Assay 2"}) "AssayIdentifiers" let s = i.Studies.Item 0 Expect.equal s.RegisteredAssayCount 2 "Registered AssayCount" let s2 = i.Studies.Item 1 @@ -652,8 +648,8 @@ let tests_Assay = testList "CRUD Assay" [ // Expect.equal actual.Contacts expected.Contacts "Contacts" // Expect.equal actual.Assays.Count 1 "Count 1" // Expect.equal expected.Assays.Count 1 "Count 2" -// TestingUtils.Expect.mySequenceEqual actual.Assays expected.Assays "Assays" -// TestingUtils.Expect.mySequenceEqual actual.Studies expected.Studies "Studies" +// TestingUtils.Expect.sequenceEqual actual.Assays expected.Assays "Assays" +// TestingUtils.Expect.sequenceEqual actual.Studies expected.Studies "Studies" // Expect.equal actual.RegisteredStudyIdentifiers expected.RegisteredStudyIdentifiers "RegisteredStudyIdentifiers" // Expect.equal actual.Comments expected.Comments "Comments" // Expect.equal actual.Remarks expected.Remarks "Remarks" diff --git a/tests/ISA/ISA.Tests/ArcJsonConversionTests.fs b/tests/ISA/ISA.Tests/ArcJsonConversionTests.fs index 1c2bdf3c..f257a39b 100644 --- a/tests/ISA/ISA.Tests/ArcJsonConversionTests.fs +++ b/tests/ISA/ISA.Tests/ArcJsonConversionTests.fs @@ -2,11 +2,6 @@ open ARCtrl.ISA -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif open TestingUtils module Helper = @@ -397,8 +392,8 @@ let private tests_arcAssay = Expect.equal resultingArcAssay.TechnologyPlatform arcAssay.TechnologyPlatform "ArcAssay technologyPlatform should match" let expectedTables = [t1;t2] - Expect.mySequenceEqual resultingArcAssay.Tables expectedTables "ArcAssay tables should match" - Expect.mySequenceEqual resultingArcAssay.Comments arcAssay.Comments "ArcAssay comments should match" + Expect.sequenceEqual resultingArcAssay.Tables expectedTables "ArcAssay tables should match" + Expect.sequenceEqual resultingArcAssay.Comments arcAssay.Comments "ArcAssay comments should match" ) ] @@ -522,7 +517,7 @@ let private tests_protocolTransformation = let t = ArcTable.init "TestTable" let expected = [Protocol.create(Name = "TestTable")] - TestingUtils.Expect.mySequenceEqual (t.GetProtocols()) expected "Protocol Name should be ArcTable name." + TestingUtils.Expect.sequenceEqual (t.GetProtocols()) expected "Protocol Name should be ArcTable name." ) testCase "GetProtocols SingleName" (fun () -> let t = ArcTable.init "TestTable" @@ -530,7 +525,7 @@ let private tests_protocolTransformation = t.AddProtocolNameColumn([|name|]) let expected = [Protocol.create(Name = name)] - TestingUtils.Expect.mySequenceEqual (t.GetProtocols()) expected "Protocols do not match" + TestingUtils.Expect.sequenceEqual (t.GetProtocols()) expected "Protocols do not match" ) testCase "GetProtocols SameNames" (fun () -> let t = ArcTable.init "TestTable" @@ -538,7 +533,7 @@ let private tests_protocolTransformation = t.AddProtocolNameColumn([|name;name|]) let expected = [Protocol.create(Name = name)] - TestingUtils.Expect.mySequenceEqual (t.GetProtocols()) expected "Protocols do not match" + TestingUtils.Expect.sequenceEqual (t.GetProtocols()) expected "Protocols do not match" ) testCase "GetProtocols DifferentNames" (fun () -> let t = ArcTable.init "TestTable" @@ -547,7 +542,7 @@ let private tests_protocolTransformation = t.AddProtocolNameColumn([|name1;name2|]) let expected = [Protocol.create(Name = name1);Protocol.create(Name = name2)] - TestingUtils.Expect.mySequenceEqual (t.GetProtocols()) expected "Protocols do not match" + TestingUtils.Expect.sequenceEqual (t.GetProtocols()) expected "Protocols do not match" ) //testCase "GetProtocols Parameters" (fun () -> // let t = ArcTable.init "TestTable" @@ -556,7 +551,7 @@ let private tests_protocolTransformation = // t.AddProtocolNameColumn([|name1;name2|]) // t.addpara([|pParam1;pParam1|]) // let expected = [Protocol.create(Name = name1;Parameters = [pParam1]);Protocol.create(Name = name2;Parameters = [pParam1])] - // TestingUtils.Expect.mySequenceEqual (t.GetProtocols()) expected "Protocols do not match" + // TestingUtils.Expect.sequenceEqual (t.GetProtocols()) expected "Protocols do not match" //) diff --git a/tests/ISA/ISA.Tests/ArcStudy.Tests.fs b/tests/ISA/ISA.Tests/ArcStudy.Tests.fs index 7e2b23c6..68244d13 100644 --- a/tests/ISA/ISA.Tests/ArcStudy.Tests.fs +++ b/tests/ISA/ISA.Tests/ArcStudy.Tests.fs @@ -2,11 +2,7 @@ open ARCtrl.ISA -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif +open TestingUtils let createExampleAssays() = ResizeArray([|ArcAssay.init("Assay 1")|]) @@ -379,11 +375,11 @@ let tests_UpdateBy = testList "UpdateReferenceByStudyFile" [ let expectedDescription = Array.create 2 (CompositeCell.createFreeText ArcTables.Tests.TestObjects.descriptionValue2) |> Array.append (Array.create 2 (CompositeCell.createFreeText ArcTables.Tests.TestObjects.descriptionValue1)) - TestingUtils.Expect.mySequenceEqual + TestingUtils.Expect.sequenceEqual (resultTable.GetColumnByHeader CompositeHeader.ProtocolDescription).Cells (expectedDescription) "Description value was not taken correctly" - TestingUtils.Expect.mySequenceEqual + TestingUtils.Expect.sequenceEqual (resultTable.GetColumnByHeader (CompositeHeader.Parameter ArcTables.Tests.TestObjects.oa_species)).Cells (Array.create 4 (CompositeCell.createTerm ArcTables.Tests.TestObjects.oa_chlamy)) "Check for previous param correctness" @@ -402,8 +398,8 @@ let tests_UpdateBy = testList "UpdateReferenceByStudyFile" [ Expect.equal actual.Publications expected.Publications "Publications" Expect.equal actual.Contacts expected.Contacts "Contacts" Expect.equal actual.StudyDesignDescriptors expected.StudyDesignDescriptors "StudyDesignDescriptors" - TestingUtils.Expect.mySequenceEqual actual.Tables expected.Tables "Tables" - TestingUtils.Expect.mySequenceEqual actual.RegisteredAssayIdentifiers expected.RegisteredAssayIdentifiers "RegisteredAssayIdentifiers" + TestingUtils.Expect.sequenceEqual actual.Tables expected.Tables "Tables" + TestingUtils.Expect.sequenceEqual actual.RegisteredAssayIdentifiers expected.RegisteredAssayIdentifiers "RegisteredAssayIdentifiers" Expect.equal actual.Factors expected.Factors "Factors" Expect.equal actual.Comments expected.Comments "Comments" testCase "replace existing, all replaced" <| fun _ -> @@ -433,8 +429,8 @@ let tests_UpdateBy = testList "UpdateReferenceByStudyFile" [ Expect.equal actual.Publications next.Publications "Publications" Expect.equal actual.Contacts next.Contacts "Contacts" Expect.equal actual.StudyDesignDescriptors next.StudyDesignDescriptors "StudyDesignDescriptors" - TestingUtils.Expect.mySequenceEqual actual.Tables next.Tables "Tables" - TestingUtils.Expect.mySequenceEqual actual.RegisteredAssayIdentifiers next.RegisteredAssayIdentifiers "RegisteredAssayIdentifiers" + TestingUtils.Expect.sequenceEqual actual.Tables next.Tables "Tables" + TestingUtils.Expect.sequenceEqual actual.RegisteredAssayIdentifiers next.RegisteredAssayIdentifiers "RegisteredAssayIdentifiers" Expect.equal actual.Factors next.Factors "Factors" Expect.equal actual.Comments next.Comments "Comments" testCase "full replace, empty" <| fun _ -> diff --git a/tests/ISA/ISA.Tests/ArcTable.Tests.fs b/tests/ISA/ISA.Tests/ArcTable.Tests.fs index a1d64722..48f4caff 100644 --- a/tests/ISA/ISA.Tests/ArcTable.Tests.fs +++ b/tests/ISA/ISA.Tests/ArcTable.Tests.fs @@ -2,11 +2,7 @@ open ARCtrl.ISA -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif +open TestingUtils let private TableName = "Test" let private oa_species = OntologyAnnotation.fromString("species", "GO", "GO:0123456") @@ -376,8 +372,8 @@ let private tests_UpdateHeader = Expect.equal table.Values.[3,4] (CompositeCell.createTerm oa_SCIEXInstrumentModel) "cell 3,4" Expect.equal table.Headers.[4] column_param.Header "header4" Expect.equal table.Values.[4,4] (CompositeCell.createUnitized (string 4,OntologyAnnotation.empty)) "cell 4,4" - TestingUtils.Expect.mySequenceEqual table.Headers table2.Headers "equal table headers" - TestingUtils.Expect.mySequenceEqual table.Values table2.Values "equal table values" + TestingUtils.Expect.sequenceEqual table.Headers table2.Headers "equal table headers" + TestingUtils.Expect.sequenceEqual table.Values table2.Values "equal table values" ) ] @@ -566,7 +562,7 @@ let private tests_AddColumn = let expected = let m = [ for rowIndex, cell in Array.indexed cells do yield (0, rowIndex), cell] |> Map.ofList System.Collections.Generic.Dictionary(m) - TestingUtils.Expect.mySequenceEqual table.Values expected "values" + TestingUtils.Expect.sequenceEqual table.Values expected "values" ) testCase "term column, with cells" (fun () -> let table = create_table() @@ -579,7 +575,7 @@ let private tests_AddColumn = let expected = let m = [ for rowIndex, cell in Array.indexed cells do yield (0, rowIndex), cell] |> Map.ofList System.Collections.Generic.Dictionary(m) - TestingUtils.Expect.mySequenceEqual table.Values expected "values" + TestingUtils.Expect.sequenceEqual table.Values expected "values" ) testCase "IO column, with wrong cells" (fun () -> let table = create_table() @@ -803,7 +799,7 @@ let private tests_addColumn = let expected = let m = [ for rowIndex, cell in Array.indexed cells do yield (0, rowIndex), cell] |> Map.ofList System.Collections.Generic.Dictionary(m) - TestingUtils.Expect.mySequenceEqual updatedTable.Values expected "values" + TestingUtils.Expect.sequenceEqual updatedTable.Values expected "values" ) testCase "term column, with cells" (fun () -> let table = create_table() @@ -819,7 +815,7 @@ let private tests_addColumn = let expected = let m = [ for rowIndex, cell in Array.indexed cells do yield (0, rowIndex), cell] |> Map.ofList System.Collections.Generic.Dictionary(m) - TestingUtils.Expect.mySequenceEqual updatedTable.Values expected "values" + TestingUtils.Expect.sequenceEqual updatedTable.Values expected "values" ) testCase "IO column, with cells at index" (fun () -> let table = create_table() @@ -1971,11 +1967,11 @@ let private tests_UpdateRefWithSheet = Expect.equal refTable.RowCount expectedRowCount "RowCount of reference table should be the same as value table after update" Expect.equal refTable.ColumnCount expectedColumnCount "ColumnCount of reference table should be the sum of value table and protocol table after update" - TestingUtils.Expect.mySequenceEqual + TestingUtils.Expect.sequenceEqual (refTable.GetProtocolDescriptionColumn().Cells) (Array.create 5 (CompositeCell.createFreeText protocolDescription)) "ProtocolDescriptionColumn should be filled with protocol description" - TestingUtils.Expect.mySequenceEqual + TestingUtils.Expect.sequenceEqual (refTable.GetColumnByHeader column_component.Header).Cells column_component.Cells "Component column should have been taken as is" @@ -2004,11 +2000,11 @@ let private tests_UpdateRefWithSheet = Expect.equal refTable.RowCount expectedRowCount "RowCount of reference table should be the same as value table after update" Expect.equal refTable.ColumnCount expectedColumnCount "ColumnCount of reference table should be the sum of value table and protocol table after update" - TestingUtils.Expect.mySequenceEqual + TestingUtils.Expect.sequenceEqual (refTable.GetProtocolDescriptionColumn().Cells) (Array.create 5 (CompositeCell.createFreeText newProtocolDescription)) "ProtocolDescriptionColumn should be filled with protocol description" - TestingUtils.Expect.mySequenceEqual + TestingUtils.Expect.sequenceEqual (refTable.GetColumnByHeader column_component.Header).Cells column_component.Cells "Component column should have been taken as is" diff --git a/tests/ISA/ISA.Tests/ArcTables.Tests.fs b/tests/ISA/ISA.Tests/ArcTables.Tests.fs index 3ecb074a..7c070eed 100644 --- a/tests/ISA/ISA.Tests/ArcTables.Tests.fs +++ b/tests/ISA/ISA.Tests/ArcTables.Tests.fs @@ -182,7 +182,7 @@ let updateReferenceWithSheet = Expect.equal resultTable.Name tableOfInterest.Name "Should be same table name" Expect.equal resultTable.ColumnCount (tableOfInterest.ColumnCount + 1) "Should be same number of columns" Expect.equal resultTable.RowCount tableOfInterest.RowCount "Should be same number of rows" - Expect.mySequenceEqual + Expect.sequenceEqual (resultTable.GetColumnByHeader CompositeHeader.ProtocolDescription).Cells (Array.create 2 (CompositeCell.createFreeText descriptionValue1)) "Description value was not taken correctly" @@ -198,7 +198,7 @@ let updateReferenceWithSheet = Expect.equal resultTable.Name tableOfInterest.Name "Should be same table name" Expect.equal resultTable.ColumnCount (tableOfInterest.ColumnCount + 2) "Should be same number of columns" Expect.equal resultTable.RowCount tableOfInterest.RowCount "Should be same number of rows" - Expect.mySequenceEqual + Expect.sequenceEqual (resultTable.GetColumnByHeader CompositeHeader.ProtocolDescription).Cells (Array.create 2 (CompositeCell.createFreeText descriptionValue1)) "Description value was not taken correctly" @@ -229,11 +229,11 @@ let updateReferenceWithSheet = Expect.equal resultTable1.Name tableOfInterest1.Name "Should be same table name" Expect.equal resultTable1.ColumnCount (tableOfInterest1.ColumnCount + 1) "Should be same number of columns" Expect.equal tableOfInterest1.RowCount tableOfInterest1.RowCount "Should be same number of rows" - Expect.mySequenceEqual + Expect.sequenceEqual (resultTable1.GetColumnByHeader CompositeHeader.ProtocolDescription).Cells (Array.create 2 (CompositeCell.createFreeText descriptionValue1)) "Description value was not taken correctly" - Expect.mySequenceEqual + Expect.sequenceEqual (resultTable1.GetColumnByHeader (CompositeHeader.Parameter oa_species)).Cells (Array.create 2 (CompositeCell.createTerm oa_chlamy)) "Check for previous param correctness" @@ -242,11 +242,11 @@ let updateReferenceWithSheet = Expect.equal resultTable2.Name tableOfInterest2.Name "Should be same table name" Expect.equal resultTable2.ColumnCount (tableOfInterest2.ColumnCount + 1) "Should be same number of columns" Expect.equal tableOfInterest2.RowCount tableOfInterest2.RowCount "Should be same number of rows" - Expect.mySequenceEqual + Expect.sequenceEqual (resultTable2.GetProtocolDescriptionColumn()).Cells (Array.create 3 (CompositeCell.createFreeText descriptionValue1)) "Description value was not taken correctly" - Expect.mySequenceEqual + Expect.sequenceEqual (resultTable2.GetColumnByHeader (CompositeHeader.Factor oa_instrumentModel)).Cells (Array.create 3 (CompositeCell.createTerm oa_SCIEXInstrumentModel)) "Check for previous param correctness" @@ -267,11 +267,11 @@ let updateReferenceWithSheet = let expectedDescription = Array.create 2 (CompositeCell.emptyFreeText) |> Array.append (Array.create 2 (CompositeCell.createFreeText descriptionValue1)) - Expect.mySequenceEqual + Expect.sequenceEqual (resultTable.GetColumnByHeader CompositeHeader.ProtocolDescription).Cells (expectedDescription) "Description value was not taken correctly" - Expect.mySequenceEqual + Expect.sequenceEqual (resultTable.GetColumnByHeader (CompositeHeader.Parameter oa_species)).Cells (Array.create 4 (CompositeCell.createTerm oa_chlamy)) "Check for previous param correctness" @@ -292,11 +292,11 @@ let updateReferenceWithSheet = let expectedDescription = Array.create 2 (CompositeCell.createFreeText descriptionValue2) |> Array.append (Array.create 2 (CompositeCell.createFreeText descriptionValue1)) - Expect.mySequenceEqual + Expect.sequenceEqual (resultTable.GetColumnByHeader CompositeHeader.ProtocolDescription).Cells (expectedDescription) "Description value was not taken correctly" - Expect.mySequenceEqual + Expect.sequenceEqual (resultTable.GetColumnByHeader (CompositeHeader.Parameter oa_species)).Cells (Array.create 4 (CompositeCell.createTerm oa_chlamy)) "Check for previous param correctness" diff --git a/tests/ISA/ISA.Tests/CompositeCell.Tests.fs b/tests/ISA/ISA.Tests/CompositeCell.Tests.fs index 1c570974..2b08a8d3 100644 --- a/tests/ISA/ISA.Tests/CompositeCell.Tests.fs +++ b/tests/ISA/ISA.Tests/CompositeCell.Tests.fs @@ -2,11 +2,7 @@ open ARCtrl.ISA -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif +open TestingUtils let private tests_cellConverter = testList "CellConverter" [ diff --git a/tests/ISA/ISA.Tests/CompositeColumn.Tests.fs b/tests/ISA/ISA.Tests/CompositeColumn.Tests.fs index 5ea1a1e9..ba327961 100644 --- a/tests/ISA/ISA.Tests/CompositeColumn.Tests.fs +++ b/tests/ISA/ISA.Tests/CompositeColumn.Tests.fs @@ -2,11 +2,7 @@ open ARCtrl.ISA -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif +open TestingUtils let private tests_validate = testList "validate" [ diff --git a/tests/ISA/ISA.Tests/CompositeHeader.Tests.fs b/tests/ISA/ISA.Tests/CompositeHeader.Tests.fs index 6b25f871..99eedd5d 100644 --- a/tests/ISA/ISA.Tests/CompositeHeader.Tests.fs +++ b/tests/ISA/ISA.Tests/CompositeHeader.Tests.fs @@ -2,11 +2,7 @@ open ARCtrl.ISA -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif +open TestingUtils let tests_iotype = testList "IOType" [ diff --git a/tests/ISA/ISA.Tests/DataModel.Tests.fs b/tests/ISA/ISA.Tests/DataModel.Tests.fs index a0811a1f..65cf01c3 100644 --- a/tests/ISA/ISA.Tests/DataModel.Tests.fs +++ b/tests/ISA/ISA.Tests/DataModel.Tests.fs @@ -1,10 +1,6 @@ module DataModel.Tests -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif +open TestingUtils open ARCtrl.ISA diff --git a/tests/ISA/ISA.Tests/Fable.Tests.fs b/tests/ISA/ISA.Tests/Fable.Tests.fs index ae9ef457..cd2f9f64 100644 --- a/tests/ISA/ISA.Tests/Fable.Tests.fs +++ b/tests/ISA/ISA.Tests/Fable.Tests.fs @@ -2,11 +2,7 @@ open ARCtrl.ISA -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif +open TestingUtils let private tests_EmptyObjectCreation = testList "EmptyObjectCreationTests" [ diff --git a/tests/ISA/ISA.Tests/Identifier.Tests.fs b/tests/ISA/ISA.Tests/Identifier.Tests.fs index 86a3b774..0821d922 100644 --- a/tests/ISA/ISA.Tests/Identifier.Tests.fs +++ b/tests/ISA/ISA.Tests/Identifier.Tests.fs @@ -2,11 +2,7 @@ open ARCtrl.ISA -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif +open TestingUtils open ARCtrl.ISA.Identifier diff --git a/tests/ISA/ISA.Tests/Person.Tests.fs b/tests/ISA/ISA.Tests/Person.Tests.fs index 4275cbaf..55d45c0a 100644 --- a/tests/ISA/ISA.Tests/Person.Tests.fs +++ b/tests/ISA/ISA.Tests/Person.Tests.fs @@ -2,11 +2,7 @@ open ARCtrl.ISA -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif +open TestingUtils let private createTestPerson() = Person.create(FirstName="Kevin", LastName="Frey",Email="MyAwesomeMail@Awesome.mail") diff --git a/tests/ISA/ISA.Tests/Regex.Tests.fs b/tests/ISA/ISA.Tests/Regex.Tests.fs index 00a5cf96..63529ddc 100644 --- a/tests/ISA/ISA.Tests/Regex.Tests.fs +++ b/tests/ISA/ISA.Tests/Regex.Tests.fs @@ -2,11 +2,7 @@ open ARCtrl.ISA -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif +open TestingUtils let private tests_AutoGeneratedTableName = testList "AutoGeneratedTableName" [ diff --git a/tests/ISA/ISA.Tests/Update.Tests.fs b/tests/ISA/ISA.Tests/Update.Tests.fs index 7545a2d2..c5e7effc 100644 --- a/tests/ISA/ISA.Tests/Update.Tests.fs +++ b/tests/ISA/ISA.Tests/Update.Tests.fs @@ -1,10 +1,6 @@ module Update.Tests -#if FABLE_COMPILER -open Fable.Mocha -#else -open Expecto -#endif +open TestingUtils open ARCtrl.ISA.Aux open Update @@ -351,8 +347,8 @@ let updateTests = let update = UpdateAllAppendLists.updateRecordType eOld eNew // new IntList is empty and should not update - TestingUtils.Expect.mySequenceEqual update.IntList (List.append eOld.IntList eNew.IntList) "ListType UpdateAllAppendLists; failed by not correctly appending IntList" - TestingUtils.Expect.mySequenceEqual update.StringList (List.append eOld.StringList eNew.StringList) "ListType UpdateAllAppendLists; failed by not correctly appending StringList" + TestingUtils.Expect.sequenceEqual update.IntList (List.append eOld.IntList eNew.IntList) "ListType UpdateAllAppendLists; failed by not correctly appending IntList" + TestingUtils.Expect.sequenceEqual update.StringList (List.append eOld.StringList eNew.StringList) "ListType UpdateAllAppendLists; failed by not correctly appending StringList" ) testCase "ArrayType UpdateByExisting" (fun () -> @@ -385,8 +381,8 @@ let updateTests = let update = UpdateAllAppendLists.updateRecordType eOld eNew // new IntList is empty and should not update - TestingUtils.Expect.mySequenceEqual update.FloatArray (Array.append eOld.FloatArray eNew.FloatArray) "ArrayType UpdateAllAppendLists; failed by not correctly appending IntList" - TestingUtils.Expect.mySequenceEqual update.StringArray (Array.append eOld.StringArray eNew.StringArray) "ArrayType UpdateAllAppendLists; failed by not correctly appending StringList" + TestingUtils.Expect.sequenceEqual update.FloatArray (Array.append eOld.FloatArray eNew.FloatArray) "ArrayType UpdateAllAppendLists; failed by not correctly appending IntList" + TestingUtils.Expect.sequenceEqual update.StringArray (Array.append eOld.StringArray eNew.StringArray) "ArrayType UpdateAllAppendLists; failed by not correctly appending StringList" ) testCase "SeqType UpdateByExisting" (fun () -> @@ -419,8 +415,8 @@ let updateTests = let update = UpdateAllAppendLists.updateRecordType eOld eNew // Here the values are passed hard coded as Expect seems to interact strangely when comparing seqs. - TestingUtils.Expect.mySequenceEqual update.StringSeq (Seq.append eOld.StringSeq eNew.StringSeq) "ArrayType UpdateAllAppendLists; failed by not correctly appending list1" - TestingUtils.Expect.mySequenceEqual update.StringOptSeq (Seq.append eOld.StringOptSeq eNew.StringOptSeq) "ArrayType UpdateAllAppendLists; failed by not correctly appending list2" + TestingUtils.Expect.sequenceEqual update.StringSeq (Seq.append eOld.StringSeq eNew.StringSeq) "ArrayType UpdateAllAppendLists; failed by not correctly appending list1" + TestingUtils.Expect.sequenceEqual update.StringOptSeq (Seq.append eOld.StringOptSeq eNew.StringOptSeq) "ArrayType UpdateAllAppendLists; failed by not correctly appending list2" ) testCase "SeqType UpdateByExistingAppendLists" (fun () -> @@ -436,8 +432,8 @@ let updateTests = let update = UpdateByExistingAppendLists.updateRecordType eOld eNew // Here the values are passed hard coded as Expect seems to interact strangely when comparing seqs. - TestingUtils.Expect.mySequenceEqual update.StringSeq (Seq.append eOld.StringSeq eNew.StringSeq) "ArrayType UpdateAllAppendLists; failed by not correctly appending list1" - TestingUtils.Expect.mySequenceEqual update.StringOptSeq (Seq.append eOld.StringOptSeq eNew.StringOptSeq) "ArrayType UpdateAllAppendLists; failed by not correctly appending list2" + TestingUtils.Expect.sequenceEqual update.StringSeq (Seq.append eOld.StringSeq eNew.StringSeq) "ArrayType UpdateAllAppendLists; failed by not correctly appending list1" + TestingUtils.Expect.sequenceEqual update.StringOptSeq (Seq.append eOld.StringOptSeq eNew.StringOptSeq) "ArrayType UpdateAllAppendLists; failed by not correctly appending list2" ) testCase "RecordTypeType UpdateByExisting" (fun () -> @@ -584,7 +580,7 @@ let updateTests = let appendedList = List.append eOld.OptionalList.Value eNew.OptionalList.Value // map types will never be checked if they are empty or not, so they will always be replaced - TestingUtils.Expect.mySequenceEqual update.OptionalList.Value appendedList "Optional Lists were not appended correctly" + TestingUtils.Expect.sequenceEqual update.OptionalList.Value appendedList "Optional Lists were not appended correctly" ) testCase "OptionalListType UpdateAllAppendListsEmpty" (fun () -> @@ -615,7 +611,7 @@ let updateTests = let appendedList = List.append eOld.OptionalList.Value eNew.OptionalList.Value // map types will never be checked if they are empty or not, so they will always be replaced - TestingUtils.Expect.mySequenceEqual update.OptionalList.Value appendedList "Optional Lists were not appended correctly" + TestingUtils.Expect.sequenceEqual update.OptionalList.Value appendedList "Optional Lists were not appended correctly" ) testCase "OptionalListType UpdateByExistingAppendListsEmpty" (fun () -> diff --git a/tests/ISA/ISA.Tests/paket.references b/tests/ISA/ISA.Tests/paket.references index 2561dfaa..47cc4278 100644 --- a/tests/ISA/ISA.Tests/paket.references +++ b/tests/ISA/ISA.Tests/paket.references @@ -1,6 +1,3 @@ FSharp.Core -Fable.Core -Expecto -Fable.Mocha Microsoft.NET.Test.Sdk YoloDev.Expecto.TestSdk \ No newline at end of file diff --git a/tests/TestingUtils/Library.fs b/tests/TestingUtils/Library.fs index 97bd5757..80e1110a 100644 --- a/tests/TestingUtils/Library.fs +++ b/tests/TestingUtils/Library.fs @@ -45,10 +45,41 @@ module Result = | Ok m -> m | Error m -> m + + +/// Fable compatible Expecto/Mocha unification module Expect = open Utils + + let inline equal actual expected message = Expect.equal actual expected message + let inline notEqual actual expected message = Expect.notEqual actual expected message + + let inline isNull actual message = Expect.isNull actual message + let inline isNotNull actual message = Expect.isNotNull actual message + + let inline isSome actual message = Expect.isSome actual message + let inline isNone actual message = Expect.isNone actual message + let inline wantSome actual message = Expect.wantSome actual message + + let inline isEmpty actual message = Expect.isEmpty actual message + let inline hasLength actual expectedLength message = Expect.hasLength actual expectedLength message + + let inline isTrue actual message = Expect.isTrue actual message + let inline isFalse actual message = Expect.isFalse actual message + + let inline wantError actual message = Expect.wantError actual message + let inline wantOk actual message = Expect.wantOk actual message + let inline isOk actual message = Expect.isOk actual message + let inline isError actual message = Expect.isError actual message + + let inline throws actual message = Expect.throws actual message + let inline throwsC actual message = Expect.throwsC actual message + + let inline exists actual asserter message = Expect.exists actual asserter message + let inline containsAll actual expected message = Expect.containsAll actual expected message + /// Expects the `actual` sequence to equal the `expected` one. - let inline mySequenceEqual actual expected message = + let inline sequenceEqual actual expected message = match firstDiff actual expected with | _,None,None -> () | i,Some a, Some e -> @@ -69,20 +100,20 @@ module Expect = |> Seq.map (fun r -> r.Cells |> Seq.map (fun c -> c.Value) |> Seq.reduce (fun a b -> a + b)) if actual.Name <> expected.Name then failwithf $"{message}. Worksheet names do not match. Expected {expected.Name} but got {actual.Name}" - mySequenceEqual (f actual) (f expected) $"{message}. Worksheet does not match" + sequenceEqual (f actual) (f expected) $"{message}. Worksheet does not match" let columnsEqual (actual : FsCell seq seq) (expected : FsCell seq seq) message = let f (cols : FsCell seq seq) = cols |> Seq.map (fun r -> r |> Seq.map (fun c -> c.Value) |> Seq.reduce (fun a b -> a + b)) - mySequenceEqual (f actual) (f expected) $"{message}. Columns do not match" + sequenceEqual (f actual) (f expected) $"{message}. Columns do not match" let arcTableEqual (t1 : ArcTable) (t2 : ArcTable) (message : string) = let sortVals (dict : System.Collections.Generic.Dictionary) = dict |> Seq.sortBy (fun kv -> kv.Key) Expect.equal t1.Name t2.Name (sprintf "%s: Name" message) - mySequenceEqual t1.Headers t2.Headers (sprintf "%s: Headers" message) - mySequenceEqual (t1.Values |> sortVals) (t2.Values |> sortVals) (sprintf "%s: Values" message) + sequenceEqual t1.Headers t2.Headers (sprintf "%s: Headers" message) + sequenceEqual (t1.Values |> sortVals) (t2.Values |> sortVals) (sprintf "%s: Values" message) let rec testFileSystemTree (actual:FileSystemTree) (expected:FileSystemTree) = match actual, expected with @@ -97,4 +128,22 @@ module Expect = {anyActual} Expected: - {anyExpected}" \ No newline at end of file + {anyExpected}" + +/// Fable compatible Expecto/Mocha unification +[] +module Test = + + let test = test + let testAsync = testAsync + let testSequenced = testSequenced + + let testCase = testCase + let ptestCase = ptestCase + let ftestCase = ftestCase + let testCaseAsync = testCaseAsync + let ptestCaseAsync = ptestCaseAsync + let ftestCaseAsync = ftestCaseAsync + + + let testList = testList