forked from chiguirez/cromberbus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
command_handler_resolver_mock.go
76 lines (68 loc) · 2.22 KB
/
command_handler_resolver_mock.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
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package cromberbus
import (
"sync"
)
var (
lockCommandHandlerResolverMockResolve sync.RWMutex
)
// Ensure, that CommandHandlerResolverMock does implement CommandHandlerResolver.
// If this is not the case, regenerate this file with moq.
var _ CommandHandlerResolver = &CommandHandlerResolverMock{}
// CommandHandlerResolverMock is a mock implementation of CommandHandlerResolver.
//
// func TestSomethingThatUsesCommandHandlerResolver(t *testing.T) {
//
// // make and configure a mocked CommandHandlerResolver
// mockedCommandHandlerResolver := &CommandHandlerResolverMock{
// ResolveFunc: func(command Command) (CommandHandler, error) {
// panic("mock out the Resolve method")
// },
// }
//
// // use mockedCommandHandlerResolver in code that requires CommandHandlerResolver
// // and then make assertions.
//
// }
type CommandHandlerResolverMock struct {
// ResolveFunc mocks the Resolve method.
ResolveFunc func(command Command) (CommandHandler, error)
// calls tracks calls to the methods.
calls struct {
// Resolve holds details about calls to the Resolve method.
Resolve []struct {
// Command is the command argument value.
Command Command
}
}
}
// Resolve calls ResolveFunc.
func (mock *CommandHandlerResolverMock) Resolve(command Command) (CommandHandler, error) {
if mock.ResolveFunc == nil {
panic("CommandHandlerResolverMock.ResolveFunc: method is nil but CommandHandlerResolver.Resolve was just called")
}
callInfo := struct {
Command Command
}{
Command: command,
}
lockCommandHandlerResolverMockResolve.Lock()
mock.calls.Resolve = append(mock.calls.Resolve, callInfo)
lockCommandHandlerResolverMockResolve.Unlock()
return mock.ResolveFunc(command)
}
// ResolveCalls gets all the calls that were made to Resolve.
// Check the length with:
// len(mockedCommandHandlerResolver.ResolveCalls())
func (mock *CommandHandlerResolverMock) ResolveCalls() []struct {
Command Command
} {
var calls []struct {
Command Command
}
lockCommandHandlerResolverMockResolve.RLock()
calls = mock.calls.Resolve
lockCommandHandlerResolverMockResolve.RUnlock()
return calls
}