package mocks

// Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.

//go:generate minimock -i git.dmitriygnatenko.ru/dima/homethings/internal/interfaces.PlaceThingRepository -o ./mocks/place_thing_repository_minimock.go -n PlaceThingRepositoryMock

import (
	"context"
	"database/sql"
	"sync"
	mm_atomic "sync/atomic"
	mm_time "time"

	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
	"github.com/gojuno/minimock/v3"
)

// PlaceThingRepositoryMock implements interfaces.PlaceThingRepository
type PlaceThingRepositoryMock struct {
	t minimock.Tester

	funcAdd          func(ctx context.Context, req models.AddPlaceThingRequest, tx *sql.Tx) (err error)
	inspectFuncAdd   func(ctx context.Context, req models.AddPlaceThingRequest, tx *sql.Tx)
	afterAddCounter  uint64
	beforeAddCounter uint64
	AddMock          mPlaceThingRepositoryMockAdd

	funcDeleteThing          func(ctx context.Context, thingID int, tx *sql.Tx) (err error)
	inspectFuncDeleteThing   func(ctx context.Context, thingID int, tx *sql.Tx)
	afterDeleteThingCounter  uint64
	beforeDeleteThingCounter uint64
	DeleteThingMock          mPlaceThingRepositoryMockDeleteThing

	funcGetByThingID          func(ctx context.Context, thingID int) (pp1 *models.PlaceThing, err error)
	inspectFuncGetByThingID   func(ctx context.Context, thingID int)
	afterGetByThingIDCounter  uint64
	beforeGetByThingIDCounter uint64
	GetByThingIDMock          mPlaceThingRepositoryMockGetByThingID

	funcUpdatePlace          func(ctx context.Context, req models.UpdatePlaceThingRequest, tx *sql.Tx) (err error)
	inspectFuncUpdatePlace   func(ctx context.Context, req models.UpdatePlaceThingRequest, tx *sql.Tx)
	afterUpdatePlaceCounter  uint64
	beforeUpdatePlaceCounter uint64
	UpdatePlaceMock          mPlaceThingRepositoryMockUpdatePlace
}

// NewPlaceThingRepositoryMock returns a mock for interfaces.PlaceThingRepository
func NewPlaceThingRepositoryMock(t minimock.Tester) *PlaceThingRepositoryMock {
	m := &PlaceThingRepositoryMock{t: t}
	if controller, ok := t.(minimock.MockController); ok {
		controller.RegisterMocker(m)
	}

	m.AddMock = mPlaceThingRepositoryMockAdd{mock: m}
	m.AddMock.callArgs = []*PlaceThingRepositoryMockAddParams{}

	m.DeleteThingMock = mPlaceThingRepositoryMockDeleteThing{mock: m}
	m.DeleteThingMock.callArgs = []*PlaceThingRepositoryMockDeleteThingParams{}

	m.GetByThingIDMock = mPlaceThingRepositoryMockGetByThingID{mock: m}
	m.GetByThingIDMock.callArgs = []*PlaceThingRepositoryMockGetByThingIDParams{}

	m.UpdatePlaceMock = mPlaceThingRepositoryMockUpdatePlace{mock: m}
	m.UpdatePlaceMock.callArgs = []*PlaceThingRepositoryMockUpdatePlaceParams{}

	return m
}

type mPlaceThingRepositoryMockAdd struct {
	mock               *PlaceThingRepositoryMock
	defaultExpectation *PlaceThingRepositoryMockAddExpectation
	expectations       []*PlaceThingRepositoryMockAddExpectation

	callArgs []*PlaceThingRepositoryMockAddParams
	mutex    sync.RWMutex
}

// PlaceThingRepositoryMockAddExpectation specifies expectation struct of the PlaceThingRepository.Add
type PlaceThingRepositoryMockAddExpectation struct {
	mock    *PlaceThingRepositoryMock
	params  *PlaceThingRepositoryMockAddParams
	results *PlaceThingRepositoryMockAddResults
	Counter uint64
}

// PlaceThingRepositoryMockAddParams contains parameters of the PlaceThingRepository.Add
type PlaceThingRepositoryMockAddParams struct {
	ctx context.Context
	req models.AddPlaceThingRequest
	tx  *sql.Tx
}

// PlaceThingRepositoryMockAddResults contains results of the PlaceThingRepository.Add
type PlaceThingRepositoryMockAddResults struct {
	err error
}

// Expect sets up expected params for PlaceThingRepository.Add
func (mmAdd *mPlaceThingRepositoryMockAdd) Expect(ctx context.Context, req models.AddPlaceThingRequest, tx *sql.Tx) *mPlaceThingRepositoryMockAdd {
	if mmAdd.mock.funcAdd != nil {
		mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Set")
	}

	if mmAdd.defaultExpectation == nil {
		mmAdd.defaultExpectation = &PlaceThingRepositoryMockAddExpectation{}
	}

	mmAdd.defaultExpectation.params = &PlaceThingRepositoryMockAddParams{ctx, req, tx}
	for _, e := range mmAdd.expectations {
		if minimock.Equal(e.params, mmAdd.defaultExpectation.params) {
			mmAdd.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmAdd.defaultExpectation.params)
		}
	}

	return mmAdd
}

// Inspect accepts an inspector function that has same arguments as the PlaceThingRepository.Add
func (mmAdd *mPlaceThingRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddPlaceThingRequest, tx *sql.Tx)) *mPlaceThingRepositoryMockAdd {
	if mmAdd.mock.inspectFuncAdd != nil {
		mmAdd.mock.t.Fatalf("Inspect function is already set for PlaceThingRepositoryMock.Add")
	}

	mmAdd.mock.inspectFuncAdd = f

	return mmAdd
}

