Documentation ¶
Overview ¶
Package fake provides basic mocks for IParser, IGameState and IParticipants. See examples/mocking (https://github.com/markus-wa/demoinfocs-golang/tree/master/examples/mocking).
Index ¶
- type GameState
- func (gs *GameState) Bomb() *common.Bomb
- func (gs *GameState) ConVars() map[string]string
- func (gs *GameState) Entities() map[int]*st.Entity
- func (gs *GameState) GamePhase() common.GamePhase
- func (gs *GameState) GrenadeProjectiles() map[int]*common.GrenadeProjectile
- func (gs *GameState) Infernos() map[int]*common.Inferno
- func (gs *GameState) IngameTick() int
- func (gs *GameState) IsMatchStarted() bool
- func (gs *GameState) IsWarmupPeriod() bool
- func (gs *GameState) Participants() dem.IParticipants
- 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) CurrentFrame() int
- func (p *Parser) CurrentTime() time.Duration
- func (p *Parser) GameState() dem.IGameState
- func (p *Parser) Header() common.DemoHeader
- func (p *Parser) MockEvents(events ...interface{})
- func (p *Parser) MockEventsFrame(frame int, events ...interface{})
- func (p *Parser) MockNetMessages(messages ...interface{})
- func (p *Parser) MockNetMessagesFrame(frame int, messages ...interface{})
- 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 interface{}) dp.HandlerIdentifier
- func (p *Parser) RegisterNetMessageHandler(handler interface{}) 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) 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 GameState ¶
GameState is a mock for of demoinfocs.IGameState.
func (*GameState) ConVars ¶ added in v1.3.0
ConVars is a mock-implementation of IGameState.ConVars().
func (*GameState) GamePhase ¶ added in v1.3.0
GamePhase is a mock-implementation of IGameState.GamePhase().
func (*GameState) GrenadeProjectiles ¶
func (gs *GameState) GrenadeProjectiles() map[int]*common.GrenadeProjectile
GrenadeProjectiles is a mock-implementation of IGameState.GrenadeProjectiles().
func (*GameState) IngameTick ¶
IngameTick is a mock-implementation of IGameState.IngameTick().
func (*GameState) IsMatchStarted ¶
IsMatchStarted is a mock-implementation of IGameState.IsMatchStarted().
func (*GameState) IsWarmupPeriod ¶
IsWarmupPeriod is a mock-implementation of IGameState.IsWarmupPeriod().
func (*GameState) Participants ¶
func (gs *GameState) Participants() dem.IParticipants
Participants is a mock-implementation of IGameState.Participants().
func (*GameState) TeamCounterTerrorists ¶
TeamCounterTerrorists is a mock-implementation of IGameState.TeamCounterTerrorists().
func (*GameState) TeamTerrorists ¶
TeamTerrorists is a mock-implementation of IGameState.TeamTerrorists().
func (*GameState) TotalRoundsPlayed ¶
TotalRoundsPlayed is a mock-implementation of IGameState.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][]interface{} // List of net-messages to be dispatched by frame. // ParseToEnd() / ParseNextFrame() will dispatch them accordingly. // See also: MockNetMessages() / MockNetMessagesFrame() NetMessages map[int][]interface{} // contains filtered or unexported fields }
Parser is a mock for of demoinfocs.IParser.
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 IParser.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 IParser.CurrentFrame().
func (*Parser) CurrentTime ¶
CurrentTime is a mock-implementation of IParser.CurrentTime().
func (*Parser) GameState ¶
func (p *Parser) GameState() dem.IGameState
GameState is a mock-implementation of IParser.GameState().
func (*Parser) Header ¶
func (p *Parser) Header() common.DemoHeader
Header is a mock-implementation of IParser.Header().
func (*Parser) MockEvents ¶
func (p *Parser) MockEvents(events ...interface{})
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 ¶
func (p *Parser) MockNetMessages(messages ...interface{})
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 IParser.ParseHeader().
func (*Parser) ParseNextFrame ¶
ParseNextFrame is a mock-implementation of IParser.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 IParser.ParseToEnd().
Dispatches Parser.Events and Parser.NetMessages in the specified order.
Returns the mocked error value.
func (*Parser) RegisterEventHandler ¶
func (p *Parser) RegisterEventHandler(handler interface{}) dp.HandlerIdentifier
RegisterEventHandler is a mock-implementation of IParser.RegisterEventHandler(). Return HandlerIdentifier cannot be mocked (for now).
func (*Parser) RegisterNetMessageHandler ¶
func (p *Parser) RegisterNetMessageHandler(handler interface{}) dp.HandlerIdentifier
RegisterNetMessageHandler is a mock-implementation of IParser.RegisterNetMessageHandler(). Return HandlerIdentifier cannot be mocked (for now).
func (*Parser) ServerClasses ¶
func (p *Parser) ServerClasses() st.ServerClasses
ServerClasses is a mock-implementation of IParser.ServerClasses().
Unfortunately sendtables.ServerClasses currently isn't mockable.
func (*Parser) UnregisterEventHandler ¶
func (p *Parser) UnregisterEventHandler(identifier dp.HandlerIdentifier)
UnregisterEventHandler is a mock-implementation of IParser.UnregisterEventHandler().
func (*Parser) UnregisterNetMessageHandler ¶
func (p *Parser) UnregisterNetMessageHandler(identifier dp.HandlerIdentifier)
UnregisterNetMessageHandler is a mock-implementation of IParser.UnregisterNetMessageHandler().
type Participants ¶
Participants is a mock for of demoinfocs.IParticipants.
func (*Participants) All ¶
func (ptcp *Participants) All() []*common.Player
All is a mock-implementation of IParticipants.All().
func (*Participants) AllByUserID ¶ added in v1.7.0
func (ptcp *Participants) AllByUserID() map[int]*common.Player
AllByUserID is a mock-implementation of IParticipants.AllByUserID().
func (*Participants) ByEntityID ¶
func (ptcp *Participants) ByEntityID() map[int]*common.Player
ByEntityID is a mock-implementation of IParticipants.ByEntityID().
func (*Participants) ByUserID ¶
func (ptcp *Participants) ByUserID() map[int]*common.Player
ByUserID is a mock-implementation of IParticipants.ByUserID().
func (*Participants) Connected ¶ added in v1.1.0
func (ptcp *Participants) Connected() []*common.Player
Connected is a mock-implementation of IParticipants.Connected().
func (*Participants) FindByHandle ¶
func (ptcp *Participants) FindByHandle(handle int) *common.Player
FindByHandle is a mock-implementation of IParticipants.FindByHandle().
func (*Participants) Playing ¶
func (ptcp *Participants) Playing() []*common.Player
Playing is a mock-implementation of IParticipants.Playing().
func (*Participants) SpottedBy ¶ added in v1.2.0
func (ptcp *Participants) SpottedBy(spotter *common.Player) []*common.Player
SpottedBy is a mock-implementation of IParticipants.SpottedBy().
func (*Participants) SpottersOf ¶ added in v1.2.0
func (ptcp *Participants) SpottersOf(spotted *common.Player) []*common.Player
SpottersOf is a mock-implementation of IParticipants.SpottersOf().
func (*Participants) TeamMembers ¶
func (ptcp *Participants) TeamMembers(team common.Team) []*common.Player
TeamMembers is a mock-implementation of IParticipants.TeamMembers().