// This file was generated by counterfeiter
package fakes

import (
	"sync"

	"github.com/cloudfoundry/yagnats"
)

type FakeConnectionProvider struct {
	ProvideConnectionStub        func() (*yagnats.Connection, error)
	provideConnectionMutex       sync.RWMutex
	provideConnectionArgsForCall []struct{}
	provideConnectionReturns     struct {
		result1 *yagnats.Connection
		result2 error
	}
	provideConnectionReturnsOnCall map[int]struct {
		result1 *yagnats.Connection
		result2 error
	}
	invocations      map[string][][]interface{}
	invocationsMutex sync.RWMutex
}

func (fake *FakeConnectionProvider) ProvideConnection() (*yagnats.Connection, error) {
	fake.provideConnectionMutex.Lock()
	ret, specificReturn := fake.provideConnectionReturnsOnCall[len(fake.provideConnectionArgsForCall)]
	fake.provideConnectionArgsForCall = append(fake.provideConnectionArgsForCall, struct{}{})
	fake.recordInvocation("ProvideConnection", []interface{}{})
	fake.provideConnectionMutex.Unlock()
	if fake.ProvideConnectionStub != nil {
		return fake.ProvideConnectionStub()
	}
	if specificReturn {
		return ret.result1, ret.result2
	}
	return fake.provideConnectionReturns.result1, fake.provideConnectionReturns.result2
}

func (fake *FakeConnectionProvider) ProvideConnectionCallCount() int {
	fake.provideConnectionMutex.RLock()
	defer fake.provideConnectionMutex.RUnlock()
	return len(fake.provideConnectionArgsForCall)
}

func (fake *FakeConnectionProvider) ProvideConnectionReturns(result1 *yagnats.Connection, result2 error) {
	fake.ProvideConnectionStub = nil
	fake.provideConnectionReturns = struct {
		result1 *yagnats.Connection
		result2 error
	}{result1, result2}
}

func (fake *FakeConnectionProvider) ProvideConnectionReturnsOnCall(i int, result1 *yagnats.Connection, result2 error) {
	fake.ProvideConnectionStub = nil
	if fake.provideConnectionReturnsOnCall == nil {
		fake.provideConnectionReturnsOnCall = make(map[int]struct {
			result1 *yagnats.Connection
			result2 error
		})
	}
	fake.provideConnectionReturnsOnCall[i] = struct {
		result1 *yagnats.Connection
		result2 error
	}{result1, result2}
}

func (fake *FakeConnectionProvider) Invocations() map[string][][]interface{} {
	fake.invocationsMutex.RLock()
	defer fake.invocationsMutex.RUnlock()
	fake.provideConnectionMutex.RLock()
	defer fake.provideConnectionMutex.RUnlock()
	return fake.invocations
}

func (fake *FakeConnectionProvider) 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 _ yagnats.ConnectionProvider = new(FakeConnectionProvider)
