start of the unit tests for the module Split.
This commit is contained in:
parent
5cd98d2094
commit
7cb1814535
|
@ -1,5 +1,11 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Main where
|
||||
|
||||
import qualified Billy.Bill as B
|
||||
import qualified Billy.Interval as I
|
||||
import qualified Billy.Payer as P
|
||||
import qualified Billy.Split as S
|
||||
import qualified Data.Time.Calendar as D
|
||||
import Test.Tasty
|
||||
import Test.Tasty.HUnit
|
||||
|
@ -8,7 +14,7 @@ main :: IO ()
|
|||
main = defaultMain tests
|
||||
|
||||
tests :: TestTree
|
||||
tests = testGroup "Tests" [intervalUnitTests]
|
||||
tests = testGroup "Tests" [intervalUnitTests, splitUnitTests]
|
||||
|
||||
intervalUnitTests :: TestTree
|
||||
intervalUnitTests = testGroup "Unit Tests for Billy.Interval"
|
||||
|
@ -69,3 +75,27 @@ intervalUnitTests = testGroup "Unit Tests for Billy.Interval"
|
|||
middle = D.fromGregorian 2016 01 15
|
||||
threeQuarter = D.fromGregorian 2016 01 21
|
||||
endOut = D.fromGregorian 2016 02 01
|
||||
|
||||
splitUnitTests :: TestTree
|
||||
splitUnitTests = testGroup "Unit Tests for Billy.Split"
|
||||
[ testCase "Creating a new Split" $
|
||||
((billString ==) . show) (S.new bill) @?= True
|
||||
, testCase "Adding a Payer without Interval" $
|
||||
let split = S.new bill
|
||||
newSplit = S.addPayer payer Nothing split
|
||||
newSplitString = "Split {bill = Bill {name = \"Bill A\",\
|
||||
\ value = 100.0, period = Interval {start = 2016-01-01,\
|
||||
\ end = 2016-01-31, kind = Closed}}, payers = [\
|
||||
\(Payer {name = \"Payer A\"},Interval {start = 2016-01-01,\
|
||||
\ end = 2016-01-31, kind = Closed})],\
|
||||
\ endpoints = [2016-01-01,2016-01-31]}"
|
||||
in newSplit /= split && show newSplit == newSplitString @?= True
|
||||
]
|
||||
where
|
||||
bill = B.new "Bill A" 100 interval
|
||||
interval = I.new (D.fromGregorian 2016 01 01)
|
||||
(D.fromGregorian 2016 01 31)
|
||||
payer = P.new "Payer A"
|
||||
billString = "Split {bill = Bill {name = \"Bill A\", value = 100.0,\
|
||||
\ period = Interval {start = 2016-01-01, end = 2016-01-31,\
|
||||
\ kind = Closed}}, payers = [], endpoints = []}"
|
||||
|
|
Loading…
Reference in a new issue