// Return sets up results that will be returned by PlaceThingRepository.Add
func (mmAdd *mPlaceThingRepositoryMockAdd) Return(err error) *PlaceThingRepositoryMock {
	if mmAdd.mock.funcAdd != nil {
		mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Set")
	}

	if mmAdd.defaultExpectation == nil {
		mmAdd.defaultExpectation = &PlaceThingRepositoryMockAddExpectation{mock: mmAdd.mock}
	}
	mmAdd.defaultExpectation.results = &PlaceThingRepositoryMockAddResults{err}
	return mmAdd.mock
}

// Set uses given function f to mock the PlaceThingRepository.Add method
func (mmAdd *mPlaceThingRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddPlaceThingRequest, tx *sql.Tx) (err error)) *PlaceThingRepositoryMock {
	if mmAdd.defaultExpectation != nil {
		mmAdd.mock.t.Fatalf("Default expectation is already set for the PlaceThingRepository.Add method")
	}

	if len(mmAdd.expectations) > 0 {
		mmAdd.mock.t.Fatalf("Some expectations are already set for the PlaceThingRepository.Add method")
	}

	mmAdd.mock.funcAdd = f
	return mmAdd.mock
}

// When sets expectation for the PlaceThingRepository.Add which will trigger the result defined by the following
// Then helper
func (mmAdd *mPlaceThingRepositoryMockAdd) When(ctx context.Context, req models.AddPlaceThingRequest, tx *sql.Tx) *PlaceThingRepositoryMockAddExpectation {
	if mmAdd.mock.funcAdd != nil {
		mmAdd.mock.t.Fatalf("PlaceThingRepositoryMock.Add mock is already set by Set")
	}

	expectation := &PlaceThingRepositoryMockAddExpectation{
		mock:   mmAdd.mock,
		params: &PlaceThingRepositoryMockAddParams{ctx, req, tx},
	}
	mmAdd.expectations = append(mmAdd.expectations, expectation)
	return expectation
}

// Then sets up PlaceThingRepository.Add return parameters for the expectation previously defined by the When method
func (e *PlaceThingRepositoryMockAddExpectation) Then(err error) *PlaceThingRepositoryMock {
	e.results = &PlaceThingRepositoryMockAddResults{err}
	return e.mock
}

// Add implements interfaces.PlaceThingRepository
func (mmAdd *PlaceThingRepositoryMock) Add(ctx context.Context, req models.AddPlaceThingRequest, tx *sql.Tx) (err error) {
	mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
	defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)

	if mmAdd.inspectFuncAdd != nil {
		mmAdd.inspectFuncAdd(ctx, req, tx)
	}

	mm_params := &PlaceThingRepositoryMockAddParams{ctx, req, tx}

	// Record call args
	mmAdd.AddMock.mutex.Lock()
	mmAdd.AddMock.callArgs = append(mmAdd.AddMock.callArgs, mm_params)
	mmAdd.AddMock.mutex.Unlock()

	for _, e := range mmAdd.AddMock.expectations {
		if minimock.Equal(e.params, mm_params) {
			mm_atomic.AddUint64(&e.Counter, 1)
			return e.results.err
		}
	}

	if mmAdd.AddMock.defaultExpectation != nil {
		mm_atomic.AddUint64(&mmAdd.AddMock.defaultExpectation.Counter, 1)
		mm_want := mmAdd.AddMock.defaultExpectation.params
		mm_got := PlaceThingRepositoryMockAddParams{ctx, req, tx}
		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
			mmAdd.t.Errorf("PlaceThingRepositoryMock.Add got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
		}

		mm_results := mmAdd.AddMock.defaultExpectation.results
		if mm_results == nil {
			mmAdd.t.Fatal("No results are set for the PlaceThingRepositoryMock.Add")
		}
		return (*mm_results).err
	}
	if mmAdd.funcAdd != nil {
		return mmAdd.funcAdd(ctx, req, tx)
	}
	mmAdd.t.Fatalf("Unexpected call to PlaceThingRepositoryMock.Add. %v %v %v", ctx, req, tx)
	return
}

// AddAfterCounter returns a count of finished PlaceThingRepositoryMock.Add invocations
func (mmAdd *PlaceThingRepositoryMock) AddAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
}

// AddBeforeCounter returns a count of PlaceThingRepositoryMock.Add invocations
func (mmAdd *PlaceThingRepositoryMock) AddBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
}

// Calls returns a list of arguments used in each call to PlaceThingRepositoryMock.Add.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmAdd *mPlaceThingRepositoryMockAdd) Calls() []*PlaceThingRepositoryMockAddParams {
	mmAdd.mutex.RLock()

	argCopy := make([]*PlaceThingRepositoryMockAddParams, len(mmAdd.callArgs))
	copy(argCopy, mmAdd.callArgs)

	mmAdd.mutex.RUnlock()

	return argCopy
}

// MinimockAddDone returns true if the count of the Add invocations corresponds
// the number of defined expectations
func (m *PlaceThingRepositoryMock) MinimockAddDone() bool {
	for _, e := range m.AddMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			return false
		}
	}

	// if default expectation was set then invocations count should be greater than zero
	if m.AddMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
		return false
	}
	// if func was set then invocations count should be greater than zero
	if m.funcAdd != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
		return false
	}
	return true
}

