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

package mocks

//go:generate minimock -i git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/place.ThingTagRepository -o thing_tag_repository_minimock.go -n ThingTagRepositoryMock -p mocks

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

	"github.com/gojuno/minimock/v3"
)

// ThingTagRepositoryMock implements place.ThingTagRepository
type ThingTagRepositoryMock struct {
	t          minimock.Tester
	finishOnce sync.Once

	funcDeleteByThingID          func(ctx context.Context, id uint64) (err error)
	inspectFuncDeleteByThingID   func(ctx context.Context, id uint64)
	afterDeleteByThingIDCounter  uint64
	beforeDeleteByThingIDCounter uint64
	DeleteByThingIDMock          mThingTagRepositoryMockDeleteByThingID
}

// NewThingTagRepositoryMock returns a mock for place.ThingTagRepository
func NewThingTagRepositoryMock(t minimock.Tester) *ThingTagRepositoryMock {
	m := &ThingTagRepositoryMock{t: t}

	if controller, ok := t.(minimock.MockController); ok {
		controller.RegisterMocker(m)
	}

	m.DeleteByThingIDMock = mThingTagRepositoryMockDeleteByThingID{mock: m}
	m.DeleteByThingIDMock.callArgs = []*ThingTagRepositoryMockDeleteByThingIDParams{}

	t.Cleanup(m.MinimockFinish)

	return m
}

type mThingTagRepositoryMockDeleteByThingID struct {
	optional           bool
	mock               *ThingTagRepositoryMock
	defaultExpectation *ThingTagRepositoryMockDeleteByThingIDExpectation
	expectations       []*ThingTagRepositoryMockDeleteByThingIDExpectation

	callArgs []*ThingTagRepositoryMockDeleteByThingIDParams
	mutex    sync.RWMutex

	expectedInvocations uint64
}

// ThingTagRepositoryMockDeleteByThingIDExpectation specifies expectation struct of the ThingTagRepository.DeleteByThingID
type ThingTagRepositoryMockDeleteByThingIDExpectation struct {
	mock      *ThingTagRepositoryMock
	params    *ThingTagRepositoryMockDeleteByThingIDParams
	paramPtrs *ThingTagRepositoryMockDeleteByThingIDParamPtrs
	results   *ThingTagRepositoryMockDeleteByThingIDResults
	Counter   uint64
}

// ThingTagRepositoryMockDeleteByThingIDParams contains parameters of the ThingTagRepository.DeleteByThingID
type ThingTagRepositoryMockDeleteByThingIDParams struct {
	ctx context.Context
	id  uint64
}

// ThingTagRepositoryMockDeleteByThingIDParamPtrs contains pointers to parameters of the ThingTagRepository.DeleteByThingID
type ThingTagRepositoryMockDeleteByThingIDParamPtrs struct {
	ctx *context.Context
	id  *uint64
}

// ThingTagRepositoryMockDeleteByThingIDResults contains results of the ThingTagRepository.DeleteByThingID
type ThingTagRepositoryMockDeleteByThingIDResults struct {
	err error
}

// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
// Optional() makes method check to work in '0 or more' mode.
// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
// catch the problems when the expected method call is totally skipped during test run.
func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Optional() *mThingTagRepositoryMockDeleteByThingID {
	mmDeleteByThingID.optional = true
	return mmDeleteByThingID
}

// Expect sets up expected params for ThingTagRepository.DeleteByThingID
func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Expect(ctx context.Context, id uint64) *mThingTagRepositoryMockDeleteByThingID {
	if mmDeleteByThingID.mock.funcDeleteByThingID != nil {
		mmDeleteByThingID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByThingID mock is already set by Set")
	}

	if mmDeleteByThingID.defaultExpectation == nil {
		mmDeleteByThingID.defaultExpectation = &ThingTagRepositoryMockDeleteByThingIDExpectation{}
	}

	if mmDeleteByThingID.defaultExpectation.paramPtrs != nil {
		mmDeleteByThingID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByThingID mock is already set by ExpectParams functions")
	}

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

	return mmDeleteByThingID
}

// ExpectCtxParam1 sets up expected param ctx for ThingTagRepository.DeleteByThingID
func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) ExpectCtxParam1(ctx context.Context) *mThingTagRepositoryMockDeleteByThingID {
	if mmDeleteByThingID.mock.funcDeleteByThingID != nil {
		mmDeleteByThingID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByThingID mock is already set by Set")
	}

	if mmDeleteByThingID.defaultExpectation == nil {
		mmDeleteByThingID.defaultExpectation = &ThingTagRepositoryMockDeleteByThingIDExpectation{}
	}

	if mmDeleteByThingID.defaultExpectation.params != nil {
		mmDeleteByThingID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByThingID mock is already set by Expect")
	}

	if mmDeleteByThingID.defaultExpectation.paramPtrs == nil {
		mmDeleteByThingID.defaultExpectation.paramPtrs = &ThingTagRepositoryMockDeleteByThingIDParamPtrs{}
	}
	mmDeleteByThingID.defaultExpectation.paramPtrs.ctx = &ctx

	return mmDeleteByThingID
}

