From 60809125569ed9acc427cded73ad5e561107e347 Mon Sep 17 00:00:00 2001 From: HLWeil Date: Mon, 17 Jun 2024 16:30:52 +0200 Subject: [PATCH] add json column representation --- src/FsSpreadsheet.Js/FsExtensions.fs | 22 ++++-- src/FsSpreadsheet.Js/Json.fs | 27 +++++-- src/FsSpreadsheet.Net/FsExtensions.fs | 85 ++++++++++++++++----- src/FsSpreadsheet.Py/FsExtension.fs | 22 ++++-- src/FsSpreadsheet.Py/Json.fs | 25 ++++-- src/FsSpreadsheet/FsSpreadsheet.fsproj | 5 +- src/FsSpreadsheet/Json/Cell.fs | 21 ++++- src/FsSpreadsheet/Json/Column.fs | 23 ++++++ src/FsSpreadsheet/Json/Row.fs | 4 +- src/FsSpreadsheet/Json/Workbook.fs | 23 ++++-- src/FsSpreadsheet/Json/Worksheet.fs | 44 ++++++++++- tests/FsSpreadsheet.Js.Tests/Json.Tests.fs | 25 ++++-- tests/FsSpreadsheet.Net.Tests/Json.Tests.fs | 24 ++++-- tests/FsSpreadsheet.Py.Tests/Json.Tests.fs | 25 ++++-- 14 files changed, 296 insertions(+), 79 deletions(-) create mode 100644 src/FsSpreadsheet/Json/Column.fs diff --git a/src/FsSpreadsheet.Js/FsExtensions.fs b/src/FsSpreadsheet.Js/FsExtensions.fs index 41dadc7..9702b28 100644 --- a/src/FsSpreadsheet.Js/FsExtensions.fs +++ b/src/FsSpreadsheet.Js/FsExtensions.fs @@ -40,11 +40,11 @@ type FsWorkbook with - static member fromJsonString (json:string) : FsWorkbook = - Json.fromJsonString json + static member fromRowsJsonString (json:string) : FsWorkbook = + Json.fromRowsJsonString json - static member toJsonString (wb:FsWorkbook) : string = - Json.toJsonString wb + static member toRowsJsonString (wb:FsWorkbook) : string = + Json.toRowsJsonString wb //static member fromJsonFile (path:string) : Promise = // Json.fromJsonFile path @@ -55,5 +55,15 @@ type FsWorkbook with //member this.ToJsonFile(path: string) : Promise = // FsWorkbook.toJsonFile path this - member this.ToJsonString() : string = - FsWorkbook.toJsonString this \ No newline at end of file + member this.ToRowsJsonString() : string = + FsWorkbook.toRowsJsonString this + + + static member fromColumnsJsonString (json:string) : FsWorkbook = + Json.fromColumnsJsonString json + + static member toColumnsJsonString (wb:FsWorkbook) : string = + Json.toColumnsJsonString wb + + member this.ToColumnsJsonString() : string = + FsWorkbook.toColumnsJsonString this \ No newline at end of file diff --git a/src/FsSpreadsheet.Js/Json.fs b/src/FsSpreadsheet.Js/Json.fs index 3869db0..dd1efff 100644 --- a/src/FsSpreadsheet.Js/Json.fs +++ b/src/FsSpreadsheet.Js/Json.fs @@ -16,19 +16,34 @@ open Thoth.Json.JavaScript [] type Json = - static member tryFromJsonString (json:string) : Result = - match Thoth.Json.JavaScript.Decode.fromString FsSpreadsheet.Json.Workbook.decode json with + static member tryFromRowsJsonString (json:string) : Result = + match Thoth.Json.JavaScript.Decode.fromString FsSpreadsheet.Json.Workbook.decodeRows json with | Ok wb -> Ok wb | Error e -> Error e - static member fromJsonString (json:string) : FsWorkbook = - match Json.tryFromJsonString json with + static member fromRowsJsonString (json:string) : FsWorkbook = + match Json.tryFromRowsJsonString json with | Ok wb -> wb | Error e -> failwithf "Could not deserialize json Workbook: \n%s" e - static member toJsonString (wb:FsWorkbook, ?spaces) : string = + static member toRowsJsonString (wb:FsWorkbook, ?spaces) : string = let spaces = defaultArg spaces 2 - FsSpreadsheet.Json.Workbook.encode wb + FsSpreadsheet.Json.Workbook.encodeRows wb + |> Thoth.Json.JavaScript.Encode.toString spaces + + static member tryFromColumnsJsonString (json:string) : Result = + match Thoth.Json.JavaScript.Decode.fromString FsSpreadsheet.Json.Workbook.decodeColumns json with + | Ok wb -> Ok wb + | Error e -> Error e + + static member fromColumnsJsonString (json:string) : FsWorkbook = + match Json.tryFromColumnsJsonString json with + | Ok wb -> wb + | Error e -> failwithf "Could not deserialize json Workbook: \n%s" e + + static member toColumnsJsonString (wb:FsWorkbook, ?spaces) : string = + let spaces = defaultArg spaces 2 + FsSpreadsheet.Json.Workbook.encodeColumns wb |> Thoth.Json.JavaScript.Encode.toString spaces //static member fromJsonFile (path:string) : Promise = diff --git a/src/FsSpreadsheet.Net/FsExtensions.fs b/src/FsSpreadsheet.Net/FsExtensions.fs index 7558ebf..6451cf4 100644 --- a/src/FsSpreadsheet.Net/FsExtensions.fs +++ b/src/FsSpreadsheet.Net/FsExtensions.fs @@ -330,30 +330,59 @@ module FsExtensions = /// /// Takes a json string and returns the FsWorkbook based on its content. /// - static member tryFromJsonString (json : string) = - Thoth.Json.Newtonsoft.Decode.fromString FsSpreadsheet.Json.Workbook.decode json + static member tryFromRowsJsonString (json : string) = + Thoth.Json.Newtonsoft.Decode.fromString FsSpreadsheet.Json.Workbook.decodeRows json /// /// Takes a json string and returns the FsWorkbook based on its content. /// - static member fromJsonString (json : string) = - match FsWorkbook.tryFromJsonString json with + static member fromRowsJsonString (json : string) = + match FsWorkbook.tryFromRowsJsonString json with | Ok wb -> wb | Error e -> failwithf "Could not deserialize json Workbook: \n%s" e /// /// Takes the path to an json file and returns the FsWorkbook based on its content. /// - static member tryFromJsonFile (filePath : string) = + static member tryFromRowsJsonFile (filePath : string) = let json = File.ReadAllText filePath - FsWorkbook.tryFromJsonString json + FsWorkbook.tryFromRowsJsonString json /// /// Takes the path to an json file and returns the FsWorkbook based on its content. /// - static member fromJsonFile (filePath : string) = + static member fromRowsJsonFile (filePath : string) = let json = File.ReadAllText filePath - FsWorkbook.fromJsonString json + FsWorkbook.fromRowsJsonString json + + /// + /// Takes a json string and returns the FsWorkbook based on its content. + /// + static member tryFromColumnsJsonString (json : string) = + Thoth.Json.Newtonsoft.Decode.fromString FsSpreadsheet.Json.Workbook.decodeColumns json + + /// + /// Takes a json string and returns the FsWorkbook based on its content. + /// + static member fromColumnsJsonString (json : string) = + match FsWorkbook.tryFromColumnsJsonString json with + | Ok wb -> wb + | Error e -> failwithf "Could not deserialize json Workbook: \n%s" e + + /// + /// Takes the path to an json file and returns the FsWorkbook based on its content. + /// + static member tryFromColumnsJsonFile (filePath : string) = + let json = File.ReadAllText filePath + FsWorkbook.tryFromColumnsJsonString json + + /// + /// Takes the path to an json file and returns the FsWorkbook based on its content. + /// + static member fromColumnsJsonFile (filePath : string) = + let json = File.ReadAllText filePath + FsWorkbook.fromColumnsJsonString json + member self.ToEmptySpreadsheet(doc : Packaging.SpreadsheetDocument) = @@ -428,21 +457,37 @@ module FsExtensions = static member toFile (filePath : string) path (workbook : FsWorkbook) = workbook.ToXlsxFile(path) - static member toJsonString (workbook : FsWorkbook, ?spaces) = + static member toRowsJsonString (workbook : FsWorkbook, ?spaces) = + let spaces = defaultArg spaces 2 + FsSpreadsheet.Json.Workbook.encodeRows workbook + |> Thoth.Json.Newtonsoft.Encode.toString spaces + + static member toRowsJsonFile (path, ?spaces) = + fun workbook -> + let json = FsWorkbook.toRowsJsonString (workbook,?spaces = spaces) + File.WriteAllText(path,json) + + member this.ToRowsJsonString(?spaces) = + FsWorkbook.toRowsJsonString(this, ?spaces = spaces) + + member this.ToRowsJsonFile(path: string, ?spaces) = + FsWorkbook.toRowsJsonFile(path, ?spaces = spaces) this + + static member toColumnsJsonString (workbook : FsWorkbook, ?spaces) = let spaces = defaultArg spaces 2 - FsSpreadsheet.Json.Workbook.encode workbook + FsSpreadsheet.Json.Workbook.encodeColumns workbook |> Thoth.Json.Newtonsoft.Encode.toString spaces - static member toJsonFile (path, ?spaces) = + static member toColumnsJsonFile (path, ?spaces) = fun workbook -> - let json = FsWorkbook.toJsonString (workbook,?spaces = spaces) + let json = FsWorkbook.toColumnsJsonString (workbook,?spaces = spaces) File.WriteAllText(path,json) - member this.ToJsonString(?spaces) = - FsWorkbook.toJsonString(this, ?spaces = spaces) + member this.ToColumnsJsonString(?spaces) = + FsWorkbook.toColumnsJsonString(this, ?spaces = spaces) - member this.ToJsonFile(path: string, ?spaces) = - FsWorkbook.toJsonFile(path, ?spaces = spaces) this + member this.ToColumnsJsonFile(path: string, ?spaces) = + FsWorkbook.toColumnsJsonFile(path, ?spaces = spaces) this type Writer = @@ -474,8 +519,8 @@ type Writer = static member toFile(path,workbook: FsWorkbook) = workbook.ToXlsxFile(path) - static member toJsonString (workbook : FsWorkbook, ?spaces) = - FsWorkbook.toJsonString(workbook, ?spaces = spaces) + static member toRowsJsonString (workbook : FsWorkbook, ?spaces) = + FsWorkbook.toRowsJsonString(workbook, ?spaces = spaces) - static member toJsonFile (path, ?spaces) = - fun workbook -> FsWorkbook.toJsonFile (path, ?spaces = spaces) workbook \ No newline at end of file + static member toRowsJsonFile (path, ?spaces) = + fun workbook -> FsWorkbook.toRowsJsonFile (path, ?spaces = spaces) workbook \ No newline at end of file diff --git a/src/FsSpreadsheet.Py/FsExtension.fs b/src/FsSpreadsheet.Py/FsExtension.fs index eadbf41..13a3c6c 100644 --- a/src/FsSpreadsheet.Py/FsExtension.fs +++ b/src/FsSpreadsheet.Py/FsExtension.fs @@ -36,11 +36,11 @@ type FsWorkbook with member this.ToXlsxBytes() : byte [] = FsWorkbook.toXlsxBytes this - static member fromJsonString (json:string) : FsWorkbook = - Json.fromJsonString json + static member fromRowsJsonString (json:string) : FsWorkbook = + Json.fromRowsJsonString json - static member toJsonString (wb:FsWorkbook) : string = - Json.toJsonString wb + static member toRowsJsonString (wb:FsWorkbook) : string = + Json.toRowsJsonString wb //static member fromJsonFile (path:string) : Promise = // Json.fromJsonFile path @@ -51,5 +51,15 @@ type FsWorkbook with //member this.ToJsonFile(path: string) : Promise = // FsWorkbook.toJsonFile path this - member this.ToJsonString() : string = - FsWorkbook.toJsonString this \ No newline at end of file + member this.ToRowsJsonString() : string = + FsWorkbook.toRowsJsonString this + + static member fromColumnsJsonString (json:string) : FsWorkbook = + Json.fromColumnsJsonString json + + static member toColumnsJsonString (wb:FsWorkbook) : string = + Json.toColumnsJsonString wb + + member this.ToColumnsJsonString() : string = + FsWorkbook.toColumnsJsonString this + \ No newline at end of file diff --git a/src/FsSpreadsheet.Py/Json.fs b/src/FsSpreadsheet.Py/Json.fs index 17f22cd..64f54c3 100644 --- a/src/FsSpreadsheet.Py/Json.fs +++ b/src/FsSpreadsheet.Py/Json.fs @@ -15,15 +15,28 @@ open Thoth.Json.Python [] type Json = - static member tryFromJsonString (json:string) : Result = - Decode.fromString FsSpreadsheet.Json.Workbook.decode json + static member tryFromRowsJsonString (json:string) : Result = + Decode.fromString FsSpreadsheet.Json.Workbook.decodeRows json - static member fromJsonString (json:string) : FsWorkbook = - match Json.tryFromJsonString json with + static member fromRowsJsonString (json:string) : FsWorkbook = + match Json.tryFromRowsJsonString json with | Ok wb -> wb | Error e -> failwithf "Could not deserialize json Workbook: \n%s" e - static member toJsonString (wb:FsWorkbook, ?spaces) : string = + static member toRowsJsonString (wb:FsWorkbook, ?spaces) : string = let spaces = defaultArg spaces 2 - FsSpreadsheet.Json.Workbook.encode wb + FsSpreadsheet.Json.Workbook.encodeRows wb |> Encode.toString spaces + + static member tryFromColumnsJsonString (json:string) : Result = + Decode.fromString FsSpreadsheet.Json.Workbook.decodeColumns json + + static member fromColumnsJsonString (json:string) : FsWorkbook = + match Json.tryFromColumnsJsonString json with + | Ok wb -> wb + | Error e -> failwithf "Could not deserialize json Workbook: \n%s" e + + static member toColumnsJsonString (wb:FsWorkbook, ?spaces) : string = + let spaces = defaultArg spaces 2 + FsSpreadsheet.Json.Workbook.encodeColumns wb + |> Encode.toString spaces \ No newline at end of file diff --git a/src/FsSpreadsheet/FsSpreadsheet.fsproj b/src/FsSpreadsheet/FsSpreadsheet.fsproj index aead6ed..895b5e5 100644 --- a/src/FsSpreadsheet/FsSpreadsheet.fsproj +++ b/src/FsSpreadsheet/FsSpreadsheet.fsproj @@ -36,6 +36,7 @@ + @@ -57,8 +58,6 @@ - - - + diff --git a/src/FsSpreadsheet/Json/Cell.fs b/src/FsSpreadsheet/Json/Cell.fs index 118aad9..5978d00 100644 --- a/src/FsSpreadsheet/Json/Cell.fs +++ b/src/FsSpreadsheet/Json/Cell.fs @@ -6,18 +6,35 @@ open Thoth.Json.Core [] let column = "column" +[] +let row = "row" + [] let value = "value" -let encode (cell:FsCell) = +let encodeRows (cell:FsCell) = Encode.object [ column, Encode.int cell.ColumnNumber value, Value.encode cell.Value ] -let decode rowNumber : Decoder = +let decodeRows rowNumber : Decoder = Decode.object (fun builder -> let v,dt = builder.Required.Field value (Value.decode) let c = builder.Required.Field column Decode.int new FsCell(v,dt,FsAddress(rowNumber,c)) ) + + +let encodeCols (cell:FsCell) = + Encode.object [ + row, Encode.int cell.RowNumber + value, Value.encode cell.Value + ] + +let decodeCols colNumber : Decoder = + Decode.object (fun builder -> + let v,dt = builder.Required.Field value (Value.decode) + let r = builder.Required.Field row Decode.int + new FsCell(v,dt,FsAddress(r,colNumber)) + ) diff --git a/src/FsSpreadsheet/Json/Column.fs b/src/FsSpreadsheet/Json/Column.fs new file mode 100644 index 0000000..ed40b64 --- /dev/null +++ b/src/FsSpreadsheet/Json/Column.fs @@ -0,0 +1,23 @@ +module FsSpreadsheet.Json.Column + +open FsSpreadsheet +open Thoth.Json.Core + +[] +let cells = "cells" + +[] +let number = "number" + +let encode (col:FsColumn) = + Encode.object [ + number, Encode.int col.Index + cells, Encode.seq (col.Cells |> Seq.map Cell.encodeCols) + ] + +let decode : Decoder = + Decode.object (fun builder -> + let n = builder.Required.Field number Decode.int + let cs = builder.Required.Field cells (Decode.seq (Cell.decodeCols n)) + n,cs + ) \ No newline at end of file diff --git a/src/FsSpreadsheet/Json/Row.fs b/src/FsSpreadsheet/Json/Row.fs index d633a42..66a659e 100644 --- a/src/FsSpreadsheet/Json/Row.fs +++ b/src/FsSpreadsheet/Json/Row.fs @@ -12,12 +12,12 @@ let number = "number" let encode (row:FsRow) = Encode.object [ number, Encode.int row.Index - cells, Encode.seq (row.Cells |> Seq.map Cell.encode) + cells, Encode.seq (row.Cells |> Seq.map Cell.encodeRows) ] let decode : Decoder = Decode.object (fun builder -> let n = builder.Required.Field number Decode.int - let cs = builder.Required.Field cells (Decode.seq (Cell.decode n)) + let cs = builder.Required.Field cells (Decode.seq (Cell.decodeRows n)) n,cs ) \ No newline at end of file diff --git a/src/FsSpreadsheet/Json/Workbook.fs b/src/FsSpreadsheet/Json/Workbook.fs index cd00d6a..1617ed1 100644 --- a/src/FsSpreadsheet/Json/Workbook.fs +++ b/src/FsSpreadsheet/Json/Workbook.fs @@ -6,15 +6,28 @@ open Thoth.Json.Core [] let sheets = "sheets" -let encode (wb:FsWorkbook) = +let encodeRows (wb:FsWorkbook) = Encode.object [ - sheets, Encode.seq (wb.GetWorksheets() |> Seq.map Worksheet.encode) + sheets, Encode.seq (wb.GetWorksheets() |> Seq.map Worksheet.encodeRows) ] -let decode : Decoder = +let decodeRows : Decoder = Decode.object (fun builder -> let wb = new FsWorkbook() - let ws = builder.Required.Field sheets (Decode.seq Worksheet.decode) + let ws = builder.Required.Field sheets (Decode.seq Worksheet.decodeRows) wb.AddWorksheets(ws) wb - ) \ No newline at end of file + ) + +let encodeColumns (wb:FsWorkbook) = + Encode.object [ + sheets, Encode.seq (wb.GetWorksheets() |> Seq.map Worksheet.encodeColumns) + ] + +let decodeColumns : Decoder = + Decode.object (fun builder -> + let wb = new FsWorkbook() + let ws = builder.Required.Field sheets (Decode.seq Worksheet.decodeColumns) + wb.AddWorksheets(ws) + wb + ) diff --git a/src/FsSpreadsheet/Json/Worksheet.fs b/src/FsSpreadsheet/Json/Worksheet.fs index f126b2f..10e7333 100644 --- a/src/FsSpreadsheet/Json/Worksheet.fs +++ b/src/FsSpreadsheet/Json/Worksheet.fs @@ -9,10 +9,13 @@ let name = "name" [] let rows = "rows" +[] +let columns = "columns" + [] let tables = "tables" -let encode (sheet:FsWorksheet) = +let encodeRows (sheet:FsWorksheet) = sheet.RescanRows() Encode.object [ name, Encode.string sheet.Name @@ -22,7 +25,7 @@ let encode (sheet:FsWorksheet) = ] -let decode : Decoder = +let decodeRows : Decoder = Decode.object (fun builder -> let n = builder.Required.Field name Decode.string let ts = builder.Optional.Field tables (Decode.seq Table.decode) @@ -46,4 +49,39 @@ let decode : Decoder = ) | None -> () sheet - ) \ No newline at end of file + ) + +let encodeColumns (sheet:FsWorksheet) = + sheet.RescanRows() + Encode.object [ + name, Encode.string sheet.Name + if Seq.isEmpty sheet.Tables |> not then + tables, Encode.seq (sheet.Tables |> Seq.map Table.encode) + columns, Encode.seq (sheet.Columns |> Seq.map Column.encode) + ] + +let decodeColumns : Decoder = + Decode.object (fun builder -> + let n = builder.Required.Field name Decode.string + let ts = builder.Optional.Field tables (Decode.seq Table.decode) + let cs = builder.Required.Field columns (Decode.seq Column.decode) + let sheet = new FsWorksheet(n) + cs + |> Seq.iter (fun (colI,cells) -> + let col = sheet.Column(colI) + cells + |> Seq.iter (fun cell -> + let c = col[cell.RowNumber] + c.Value <- cell.Value + c.DataType <- cell.DataType + ) + ) + match ts with + | Some ts -> + ts + |> Seq.iter (fun t -> + sheet.AddTable(t) |> ignore + ) + | None -> () + sheet + ) diff --git a/tests/FsSpreadsheet.Js.Tests/Json.Tests.fs b/tests/FsSpreadsheet.Js.Tests/Json.Tests.fs index 1316477..79b4591 100644 --- a/tests/FsSpreadsheet.Js.Tests/Json.Tests.fs +++ b/tests/FsSpreadsheet.Js.Tests/Json.Tests.fs @@ -1,19 +1,32 @@ module Json.Tests +open TestingUtils open FsSpreadsheet open FsSpreadsheet.Js open Fable.Pyxpecto -let defaultTestObject = - testList "defaultTestObject" [ +let rows = + testList "Rows" [ testCase "Read-Write DefaultTestObject" <| fun _ -> let dto = DefaultTestObject.defaultTestObject() - let s = dto.ToJsonString() - let dto2 = FsWorkbook.fromJsonString(s) - TestingUtils.Expect.isDefaultTestObject dto2 + let s = dto.ToRowsJsonString() + let dto2 = FsWorkbook.fromRowsJsonString(s) + Expect.isDefaultTestObject dto2 + ] + +let columns = + testList "Columns" [ + + testCase "Read-Write DefaultTestObject" <| fun _ -> + let dto = DefaultTestObject.defaultTestObject() + let s = dto.ToColumnsJsonString() + let dto2 = FsWorkbook.fromColumnsJsonString(s) + Expect.isDefaultTestObject dto2 + ] let main = testList "Json" [ - defaultTestObject + rows + columns ] \ No newline at end of file diff --git a/tests/FsSpreadsheet.Net.Tests/Json.Tests.fs b/tests/FsSpreadsheet.Net.Tests/Json.Tests.fs index 28803b0..25028fb 100644 --- a/tests/FsSpreadsheet.Net.Tests/Json.Tests.fs +++ b/tests/FsSpreadsheet.Net.Tests/Json.Tests.fs @@ -5,17 +5,29 @@ open FsSpreadsheet open FsSpreadsheet.Net open Fable.Pyxpecto -let defaultTestObject = - testList "defaultTestObject" [ +let rows = + testList "Rows" [ testCase "Read-Write DefaultTestObject" <| fun _ -> let dto = DefaultTestObject.defaultTestObject() - let s = dto.ToJsonString() + let s = dto.ToRowsJsonString() System.IO.File.WriteAllText(DefaultTestObject.FsSpreadsheetJSON.asRelativePath,s) - let dto2 = FsWorkbook.fromJsonString(s) - TestingUtils.Expect.isDefaultTestObject dto2 + let dto2 = FsWorkbook.fromRowsJsonFile(DefaultTestObject.FsSpreadsheetJSON.asRelativePath) + Expect.isDefaultTestObject dto2 + ] + +let columns = + testList "Columns" [ + + testCase "Read-Write DefaultTestObject" <| fun _ -> + let dto = DefaultTestObject.defaultTestObject() + let s = dto.ToColumnsJsonString() + System.IO.File.WriteAllText(DefaultTestObject.FsSpreadsheetJSON.asRelativePath,s) + let dto2 = FsWorkbook.fromColumnsJsonFile(DefaultTestObject.FsSpreadsheetJSON.asRelativePath) + Expect.isDefaultTestObject dto2 ] let main = testList "Json" [ - defaultTestObject + rows + columns ] \ No newline at end of file diff --git a/tests/FsSpreadsheet.Py.Tests/Json.Tests.fs b/tests/FsSpreadsheet.Py.Tests/Json.Tests.fs index 9880c45..67686d0 100644 --- a/tests/FsSpreadsheet.Py.Tests/Json.Tests.fs +++ b/tests/FsSpreadsheet.Py.Tests/Json.Tests.fs @@ -1,22 +1,31 @@ module Json.Tests +open TestingUtils open FsSpreadsheet open FsSpreadsheet.Py open Fable.Pyxpecto -let defaultTestObject = - testList "defaultTestObject" [ +let rows = + testList "Rows" [ testCase "Read-Write DefaultTestObject" <| fun _ -> let dto = DefaultTestObject.defaultTestObject() - let s = dto.ToJsonString() - let dto2 = FsWorkbook.fromJsonString(s) - TestingUtils.Expect.isDefaultTestObject dto2 + let s = dto.ToRowsJsonString() + let dto2 = FsWorkbook.fromRowsJsonString(s) + Expect.isDefaultTestObject dto2 + ] + +let columns = + testList "Columns" [ - //testCase "Should Fail" <| fun _ -> - // Expect.isTrue false "is not the expected DataType.Boolean" + testCase "Read-Write DefaultTestObject" <| fun _ -> + let dto = DefaultTestObject.defaultTestObject() + let s = dto.ToColumnsJsonString() + let dto2 = FsWorkbook.fromColumnsJsonString(s) + Expect.isDefaultTestObject dto2 ] let main = testList "Json" [ - defaultTestObject + rows + columns ] \ No newline at end of file