// MinimockAddInspect logs each unmet expectation
func (m *PlaceThingRepositoryMock) MinimockAddInspect() {
	for _, e := range m.AddMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			m.t.Errorf("Expected call to PlaceThingRepositoryMock.Add with params: %#v", *e.params)
		}
	}

	// if default expectation was set then invocations count should be greater than zero
	if m.AddMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
		if m.AddMock.defaultExpectation.params == nil {
			m.t.Error("Expected call to PlaceThingRepositoryMock.Add")
		} else {
			m.t.Errorf("Expected call to PlaceThingRepositoryMock.Add with params: %#v", *m.AddMock.defaultExpectation.params)
		}
	}
	// if func was set then invocations count should be greater than zero
	if m.funcAdd != nil && mm_atomic.LoadUint64(&m.afterAddCounter) < 1 {
		m.t.Error("Expected call to PlaceThingRepositoryMock.Add")
	}
}

type mPlaceThingRepositoryMockDeleteThing struct {
	mock               *PlaceThingRepositoryMock
	defaultExpectation *PlaceThingRepositoryMockDeleteThingExpectation
	expectations       []*PlaceThingRepositoryMockDeleteThingExpectation

	callArgs []*PlaceThingRepositoryMockDeleteThingParams
	mutex    sync.RWMutex
}

// PlaceThingRepositoryMockDeleteThingExpectation specifies expectation struct of the PlaceThingRepository.DeleteThing
type PlaceThingRepositoryMockDeleteThingExpectation struct {
	mock    *PlaceThingRepositoryMock
	params  *PlaceThingRepositoryMockDeleteThingParams
	results *PlaceThingRepositoryMockDeleteThingResults
	Counter uint64
}

// PlaceThingRepositoryMockDeleteThingParams contains parameters of the PlaceThingRepository.DeleteThing
type PlaceThingRepositoryMockDeleteThingParams struct {
	ctx     context.Context
	thingID int
	tx      *sql.Tx
}

// PlaceThingRepositoryMockDeleteThingResults contains results of the PlaceThingRepository.DeleteThing
type PlaceThingRepositoryMockDeleteThingResults struct {
	err error
}

// Expect sets up expected params for PlaceThingRepository.DeleteThing
func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Expect(ctx context.Context, thingID int, tx *sql.Tx) *mPlaceThingRepositoryMockDeleteThing {
	if mmDeleteThing.mock.funcDeleteThing != nil {
		mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Set")
	}

	if mmDeleteThing.defaultExpectation == nil {
		mmDeleteThing.defaultExpectation = &PlaceThingRepositoryMockDeleteThingExpectation{}
	}

	mmDeleteThing.defaultExpectation.params = &PlaceThingRepositoryMockDeleteThingParams{ctx, thingID, tx}
	for _, e := range mmDeleteThing.expectations {
		if minimock.Equal(e.params, mmDeleteThing.defaultExpectation.params) {
			mmDeleteThing.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDeleteThing.defaultExpectation.params)
		}
	}

	return mmDeleteThing
}

// Inspect accepts an inspector function that has same arguments as the PlaceThingRepository.DeleteThing
func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Inspect(f func(ctx context.Context, thingID int, tx *sql.Tx)) *mPlaceThingRepositoryMockDeleteThing {
	if mmDeleteThing.mock.inspectFuncDeleteThing != nil {
		mmDeleteThing.mock.t.Fatalf("Inspect function is already set for PlaceThingRepositoryMock.DeleteThing")
	}

	mmDeleteThing.mock.inspectFuncDeleteThing = f

	return mmDeleteThing
}

// Return sets up results that will be returned by PlaceThingRepository.DeleteThing
func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Return(err error) *PlaceThingRepositoryMock {
	if mmDeleteThing.mock.funcDeleteThing != nil {
		mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Set")
	}

	if mmDeleteThing.defaultExpectation == nil {
		mmDeleteThing.defaultExpectation = &PlaceThingRepositoryMockDeleteThingExpectation{mock: mmDeleteThing.mock}
	}
	mmDeleteThing.defaultExpectation.results = &PlaceThingRepositoryMockDeleteThingResults{err}
	return mmDeleteThing.mock
}

// Set uses given function f to mock the PlaceThingRepository.DeleteThing method
func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Set(f func(ctx context.Context, thingID int, tx *sql.Tx) (err error)) *PlaceThingRepositoryMock {
	if mmDeleteThing.defaultExpectation != nil {
		mmDeleteThing.mock.t.Fatalf("Default expectation is already set for the PlaceThingRepository.DeleteThing method")
	}

	if len(mmDeleteThing.expectations) > 0 {
		mmDeleteThing.mock.t.Fatalf("Some expectations are already set for the PlaceThingRepository.DeleteThing method")
	}

	mmDeleteThing.mock.funcDeleteThing = f
	return mmDeleteThing.mock
}

// When sets expectation for the PlaceThingRepository.DeleteThing which will trigger the result defined by the following
// Then helper
func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) When(ctx context.Context, thingID int, tx *sql.Tx) *PlaceThingRepositoryMockDeleteThingExpectation {
	if mmDeleteThing.mock.funcDeleteThing != nil {
		mmDeleteThing.mock.t.Fatalf("PlaceThingRepositoryMock.DeleteThing mock is already set by Set")
	}

	expectation := &PlaceThingRepositoryMockDeleteThingExpectation{
		mock:   mmDeleteThing.mock,
		params: &PlaceThingRepositoryMockDeleteThingParams{ctx, thingID, tx},
	}
	mmDeleteThing.expectations = append(mmDeleteThing.expectations, expectation)
	return expectation
}

