Skip to content

Commit

Permalink
Add Sheet tests
Browse files Browse the repository at this point in the history
Tests for `Sheets.get` and `Sheets.getSheets`.
  • Loading branch information
omaus committed Mar 13, 2023
1 parent 24bdd61 commit 0d60c04
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<ItemGroup>
<Compile Include="Spreadsheet.fs" />
<Compile Include="Workbook.fs" />
<Compile Include="Sheet.fs" />
<Compile Include="Main.fs" />
</ItemGroup>

Expand Down
29 changes: 29 additions & 0 deletions tests/FsSpreadsheet.ExcelIO.Tests/Sheet.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module Sheet

open Expecto
open FsSpreadsheet.ExcelIO
open DocumentFormat.OpenXml

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 wbFox = wbpFox.Workbook
let shtsFox = wbFox.Sheets
let shtssFox = shtsFox.Descendants<Spreadsheet.Sheet>() |> Array.ofSeq // array is needed since seqs cannot be compared


[<Tests>]
let sheetsTests =
testList "Sheets" [
testList "get" [
testCase "is equal to shtsFox" <| fun _ ->
let shts = Sheet.Sheets.get wbFox
Expect.equal shts shtsFox "Differs"
]
testList "getSheets" [
testCase "is equal to shtssFox" <| fun _ ->
let shtss = Sheet.Sheets.getSheets shtsFox |> Array.ofSeq // array is needed since seqs cannot be compared
Expect.equal shtss shtssFox "Differs"
]
]

0 comments on commit 0d60c04

Please sign in to comment.