func (m *Mock) AssertNumberOfCalls(t TestingT, methodName string, expectedCalls int) bool {
	var actualCalls int = 0
	for _, call := range m.Calls {
		if call.Method == methodName {
			actualCalls++
		}
	}
	return assert.Equal(t, actualCalls, expectedCalls, fmt.Sprintf("Expected number of calls (%d) does not match the actual number of calls (%d).", expectedCalls, actualCalls))
}
AssertNumberOfCalls asserts that the method was called expectedCalls times.
package mock
import (
	"fmt"
	"github.com/stretchr/objx"
	"github.com/stretchr/testify/assert"
	"reflect"
	"runtime"
	"strings"
	"sync"
)
type TestingT interface {
	Logf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
}
type Call struct {
	Method string
	Arguments Arguments
	ReturnArguments Arguments
	Repeatability int
}
type Mock struct {
	onMethodName string
	onMethodArguments Arguments
	ExpectedCalls []Call
	Calls []Call
	testData objx.Map
	mutex sync.Mutex
}
func (m *Mock) TestData() objx.Map {
	if m.testData == nil {
		m.testData = make(objx.Map)
	}
	return m.testData
}
func (m *Mock) On(methodName string, arguments ...interface{}) *Mock {
	m.onMethodName = methodName
	m.onMethodArguments = arguments
	return m
}
func (m *Mock) Return(returnArguments ...interface{}) *Mock {
	m.ExpectedCalls = append(m.ExpectedCalls, Call{m.onMethodName, m.onMethodArguments, returnArguments, 0})
	return m
}
func (m *Mock) Once() {
	m.ExpectedCalls[len(m.ExpectedCalls)-1].Repeatability = 1
}
func (m *Mock) Twice() {
	m.ExpectedCalls[len(m.ExpectedCalls)-1].Repeatability = 2
}
func (m *Mock) Times(i int) {
	m.ExpectedCalls[len(m.ExpectedCalls)-1].Repeatability = i
}
func (m *Mock) findExpectedCall(method string, arguments ...interface{}) (int, *Call) {
	for i, call := range m.ExpectedCalls {
		if call.Method == method && call.Repeatability > -1 {
			_, diffCount := call.Arguments.Diff(arguments)
			if diffCount == 0 {
				return i, &call
			}
		}
	}
	return -1, nil
}
func (m *Mock) findClosestCall(method string, arguments ...interface{}) (bool, *Call) {
	diffCount := 0
	var closestCall *Call = nil
	for _, call := range m.ExpectedCalls {
		if call.Method == method {
			_, tempDiffCount := call.Arguments.Diff(arguments)
			if tempDiffCount < diffCount || diffCount == 0 {
				diffCount = tempDiffCount
				closestCall = &call
			}
		}
	}
	if closestCall == nil {
		return false, nil
	}
	return true, closestCall
}
func callString(method string, arguments Arguments, includeArgumentValues bool) string {
	var argValsString string = ""
	if includeArgumentValues {
		var argVals []string
		for argIndex, arg := range arguments {
			argVals = append(argVals, fmt.Sprintf("%d: %v", argIndex, arg))
		}
		argValsString = fmt.Sprintf("\n\t\t%s", strings.Join(argVals, "\n\t\t"))
	}
	return fmt.Sprintf("%s(%s)%s", method, arguments.String(), argValsString)
}
func (m *Mock) Called(arguments ...interface{}) Arguments {
	defer m.mutex.Unlock()
	m.mutex.Lock()
	pc, _, _, ok := runtime.Caller(1)
	if !ok {
		panic("Couldn't get the caller information")
	}
	functionPath := runtime.FuncForPC(pc).Name()
	parts := strings.Split(functionPath, ".")
	functionName := parts[len(parts)-1]
	found, call := m.findExpectedCall(functionName, arguments...)
	switch {
	case found < 0:
		closestFound, closestCall := m.findClosestCall(functionName, arguments...)
		if closestFound {
			panic(fmt.Sprintf("\n\nmock: Unexpected Method Call\n-----------------------------\n\n%s\n\nThe closest call I have is: \n\n%s\n", callString(functionName, arguments, true), callString(functionName, closestCall.Arguments, true)))
		} else {
			panic(fmt.Sprintf("\nassert: mock: I don't know what to return because the method call was unexpected.\n\tEither do Mock.On(\"%s\").Return(...) first, or remove the %s() call.\n\tThis method was unexpected:\n\t\t%s\n\tat: %s", functionName, functionName, callString(functionName, arguments, true), assert.CallerInfo()))
		}
	case call.Repeatability == 1:
		call.Repeatability = -1
		m.ExpectedCalls[found] = *call
	case call.Repeatability > 1:
		call.Repeatability -= 1
		m.ExpectedCalls[found] = *call
	}
	m.Calls = append(m.Calls, Call{functionName, arguments, make([]interface{}, 0), 0})
	return call.ReturnArguments
}
func AssertExpectationsForObjects(t TestingT, testObjects ...interface{}) bool {
	var success bool = true
	for _, obj := range testObjects {
		mockObj := obj.(Mock)
		success = success && mockObj.AssertExpectations(t)
	}
	return success
}
func (m *Mock) AssertExpectations(t TestingT) bool {
	var somethingMissing bool = false
	var failedExpectations int = 0
	for _, expectedCall := range m.ExpectedCalls {
		switch {
		case !m.methodWasCalled(expectedCall.Method, expectedCall.Arguments):
			somethingMissing = true
			failedExpectations++
			t.Logf("\u274C\t%s(%s)", expectedCall.Method, expectedCall.Arguments.String())
		case expectedCall.Repeatability > 0:
			somethingMissing = true
			failedExpectations++
		default:
			t.Logf("\u2705\t%s(%s)", expectedCall.Method, expectedCall.Arguments.String())
		}
	}
	if somethingMissing {
		t.Errorf("FAIL: %d out of %d expectation(s) were met.\n\tThe code you are testing needs to make %d more call(s).\n\tat: %s", len(m.ExpectedCalls)-failedExpectations, len(m.ExpectedCalls), failedExpectations, assert.CallerInfo())
	}
	return !somethingMissing
}