// Then sets up PlaceThingRepository.DeleteThing return parameters for the expectation previously defined by the When method
func (e *PlaceThingRepositoryMockDeleteThingExpectation) Then(err error) *PlaceThingRepositoryMock {
	e.results = &PlaceThingRepositoryMockDeleteThingResults{err}
	return e.mock
}

// DeleteThing implements interfaces.PlaceThingRepository
func (mmDeleteThing *PlaceThingRepositoryMock) DeleteThing(ctx context.Context, thingID int, tx *sql.Tx) (err error) {
	mm_atomic.AddUint64(&mmDeleteThing.beforeDeleteThingCounter, 1)
	defer mm_atomic.AddUint64(&mmDeleteThing.afterDeleteThingCounter, 1)

	if mmDeleteThing.inspectFuncDeleteThing != nil {
		mmDeleteThing.inspectFuncDeleteThing(ctx, thingID, tx)
	}

	mm_params := &PlaceThingRepositoryMockDeleteThingParams{ctx, thingID, tx}

	// Record call args
	mmDeleteThing.DeleteThingMock.mutex.Lock()
	mmDeleteThing.DeleteThingMock.callArgs = append(mmDeleteThing.DeleteThingMock.callArgs, mm_params)
	mmDeleteThing.DeleteThingMock.mutex.Unlock()

	for _, e := range mmDeleteThing.DeleteThingMock.expectations {
		if minimock.Equal(e.params, mm_params) {
			mm_atomic.AddUint64(&e.Counter, 1)
			return e.results.err
		}
	}

	if mmDeleteThing.DeleteThingMock.defaultExpectation != nil {
		mm_atomic.AddUint64(&mmDeleteThing.DeleteThingMock.defaultExpectation.Counter, 1)
		mm_want := mmDeleteThing.DeleteThingMock.defaultExpectation.params
		mm_got := PlaceThingRepositoryMockDeleteThingParams{ctx, thingID, tx}
		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
			mmDeleteThing.t.Errorf("PlaceThingRepositoryMock.DeleteThing got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
		}

		mm_results := mmDeleteThing.DeleteThingMock.defaultExpectation.results
		if mm_results == nil {
			mmDeleteThing.t.Fatal("No results are set for the PlaceThingRepositoryMock.DeleteThing")
		}
		return (*mm_results).err
	}
	if mmDeleteThing.funcDeleteThing != nil {
		return mmDeleteThing.funcDeleteThing(ctx, thingID, tx)
	}
	mmDeleteThing.t.Fatalf("Unexpected call to PlaceThingRepositoryMock.DeleteThing. %v %v %v", ctx, thingID, tx)
	return
}

// DeleteThingAfterCounter returns a count of finished PlaceThingRepositoryMock.DeleteThing invocations
func (mmDeleteThing *PlaceThingRepositoryMock) DeleteThingAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmDeleteThing.afterDeleteThingCounter)
}

// DeleteThingBeforeCounter returns a count of PlaceThingRepositoryMock.DeleteThing invocations
func (mmDeleteThing *PlaceThingRepositoryMock) DeleteThingBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmDeleteThing.beforeDeleteThingCounter)
}

// Calls returns a list of arguments used in each call to PlaceThingRepositoryMock.DeleteThing.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmDeleteThing *mPlaceThingRepositoryMockDeleteThing) Calls() []*PlaceThingRepositoryMockDeleteThingParams {
	mmDeleteThing.mutex.RLock()

	argCopy := make([]*PlaceThingRepositoryMockDeleteThingParams, len(mmDeleteThing.callArgs))
	copy(argCopy, mmDeleteThing.callArgs)

	mmDeleteThing.mutex.RUnlock()

	return argCopy
}

// MinimockDeleteThingDone returns true if the count of the DeleteThing invocations corresponds
// the number of defined expectations
func (m *PlaceThingRepositoryMock) MinimockDeleteThingDone() bool {
	for _, e := range m.DeleteThingMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			return false
		}
	}

	// if default expectation was set then invocations count should be greater than zero
	if m.DeleteThingMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterDeleteThingCounter) < 1 {
		return false
	}
	// if func was set then invocations count should be greater than zero
	if m.funcDeleteThing != nil && mm_atomic.LoadUint64(&m.afterDeleteThingCounter) < 1 {
		return false
	}
	return true
}

// MinimockDeleteThingInspect logs each unmet expectation
func (m *PlaceThingRepositoryMock) MinimockDeleteThingInspect() {
	for _, e := range m.DeleteThingMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			m.t.Errorf("Expected call to PlaceThingRepositoryMock.DeleteThing with params: %#v", *e.params)
		}
	}

	// if default expectation was set then invocations count should be greater than zero
	if m.DeleteThingMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterDeleteThingCounter) < 1 {
		if m.DeleteThingMock.defaultExpectation.params == nil {
			m.t.Error("Expected call to PlaceThingRepositoryMock.DeleteThing")
		} else {
			m.t.Errorf("Expected call to PlaceThingRepositoryMock.DeleteThing with params: %#v", *m.DeleteThingMock.defaultExpectation.params)
		}
	}
	// if func was set then invocations count should be greater than zero
	if m.funcDeleteThing != nil && mm_atomic.LoadUint64(&m.afterDeleteThingCounter) < 1 {
		m.t.Error("Expected call to PlaceThingRepositoryMock.DeleteThing")
	}
}

