-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
68 lines (55 loc) · 1.44 KB
/
Copy pathmain_test.go
File metadata and controls
68 lines (55 loc) · 1.44 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
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
package main
import (
"github.com/sjurtf/elvia-ny-nettleie/elvia"
"github.com/stretchr/testify/assert"
"testing"
)
func getTestadata(consumptionData map[string]float64) *elvia.Data {
var months []elvia.Month
var years []elvia.Year
var days []elvia.Day
var hours []elvia.Hour
for k, f := range consumptionData {
h := elvia.Hour{
Hour: k,
Id: k,
Consumption: elvia.Consumption{Value: f},
}
hours = append(hours, h)
}
d := elvia.Day{
Day: "01",
Hours: hours,
}
days = append(days, d)
m := elvia.Month{
Month: "10",
Days: days,
}
months = append(months, m)
y := elvia.Year{
Year: "2021",
Months: months,
Consumption: elvia.Consumption{},
}
years = append(years, y)
return &elvia.Data{Years: years}
}
func TestMonth_GetCost_Old(t *testing.T) {
consumption := make(map[string]float64)
consumption["10"] = 1.5
consumption["22"] = 3
data := getTestadata(consumption)
r := CalculateOldModel(data)
expected := elvia.OldConstPriceNOK + (elvia.OldEnergy * 1.5 / 100) + (elvia.OldEnergy * 3 / 100)
assert.Equal(t, expected, r.GetCost())
}
func TestMonth_GetCost_New(t *testing.T) {
consumption := make(map[string]float64)
consumption["10"] = 1.5
consumption["22"] = 3
data := getTestadata(consumption)
r := CalculateNewModel(data)
expected := elvia.NewConstPriceTier1NOK + (elvia.NewEnergyDay * 1.5 / 100) + (elvia.NewEnergyNight * 3 / 100)
assert.Equal(t, expected, r.GetCost())
}