Skip to content

Commit

Permalink
Add Spreadsheet tests
Browse files Browse the repository at this point in the history
Tests for `fromFile` (does not work atm. => WIP), `tryGetSharedStringTable`, and `getWorkbookPart`.
  • Loading branch information
omaus committed Mar 13, 2023
1 parent 3f6e431 commit 866dc33
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tests/FsSpreadsheet.ExcelIO.Tests/Spreadsheet.fs
Original file line number Diff line number Diff line change
@@ -1,2 +1,61 @@
module Spreadsheet

open Expecto
open FsSpreadsheet.ExcelIO
open DocumentFormat.OpenXml


//let testFilePath = @"C:\Repos\CSBiology\FsSpreadsheet\tests\FsSpreadsheet.ExcelIO.Tests\data\testUnit.xlsx"
let testFilePath = System.IO.Path.Combine(__SOURCE_DIRECTORY__, "data", "testUnit.xlsx")
// *fox = from OpenXml, to distinguish between objects from FsSpreadsheet.ExcelIO
let ssdFox = Packaging.SpreadsheetDocument.Open(testFilePath, false)
let wbpFox = ssdFox.WorkbookPart
let sstpFox = wbpFox.SharedStringTablePart
let sstFox = sstpFox.SharedStringTable
let sstFoxInnerText = sstFox.InnerText


//let testSsdFox2 = Packaging.SpreadsheetDocument.Open(testFilePath, false)

//let testDoc = Spreadsheet.fromFile testFilePath false

//testSsdFox = testDoc
//testSsdFox = testSsdFox2



[<Tests>]
let spreadsheetTests =
testList "Spreadsheet" [
// is it even possible to test this?
//testList "fromFile" [
//testCase "is equal to testSsd" <| fun _ ->
// let ssd = Spreadsheet.fromFile testFilePath false
// Expect.equal testDoc ssdFox "Both testFiles differ"
// testSsd.Close()
//]
testList "tryGetSharedStringTable" [
let sst = Spreadsheet.tryGetSharedStringTable ssdFox
testCase "is Some" <| fun _ ->
Expect.isSome sst "Is None"
testCase "is equal to testSstFox" <| fun _ ->
Expect.equal sst.Value sstFox "Differs"
testCase "inner text is correct" <| fun _ ->
Expect.equal sst.Value.InnerText sstFoxInnerText "Differs"
]
testList "getWorkbookPart" [
let wbp = Spreadsheet.getWorkbookPart ssdFox
testCase "is equal to wbpFox" <| fun _ ->
Expect.equal wbp wbpFox "Differs"
]
]









//testSsdFox.Close()

0 comments on commit 866dc33

Please sign in to comment.