type mPlaceThingRepositoryMockGetByThingID struct {
	mock               *PlaceThingRepositoryMock
	defaultExpectation *PlaceThingRepositoryMockGetByThingIDExpectation
	expectations       []*PlaceThingRepositoryMockGetByThingIDExpectation

	callArgs []*PlaceThingRepositoryMockGetByThingIDParams
	mutex    sync.RWMutex
}

// PlaceThingRepositoryMockGetByThingIDExpectation specifies expectation struct of the PlaceThingRepository.GetByThingID
type PlaceThingRepositoryMockGetByThingIDExpectation struct {
	mock    *PlaceThingRepositoryMock
	params  *PlaceThingRepositoryMockGetByThingIDParams
	results *PlaceThingRepositoryMockGetByThingIDResults
	Counter uint64
}

// PlaceThingRepositoryMockGetByThingIDParams contains parameters of the PlaceThingRepository.GetByThingID
type PlaceThingRepositoryMockGetByThingIDParams struct {
	ctx     context.Context
	thingID int
}

// PlaceThingRepositoryMockGetByThingIDResults contains results of the PlaceThingRepository.GetByThingID
type PlaceThingRepositoryMockGetByThingIDResults struct {
	pp1 *models.PlaceThing
	err error
}

// Expect sets up expected params for PlaceThingRepository.GetByThingID
func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Expect(ctx context.Context, thingID int) *mPlaceThingRepositoryMockGetByThingID {
	if mmGetByThingID.mock.funcGetByThingID != nil {
		mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by Set")
	}

	if mmGetByThingID.defaultExpectation == nil {
		mmGetByThingID.defaultExpectation = &PlaceThingRepositoryMockGetByThingIDExpectation{}
	}

	mmGetByThingID.defaultExpectation.params = &PlaceThingRepositoryMockGetByThingIDParams{ctx, thingID}
	for _, e := range mmGetByThingID.expectations {
		if minimock.Equal(e.params, mmGetByThingID.defaultExpectation.params) {
			mmGetByThingID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByThingID.defaultExpectation.params)
		}
	}

	return mmGetByThingID
}

// Inspect accepts an inspector function that has same arguments as the PlaceThingRepository.GetByThingID
func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Inspect(f func(ctx context.Context, thingID int)) *mPlaceThingRepositoryMockGetByThingID {
	if mmGetByThingID.mock.inspectFuncGetByThingID != nil {
		mmGetByThingID.mock.t.Fatalf("Inspect function is already set for PlaceThingRepositoryMock.GetByThingID")
	}

	mmGetByThingID.mock.inspectFuncGetByThingID = f

	return mmGetByThingID
}

// Return sets up results that will be returned by PlaceThingRepository.GetByThingID
func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Return(pp1 *models.PlaceThing, err error) *PlaceThingRepositoryMock {
	if mmGetByThingID.mock.funcGetByThingID != nil {
		mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by Set")
	}

	if mmGetByThingID.defaultExpectation == nil {
		mmGetByThingID.defaultExpectation = &PlaceThingRepositoryMockGetByThingIDExpectation{mock: mmGetByThingID.mock}
	}
	mmGetByThingID.defaultExpectation.results = &PlaceThingRepositoryMockGetByThingIDResults{pp1, err}
	return mmGetByThingID.mock
}

// Set uses given function f to mock the PlaceThingRepository.GetByThingID method
func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Set(f func(ctx context.Context, thingID int) (pp1 *models.PlaceThing, err error)) *PlaceThingRepositoryMock {
	if mmGetByThingID.defaultExpectation != nil {
		mmGetByThingID.mock.t.Fatalf("Default expectation is already set for the PlaceThingRepository.GetByThingID method")
	}

	if len(mmGetByThingID.expectations) > 0 {
		mmGetByThingID.mock.t.Fatalf("Some expectations are already set for the PlaceThingRepository.GetByThingID method")
	}

	mmGetByThingID.mock.funcGetByThingID = f
	return mmGetByThingID.mock
}

// When sets expectation for the PlaceThingRepository.GetByThingID which will trigger the result defined by the following
// Then helper
func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) When(ctx context.Context, thingID int) *PlaceThingRepositoryMockGetByThingIDExpectation {
	if mmGetByThingID.mock.funcGetByThingID != nil {
		mmGetByThingID.mock.t.Fatalf("PlaceThingRepositoryMock.GetByThingID mock is already set by Set")
	}

	expectation := &PlaceThingRepositoryMockGetByThingIDExpectation{
		mock:   mmGetByThingID.mock,
		params: &PlaceThingRepositoryMockGetByThingIDParams{ctx, thingID},
	}
	mmGetByThingID.expectations = append(mmGetByThingID.expectations, expectation)
	return expectation
}

// Then sets up PlaceThingRepository.GetByThingID return parameters for the expectation previously defined by the When method
func (e *PlaceThingRepositoryMockGetByThingIDExpectation) Then(pp1 *models.PlaceThing, err error) *PlaceThingRepositoryMock {
	e.results = &PlaceThingRepositoryMockGetByThingIDResults{pp1, err}
	return e.mock
}

