// 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/thing.ThingNotificationRepository -o thing_notification_repository_minimock.go -n ThingNotificationRepositoryMock -p mocks

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

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

// ThingNotificationRepositoryMock implements thing.ThingNotificationRepository
type ThingNotificationRepositoryMock struct {
	t          minimock.Tester
	finishOnce sync.Once

	funcDelete          func(ctx context.Context, id uint64) (err error)
	inspectFuncDelete   func(ctx context.Context, id uint64)
	afterDeleteCounter  uint64
	beforeDeleteCounter uint64
	DeleteMock          mThingNotificationRepositoryMockDelete
}

// NewThingNotificationRepositoryMock returns a mock for thing.ThingNotificationRepository
func NewThingNotificationRepositoryMock(t minimock.Tester) *ThingNotificationRepositoryMock {
	m := &ThingNotificationRepositoryMock{t: t}

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

	m.DeleteMock = mThingNotificationRepositoryMockDelete{mock: m}
	m.DeleteMock.callArgs = []*ThingNotificationRepositoryMockDeleteParams{}

	t.Cleanup(m.MinimockFinish)

	return m
}

type mThingNotificationRepositoryMockDelete struct {
	optional           bool
	mock               *ThingNotificationRepositoryMock
	defaultExpectation *ThingNotificationRepositoryMockDeleteExpectation
	expectations       []*ThingNotificationRepositoryMockDeleteExpectation

	callArgs []*ThingNotificationRepositoryMockDeleteParams
	mutex    sync.RWMutex

	expectedInvocations uint64
}

// ThingNotificationRepositoryMockDeleteExpectation specifies expectation struct of the ThingNotificationRepository.Delete
type ThingNotificationRepositoryMockDeleteExpectation struct {
	mock      *ThingNotificationRepositoryMock
	params    *ThingNotificationRepositoryMockDeleteParams
	paramPtrs *ThingNotificationRepositoryMockDeleteParamPtrs
	results   *ThingNotificationRepositoryMockDeleteResults
	Counter   uint64
}

// ThingNotificationRepositoryMockDeleteParams contains parameters of the ThingNotificationRepository.Delete
type ThingNotificationRepositoryMockDeleteParams struct {
	ctx context.Context
	id  uint64
}

// ThingNotificationRepositoryMockDeleteParamPtrs contains pointers to parameters of the ThingNotificationRepository.Delete
type ThingNotificationRepositoryMockDeleteParamPtrs struct {
	ctx *context.Context
	id  *uint64
}

// ThingNotificationRepositoryMockDeleteResults contains results of the ThingNotificationRepository.Delete
type ThingNotificationRepositoryMockDeleteResults 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 (mmDelete *mThingNotificationRepositoryMockDelete) Optional() *mThingNotificationRepositoryMockDelete {
	mmDelete.optional = true
	return mmDelete
}

// Expect sets up expected params for ThingNotificationRepository.Delete
func (mmDelete *mThingNotificationRepositoryMockDelete) Expect(ctx context.Context, id uint64) *mThingNotificationRepositoryMockDelete {
	if mmDelete.mock.funcDelete != nil {
		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
	}

	if mmDelete.defaultExpectation == nil {
		mmDelete.defaultExpectation = &ThingNotificationRepositoryMockDeleteExpectation{}
	}

	if mmDelete.defaultExpectation.paramPtrs != nil {
		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by ExpectParams functions")
	}

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

	return mmDelete
}

// ExpectCtxParam1 sets up expected param ctx for ThingNotificationRepository.Delete
func (mmDelete *mThingNotificationRepositoryMockDelete) ExpectCtxParam1(ctx context.Context) *mThingNotificationRepositoryMockDelete {
	if mmDelete.mock.funcDelete != nil {
		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
	}

	if mmDelete.defaultExpectation == nil {
		mmDelete.defaultExpectation = &ThingNotificationRepositoryMockDeleteExpectation{}
	}

	if mmDelete.defaultExpectation.params != nil {
		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Expect")
	}

	if mmDelete.defaultExpectation.paramPtrs == nil {
		mmDelete.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockDeleteParamPtrs{}
	}
	mmDelete.defaultExpectation.paramPtrs.ctx = &ctx

	return mmDelete
}

// ExpectIdParam2 sets up expected param id for ThingNotificationRepository.Delete
func (mmDelete *mThingNotificationRepositoryMockDelete) ExpectIdParam2(id uint64) *mThingNotificationRepositoryMockDelete {
	if mmDelete.mock.funcDelete != nil {
		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
	}

	if mmDelete.defaultExpectation == nil {
		mmDelete.defaultExpectation = &ThingNotificationRepositoryMockDeleteExpectation{}
	}

	if mmDelete.defaultExpectation.params != nil {
		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Expect")
	}

	if mmDelete.defaultExpectation.paramPtrs == nil {
		mmDelete.defaultExpectation.paramPtrs = &ThingNotificationRepositoryMockDeleteParamPtrs{}
	}
	mmDelete.defaultExpectation.paramPtrs.id = &id

	return mmDelete
}

// Inspect accepts an inspector function that has same arguments as the ThingNotificationRepository.Delete
func (mmDelete *mThingNotificationRepositoryMockDelete) Inspect(f func(ctx context.Context, id uint64)) *mThingNotificationRepositoryMockDelete {
	if mmDelete.mock.inspectFuncDelete != nil {
		mmDelete.mock.t.Fatalf("Inspect function is already set for ThingNotificationRepositoryMock.Delete")
	}

	mmDelete.mock.inspectFuncDelete = f

	return mmDelete
}