// ExpectIdParam2 sets up expected param id for ThingTagRepository.DeleteByThingID
func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) ExpectIdParam2(id uint64) *mThingTagRepositoryMockDeleteByThingID {
	if mmDeleteByThingID.mock.funcDeleteByThingID != nil {
		mmDeleteByThingID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByThingID mock is already set by Set")
	}

	if mmDeleteByThingID.defaultExpectation == nil {
		mmDeleteByThingID.defaultExpectation = &ThingTagRepositoryMockDeleteByThingIDExpectation{}
	}

	if mmDeleteByThingID.defaultExpectation.params != nil {
		mmDeleteByThingID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByThingID mock is already set by Expect")
	}

	if mmDeleteByThingID.defaultExpectation.paramPtrs == nil {
		mmDeleteByThingID.defaultExpectation.paramPtrs = &ThingTagRepositoryMockDeleteByThingIDParamPtrs{}
	}
	mmDeleteByThingID.defaultExpectation.paramPtrs.id = &id

	return mmDeleteByThingID
}

// Inspect accepts an inspector function that has same arguments as the ThingTagRepository.DeleteByThingID
func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Inspect(f func(ctx context.Context, id uint64)) *mThingTagRepositoryMockDeleteByThingID {
	if mmDeleteByThingID.mock.inspectFuncDeleteByThingID != nil {
		mmDeleteByThingID.mock.t.Fatalf("Inspect function is already set for ThingTagRepositoryMock.DeleteByThingID")
	}

	mmDeleteByThingID.mock.inspectFuncDeleteByThingID = f

	return mmDeleteByThingID
}

// Return sets up results that will be returned by ThingTagRepository.DeleteByThingID
func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Return(err error) *ThingTagRepositoryMock {
	if mmDeleteByThingID.mock.funcDeleteByThingID != nil {
		mmDeleteByThingID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByThingID mock is already set by Set")
	}

	if mmDeleteByThingID.defaultExpectation == nil {
		mmDeleteByThingID.defaultExpectation = &ThingTagRepositoryMockDeleteByThingIDExpectation{mock: mmDeleteByThingID.mock}
	}
	mmDeleteByThingID.defaultExpectation.results = &ThingTagRepositoryMockDeleteByThingIDResults{err}
	return mmDeleteByThingID.mock
}

// Set uses given function f to mock the ThingTagRepository.DeleteByThingID method
func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Set(f func(ctx context.Context, id uint64) (err error)) *ThingTagRepositoryMock {
	if mmDeleteByThingID.defaultExpectation != nil {
		mmDeleteByThingID.mock.t.Fatalf("Default expectation is already set for the ThingTagRepository.DeleteByThingID method")
	}

	if len(mmDeleteByThingID.expectations) > 0 {
		mmDeleteByThingID.mock.t.Fatalf("Some expectations are already set for the ThingTagRepository.DeleteByThingID method")
	}

	mmDeleteByThingID.mock.funcDeleteByThingID = f
	return mmDeleteByThingID.mock
}

// When sets expectation for the ThingTagRepository.DeleteByThingID which will trigger the result defined by the following
// Then helper
func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) When(ctx context.Context, id uint64) *ThingTagRepositoryMockDeleteByThingIDExpectation {
	if mmDeleteByThingID.mock.funcDeleteByThingID != nil {
		mmDeleteByThingID.mock.t.Fatalf("ThingTagRepositoryMock.DeleteByThingID mock is already set by Set")
	}

	expectation := &ThingTagRepositoryMockDeleteByThingIDExpectation{
		mock:   mmDeleteByThingID.mock,
		params: &ThingTagRepositoryMockDeleteByThingIDParams{ctx, id},
	}
	mmDeleteByThingID.expectations = append(mmDeleteByThingID.expectations, expectation)
	return expectation
}

// Then sets up ThingTagRepository.DeleteByThingID return parameters for the expectation previously defined by the When method
func (e *ThingTagRepositoryMockDeleteByThingIDExpectation) Then(err error) *ThingTagRepositoryMock {
	e.results = &ThingTagRepositoryMockDeleteByThingIDResults{err}
	return e.mock
}

// Times sets number of times ThingTagRepository.DeleteByThingID should be invoked
func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Times(n uint64) *mThingTagRepositoryMockDeleteByThingID {
	if n == 0 {
		mmDeleteByThingID.mock.t.Fatalf("Times of ThingTagRepositoryMock.DeleteByThingID mock can not be zero")
	}
	mm_atomic.StoreUint64(&mmDeleteByThingID.expectedInvocations, n)
	return mmDeleteByThingID
}

func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) invocationsDone() bool {
	if len(mmDeleteByThingID.expectations) == 0 && mmDeleteByThingID.defaultExpectation == nil && mmDeleteByThingID.mock.funcDeleteByThingID == nil {
		return true
	}

	totalInvocations := mm_atomic.LoadUint64(&mmDeleteByThingID.mock.afterDeleteByThingIDCounter)
	expectedInvocations := mm_atomic.LoadUint64(&mmDeleteByThingID.expectedInvocations)

	return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
}

