Skip to content

Commit

Permalink
restructure testing environment
Browse files Browse the repository at this point in the history
  • Loading branch information
HLWeil committed Sep 20, 2023
1 parent 104282e commit 91b3f01
Show file tree
Hide file tree
Showing 46 changed files with 480 additions and 537 deletions.
7 changes: 7 additions & 0 deletions ARCtrl.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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}
Expand Down
27 changes: 14 additions & 13 deletions tests/ARCtrl/ARCtrl.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _ ->
Expand Down Expand Up @@ -53,27 +54,27 @@ 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"

Expect.equal study1.RegisteredAssayCount 3 "study 1 should have read three assays"
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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down
7 changes: 1 addition & 6 deletions tests/ARCtrl/ARCtrl.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,16 @@
<GenerateProgramFile>false</GenerateProgramFile>
</PropertyGroup>
<ItemGroup>
<Compile Include="Utils.fs" />
<Compile Include="ArcTable.fs" />
<Compile Include="Assay.fs" />
<Compile Include="Study.fs" />
<Compile Include="InvestigationFile.fs" />
<Compile Include="Templates.Tests.fs" />
<Compile Include="SemVer.Tests.fs" />
<Compile Include="TestObjects/ISAContracts.fs" />
<None Include="paket.references" />
<Compile Include="ARCtrl.Contracts.Tests.fs" />
<Compile Include="ARCtrl.Tests.fs" />
<Compile Include="Main.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\ARCtrl\ARCtrl.fsproj" />
<ProjectReference Include="..\TestingUtils\TestingUtils.fsproj" />
</ItemGroup>
<Import Project="..\..\.paket\Paket.Restore.targets" />
</Project>
5 changes: 3 additions & 2 deletions tests/ARCtrl/Templates.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tests/FileSystem/FileSystem.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
</PropertyGroup>
<ItemGroup>
<None Include="paket.references" />
<Compile Include="Utils.fs" />
<Compile Include="FileSystemTree.Tests.fs" />
<Compile Include="Main.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\FileSystem\ARCtrl.FileSystem.fsproj" />
<ProjectReference Include="..\TestingUtils\TestingUtils.fsproj" />
</ItemGroup>
<Import Project="..\..\.paket\Paket.Restore.targets" />
</Project>
9 changes: 5 additions & 4 deletions tests/FileSystem/FileSystemTree.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ open Expecto
#endif

open ARCtrl.FileSystem
open TestingUtils

let private newArcRelativePaths = [|
@"isa.investigation.xlsx"; @".arc\.gitkeep"; @".git\config";
Expand Down Expand Up @@ -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"
]

Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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" [
Expand Down
48 changes: 0 additions & 48 deletions tests/FileSystem/Utils.fs

This file was deleted.

11 changes: 1 addition & 10 deletions tests/ISA/ISA.Json.Tests/ISA.Json.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,13 @@
</PropertyGroup>
<ItemGroup>
<None Include="paket.references" />
<Compile Include="TestObjects\OntologyAnnotation.fs" />
<Compile Include="TestObjects\ProcessInput.fs" />
<Compile Include="TestObjects\Validation.fs" />
<Compile Include="TestObjects\Protocol.fs" />
<Compile Include="TestObjects\Investigation.fs" />
<Compile Include="TestObjects\Assay.fs" />
<Compile Include="TestObjects\Person.fs" />
<Compile Include="TestObjects\Process.fs" />
<Compile Include="TestObjects\Publication.fs" />
<Compile Include="Utils.fs" />
<Compile Include="JsonSchema.Tests.fs" />
<Compile Include="Json.Tests.fs" />
<Compile Include="Main.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\ISA\ISA.Json\ARCtrl.ISA.Json.fsproj" />
<ProjectReference Include="..\..\TestingUtils\TestingUtils.fsproj" />
</ItemGroup>
<Import Project="..\..\..\.paket\Paket.Restore.targets" />
</Project>
Loading

0 comments on commit 91b3f01

Please sign in to comment.