// Return sets up results that will be returned by ThingNotificationRepository.Delete
func (mmDelete *mThingNotificationRepositoryMockDelete) Return(err error) *ThingNotificationRepositoryMock {
	if mmDelete.mock.funcDelete != nil {
		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
	}

	if mmDelete.defaultExpectation == nil {
		mmDelete.defaultExpectation = &ThingNotificationRepositoryMockDeleteExpectation{mock: mmDelete.mock}
	}
	mmDelete.defaultExpectation.results = &ThingNotificationRepositoryMockDeleteResults{err}
	return mmDelete.mock
}

// Set uses given function f to mock the ThingNotificationRepository.Delete method
func (mmDelete *mThingNotificationRepositoryMockDelete) Set(f func(ctx context.Context, id uint64) (err error)) *ThingNotificationRepositoryMock {
	if mmDelete.defaultExpectation != nil {
		mmDelete.mock.t.Fatalf("Default expectation is already set for the ThingNotificationRepository.Delete method")
	}

	if len(mmDelete.expectations) > 0 {
		mmDelete.mock.t.Fatalf("Some expectations are already set for the ThingNotificationRepository.Delete method")
	}

	mmDelete.mock.funcDelete = f
	return mmDelete.mock
}

// When sets expectation for the ThingNotificationRepository.Delete which will trigger the result defined by the following
// Then helper
func (mmDelete *mThingNotificationRepositoryMockDelete) When(ctx context.Context, id uint64) *ThingNotificationRepositoryMockDeleteExpectation {
	if mmDelete.mock.funcDelete != nil {
		mmDelete.mock.t.Fatalf("ThingNotificationRepositoryMock.Delete mock is already set by Set")
	}

	expectation := &ThingNotificationRepositoryMockDeleteExpectation{
		mock:   mmDelete.mock,
		params: &ThingNotificationRepositoryMockDeleteParams{ctx, id},
	}
	mmDelete.expectations = append(mmDelete.expectations, expectation)
	return expectation
}

// Then sets up ThingNotificationRepository.Delete return parameters for the expectation previously defined by the When method
func (e *ThingNotificationRepositoryMockDeleteExpectation) Then(err error) *ThingNotificationRepositoryMock {
	e.results = &ThingNotificationRepositoryMockDeleteResults{err}
	return e.mock
}

// Times sets number of times ThingNotificationRepository.Delete should be invoked
func (mmDelete *mThingNotificationRepositoryMockDelete) Times(n uint64) *mThingNotificationRepositoryMockDelete {
	if n == 0 {
		mmDelete.mock.t.Fatalf("Times of ThingNotificationRepositoryMock.Delete mock can not be zero")
	}
	mm_atomic.StoreUint64(&mmDelete.expectedInvocations, n)
	return mmDelete
}

func (mmDelete *mThingNotificationRepositoryMockDelete) invocationsDone() bool {
	if len(mmDelete.expectations) == 0 && mmDelete.defaultExpectation == nil && mmDelete.mock.funcDelete == nil {
		return true
	}

	totalInvocations := mm_atomic.LoadUint64(&mmDelete.mock.afterDeleteCounter)
	expectedInvocations := mm_atomic.LoadUint64(&mmDelete.expectedInvocations)

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

// Delete implements thing.ThingNotificationRepository
func (mmDelete *ThingNotificationRepositoryMock) Delete(ctx context.Context, id uint64) (err error) {
	mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
	defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)

	if mmDelete.inspectFuncDelete != nil {
		mmDelete.inspectFuncDelete(ctx, id)
	}

	mm_params := ThingNotificationRepositoryMockDeleteParams{ctx, id}

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

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

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

		mm_got := ThingNotificationRepositoryMockDeleteParams{ctx, id}

		if mm_want_ptrs != nil {

			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
				mmDelete.t.Errorf("ThingNotificationRepositoryMock.Delete 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) {
				mmDelete.t.Errorf("ThingNotificationRepositoryMock.Delete 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) {
			mmDelete.t.Errorf("ThingNotificationRepositoryMock.Delete got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
		}

		mm_results := mmDelete.DeleteMock.defaultExpectation.results
		if mm_results == nil {
			mmDelete.t.Fatal("No results are set for the ThingNotificationRepositoryMock.Delete")
		}
		return (*mm_results).err
	}
	if mmDelete.funcDelete != nil {
		return mmDelete.funcDelete(ctx, id)
	}
	mmDelete.t.Fatalf("Unexpected call to ThingNotificationRepositoryMock.Delete. %v %v", ctx, id)
	return
}

// DeleteAfterCounter returns a count of finished ThingNotificationRepositoryMock.Delete invocations
func (mmDelete *ThingNotificationRepositoryMock) DeleteAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter)
}

// DeleteBeforeCounter returns a count of ThingNotificationRepositoryMock.Delete invocations
func (mmDelete *ThingNotificationRepositoryMock) DeleteBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter)
}

// Calls returns a list of arguments used in each call to ThingNotificationRepositoryMock.Delete.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmDelete *mThingNotificationRepositoryMockDelete) Calls() []*ThingNotificationRepositoryMockDeleteParams {
	mmDelete.mutex.RLock()

	argCopy := make([]*ThingNotificationRepositoryMockDeleteParams, len(mmDelete.callArgs))
	copy(argCopy, mmDelete.callArgs)

	mmDelete.mutex.RUnlock()

	return argCopy
}

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

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

	return m.DeleteMock.invocationsDone()
}

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

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

	if !m.DeleteMock.invocationsDone() && afterDeleteCounter > 0 {
		m.t.Errorf("Expected %d calls to ThingNotificationRepositoryMock.Delete but found %d calls",
			mm_atomic.LoadUint64(&m.DeleteMock.expectedInvocations), afterDeleteCounter)
	}
}

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

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