-
Notifications
You must be signed in to change notification settings - Fork 0
/
estimator_test.go
82 lines (69 loc) · 1.97 KB
/
estimator_test.go
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package ecaas
import "testing"
//mockMoveType implements the MoveType Interface
type mockMoveType struct {
name string
multiplier string
taxRate string
}
func (m *mockMoveType) GetName() string {
return m.name
}
func (m *mockMoveType) GetMultiplier() string {
return m.multiplier
}
func (m *mockMoveType) GetTaxRate() string {
return m.taxRate
}
var (
//Test Dates
monday = "Mon Dec 04 12:00:00 EST 2017"
saturday = "Sat Dec 02 12:00:00 EST 2017"
)
func TestJobComplexityForDate(t *testing.T) {
actual, err := jobComplexityForDate(monday)
if err != nil {
t.Error(err)
}
expected := 0.15
if actual != expected {
t.Errorf("Job complexity factor should be %f, but got %f", expected, actual)
}
actual, err = jobComplexityForDate(saturday)
if err != nil {
t.Error(err)
}
expected = 0.3
if actual != expected {
t.Errorf("Job complexity factor should be %f, but got %f", expected, actual)
}
}
func TestCalculateTotalCost(t *testing.T) {
//Test a normal weekday move
details := NewJobDetails(10, "120.50", monday)
moveType := &mockMoveType{
name: "Local",
multiplier: "0.05",
taxRate: "0.06",
}
estimateRange := CalculateTotalCost(details, moveType)
expectedLow := "$1341.17"
expectedHigh := "$1542.34"
if estimateRange.Low != expectedLow {
t.Errorf("Expected estimate low to be %s, but instead got %s", expectedLow, estimateRange.Low)
}
if estimateRange.High != expectedHigh {
t.Errorf("Expected estimate high to be %s, but instead got %s", expectedHigh, estimateRange.High)
}
//Testing weekend move
details = NewJobDetails(10, "120.50", saturday)
weekendRange := CalculateTotalCost(details, moveType)
expectedLow = "$1341.17"
expectedHigh = "$1743.51"
if weekendRange.Low != expectedLow {
t.Errorf("Expected estimate low to be %s, but instead got %s", expectedLow, weekendRange.Low)
}
if weekendRange.High != expectedHigh {
t.Errorf("Expected estimate high to be %s, but instead got %s", expectedHigh, weekendRange.High)
}
}