-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmortgagekit_test.go
More file actions
34 lines (27 loc) · 1 KB
/
mortgagekit_test.go
File metadata and controls
34 lines (27 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package mortgagekit_test
import (
// "fmt"
"testing"
"github.com/rhymond/go-money"
"github.com/mikasoftware/mortgagekit"
)
func TestNew(t *testing.T) {
// Setup unit test and then test and verify.
totalAmount := money.New(250000, "CAD")
downPaymentAmount := money.New(50000, "CAD")
calculator := mortgagekit.New(totalAmount, downPaymentAmount, 25, 0.04, mortgagekit.Month, mortgagekit.SemiAnnual, "2008-01-01", "CAD",)
if &calculator == nil {
t.Error("Failed initializing calculator using `New` function.")
}
}
func TestGetPercentOfLoanFinanced(t *testing.T) {
// Setup our unit tests.
totalAmount := money.New(250000, "CAD")
downPaymentAmount := money.New(50000, "CAD")
calculator := mortgagekit.New(totalAmount, downPaymentAmount, 25, 0.04, mortgagekit.Month, mortgagekit.SemiAnnual, "2008-01-01", "CAD",)
// Test and verify.
percent, _ := calculator.GetPercentOfLoanFinanced()
if percent != 80 {
t.Error("Does not equal 80%")
}
}