Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure testing environment #194

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 1 addition & 5 deletions tests/ARCtrl/ARCtrl.Contracts.Tests.fs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
32 changes: 14 additions & 18 deletions tests/ARCtrl/ARCtrl.Tests.fs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
module ARCtrl.Tests

#if FABLE_COMPILER
open Fable.Mocha
#else
open Expecto
#endif

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 +49,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 +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"
TestingUtils.mySequenceEqual
Expect.sequenceEqual
(studyTable.GetProtocolDescriptionColumn()).Cells
[CompositeCell.createFreeText UpdateAssayWithStudyProtocol.description]
"Description value was not kept correctly"
TestingUtils.mySequenceEqual
Expect.sequenceEqual
(studyTable.GetProtocolNameColumn()).Cells
[CompositeCell.createFreeText UpdateAssayWithStudyProtocol.protocolName]
"Protocol ref value was not kept correctly"
Expand All @@ -109,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"
TestingUtils.mySequenceEqual
Expect.sequenceEqual
(assayTable.GetProtocolNameColumn()).Cells
(Array.create 2 (CompositeCell.createFreeText UpdateAssayWithStudyProtocol.protocolName))
"Protocol ref value was not kept correctly"
TestingUtils.mySequenceEqual
Expect.sequenceEqual
(assayTable.GetColumnByHeader(UpdateAssayWithStudyProtocol.inputHeader)).Cells
(Array.create 2 UpdateAssayWithStudyProtocol.inputCell)
"Protocol ref value was not kept correctly"
TestingUtils.mySequenceEqual
Expect.sequenceEqual
(assayTable.GetProtocolDescriptionColumn()).Cells
(Array.create 2 (CompositeCell.createFreeText UpdateAssayWithStudyProtocol.description))
"Description value was not taken correctly"
Expand Down
9 changes: 2 additions & 7 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" />
<None Include="paket.references" />
<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>
6 changes: 1 addition & 5 deletions tests/ARCtrl/SemVer.Tests.fs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
module ARCtrl.SemVer.Tests

#if FABLE_COMPILER
open Fable.Mocha
#else
open Expecto
#endif
open TestingUtils

open ARCtrl

Expand Down
9 changes: 3 additions & 6 deletions tests/ARCtrl/Templates.Tests.fs
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
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) =
str.Replace("\r\n","\n").Replace("\n\r","\n")
Expand Down Expand Up @@ -143,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"
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.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"
Expand Down
3 changes: 0 additions & 3 deletions tests/ARCtrl/paket.references
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
FSharp.Core
Fable.Core
Expecto
Fable.Mocha
Microsoft.NET.Test.Sdk
YoloDev.Expecto.TestSdk
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>
15 changes: 6 additions & 9 deletions tests/FileSystem/FileSystemTree.Tests.fs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
module ARCtrl.FileSystemTree.Tests

#if FABLE_COMPILER
open Fable.Mocha
#else
open Expecto
#endif
open TestingUtils

open ARCtrl.FileSystem
open TestingUtils

let private newArcRelativePaths = [|
@"isa.investigation.xlsx"; @".arc\.gitkeep"; @".git\config";
Expand Down Expand Up @@ -97,7 +94,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 +370,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 +425,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 +481,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.

3 changes: 0 additions & 3 deletions tests/FileSystem/paket.references
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
FSharp.Core
Fable.Core
Expecto
Fable.Mocha
Microsoft.NET.Test.Sdk
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not remove these two dependencies?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise they don't appear in the test explorer in vs

YoloDev.Expecto.TestSdk
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