// GetByThingID implements interfaces.PlaceThingRepository
func (mmGetByThingID *PlaceThingRepositoryMock) GetByThingID(ctx context.Context, thingID int) (pp1 *models.PlaceThing, err error) {
	mm_atomic.AddUint64(&mmGetByThingID.beforeGetByThingIDCounter, 1)
	defer mm_atomic.AddUint64(&mmGetByThingID.afterGetByThingIDCounter, 1)

	if mmGetByThingID.inspectFuncGetByThingID != nil {
		mmGetByThingID.inspectFuncGetByThingID(ctx, thingID)
	}

	mm_params := &PlaceThingRepositoryMockGetByThingIDParams{ctx, thingID}

	// Record call args
	mmGetByThingID.GetByThingIDMock.mutex.Lock()
	mmGetByThingID.GetByThingIDMock.callArgs = append(mmGetByThingID.GetByThingIDMock.callArgs, mm_params)
	mmGetByThingID.GetByThingIDMock.mutex.Unlock()

	for _, e := range mmGetByThingID.GetByThingIDMock.expectations {
		if minimock.Equal(e.params, mm_params) {
			mm_atomic.AddUint64(&e.Counter, 1)
			return e.results.pp1, e.results.err
		}
	}

	if mmGetByThingID.GetByThingIDMock.defaultExpectation != nil {
		mm_atomic.AddUint64(&mmGetByThingID.GetByThingIDMock.defaultExpectation.Counter, 1)
		mm_want := mmGetByThingID.GetByThingIDMock.defaultExpectation.params
		mm_got := PlaceThingRepositoryMockGetByThingIDParams{ctx, thingID}
		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
			mmGetByThingID.t.Errorf("PlaceThingRepositoryMock.GetByThingID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
		}

		mm_results := mmGetByThingID.GetByThingIDMock.defaultExpectation.results
		if mm_results == nil {
			mmGetByThingID.t.Fatal("No results are set for the PlaceThingRepositoryMock.GetByThingID")
		}
		return (*mm_results).pp1, (*mm_results).err
	}
	if mmGetByThingID.funcGetByThingID != nil {
		return mmGetByThingID.funcGetByThingID(ctx, thingID)
	}
	mmGetByThingID.t.Fatalf("Unexpected call to PlaceThingRepositoryMock.GetByThingID. %v %v", ctx, thingID)
	return
}

// GetByThingIDAfterCounter returns a count of finished PlaceThingRepositoryMock.GetByThingID invocations
func (mmGetByThingID *PlaceThingRepositoryMock) GetByThingIDAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmGetByThingID.afterGetByThingIDCounter)
}

// GetByThingIDBeforeCounter returns a count of PlaceThingRepositoryMock.GetByThingID invocations
func (mmGetByThingID *PlaceThingRepositoryMock) GetByThingIDBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmGetByThingID.beforeGetByThingIDCounter)
}

// Calls returns a list of arguments used in each call to PlaceThingRepositoryMock.GetByThingID.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmGetByThingID *mPlaceThingRepositoryMockGetByThingID) Calls() []*PlaceThingRepositoryMockGetByThingIDParams {
	mmGetByThingID.mutex.RLock()

	argCopy := make([]*PlaceThingRepositoryMockGetByThingIDParams, len(mmGetByThingID.callArgs))
	copy(argCopy, mmGetByThingID.callArgs)

	mmGetByThingID.mutex.RUnlock()

	return argCopy
}

// MinimockGetByThingIDDone returns true if the count of the GetByThingID invocations corresponds
// the number of defined expectations
func (m *PlaceThingRepositoryMock) MinimockGetByThingIDDone() bool {
	for _, e := range m.GetByThingIDMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			return false
		}
	}

	// if default expectation was set then invocations count should be greater than zero
	if m.GetByThingIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByThingIDCounter) < 1 {
		return false
	}
	// if func was set then invocations count should be greater than zero
	if m.funcGetByThingID != nil && mm_atomic.LoadUint64(&m.afterGetByThingIDCounter) < 1 {
		return false
	}
	return true
}

// MinimockGetByThingIDInspect logs each unmet expectation
func (m *PlaceThingRepositoryMock) MinimockGetByThingIDInspect() {
	for _, e := range m.GetByThingIDMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			m.t.Errorf("Expected call to PlaceThingRepositoryMock.GetByThingID with params: %#v", *e.params)
		}
	}

	// if default expectation was set then invocations count should be greater than zero
	if m.GetByThingIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetByThingIDCounter) < 1 {
		if m.GetByThingIDMock.defaultExpectation.params == nil {
			m.t.Error("Expected call to PlaceThingRepositoryMock.GetByThingID")
		} else {
			m.t.Errorf("Expected call to PlaceThingRepositoryMock.GetByThingID with params: %#v", *m.GetByThingIDMock.defaultExpectation.params)
		}
	}
	// if func was set then invocations count should be greater than zero
	if m.funcGetByThingID != nil && mm_atomic.LoadUint64(&m.afterGetByThingIDCounter) < 1 {
		m.t.Error("Expected call to PlaceThingRepositoryMock.GetByThingID")
	}
}

type mPlaceThingRepositoryMockUpdatePlace struct {
	mock               *PlaceThingRepositoryMock
	defaultExpectation *PlaceThingRepositoryMockUpdatePlaceExpectation
	expectations       []*PlaceThingRepositoryMockUpdatePlaceExpectation

	callArgs []*PlaceThingRepositoryMockUpdatePlaceParams
	mutex    sync.RWMutex
}

// PlaceThingRepositoryMockUpdatePlaceExpectation specifies expectation struct of the PlaceThingRepository.UpdatePlace
type PlaceThingRepositoryMockUpdatePlaceExpectation struct {
	mock    *PlaceThingRepositoryMock
	params  *PlaceThingRepositoryMockUpdatePlaceParams
	results *PlaceThingRepositoryMockUpdatePlaceResults
	Counter uint64
}

