// Code generated by counterfeiter. DO NOT EDIT.
package sshfakes

import (
	"net"
	"sync"

	sshCmd "code.cloudfoundry.org/cli/cf/ssh"
)

type FakeListenerFactory struct {
	ListenStub        func(string, string) (net.Listener, error)
	listenMutex       sync.RWMutex
	listenArgsForCall []struct {
		arg1 string
		arg2 string
	}
	listenReturns struct {
		result1 net.Listener
		result2 error
	}
	listenReturnsOnCall map[int]struct {
		result1 net.Listener
		result2 error
	}
	invocations      map[string][][]interface{}
	invocationsMutex sync.RWMutex
}

func (fake *FakeListenerFactory) Listen(arg1 string, arg2 string) (net.Listener, error) {
	fake.listenMutex.Lock()
	ret, specificReturn := fake.listenReturnsOnCall[len(fake.listenArgsForCall)]
	fake.listenArgsForCall = append(fake.listenArgsForCall, struct {
		arg1 string
		arg2 string
	}{arg1, arg2})
	fake.recordInvocation("Listen", []interface{}{arg1, arg2})
	fake.listenMutex.Unlock()
	if fake.ListenStub != nil {
		return fake.ListenStub(arg1, arg2)
	}
	if specificReturn {
		return ret.result1, ret.result2
	}
	fakeReturns := fake.listenReturns
	return fakeReturns.result1, fakeReturns.result2
}

func (fake *FakeListenerFactory) ListenCallCount() int {
	fake.listenMutex.RLock()
	defer fake.listenMutex.RUnlock()
	return len(fake.listenArgsForCall)
}

func (fake *FakeListenerFactory) ListenCalls(stub func(string, string) (net.Listener, error)) {
	fake.listenMutex.Lock()
	defer fake.listenMutex.Unlock()
	fake.ListenStub = stub
}

func (fake *FakeListenerFactory) ListenArgsForCall(i int) (string, string) {
	fake.listenMutex.RLock()
	defer fake.listenMutex.RUnlock()
	argsForCall := fake.listenArgsForCall[i]
	return argsForCall.arg1, argsForCall.arg2
}

func (fake *FakeListenerFactory) ListenReturns(result1 net.Listener, result2 error) {
	fake.listenMutex.Lock()
	defer fake.listenMutex.Unlock()
	fake.ListenStub = nil
	fake.listenReturns = struct {
		result1 net.Listener
		result2 error
	}{result1, result2}
}

func (fake *FakeListenerFactory) ListenReturnsOnCall(i int, result1 net.Listener, result2 error) {
	fake.listenMutex.Lock()
	defer fake.listenMutex.Unlock()
	fake.ListenStub = nil
	if fake.listenReturnsOnCall == nil {
		fake.listenReturnsOnCall = make(map[int]struct {
			result1 net.Listener
			result2 error
		})
	}
	fake.listenReturnsOnCall[i] = struct {
		result1 net.Listener
		result2 error
	}{result1, result2}
}

func (fake *FakeListenerFactory) Invocations() map[string][][]interface{} {
	fake.invocationsMutex.RLock()
	defer fake.invocationsMutex.RUnlock()
	fake.listenMutex.RLock()
	defer fake.listenMutex.RUnlock()
	copiedInvocations := map[string][][]interface{}{}
	for key, value := range fake.invocations {
		copiedInvocations[key] = value
	}
	return copiedInvocations
}

func (fake *FakeListenerFactory) recordInvocation(key string, args []interface{}) {
	fake.invocationsMutex.Lock()
	defer fake.invocationsMutex.Unlock()
	if fake.invocations == nil {
		fake.invocations = map[string][][]interface{}{}
	}
	if fake.invocations[key] == nil {
		fake.invocations[key] = [][]interface{}{}
	}
	fake.invocations[key] = append(fake.invocations[key], args)
}

var _ sshCmd.ListenerFactory = new(FakeListenerFactory)
