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

package mocks

//go:generate minimock -i learngo-pockets/habits/internal/habit.tickFinder -o tick_finder_mock.go -n TickFinderMock -p mocks

import (
	"context"
	mm_habit "learngo-pockets/habits/internal/habit"
	"sync"
	mm_atomic "sync/atomic"
	"time"
	mm_time "time"

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

// TickFinderMock implements habit.tickFinder
type TickFinderMock struct {
	t          minimock.Tester
	finishOnce sync.Once

	funcFindWeeklyTicks          func(ctx context.Context, id mm_habit.ID, t time.Time) (ta1 []time.Time, err error)
	inspectFuncFindWeeklyTicks   func(ctx context.Context, id mm_habit.ID, t time.Time)
	afterFindWeeklyTicksCounter  uint64
	beforeFindWeeklyTicksCounter uint64
	FindWeeklyTicksMock          mTickFinderMockFindWeeklyTicks
}

// NewTickFinderMock returns a mock for habit.tickFinder
func NewTickFinderMock(t minimock.Tester) *TickFinderMock {
	m := &TickFinderMock{t: t}

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

	m.FindWeeklyTicksMock = mTickFinderMockFindWeeklyTicks{mock: m}
	m.FindWeeklyTicksMock.callArgs = []*TickFinderMockFindWeeklyTicksParams{}

	t.Cleanup(m.MinimockFinish)

	return m
}

type mTickFinderMockFindWeeklyTicks struct {
	mock               *TickFinderMock
	defaultExpectation *TickFinderMockFindWeeklyTicksExpectation
	expectations       []*TickFinderMockFindWeeklyTicksExpectation

	callArgs []*TickFinderMockFindWeeklyTicksParams
	mutex    sync.RWMutex
}

// TickFinderMockFindWeeklyTicksExpectation specifies expectation struct of the tickFinder.FindWeeklyTicks
type TickFinderMockFindWeeklyTicksExpectation struct {
	mock    *TickFinderMock
	params  *TickFinderMockFindWeeklyTicksParams
	results *TickFinderMockFindWeeklyTicksResults
	Counter uint64
}

// TickFinderMockFindWeeklyTicksParams contains parameters of the tickFinder.FindWeeklyTicks
type TickFinderMockFindWeeklyTicksParams struct {
	ctx context.Context
	id  mm_habit.ID
	t   time.Time
}

// TickFinderMockFindWeeklyTicksResults contains results of the tickFinder.FindWeeklyTicks
type TickFinderMockFindWeeklyTicksResults struct {
	ta1 []time.Time
	err error
}

// Expect sets up expected params for tickFinder.FindWeeklyTicks
func (mmFindWeeklyTicks *mTickFinderMockFindWeeklyTicks) Expect(ctx context.Context, id mm_habit.ID, t time.Time) *mTickFinderMockFindWeeklyTicks {
	if mmFindWeeklyTicks.mock.funcFindWeeklyTicks != nil {
		mmFindWeeklyTicks.mock.t.Fatalf("TickFinderMock.FindWeeklyTicks mock is already set by Set")
	}

	if mmFindWeeklyTicks.defaultExpectation == nil {
		mmFindWeeklyTicks.defaultExpectation = &TickFinderMockFindWeeklyTicksExpectation{}
	}

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

	return mmFindWeeklyTicks
}

// Inspect accepts an inspector function that has same arguments as the tickFinder.FindWeeklyTicks
func (mmFindWeeklyTicks *mTickFinderMockFindWeeklyTicks) Inspect(f func(ctx context.Context, id mm_habit.ID, t time.Time)) *mTickFinderMockFindWeeklyTicks {
	if mmFindWeeklyTicks.mock.inspectFuncFindWeeklyTicks != nil {
		mmFindWeeklyTicks.mock.t.Fatalf("Inspect function is already set for TickFinderMock.FindWeeklyTicks")
	}

	mmFindWeeklyTicks.mock.inspectFuncFindWeeklyTicks = f

	return mmFindWeeklyTicks
}

// Return sets up results that will be returned by tickFinder.FindWeeklyTicks
func (mmFindWeeklyTicks *mTickFinderMockFindWeeklyTicks) Return(ta1 []time.Time, err error) *TickFinderMock {
	if mmFindWeeklyTicks.mock.funcFindWeeklyTicks != nil {
		mmFindWeeklyTicks.mock.t.Fatalf("TickFinderMock.FindWeeklyTicks mock is already set by Set")
	}

	if mmFindWeeklyTicks.defaultExpectation == nil {
		mmFindWeeklyTicks.defaultExpectation = &TickFinderMockFindWeeklyTicksExpectation{mock: mmFindWeeklyTicks.mock}
	}
	mmFindWeeklyTicks.defaultExpectation.results = &TickFinderMockFindWeeklyTicksResults{ta1, err}
	return mmFindWeeklyTicks.mock
}

// Set uses given function f to mock the tickFinder.FindWeeklyTicks method
func (mmFindWeeklyTicks *mTickFinderMockFindWeeklyTicks) Set(f func(ctx context.Context, id mm_habit.ID, t time.Time) (ta1 []time.Time, err error)) *TickFinderMock {
	if mmFindWeeklyTicks.defaultExpectation != nil {
		mmFindWeeklyTicks.mock.t.Fatalf("Default expectation is already set for the tickFinder.FindWeeklyTicks method")
	}

	if len(mmFindWeeklyTicks.expectations) > 0 {
		mmFindWeeklyTicks.mock.t.Fatalf("Some expectations are already set for the tickFinder.FindWeeklyTicks method")
	}

	mmFindWeeklyTicks.mock.funcFindWeeklyTicks = f
	return mmFindWeeklyTicks.mock
}

// When sets expectation for the tickFinder.FindWeeklyTicks which will trigger the result defined by the following
// Then helper
func (mmFindWeeklyTicks *mTickFinderMockFindWeeklyTicks) When(ctx context.Context, id mm_habit.ID, t time.Time) *TickFinderMockFindWeeklyTicksExpectation {
	if mmFindWeeklyTicks.mock.funcFindWeeklyTicks != nil {
		mmFindWeeklyTicks.mock.t.Fatalf("TickFinderMock.FindWeeklyTicks mock is already set by Set")
	}

	expectation := &TickFinderMockFindWeeklyTicksExpectation{
		mock:   mmFindWeeklyTicks.mock,
		params: &TickFinderMockFindWeeklyTicksParams{ctx, id, t},
	}
	mmFindWeeklyTicks.expectations = append(mmFindWeeklyTicks.expectations, expectation)
	return expectation
}

// Then sets up tickFinder.FindWeeklyTicks return parameters for the expectation previously defined by the When method
func (e *TickFinderMockFindWeeklyTicksExpectation) Then(ta1 []time.Time, err error) *TickFinderMock {
	e.results = &TickFinderMockFindWeeklyTicksResults{ta1, err}
	return e.mock
}

// FindWeeklyTicks implements habit.tickFinder
func (mmFindWeeklyTicks *TickFinderMock) FindWeeklyTicks(ctx context.Context, id mm_habit.ID, t time.Time) (ta1 []time.Time, err error) {
	mm_atomic.AddUint64(&mmFindWeeklyTicks.beforeFindWeeklyTicksCounter, 1)
	defer mm_atomic.AddUint64(&mmFindWeeklyTicks.afterFindWeeklyTicksCounter, 1)

	if mmFindWeeklyTicks.inspectFuncFindWeeklyTicks != nil {
		mmFindWeeklyTicks.inspectFuncFindWeeklyTicks(ctx, id, t)
	}

	mm_params := TickFinderMockFindWeeklyTicksParams{ctx, id, t}

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

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

	if mmFindWeeklyTicks.FindWeeklyTicksMock.defaultExpectation != nil {
		mm_atomic.AddUint64(&mmFindWeeklyTicks.FindWeeklyTicksMock.defaultExpectation.Counter, 1)
		mm_want := mmFindWeeklyTicks.FindWeeklyTicksMock.defaultExpectation.params
		mm_got := TickFinderMockFindWeeklyTicksParams{ctx, id, t}
		if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
			mmFindWeeklyTicks.t.Errorf("TickFinderMock.FindWeeklyTicks got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
		}

		mm_results := mmFindWeeklyTicks.FindWeeklyTicksMock.defaultExpectation.results
		if mm_results == nil {
			mmFindWeeklyTicks.t.Fatal("No results are set for the TickFinderMock.FindWeeklyTicks")
		}
		return (*mm_results).ta1, (*mm_results).err
	}
	if mmFindWeeklyTicks.funcFindWeeklyTicks != nil {
		return mmFindWeeklyTicks.funcFindWeeklyTicks(ctx, id, t)
	}
	mmFindWeeklyTicks.t.Fatalf("Unexpected call to TickFinderMock.FindWeeklyTicks. %v %v %v", ctx, id, t)
	return
}

// FindWeeklyTicksAfterCounter returns a count of finished TickFinderMock.FindWeeklyTicks invocations
func (mmFindWeeklyTicks *TickFinderMock) FindWeeklyTicksAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmFindWeeklyTicks.afterFindWeeklyTicksCounter)
}