// PlaceThingRepositoryMockUpdatePlaceParams contains parameters of the PlaceThingRepository.UpdatePlace
type PlaceThingRepositoryMockUpdatePlaceParams struct {
	ctx context.Context
	req models.UpdatePlaceThingRequest
	tx  *sql.Tx
}

// PlaceThingRepositoryMockUpdatePlaceResults contains results of the PlaceThingRepository.UpdatePlace
type PlaceThingRepositoryMockUpdatePlaceResults struct {
	err error
}

// Expect sets up expected params for PlaceThingRepository.UpdatePlace
func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Expect(ctx context.Context, req models.UpdatePlaceThingRequest, tx *sql.Tx) *mPlaceThingRepositoryMockUpdatePlace {
	if mmUpdatePlace.mock.funcUpdatePlace != nil {
		mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Set")
	}

	if mmUpdatePlace.defaultExpectation == nil {
		mmUpdatePlace.defaultExpectation = &PlaceThingRepositoryMockUpdatePlaceExpectation{}
	}

	mmUpdatePlace.defaultExpectation.params = &PlaceThingRepositoryMockUpdatePlaceParams{ctx, req, tx}
	for _, e := range mmUpdatePlace.expectations {
		if minimock.Equal(e.params, mmUpdatePlace.defaultExpectation.params) {
			mmUpdatePlace.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdatePlace.defaultExpectation.params)
		}
	}

	return mmUpdatePlace
}

// Inspect accepts an inspector function that has same arguments as the PlaceThingRepository.UpdatePlace
func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Inspect(f func(ctx context.Context, req models.UpdatePlaceThingRequest, tx *sql.Tx)) *mPlaceThingRepositoryMockUpdatePlace {
	if mmUpdatePlace.mock.inspectFuncUpdatePlace != nil {
		mmUpdatePlace.mock.t.Fatalf("Inspect function is already set for PlaceThingRepositoryMock.UpdatePlace")
	}

	mmUpdatePlace.mock.inspectFuncUpdatePlace = f

	return mmUpdatePlace
}

// Return sets up results that will be returned by PlaceThingRepository.UpdatePlace
func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Return(err error) *PlaceThingRepositoryMock {
	if mmUpdatePlace.mock.funcUpdatePlace != nil {
		mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Set")
	}

	if mmUpdatePlace.defaultExpectation == nil {
		mmUpdatePlace.defaultExpectation = &PlaceThingRepositoryMockUpdatePlaceExpectation{mock: mmUpdatePlace.mock}
	}
	mmUpdatePlace.defaultExpectation.results = &PlaceThingRepositoryMockUpdatePlaceResults{err}
	return mmUpdatePlace.mock
}

// Set uses given function f to mock the PlaceThingRepository.UpdatePlace method
func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Set(f func(ctx context.Context, req models.UpdatePlaceThingRequest, tx *sql.Tx) (err error)) *PlaceThingRepositoryMock {
	if mmUpdatePlace.defaultExpectation != nil {
		mmUpdatePlace.mock.t.Fatalf("Default expectation is already set for the PlaceThingRepository.UpdatePlace method")
	}

	if len(mmUpdatePlace.expectations) > 0 {
		mmUpdatePlace.mock.t.Fatalf("Some expectations are already set for the PlaceThingRepository.UpdatePlace method")
	}

	mmUpdatePlace.mock.funcUpdatePlace = f
	return mmUpdatePlace.mock
}

// When sets expectation for the PlaceThingRepository.UpdatePlace which will trigger the result defined by the following
// Then helper
func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) When(ctx context.Context, req models.UpdatePlaceThingRequest, tx *sql.Tx) *PlaceThingRepositoryMockUpdatePlaceExpectation {
	if mmUpdatePlace.mock.funcUpdatePlace != nil {
		mmUpdatePlace.mock.t.Fatalf("PlaceThingRepositoryMock.UpdatePlace mock is already set by Set")
	}

	expectation := &PlaceThingRepositoryMockUpdatePlaceExpectation{
		mock:   mmUpdatePlace.mock,
		params: &PlaceThingRepositoryMockUpdatePlaceParams{ctx, req, tx},
	}
	mmUpdatePlace.expectations = append(mmUpdatePlace.expectations, expectation)
	return expectation
}

// Then sets up PlaceThingRepository.UpdatePlace return parameters for the expectation previously defined by the When method
func (e *PlaceThingRepositoryMockUpdatePlaceExpectation) Then(err error) *PlaceThingRepositoryMock {
	e.results = &PlaceThingRepositoryMockUpdatePlaceResults{err}
	return e.mock
}

