#lang racket

(require rackunit/text-ui rackunit)
(require racket/date)

(require racket/runtime-path)
(define-runtime-path workbook_xml_file "workbook.xml")

(require "../../main.rkt")

(define test-xml
  (test-suite
   "test-workbook"

   (test-case
    "test-workbook"

    (let ([xml_hash (xml->hash workbook_xml_file)])
      (check-equal? (hash-ref xml_hash "workbook's count") 1)
      (check-equal? (hash-ref xml_hash "workbook1.xmlns") "http://schemas.openxmlformats.org/spreadsheetml/2006/main")
      (check-equal? (hash-ref xml_hash "workbook1.xmlns:r") "http://schemas.openxmlformats.org/officeDocument/2006/relationships")
      (check-equal? (hash-ref xml_hash "workbook1.fileVersion's count") 1)
      (check-equal? (hash-ref xml_hash "workbook1.fileVersion1") "")
      (check-equal? (hash-ref xml_hash "workbook1.fileVersion1.appName") "xl")
      (check-equal? (hash-ref xml_hash "workbook1.fileVersion1.lastEdited") "4")
      (check-equal? (hash-ref xml_hash "workbook1.fileVersion1.lowestEdited") "4")
      (check-equal? (hash-ref xml_hash "workbook1.fileVersion1.rupBuild") "4505")
      (check-equal? (hash-ref xml_hash "workbook1.workbookPr's count") 1)
      (check-equal? (hash-ref xml_hash "workbook1.workbookPr1") "")
      (check-equal? (hash-ref xml_hash "workbook1.workbookPr1.filterPrivacy") "1")
      (check-equal? (hash-ref xml_hash "workbook1.workbookPr1.defaultThemeVersion") "124226")
      (check-equal? (hash-ref xml_hash "workbook1.bookViews's count") 1)
      (check-equal? (hash-ref xml_hash "workbook1.bookViews1.workbookView's count") 1)
      (check-equal? (hash-ref xml_hash "workbook1.bookViews1.workbookView1") "")
      (check-equal? (hash-ref xml_hash "workbook1.bookViews1.workbookView1.xWindow") "0")
      (check-equal? (hash-ref xml_hash "workbook1.bookViews1.workbookView1.yWindow") "90")
      (check-equal? (hash-ref xml_hash "workbook1.bookViews1.workbookView1.windowWidth") "19200")
      (check-equal? (hash-ref xml_hash "workbook1.bookViews1.workbookView1.windowHeight") "10590")
      (check-equal? (hash-ref xml_hash "workbook1.calcPr's count") 1)
      (check-equal? (hash-ref xml_hash "workbook1.calcPr1") "")
      (check-equal? (hash-ref xml_hash "workbook1.calcPr1.calcId") "124519")
      (check-equal? (hash-ref xml_hash "workbook1.sheets's count") 1)
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet's count") 10)
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet1") "")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet1.name") "DataSheet")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet1.sheetId") "1")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet1.r:id") "rId1")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet2") "")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet2.name") "DataSheetWithStyle")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet2.sheetId") "2")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet2.r:id") "rId2")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet3") "")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet3.name") "DataSheetWithStyle2")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet3.sheetId") "3")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet3.r:id") "rId3")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet4") "")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet4.name") "LineChart1")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet4.sheetId") "4")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet4.r:id") "rId4")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet5") "")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet5.name") "LineChart2")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet5.sheetId") "5")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet5.r:id") "rId5")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet6") "")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet6.name") "LineChart3D")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet6.sheetId") "6")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet6.r:id") "rId6")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet7") "")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet7.name") "BarChart")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet7.sheetId") "7")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet7.r:id") "rId7")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet8") "")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet8.name") "BarChart3D")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet8.sheetId") "8")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet8.r:id") "rId8")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet9") "")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet9.name") "PieChart")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet9.sheetId") "9")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet9.r:id") "rId9")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet10") "")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet10.name") "PieChart3D")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet10.sheetId") "10")
      (check-equal? (hash-ref xml_hash "workbook1.sheets1.sheet10.r:id") "rId10")

      (check-equal? (hash-count xml_hash) 65)
      )

    )

  ))

(run-tests test-xml)
