-
Notifications
You must be signed in to change notification settings - Fork 199
/
raterMock.go
46 lines (40 loc) · 993 Bytes
/
raterMock.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
package mock
// RaterMock -
type RaterMock struct {
ComputeRatingCalled func(string, uint32) uint32
GetRatingCalled func(string) uint32
GetStartRatingCalled func() uint32
GetChancesCalled func(uint32) uint32
}
// ComputeRating -
func (rm *RaterMock) ComputeRating(ratingOptionKey string, previousValue uint32) uint32 {
if rm.ComputeRatingCalled != nil {
return rm.ComputeRatingCalled(ratingOptionKey, previousValue)
}
return 1
}
// GetRating -
func (rm *RaterMock) GetRating(pk string) uint32 {
if rm.GetRatingCalled != nil {
return rm.GetRatingCalled(pk)
}
return 1
}
// IsInterfaceNil -
func (rm *RaterMock) IsInterfaceNil() bool {
return rm == nil
}
// GetStartRating -
func (rm *RaterMock) GetStartRating() uint32 {
if rm.GetStartRatingCalled != nil {
return rm.GetStartRatingCalled()
}
return 5
}
// GetChance -
func (rm *RaterMock) GetChance(rating uint32) uint32 {
if rm.GetChancesCalled != nil {
return rm.GetChancesCalled(rating)
}
return 5
}