58 lines
1.5 KiB
Go
58 lines
1.5 KiB
Go
package game_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/iliadenisov/galaxy/internal/controller"
|
|
|
|
"github.com/iliadenisov/galaxy/internal/game"
|
|
mg "github.com/iliadenisov/galaxy/internal/model/game"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestDeclarePeaceAndWarSingle(t *testing.T) {
|
|
c(t, func(f func(*controller.Param), ctrl func() *controller.Controller) {
|
|
hostRace := 5
|
|
opponentRace := 1
|
|
|
|
assert.Equal(t, mg.RelationWar, ctrl().Cache.Relation(5, 1))
|
|
|
|
assert.NoError(t, game.DeclarePeace(f, raceNum(hostRace), raceNum(opponentRace)))
|
|
assert.Equal(t, mg.RelationPeace, ctrl().Cache.Relation(hostRace, opponentRace))
|
|
|
|
assert.NoError(t, game.DeclareWar(f, raceNum(hostRace), raceNum(opponentRace)))
|
|
assert.Equal(t, mg.RelationWar, ctrl().Cache.Relation(hostRace, opponentRace))
|
|
})
|
|
}
|
|
|
|
func TestDeclarePeaceAndWarAll(t *testing.T) {
|
|
c(t, func(f func(*controller.Param), ctrl func() *controller.Controller) {
|
|
hostRace := 7
|
|
|
|
for i := range testRaceCount {
|
|
if i == hostRace {
|
|
continue
|
|
}
|
|
assert.Equal(t, mg.RelationWar, ctrl().Cache.Relation(hostRace, i))
|
|
}
|
|
|
|
assert.NoError(t, game.DeclarePeace(f, raceNum(hostRace), raceNum(hostRace)))
|
|
|
|
for i := range testRaceCount {
|
|
if i == hostRace {
|
|
continue
|
|
}
|
|
assert.Equal(t, mg.RelationPeace, ctrl().Cache.Relation(hostRace, i))
|
|
}
|
|
|
|
assert.NoError(t, game.DeclareWar(f, raceNum(hostRace), raceNum(hostRace)))
|
|
|
|
for i := range testRaceCount {
|
|
if i == hostRace {
|
|
continue
|
|
}
|
|
assert.Equal(t, mg.RelationWar, ctrl().Cache.Relation(hostRace, i))
|
|
}
|
|
})
|
|
}
|