fake

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: MIT Imports: 6 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GameState

type GameState struct {
	mock.Mock
}

GameState is a mock for of demoinfocs.IGameState.

func (*GameState) Bomb

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

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

func (*GameState) ConVars added in v1.3.0

func (gs *GameState) ConVars() map[string]string

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

func (*GameState) Entities

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

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

func (*GameState) GamePhase added in v1.3.0

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

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) Infernos

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

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

func (*GameState) IngameTick

func (gs *GameState) IngameTick() int

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

func (*GameState) IsMatchStarted

func (gs *GameState) IsMatchStarted() bool

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

func (*GameState) IsWarmupPeriod

func (gs *GameState) IsWarmupPeriod() bool

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) Team added in v1.2.0

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

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

func (*GameState) TeamCounterTerrorists

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

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

func (*GameState) TeamTerrorists

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

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

func (*GameState) TotalRoundsPlayed

func (gs *GameState) TotalRoundsPlayed() int

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

func (*GameState) Weapons added in v1.9.0

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

Weapons is a mock-implementation of IGameState.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][]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

func (p *Parser) CurrentFrame() int

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

func (*Parser) CurrentTime

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

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

func (p *Parser) MockEventsFrame(frame int, events ...interface{})

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

func (p *Parser) MockNetMessagesFrame(frame int, messages ...interface{})

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

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

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

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

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) Progress

func (p *Parser) Progress() float32

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

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) TickRate added in v1.8.0

func (p *Parser) TickRate() float64

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

func (*Parser) TickTime added in v1.8.0

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

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

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

type Participants struct {
	mock.Mock
}

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().

Jump to

Keyboard shortcuts

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