Merge pull request #47 from pietern/fix-assertcalled

Fix use of AnythingOfType with AssertCalled
pull/50/head
Tyler 2014-04-10 15:20:40 -06:00
commit 0d84e9b479
2 changed files with 14 additions and 2 deletions

View File

@ -296,11 +296,11 @@ func (m *Mock) AssertNotCalled(t TestingT, methodName string, arguments ...inter
return true
}
func (m *Mock) methodWasCalled(methodName string, arguments []interface{}) bool {
func (m *Mock) methodWasCalled(methodName string, expected []interface{}) bool {
for _, call := range m.Calls {
if call.Method == methodName {
_, differences := call.Arguments.Diff(arguments)
_, differences := Arguments(expected).Diff(call.Arguments)
if differences == 0 {
// found the expected call

View File

@ -473,6 +473,18 @@ func Test_Mock_AssertCalled(t *testing.T) {
}
func Test_Mock_AssertCalled_WithAnythingOfTypeArgument(t *testing.T) {
var mockedService *TestExampleImplementation = new(TestExampleImplementation)
mockedService.Mock.On("Test_Mock_AssertCalled_WithAnythingOfTypeArgument", Anything, Anything, Anything).Return()
mockedService.Mock.Called(1, "two", []uint8("three"))
assert.True(t, mockedService.AssertCalled(t, "Test_Mock_AssertCalled_WithAnythingOfTypeArgument", AnythingOfType("int"), AnythingOfType("string"), AnythingOfType("[]uint8")))
}
func Test_Mock_AssertCalled_WithArguments(t *testing.T) {
var mockedService *TestExampleImplementation = new(TestExampleImplementation)