1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2025-02-13 20:16:41 -05:00
OpenDiablo2/d2core/d2systems/timescale_test.go

42 lines
693 B
Go
Raw Normal View History

package d2systems
import (
"testing"
"time"
"github.com/gravestench/ecs"
)
func TestTimeScaleSystem_Init(t *testing.T) {
cfg := ecs.NewWorldConfig()
cfg.With(NewTimeScaleSystem())
world := ecs.NewWorld(cfg)
if len(world.Systems) != 1 {
t.Error("system not added to the world")
}
}
func TestTimeScaleSystem_Process(t *testing.T) {
cfg := ecs.NewWorldConfig()
timescaleSystem := NewTimeScaleSystem()
cfg.With(timescaleSystem)
timescaleSystem.scale = 0.01
world := ecs.NewWorld(cfg)
actual := time.Second
expected := time.Duration(timescaleSystem.scale) * actual
world.Update(actual)
if world.TimeDelta != expected {
t.Error("world time delta not scaled")
}
}