// UpdatePlace implements interfaces.PlaceThingRepository
func (mmUpdatePlace *PlaceThingRepositoryMock) UpdatePlace(ctx context.Context, req models.UpdatePlaceThingRequest, tx *sql.Tx) (err error) {
	mm_atomic.AddUint64(&mmUpdatePlace.beforeUpdatePlaceCounter, 1)
	defer mm_atomic.AddUint64(&mmUpdatePlace.afterUpdatePlaceCounter, 1)

	if mmUpdatePlace.inspectFuncUpdatePlace != nil {
		mmUpdatePlace.inspectFuncUpdatePlace(ctx, req, tx)
	}

	mm_params := &PlaceThingRepositoryMockUpdatePlaceParams{ctx, req, tx}

	// Record call args
	mmUpdatePlace.UpdatePlaceMock.mutex.Lock()
	mmUpdatePlace.UpdatePlaceMock.callArgs = append(mmUpdatePlace.UpdatePlaceMock.callArgs, mm_params)
	mmUpdatePlace.UpdatePlaceMock.mutex.Unlock()

	for _, e := range mmUpdatePlace.UpdatePlaceMock.expectations {
		if minimock.Equal(e.params, mm_params) {
			mm_atomic.AddUint64(&e.Counter, 1)
			return e.results.err
		}
	}

	if mmUpdatePlace.UpdatePlaceMock.defaultExpectation != nil {
		mm_atomic.AddUint64(&mmUpdatePlace.UpdatePlaceMock.defaultExpectation.Counter, 1)
		mm_want := mmUpdatePlace.UpdatePlaceMock.defaultExpectation.params
		mm_got := PlaceThingRepositoryMockUpdatePlaceParams{ctx, req, tx}
		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
			mmUpdatePlace.t.Errorf("PlaceThingRepositoryMock.UpdatePlace got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
		}

		mm_results := mmUpdatePlace.UpdatePlaceMock.defaultExpectation.results
		if mm_results == nil {
			mmUpdatePlace.t.Fatal("No results are set for the PlaceThingRepositoryMock.UpdatePlace")
		}
		return (*mm_results).err
	}
	if mmUpdatePlace.funcUpdatePlace != nil {
		return mmUpdatePlace.funcUpdatePlace(ctx, req, tx)
	}
	mmUpdatePlace.t.Fatalf("Unexpected call to PlaceThingRepositoryMock.UpdatePlace. %v %v %v", ctx, req, tx)
	return
}

// UpdatePlaceAfterCounter returns a count of finished PlaceThingRepositoryMock.UpdatePlace invocations
func (mmUpdatePlace *PlaceThingRepositoryMock) UpdatePlaceAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmUpdatePlace.afterUpdatePlaceCounter)
}

// UpdatePlaceBeforeCounter returns a count of PlaceThingRepositoryMock.UpdatePlace invocations
func (mmUpdatePlace *PlaceThingRepositoryMock) UpdatePlaceBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmUpdatePlace.beforeUpdatePlaceCounter)
}

// Calls returns a list of arguments used in each call to PlaceThingRepositoryMock.UpdatePlace.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmUpdatePlace *mPlaceThingRepositoryMockUpdatePlace) Calls() []*PlaceThingRepositoryMockUpdatePlaceParams {
	mmUpdatePlace.mutex.RLock()

	argCopy := make([]*PlaceThingRepositoryMockUpdatePlaceParams, len(mmUpdatePlace.callArgs))
	copy(argCopy, mmUpdatePlace.callArgs)

	mmUpdatePlace.mutex.RUnlock()

	return argCopy
}

// MinimockUpdatePlaceDone returns true if the count of the UpdatePlace invocations corresponds
// the number of defined expectations
func (m *PlaceThingRepositoryMock) MinimockUpdatePlaceDone() bool {
	for _, e := range m.UpdatePlaceMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			return false
		}
	}

	// if default expectation was set then invocations count should be greater than zero
	if m.UpdatePlaceMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterUpdatePlaceCounter) < 1 {
		return false
	}
	// if func was set then invocations count should be greater than zero
	if m.funcUpdatePlace != nil && mm_atomic.LoadUint64(&m.afterUpdatePlaceCounter) < 1 {
		return false
	}
	return true
}

// MinimockUpdatePlaceInspect logs each unmet expectation
func (m *PlaceThingRepositoryMock) MinimockUpdatePlaceInspect() {
	for _, e := range m.UpdatePlaceMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			m.t.Errorf("Expected call to PlaceThingRepositoryMock.UpdatePlace with params: %#v", *e.params)
		}
	}

	// if default expectation was set then invocations count should be greater than zero
	if m.UpdatePlaceMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterUpdatePlaceCounter) < 1 {
		if m.UpdatePlaceMock.defaultExpectation.params == nil {
			m.t.Error("Expected call to PlaceThingRepositoryMock.UpdatePlace")
		} else {
			m.t.Errorf("Expected call to PlaceThingRepositoryMock.UpdatePlace with params: %#v", *m.UpdatePlaceMock.defaultExpectation.params)
		}
	}
	// if func was set then invocations count should be greater than zero
	if m.funcUpdatePlace != nil && mm_atomic.LoadUint64(&m.afterUpdatePlaceCounter) < 1 {
		m.t.Error("Expected call to PlaceThingRepositoryMock.UpdatePlace")
	}
}

// MinimockFinish checks that all mocked methods have been called the expected number of times
func (m *PlaceThingRepositoryMock) MinimockFinish() {
	if !m.minimockDone() {
		m.MinimockAddInspect()

		m.MinimockDeleteThingInspect()

		m.MinimockGetByThingIDInspect()

		m.MinimockUpdatePlaceInspect()
		m.t.FailNow()
	}
}

// MinimockWait waits for all mocked methods to be called the expected number of times
func (m *PlaceThingRepositoryMock) MinimockWait(timeout mm_time.Duration) {
	timeoutCh := mm_time.After(timeout)
	for {
		if m.minimockDone() {
			return
		}
		select {
		case <-timeoutCh:
			m.MinimockFinish()
			return
		case <-mm_time.After(10 * mm_time.Millisecond):
		}
	}
}

func (m *PlaceThingRepositoryMock) minimockDone() bool {
	done := true
	return done &&
		m.MinimockAddDone() &&
		m.MinimockDeleteThingDone() &&
		m.MinimockGetByThingIDDone() &&
		m.MinimockUpdatePlaceDone()
}
