diff --git a/playground.fsx b/playground.fsx index ea6f5c6..6fe2f92 100644 --- a/playground.fsx +++ b/playground.fsx @@ -8,7 +8,8 @@ //File.Copy(@"C:\Repos\nfdi4plants\ArcGraphModel\src\ArcGraphModel\bin\Debug\net6.0\ArcGraphModel.dll", @"C:\Repos\nfdi4plants\ArcGraphModel\src\ArcGraphModel\bin\Debug\net6.0\ArcGraphModel_Copy.dll", true) #r "nuget: FSharpAux" -#r "nuget: FsOboParser" +//#r "nuget: FsOboParser" +#r "nuget: OBO.NET" #r "nuget: FsSpreadsheet.ExcelIO, 4.1.0" #r "nuget: FSharp.FGL.ArrayAdjacencyGraph" @@ -37,13 +38,20 @@ open System.Collections.Generic open FsSpreadsheet open FsSpreadsheet.ExcelIO -open FsOboParser +//open FsOboParser +open OBO.NET //open FsSpreadsheet.DSL open ControlledVocabulary open type ControlledVocabulary.ParamBase open ARCTokenization open ARCTokenization.StructuralOntology + +let ot = List.head Terms.InvestigationMetadata.ontology.Terms + +ARCTokenization.StructuralOntology.CodeGeneration.toCodeString ot +CodeGeneration.toSourceCode "Investigation" Terms.InvestigationMetadata.ontology + System.IO.Directory.GetCurrentDirectory() let fakePath = CvParam(cvTerm = AFSO.``File Path``, v = System.IO.Directory.GetCurrentDirectory() + "/tests/ARCTokenization.Tests/Fixtures/correct/investigation_simple.xlsx") diff --git a/tests/ARCTokenization.Tests/ARCTokenization.Tests.fsproj b/tests/ARCTokenization.Tests/ARCTokenization.Tests.fsproj index bd72fdb..8a70bcf 100644 --- a/tests/ARCTokenization.Tests/ARCTokenization.Tests.fsproj +++ b/tests/ARCTokenization.Tests/ARCTokenization.Tests.fsproj @@ -12,6 +12,7 @@ + diff --git a/tests/ARCTokenization.Tests/CodeGenerationTests.fs b/tests/ARCTokenization.Tests/CodeGenerationTests.fs new file mode 100644 index 0000000..97c1b0b --- /dev/null +++ b/tests/ARCTokenization.Tests/CodeGenerationTests.fs @@ -0,0 +1,51 @@ +namespace CodeGenerationTests + +open OBO.NET +open ARCTokenization +open ARCTokenization.Terms +open Xunit +open ARCTokenization.StructuralOntology +open FSharpAux +open type System.Environment + +open TestUtils + + +module toUnderscoredName = + + [] + let ``returns correct underscored name`` () = + let expected = "Investigation_Metadata" + let actual = List.head InvestigationMetadata.ontology.Terms |> CodeGeneration.toUnderscoredName + Assert.Equal(expected, actual) + + +module toTermSourceRef = + + [] + let ``returns correct TermSourceRef`` () = + let expected = "INVMSO" + let actual = List.head InvestigationMetadata.ontology.Terms |> CodeGeneration.toTermSourceRef + Assert.Equal(expected, actual) + + +module toCodeString = + + [] + let ``returns correct F# code`` () = + let expected = $" let Investigation_Metadata = CvTerm.create(\"INVMSO:00000001\", \"Investigation Metadata\", \"INVMSO\"){NewLine}{NewLine}" + let actual = List.head InvestigationMetadata.ontology.Terms |> CodeGeneration.toCodeString + Assert.Equal(expected, actual) + + +module toSourceCode = + + [] + let ``returns correct source code`` () = + let expected = $"namespace ARCTokenization.StructuralOntology{NewLine}{NewLine} open ControlledVocabulary{NewLine}{NewLine} module Investigation ={NewLine}{NewLine} let Investigation_Metadata = CvTerm.create(\"INVMSO:00000001\", \"Investigation Metadata\", \"INVMSO\"){NewLine}{NewLine} let ONTOLOGY_SOURCE_REFERENCE = CvTerm.create(\"INVMSO:00000002\", \"ONTOLOGY SOURCE REFERENCE\", \"INVMSO\"){NewLine}{NewLine} let Term_Source_Name = CvTerm.create(\"INVMSO:00000003\", \"Term Source Name\", \"INVMSO\")" + let actual = + CodeGeneration.toSourceCode "Investigation" InvestigationMetadata.ontology + |> String.splitS NewLine + |> Array.take 11 + |> String.concat NewLine + Assert.Equal(expected, actual) \ No newline at end of file