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 ¶
- type GameRules
- type GameState
- func (gs *GameState) Bomb() *common.Bomb
- func (gs *GameState) Entities() map[int]st.Entity
- func (gs *GameState) EntityByHandle(handle uint64) st.Entity
- func (gs *GameState) GamePhase() common.GamePhase
- func (gs *GameState) GrenadeProjectiles() map[int]*common.GrenadeProjectile
- func (gs *GameState) Hostages() []*common.Hostage
- func (gs *GameState) Infernos() map[int]*common.Inferno
- func (gs *GameState) IngameTick() int
- func (gs *GameState) IsFreezetimePeriod() bool
- func (gs *GameState) IsMatchStarted() bool
- func (gs *GameState) IsWarmupPeriod() bool
- func (gs *GameState) OvertimeCount() int
- func (gs *GameState) Participants() demoinfocs.Participants
- func (gs *GameState) PlayerResourceEntity() st.Entity
- func (gs *GameState) Rules() demoinfocs.GameRules
- func (gs *GameState) Team(team common.Team) *common.TeamState
- func (gs *GameState) TeamCounterTerrorists() *common.TeamState
- func (gs *GameState) TeamTerrorists() *common.TeamState
- func (gs *GameState) TotalRoundsPlayed() int
- func (gs *GameState) Weapons() map[int]*common.Equipment
- type Parser
- func (p *Parser) Cancel()
- func (p *Parser) Close() error
- func (p *Parser) CurrentFrame() int
- func (p *Parser) CurrentTime() time.Duration
- func (p *Parser) GameState() demoinfocs.GameState
- func (p *Parser) Header() common.DemoHeader
- func (p *Parser) MockEvents(events ...any)
- func (p *Parser) MockEventsFrame(frame int, events ...any)
- func (p *Parser) MockNetMessages(messages ...any)
- func (p *Parser) MockNetMessagesFrame(frame int, messages ...any)
- func (p *Parser) ParseHeader() (common.DemoHeader, error)
- func (p *Parser) ParseNextFrame() (b bool, err error)
- func (p *Parser) ParseToEnd() (err error)
- func (p *Parser) Progress() float32
- func (p *Parser) RegisterEventHandler(handler any) dp.HandlerIdentifier
- func (p *Parser) RegisterNetMessageHandler(handler any) dp.HandlerIdentifier
- func (p *Parser) ServerClasses() st.ServerClasses
- func (p *Parser) TickRate() float64
- func (p *Parser) TickTime() time.Duration
- func (p *Parser) UnregisterEventHandler(identifier dp.HandlerIdentifier)
- func (p *Parser) UnregisterNetMessageHandler(identifier dp.HandlerIdentifier)
- type Participants
- func (ptcp *Participants) All() []*common.Player
- func (ptcp *Participants) AllByUserID() map[int]*common.Player
- func (ptcp *Participants) ByEntityID() map[int]*common.Player
- func (ptcp *Participants) ByUserID() map[int]*common.Player
- func (ptcp *Participants) Connected() []*common.Player
- func (ptcp *Participants) FindByHandle(handle int) *common.Player
- func (ptcp *Participants) FindByHandle64(handle uint64) *common.Player
- func (ptcp *Participants) FindByPawnHandle(handle uint64) *common.Player
- func (ptcp *Participants) Playing() []*common.Player
- func (ptcp *Participants) SpottedBy(spotter *common.Player) []*common.Player
- func (ptcp *Participants) SpottersOf(spotted *common.Player) []*common.Player
- func (ptcp *Participants) TeamMembers(team common.Team) []*common.Player
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GameRules ¶
GameRules is a mock for of demoinfocs.GameRules.
func (*GameRules) FreezeTime ¶
FreezeTime is a mock-implementation of GameRules.FreezeTime().
type GameState ¶
GameState is a mock for of demoinfocs.GameState.
func (*GameState) EntityByHandle ¶
EntityByHandle is a mock-implementation of GameState.EntityByHandle().
func (*GameState) GrenadeProjectiles ¶
func (gs *GameState) GrenadeProjectiles() map[int]*common.GrenadeProjectile
GrenadeProjectiles is a mock-implementation of GameState.GrenadeProjectiles().
func (*GameState) IngameTick ¶
IngameTick is a mock-implementation of GameState.IngameTick().
func (*GameState) IsFreezetimePeriod ¶
IsFreezetimePeriod is a mock-implementation of GameState.IsFreezetimePeriod().
func (*GameState) IsMatchStarted ¶
IsMatchStarted is a mock-implementation of GameState.IsMatchStarted().
func (*GameState) IsWarmupPeriod ¶
IsWarmupPeriod is a mock-implementation of GameState.IsWarmupPeriod().
func (*GameState) OvertimeCount ¶
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 ¶
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) TeamCounterTerrorists ¶
TeamCounterTerrorists is a mock-implementation of GameState.TeamCounterTerrorists().
func (*GameState) TeamTerrorists ¶
TeamTerrorists is a mock-implementation of GameState.TeamTerrorists().
func (*GameState) TotalRoundsPlayed ¶
TotalRoundsPlayed is a mock-implementation of GameState.TotalRoundsPlayed().
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) CurrentFrame ¶
CurrentFrame is a mock-implementation of Parser.CurrentFrame().
func (*Parser) CurrentTime ¶
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 ¶
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 ¶
MockEventsFrame adds entries to Events that will be dispatched at the frame indicated by the first parameter.
See also: MockEvents()
func (*Parser) MockNetMessages ¶
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 ¶
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 ¶
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 ¶
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) 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) 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 ¶
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().