// DeleteByThingID implements place.ThingTagRepository
func (mmDeleteByThingID *ThingTagRepositoryMock) DeleteByThingID(ctx context.Context, id uint64) (err error) {
	mm_atomic.AddUint64(&mmDeleteByThingID.beforeDeleteByThingIDCounter, 1)
	defer mm_atomic.AddUint64(&mmDeleteByThingID.afterDeleteByThingIDCounter, 1)

	if mmDeleteByThingID.inspectFuncDeleteByThingID != nil {
		mmDeleteByThingID.inspectFuncDeleteByThingID(ctx, id)
	}

	mm_params := ThingTagRepositoryMockDeleteByThingIDParams{ctx, id}

	// Record call args
	mmDeleteByThingID.DeleteByThingIDMock.mutex.Lock()
	mmDeleteByThingID.DeleteByThingIDMock.callArgs = append(mmDeleteByThingID.DeleteByThingIDMock.callArgs, &mm_params)
	mmDeleteByThingID.DeleteByThingIDMock.mutex.Unlock()

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

	if mmDeleteByThingID.DeleteByThingIDMock.defaultExpectation != nil {
		mm_atomic.AddUint64(&mmDeleteByThingID.DeleteByThingIDMock.defaultExpectation.Counter, 1)
		mm_want := mmDeleteByThingID.DeleteByThingIDMock.defaultExpectation.params
		mm_want_ptrs := mmDeleteByThingID.DeleteByThingIDMock.defaultExpectation.paramPtrs

		mm_got := ThingTagRepositoryMockDeleteByThingIDParams{ctx, id}

		if mm_want_ptrs != nil {

			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
				mmDeleteByThingID.t.Errorf("ThingTagRepositoryMock.DeleteByThingID got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
			}

			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
				mmDeleteByThingID.t.Errorf("ThingTagRepositoryMock.DeleteByThingID got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
			}

		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
			mmDeleteByThingID.t.Errorf("ThingTagRepositoryMock.DeleteByThingID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
		}

		mm_results := mmDeleteByThingID.DeleteByThingIDMock.defaultExpectation.results
		if mm_results == nil {
			mmDeleteByThingID.t.Fatal("No results are set for the ThingTagRepositoryMock.DeleteByThingID")
		}
		return (*mm_results).err
	}
	if mmDeleteByThingID.funcDeleteByThingID != nil {
		return mmDeleteByThingID.funcDeleteByThingID(ctx, id)
	}
	mmDeleteByThingID.t.Fatalf("Unexpected call to ThingTagRepositoryMock.DeleteByThingID. %v %v", ctx, id)
	return
}

// DeleteByThingIDAfterCounter returns a count of finished ThingTagRepositoryMock.DeleteByThingID invocations
func (mmDeleteByThingID *ThingTagRepositoryMock) DeleteByThingIDAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmDeleteByThingID.afterDeleteByThingIDCounter)
}

// DeleteByThingIDBeforeCounter returns a count of ThingTagRepositoryMock.DeleteByThingID invocations
func (mmDeleteByThingID *ThingTagRepositoryMock) DeleteByThingIDBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmDeleteByThingID.beforeDeleteByThingIDCounter)
}

// Calls returns a list of arguments used in each call to ThingTagRepositoryMock.DeleteByThingID.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmDeleteByThingID *mThingTagRepositoryMockDeleteByThingID) Calls() []*ThingTagRepositoryMockDeleteByThingIDParams {
	mmDeleteByThingID.mutex.RLock()

	argCopy := make([]*ThingTagRepositoryMockDeleteByThingIDParams, len(mmDeleteByThingID.callArgs))
	copy(argCopy, mmDeleteByThingID.callArgs)

	mmDeleteByThingID.mutex.RUnlock()

	return argCopy
}

// MinimockDeleteByThingIDDone returns true if the count of the DeleteByThingID invocations corresponds
// the number of defined expectations
func (m *ThingTagRepositoryMock) MinimockDeleteByThingIDDone() bool {
	if m.DeleteByThingIDMock.optional {
		// Optional methods provide '0 or more' call count restriction.
		return true
	}

	for _, e := range m.DeleteByThingIDMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			return false
		}
	}

	return m.DeleteByThingIDMock.invocationsDone()
}

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

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

	if !m.DeleteByThingIDMock.invocationsDone() && afterDeleteByThingIDCounter > 0 {
		m.t.Errorf("Expected %d calls to ThingTagRepositoryMock.DeleteByThingID but found %d calls",
			mm_atomic.LoadUint64(&m.DeleteByThingIDMock.expectedInvocations), afterDeleteByThingIDCounter)
	}
}

// MinimockFinish checks that all mocked methods have been called the expected number of times
func (m *ThingTagRepositoryMock) MinimockFinish() {
	m.finishOnce.Do(func() {
		if !m.minimockDone() {
			m.MinimockDeleteByThingIDInspect()
		}
	})
}

// MinimockWait waits for all mocked methods to be called the expected number of times
func (m *ThingTagRepositoryMock) 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 *ThingTagRepositoryMock) minimockDone() bool {
	done := true
	return done &&
		m.MinimockDeleteByThingIDDone()
}