// FindWeeklyTicksBeforeCounter returns a count of TickFinderMock.FindWeeklyTicks invocations
func (mmFindWeeklyTicks *TickFinderMock) FindWeeklyTicksBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmFindWeeklyTicks.beforeFindWeeklyTicksCounter)
}

// Calls returns a list of arguments used in each call to TickFinderMock.FindWeeklyTicks.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmFindWeeklyTicks *mTickFinderMockFindWeeklyTicks) Calls() []*TickFinderMockFindWeeklyTicksParams {
	mmFindWeeklyTicks.mutex.RLock()

	argCopy := make([]*TickFinderMockFindWeeklyTicksParams, len(mmFindWeeklyTicks.callArgs))
	copy(argCopy, mmFindWeeklyTicks.callArgs)

	mmFindWeeklyTicks.mutex.RUnlock()

	return argCopy
}

// MinimockFindWeeklyTicksDone returns true if the count of the FindWeeklyTicks invocations corresponds
// the number of defined expectations
func (m *TickFinderMock) MinimockFindWeeklyTicksDone() bool {
	for _, e := range m.FindWeeklyTicksMock.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.FindWeeklyTicksMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterFindWeeklyTicksCounter) < 1 {
		return false
	}
	// if func was set then invocations count should be greater than zero
	if m.funcFindWeeklyTicks != nil && mm_atomic.LoadUint64(&m.afterFindWeeklyTicksCounter) < 1 {
		return false
	}
	return true
}

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

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

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

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