fake

package
v4.0.0-...-9ccc978 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package fake provides basic mocks for Parser, GameState and Participants. See examples/mocking (https://github.com/markus-wa/demoinfocs-golang/tree/master/examples/mocking).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GameRules

type GameRules struct {
	mock.Mock
}

GameRules is a mock for of demoinfocs.GameRules.

func (*GameRules) BombTime

func (gr *GameRules) BombTime() (time.Duration, error)

BombTime is a mock-implementation of GameRules.BombTime().

func (*GameRules) ConVars

func (gr *GameRules) ConVars() map[string]string

ConVars is a mock-implementation of GameRules.ConVars().

func (*GameRules) Entity

func (gr *GameRules) Entity() st.Entity

func (*GameRules) FreezeTime

func (gr *GameRules) FreezeTime() (time.Duration, error)

FreezeTime is a mock-implementation of GameRules.FreezeTime().

func (*GameRules) RoundTime

func (gr *GameRules) RoundTime() (time.Duration, error)

RoundTime is a mock-implementation of GameRules.RoundTime().

type GameState

type GameState struct {
	mock.Mock
}

GameState is a mock for of demoinfocs.GameState.

func (*GameState) Bomb

func (gs *GameState) Bomb() *common.Bomb

Bomb is a mock-implementation of GameState.Bomb().

func (*GameState) Entities

func (gs *GameState) Entities() map[int]st.Entity

Entities is a mock-implementation of GameState.Entities().

func (*GameState) EntityByHandle

func (gs *GameState) EntityByHandle(handle uint64) st.Entity

EntityByHandle is a mock-implementation of GameState.EntityByHandle().

func (*GameState) GamePhase

func (gs *GameState) GamePhase() common.GamePhase

GamePhase is a mock-implementation of GameState.GamePhase().

func (*GameState) GrenadeProjectiles

func (gs *GameState) GrenadeProjectiles() map[int]*common.GrenadeProjectile

GrenadeProjectiles is a mock-implementation of GameState.GrenadeProjectiles().

func (*GameState) Hostages

func (gs *GameState) Hostages() []*common.Hostage

Hostages is a mock-implementation of GameState.Hostages().

func (*GameState) Infernos

func (gs *GameState) Infernos() map[int]*common.Inferno

Infernos is a mock-implementation of GameState.Infernos().

func (*GameState) IngameTick

func (gs *GameState) IngameTick() int

IngameTick is a mock-implementation of GameState.IngameTick().

func (*GameState) IsFreezetimePeriod

func (gs *GameState) IsFreezetimePeriod() bool

IsFreezetimePeriod is a mock-implementation of GameState.IsFreezetimePeriod().

func (*GameState) IsMatchStarted

func (gs *GameState) IsMatchStarted() bool

IsMatchStarted is a mock-implementation of GameState.IsMatchStarted().

func (*GameState) IsWarmupPeriod

func (gs *GameState) IsWarmupPeriod() bool

IsWarmupPeriod is a mock-implementation of GameState.IsWarmupPeriod().

func (*GameState) OvertimeCount

func (gs *GameState) OvertimeCount() int

OvertimeCount is a mock-implementation of GameState.OvertimeCount().

func (*GameState) Participants

func (gs *GameState) Participants() demoinfocs.Participants

Participants is a mock-implementation of GameState.Participants().

func (*GameState) PlayerResourceEntity

func (gs *GameState) PlayerResourceEntity() st.Entity

PlayerResourceEntity is a mock-implementation of GameState.PlayerResourceEntity().

func (*GameState) Rules

func (gs *GameState) Rules() demoinfocs.GameRules

Rules is a mock-implementation of GameState.Rules().

func (*GameState) Team

func (gs *GameState) Team(team common.Team) *common.TeamState

Team is a mock-implementation of GameState.Team().

func (*GameState) TeamCounterTerrorists

func (gs *GameState) TeamCounterTerrorists() *common.TeamState

TeamCounterTerrorists is a mock-implementation of GameState.TeamCounterTerrorists().

func (*GameState) TeamTerrorists

func (gs *GameState) TeamTerrorists() *common.TeamState

TeamTerrorists is a mock-implementation of GameState.TeamTerrorists().

func (*GameState) TotalRoundsPlayed

func (gs *GameState) TotalRoundsPlayed() int

TotalRoundsPlayed is a mock-implementation of GameState.TotalRoundsPlayed().

func (*GameState) Weapons

func (gs *GameState) Weapons() map[int]*common.Equipment

Weapons is a mock-implementation of GameState.Weapons().

type Parser

type Parser struct {
	mock.Mock

	// List of events to be dispatched by frame.
	// ParseToEnd() / ParseNextFrame() will dispatch them accordingly.
	// See also: MockEvents() / MockEventsFrame()
	Events map[int][]any

	// List of net-messages to be dispatched by frame.
	// ParseToEnd() / ParseNextFrame() will dispatch them accordingly.
	// See also: MockNetMessages() / MockNetMessagesFrame()
	NetMessages map[int][]any
	// contains filtered or unexported fields
}

Parser is a mock for of demoinfocs.Parser.

func NewParser

func NewParser() *Parser

NewParser returns a new parser mock with pre-initialized Events and NetMessages. Pre-mocks RegisterEventHandler() and RegisterNetMessageHandler().

func (*Parser) Cancel

func (p *Parser) Cancel()

Cancel is a mock-implementation of Parser.Cancel(). Does not cancel the mock's ParseToEnd() function, mock the return value of ParseToEnd() to be ErrCancelled instead.

func (*Parser) Close

func (p *Parser) Close() error

Close is a mock-implementation of Parser.Close(). NOP implementation.

func (*Parser) CurrentFrame

func (p *Parser) CurrentFrame() int

CurrentFrame is a mock-implementation of Parser.CurrentFrame().

func (*Parser) CurrentTime

func (p *Parser) CurrentTime() time.Duration

CurrentTime is a mock-implementation of Parser.CurrentTime().

func (*Parser) GameState

func (p *Parser) GameState() demoinfocs.GameState

GameState is a mock-implementation of Parser.GameState().

func (*Parser) Header

func (p *Parser) Header() common.DemoHeader

Header is a mock-implementation of Parser.Header().

func (*Parser) MockEvents

func (p *Parser) MockEvents(events ...any)

MockEvents adds entries to Parser.Events. It increments an internal frame-index so each set of events and net-messages added in subsequent calls to this or MockNetMessages() is triggered on a separate frame.

See also: MockEventsFrame()

func (*Parser) MockEventsFrame

func (p *Parser) MockEventsFrame(frame int, events ...any)

MockEventsFrame adds entries to Events that will be dispatched at the frame indicated by the first parameter.

See also: MockEvents()

func (*Parser) MockNetMessages

func (p *Parser) MockNetMessages(messages ...any)

MockNetMessages adds entries to Parser.NetMessages. It increments an internal frame-index so each set of net-messages and events added in subsequent calls to this or MockEvents() is triggered on a separate frame.

See also: MockNetMessagesFrame()

func (*Parser) MockNetMessagesFrame

func (p *Parser) MockNetMessagesFrame(frame int, messages ...any)

MockNetMessagesFrame adds entries to NetMessages that will be dispatched at the frame indicated by the first parameter.

See also: MockNetMessages()

func (*Parser) ParseHeader

func (p *Parser) ParseHeader() (common.DemoHeader, error)

ParseHeader is a mock-implementation of Parser.ParseHeader().

func (*Parser) ParseNextFrame

func (p *Parser) ParseNextFrame() (b bool, err error)

ParseNextFrame is a mock-implementation of Parser.ParseNextFrame().

Dispatches Parser.Events and Parser.NetMessages in the specified order.

Returns the mocked bool and error values.

func (*Parser) ParseToEnd

func (p *Parser) ParseToEnd() (err error)

ParseToEnd is a mock-implementation of Parser.ParseToEnd().

Dispatches Parser.Events and Parser.NetMessages in the specified order.

Returns the mocked error value.

func (*Parser) Progress

func (p *Parser) Progress() float32

Progress is a mock-implementation of Parser.Progress().

func (*Parser) RegisterEventHandler

func (p *Parser) RegisterEventHandler(handler any) dp.HandlerIdentifier

RegisterEventHandler is a mock-implementation of Parser.RegisterEventHandler(). Return HandlerIdentifier cannot be mocked (for now).

func (*Parser) RegisterNetMessageHandler

func (p *Parser) RegisterNetMessageHandler(handler any) dp.HandlerIdentifier

RegisterNetMessageHandler is a mock-implementation of Parser.RegisterNetMessageHandler(). Return HandlerIdentifier cannot be mocked (for now).

func (*Parser) ServerClasses

func (p *Parser) ServerClasses() st.ServerClasses

ServerClasses is a mock-implementation of Parser.ServerClasses().

Unfortunately sendtables.ServerClasses currently isn't mockable.

func (*Parser) TickRate

func (p *Parser) TickRate() float64

TickRate is a mock-implementation of Parser.TickRate().

func (*Parser) TickTime

func (p *Parser) TickTime() time.Duration

TickTime is a mock-implementation of Parser.TickTime().

func (*Parser) UnregisterEventHandler

func (p *Parser) UnregisterEventHandler(identifier dp.HandlerIdentifier)

UnregisterEventHandler is a mock-implementation of Parser.UnregisterEventHandler().

func (*Parser) UnregisterNetMessageHandler

func (p *Parser) UnregisterNetMessageHandler(identifier dp.HandlerIdentifier)

UnregisterNetMessageHandler is a mock-implementation of Parser.UnregisterNetMessageHandler().

type Participants

type Participants struct {
	mock.Mock
}

Participants is a mock for of demoinfocs.Participants.

func (*Participants) All

func (ptcp *Participants) All() []*common.Player

All is a mock-implementation of Participants.All().

func (*Participants) AllByUserID

func (ptcp *Participants) AllByUserID() map[int]*common.Player

AllByUserID is a mock-implementation of Participants.AllByUserID().

func (*Participants) ByEntityID

func (ptcp *Participants) ByEntityID() map[int]*common.Player

ByEntityID is a mock-implementation of Participants.ByEntityID().

func (*Participants) ByUserID

func (ptcp *Participants) ByUserID() map[int]*common.Player

ByUserID is a mock-implementation of Participants.ByUserID().

func (*Participants) Connected

func (ptcp *Participants) Connected() []*common.Player

Connected is a mock-implementation of Participants.Connected().

func (*Participants) FindByHandle

func (ptcp *Participants) FindByHandle(handle int) *common.Player

FindByHandle is a mock-implementation of Participants.FindByHandle().

func (*Participants) FindByHandle64

func (ptcp *Participants) FindByHandle64(handle uint64) *common.Player

FindByHandle64 is a mock-implementation of Participants.FindByHandle64().

func (*Participants) FindByPawnHandle

func (ptcp *Participants) FindByPawnHandle(handle uint64) *common.Player

FindByPawnHandle is a mock-implementation of Participants.FindByPawnHandle().

func (*Participants) Playing

func (ptcp *Participants) Playing() []*common.Player

Playing is a mock-implementation of Participants.Playing().

func (*Participants) SpottedBy

func (ptcp *Participants) SpottedBy(spotter *common.Player) []*common.Player

SpottedBy is a mock-implementation of Participants.SpottedBy().

func (*Participants) SpottersOf

func (ptcp *Participants) SpottersOf(spotted *common.Player) []*common.Player

SpottersOf is a mock-implementation of Participants.SpottersOf().

func (*Participants) TeamMembers

func (ptcp *Participants) TeamMembers(team common.Team) []*common.Player

TeamMembers is a mock-implementation of Participants.TeamMembers().

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL